Closed cobungra closed 7 years ago
Hi, Thanks for your feedback. This will probably be possible. I'm working on an other project just now but I'll have a look at the code in the next days.
@cobungra: are you using only one accessory?
If yes, retain make sense, otherwise if you are using more than one accessory, the mqtt broker will retain the last payload of the topic homebridge/from/set
topic: homebridge/from/set
payload: {"name": "flex_lamp", "characteristic": "On", "value": true}
@cflurin Yes only one I hope this isn't a distraction, but when I publish client.publish("homebridge/to/set", "{\"name\": \"fooby\", \"characteristic\": \"Off\", \"value\": true }"); it is pubishing as expected. I subscribe to homebridge/to/set and can see the updates in real time. However I was expecting that subscribing after a recent publish... that I should get the last published status (that had "value": true") . I thought that "true" might be the retain flag.... I fear that I am missing something. (My MQTT server is Mosquitto)
Regards and thanks again
Try setting retain=true in your esp8266 code. Something like this:
options.retain = true;
client.publish(topic, payload, options);
BTW: there isn't a characteristic "Off".
if you implement topic: homebridge/from/response
in your esp8266 code, you will get this:
{"ack":false,"message":"characteristic 'Off' undefined."}
Brilliant! That works. (If a little embarrassing.... you were right about the error message.) Thanks @cflurin. Greetings from Australia. (hehe assuming that you are elsewhere.)
Glad it works. Indeed I'm in Switzerland. I visited the South of Australia a long time ago, great country.
Hello and thanks for this work, I am having great success with it. I wonder if there is a way to set the publish "retained" flag to true with homebridge-mqtt ? I am building an esp8266 pushbutton that goes to sleep, but needs to be aware of the last status of the controlled device when it wakes up. Many thanks.