Rigor_M
(Jean Francois Couture)
1
Hi,
i’m trying to find out how to setup a line in exec.persist so I can run a mqtt publish client at intervals.
I’ve got it working but I have to use the FQDN for the MQTT server.
Is there a way that I could have access to the mqtt URL in the openhab.cfg file ?
The reason is, I would need to change the URL in the openhab.cfg and the exec.persist if I ever changed the MQTT server.
Thanks for any input on this.
Jeff C.
watou
(John Cocula)
2
I don’t think there is a way to access the URL other than parsing the openhab.cfg file yourself.
But since you want to persist to MQTT, another option is to simply add the MQTT binding to your item. For example:
Number Temperature "my temp [%.1f °C]" { ecobee="<[123456#runtime.actualTemperature]", mqtt=">[mybroker:/mytopic/temp:state:default]" }
This would publish to MQTT every time the item was updated. If that’s too often, you could instead use a rule and the MQTT action bundle. For example:
rule PubToMQTT
when
Item Temperature changed
then
publish("mybroker","/mytopic/temp",Temperature.state.toString)
end
Rigor_M
(Jean Francois Couture)
3
Thank, I think i’ll change the exec persistence to a simple rule…
and thanks for the publishing tip… that exactly what i need.
1 Like
watou
(John Cocula)
4
Lastly, there’s even an MQTT Persistence bundle you could use! All the bases are covered!