MQTT on domoticz/in and domoticz/out

Others (MiLight, Hue, Toon etc...)

Moderator: leecollings

Post Reply
akamming
Posts: 344
Joined: Friday 17 August 2018 14:03
Target OS: Raspberry Pi / ODroid
Domoticz version:
Contact:

MQTT on domoticz/in and domoticz/out

Post by akamming »

Hi,

i am trying to sync some domoticz switches with home assistant. So i made a config in home assistant that
- reads domitcz/out/<idx> for the switch state
- can send to domoticz/in commands when a button is pushed from home assistant.

Config seems to be fine:
- If a switch state is changed in domoticz, the following messages is read on domoticz/out/idx-of-the-device:

Code: Select all

{
	"Battery" : 255,
	"LastUpdate" : "2024-12-08 11:19:12",
	"RSSI" : 12,
	"description" : "",
	"dtype" : "Lighting 1",
	"hwid" : "8",
	"id" : "65",
	"idx" : 1872,
	"name" : "Test",
	"nvalue" : 0,
	"org_hwid" : "8",
	"stype" : "X10",
	"switchType" : "On/Off",
	"unit" : 1
}
, setting the correct state in home assistant

and if i flip a switch in home assistant, the following message is published on domoticz/in

Code: Select all

{ "command": "switchlight", "idx": idx-of-the-device, "switchcmd": "Off" }
and indeed i see the device changing (in this example to Off) in domoticz.

However the hass state flips back after a few seconds. I analyzed and did some testing and found out that if a device is changed by a message on domoticz/in, the same state is not reflected on domoticz/out... and that's where it goes wrong, cause then hass assumes the command failed.

i confirmed this theory a manual test be sending manually the domoticz/out message rightaway after the domoticz/in message and then it works correct.

Looking a bit further this also explains why my homekit integration (using homebridge and the edomoticz plugin) also has the same behaviour. There i also sometimes see the wrong states in homebridge.

I think this is incorrect behaviour: i think the correct behaviour should be that when the mqtt client interface is enabled, any device change should always be reflected on domitcz/out (so also when the change was initiated by a pauload on the domoticz/in topic) and this is a bug

My question to the experts on the forum here: Is my way of thinking correct? Then i will post an issue on github... If not: Where do i go wrong and how can i fix my issue in another way?
wim57
Posts: 20
Joined: Monday 25 September 2017 12:58
Target OS: Raspberry Pi / ODroid
Domoticz version:
Contact:

Re: MQTT on domoticz/in and domoticz/out

Post by wim57 »

I think you have to set 'prevent loop' to false on the Domoticz MQTT Client Gateway in Hardware settings.
But beware that this can result in the message looping with other devices acting on domoticz/in and out.
akamming
Posts: 344
Joined: Friday 17 August 2018 14:03
Target OS: Raspberry Pi / ODroid
Domoticz version:
Contact:

Re: MQTT on domoticz/in and domoticz/out

Post by akamming »

wim57 wrote: Sunday 08 December 2024 11:44 I think you have to set 'prevent loop' to false on the Domoticz MQTT Client Gateway in Hardware settings.
But beware that this can result in the message looping with other devices acting on domoticz/in and out.
ah... perfect... this indeed fixes it!
Post Reply

Who is online

Users browsing this forum: No registered users and 1 guest