moroen / IKEA-Tradfri-plugin

A Python plugin for Domoticz to controll IKEA Gateway
68 stars 23 forks source link

Trigger lamps using Mqtt #126

Closed McMornan closed 3 years ago

McMornan commented 3 years ago

Hi,

I have a strange effect. (raspi4, 2gb, stretch, latest of everything: domoticz dev branch built from source, latest plugin Version and libraries, Updated yesterday)

When I switch an Ikea lamp using the domoticz gui everything works fine (on/off colors etc.) When I send a switch command via Mqtt (only idx and value - this has been working fine with all other switches so far, mosquitto on synology) the state in the gui changes but the lamp does not switch on/off. (also checked this monitoring the Ikea App)

Any idea why this is the case?

Thanks Lars

moroen commented 3 years ago

Does the state change in the IKEA app as well?

McMornan commented 3 years ago

No, the state does not change in the app

moroen commented 3 years ago

Could you enable debug and provide the relevant sections of the log?

McMornan commented 3 years ago

Ok, will do that tomorrow

McMornan commented 3 years ago

Hi,

here is the domoticz log. I switched first using MQTT:

2020-12-03 07:57:51.430 MQTT: Topic: domoticz/in, Message: {"nvalue":0,"idx":2391} 2020-12-03 07:57:51.433 (IKEA) Pushing 'CPluginMessageBase' on to queue 2020-12-03 07:57:51.450 (IKEA) Processing 'CPluginMessageBase' message 2020-12-03 07:57:51.452 (IKEA) Message handler 'onDeviceModified' not callable, ignored.

domoticz gui: 2020-12-03 07:58:00.682 (IKEA) Pushing 'onHeartbeatCallback' on to queue 2020-12-03 07:58:00.719 (IKEA) Processing 'onHeartbeatCallback' message 2020-12-03 07:58:00.719 (IKEA) Calling message handler 'onHeartbeat'.

moroen commented 3 years ago

I need to set up a MQTT system to test this. It's a bit hectic at the moment, but I'll try to do it as soon as possible.

From the log, it appears that nvalue is updated, which would explain why the state reflected in the GUI changes, but the plugins onCommand functions is never called...

According to the domoticz wiki topic on MQTT, the message for switching a device is:

{"command": "switchlight", "idx": 2450, "switchcmd": "On" }
{"command": "switchlight", "idx": 2450, "switchcmd": "Set Level", "level": 100 }

Have you tried this?

McMornan commented 3 years ago

Hi,

thank you very much, that works !

Obviously my laziness has found its master after all :)

As an excuse: I have been using that simple "nvalue, idx" method for years and a number of different hardware plugins. Has been working like a charm. Yours is the first where I have to stick to the rules.

Thanks for your quick support, Lars

moroen commented 3 years ago

I suspect it has something to do with the python plugin framework, as it appears that the plugin isn't even called when using the "short form". Anyway, glad it worked out!