No MQTT messages send to domoticz/out for Python plugin devices

Python and python framework

Moderator: leecollings

Post Reply
User avatar
G3rard
Posts: 669
Joined: Wednesday 04 March 2015 22:15
Target OS: -
Domoticz version: No
Location: The Netherlands
Contact:

No MQTT messages send to domoticz/out for Python plugin devices

Post by G3rard »

Hi @Dnpwwo, I use the Sonos plugin of tester22, but when switching Sonos on/off or changing the volume in Domoticz, no MQTT messages are being send. I can however control the switches with a MQTT message to domoticz/in.

Has this something to do with the HardwareType?
Not using Domoticz anymore
User avatar
Dnpwwo
Posts: 820
Joined: Sunday 23 March 2014 9:00
Target OS: Raspberry Pi / ODroid
Domoticz version: Beta
Location: Melbourne, Australia
Contact:

Re: No MQTT messages send to domoticz/out for Python plugin devices

Post by Dnpwwo »

@G3rard,

Not directly linked to the HardwareType because the Plugin Framework is linked into the standard Domoticz mechanisms for updating devices and receiving details when devices are updated through the web or event interfaces. The real problem is that not everything uses the same mechanisms because they have been done differently (Thermostats/Set Points for example have custom code).

I haven't looked at the MQTT code but I suspect it could be the same.

I don't use MQTT, how do you set up a Domoticz device to make updates go to it?
The reasonable man adapts himself to the world; the unreasonable one persists to adapt the world to himself. Therefore all progress depends on the unreasonable man. George Bernard Shaw
User avatar
G3rard
Posts: 669
Joined: Wednesday 04 March 2015 22:15
Target OS: -
Domoticz version: No
Location: The Netherlands
Contact:

Re: No MQTT messages send to domoticz/out for Python plugin devices

Post by G3rard »

@Dnpwwo,
I am using Mosquitto and have added the MQTT Client Gateway in Domoticz under Hardware.

Then all devices should send a MQTT message to domoticz/out when changing.

You can use MQTTBox (Chrome plugin) to track the messages.

Please let me know if I can do some checks here.
Not using Domoticz anymore
User avatar
G3rard
Posts: 669
Joined: Wednesday 04 March 2015 22:15
Target OS: -
Domoticz version: No
Location: The Netherlands
Contact:

Re: No MQTT messages send to domoticz/out for Python plugin devices

Post by G3rard »

@Dnpwwo, were you already able to have a look at this?
Let me know if I can do some tests.

I have tried some things like setting the device to unused (in the devices page) and then to used again, but that doesn't make a difference.
Also changing the type of the switch (now Lighting2, AC, Media Player) doesn't do anything.
Not using Domoticz anymore
User avatar
Dnpwwo
Posts: 820
Joined: Sunday 23 March 2014 9:00
Target OS: Raspberry Pi / ODroid
Domoticz version: Beta
Location: Melbourne, Australia
Contact:

Re: No MQTT messages send to domoticz/out for Python plugin devices

Post by Dnpwwo »

@G3rard,

I had a look at the MQTT code and couldn't see how it was meant to pick up updates.

Do you know who wrote it? Maybe we can get some input from them.
The reasonable man adapts himself to the world; the unreasonable one persists to adapt the world to himself. Therefore all progress depends on the unreasonable man. George Bernard Shaw
User avatar
G3rard
Posts: 669
Joined: Wednesday 04 March 2015 22:15
Target OS: -
Domoticz version: No
Location: The Netherlands
Contact:

No MQTT messages send to domoticz/out for Python plugin devices

Post by G3rard »

@Dnpwwo, I think @gizmocuz wrote the MQTT code.

Edit: maybe this issue is related?
viewtopic.php?f=65&t=15233&p=121897#p121897
Not using Domoticz anymore
User avatar
G3rard
Posts: 669
Joined: Wednesday 04 March 2015 22:15
Target OS: -
Domoticz version: No
Location: The Netherlands
Contact:

Re: No MQTT messages send to domoticz/out for Python plugin devices

Post by G3rard »

@gizmocuz, can you help us out with this?
Devices created with the Python plugins aren't sending MQTT messages to domoticz/out, but respond to MQTT messages to domoticz/in.
Not using Domoticz anymore
gerardvs
Posts: 81
Joined: Sunday 04 January 2015 0:01
Target OS: Raspberry Pi / ODroid
Domoticz version: latest-1
Location: /dev/null
Contact:

Re: No MQTT messages send to domoticz/out for Python plugin devices

Post by gerardvs »

I am also still struggling with devices create by the Python plugins. There is definitely a problem with the DeviceID. Have you looked at this and also found the DeviceID isn't correct? And, can you update the device with the json api?
Not sure if this is a Python Plugin framework bug. about everywhere I look in the Domoticz sources ID and DeviceID is mixed up.
In my opinion devices should be accessible via the unique Idx and not via "HardwareID AND Unit".

Anyhow, I can't solve your problem, only share mine in the hope there is a common cause. Is your code somewhere available to test if same issues exist here?

--Gerard
User avatar
Dnpwwo
Posts: 820
Joined: Sunday 23 March 2014 9:00
Target OS: Raspberry Pi / ODroid
Domoticz version: Beta
Location: Melbourne, Australia
Contact:

Re: No MQTT messages send to domoticz/out for Python plugin devices

Post by Dnpwwo »

@G3rard,

MQTT may be linked to notifications which would explain why I haven't seen any code for it. I am going to see if I can add notifications this weekend.

EDIT: In fact can you give it another go now. I added Event System integration, that might do it.
The reasonable man adapts himself to the world; the unreasonable one persists to adapt the world to himself. Therefore all progress depends on the unreasonable man. George Bernard Shaw
User avatar
G3rard
Posts: 669
Joined: Wednesday 04 March 2015 22:15
Target OS: -
Domoticz version: No
Location: The Netherlands
Contact:

Re: No MQTT messages send to domoticz/out for Python plugin devices

Post by G3rard »

@Dnpwwo,
I updated to Domoticz v3.6936 (latest beta) and removed and added the Sonos hardware, but unfortunately no MQTT messages are sent for the Sonos devices.

MQTT messages to domoticz/in are still working, but no messages to domoticz/out are being sent for the devices (and for other devices the MQTT messages are being sent to domoticz/out).

I enabled notifications (to pushbullet in this case) for the Sonos switch and these are working when status of the device is changing.

Edit: on my production system v3.6745 the notifications for the Sonos devices (via Python plugin) are also working.
Not using Domoticz anymore
mobzd
Posts: 2
Joined: Thursday 22 June 2017 10:45
Target OS: Raspberry Pi / ODroid
Domoticz version:
Contact:

Re: No MQTT messages send to domoticz/out for Python plugin devices

Post by mobzd »

I made a python plugin (adapting the Denon plugin) to control the Pioneer VSX-S510 receiver. Also, I came across a problem that switching devices generated by the plugin are not reflect the MQTT using domoticz/out. As I use integration with HomeKit, I really care about this information exchange, otherwise HomeKit needs to refresh twice every time to get the device status. I'm using current beta version.
User avatar
G3rard
Posts: 669
Joined: Wednesday 04 March 2015 22:15
Target OS: -
Domoticz version: No
Location: The Netherlands
Contact:

Re: No MQTT messages send to domoticz/out for Python plugin devices

Post by G3rard »

I did some more testing by creating a switch (switch type Media Player) using the Dummy Hardware (Create Virtual Sensors).
When clicking that switch a MQTT message is send. So business as usual.

Then in the database in table DeviceStatus I changed the HardwareID and Unit of that switch to the values of the plugin (and changed the Unit number of the switch which was created using the plugin).
That new switch then works with the plugin, however after that no MQTT messages are sent.

I am afraid my knowledge ends here, but maybe @Dnpwwo has an idea what could be the reason that no MQTT messages are sent.

By the way, I am also using the MQTT messages for Homekit and it's also used for Reacticz.
Not using Domoticz anymore
User avatar
Dnpwwo
Posts: 820
Joined: Sunday 23 March 2014 9:00
Target OS: Raspberry Pi / ODroid
Domoticz version: Beta
Location: Melbourne, Australia
Contact:

Re: No MQTT messages send to domoticz/out for Python plugin devices

Post by Dnpwwo »

@G3rard,

I had a better look at this and think I understand the issue.

Domoticz has a very 'rich heritage', part of that is that there is not a single way of updating a device but many. Broadly those can be broken down into a couple of types:
  • Those that interpret/convert everything as an RFX command
  • Those that don't talk RFX and update the database
AFAIK the implementors of MQTT and other push mechanisms have only handled the RFX case via a fancy callback (search the code for 'sOnDeviceReceived') that they register.

Obviously the Plugin code can only call one of these and the RFX code is too restrictive to handle arbitrary device types so it calls one of the others.

I can't test this because I don't use MQTT but I have pushed an update to the 'more-python-stuff' branch in github that may solve this. If you build from source can you switch to that branch and try it?

To use that branch you will need to change the interface to any onMessage python callbacks you have in your plugins to remove the last 2 parameters.
The reasonable man adapts himself to the world; the unreasonable one persists to adapt the world to himself. Therefore all progress depends on the unreasonable man. George Bernard Shaw
User avatar
G3rard
Posts: 669
Joined: Wednesday 04 March 2015 22:15
Target OS: -
Domoticz version: No
Location: The Netherlands
Contact:

Re: No MQTT messages send to domoticz/out for Python plugin devices

Post by G3rard »

@Dnpwwo, thanks for looking into this again!

Will build your version and test if it works.
Not using Domoticz anymore
User avatar
G3rard
Posts: 669
Joined: Wednesday 04 March 2015 22:15
Target OS: -
Domoticz version: No
Location: The Netherlands
Contact:

No MQTT messages send to domoticz/out for Python plugin devices

Post by G3rard »

@Dnpwwo, just built that version and now MQTT messages are being sent when a device of a Python plugin changes, so it works :D
That one line of code made the difference :ugeek:
Thanks!!!
Not using Domoticz anymore
mobzd
Posts: 2
Joined: Thursday 22 June 2017 10:45
Target OS: Raspberry Pi / ODroid
Domoticz version:
Contact:

Re: No MQTT messages send to domoticz/out for Python plugin devices

Post by mobzd »

Good news! I will wait to merge this into a beta build.
Post Reply

Who is online

Users browsing this forum: No registered users and 1 guest