Great work Bruce!
Thanks for sharing
Great work Bruce!
Thanks for sharing
Hello ! Great work !
It works well.
As I needed to be able to manage MQTT message from the broker, Iâve added subscribe action :
Topic and payload can be retrieved in variables âmqttLastReceivedTopicâ and âmqttLastReceivedPayloadâ.
Great work! This plugin made my need for advanced scenes in Vera less important!
This plugin with Node red, influxdb and Grafana has made my home automation system much better and easier to extend features to.
Currently verifying that my SMS modem works correctly with the node Red flows, when this is verified I have 5000 SMS / month to use with Node Red and Vera!
I made an RPI tutorial that now includes this plugin for Vera
Currently I made:
Influxdb
Grafana (v4)
Node red
Mosquitto
This MQTT plugin
The guide is in Swedish, but google translate works âOKâ
[url=http://www.automatiserar.se/guide-raspberry-pi/]http://www.automatiserar.se/guide-raspberry-pi/[/url]
Great job on the plugin!
// Ispep
Just came across this thread and it was exactly what I was looking for. Thanks for the great plug-in.
Two related questions:
Related to #1 I noticed that if I ssh into my vera I canât ping the raspberry pi by hostname but I can by IP, Iâm guessing that is the underlying issue.
Some modifications :
You can subscribe to a topic by creating a child device :
1/ Add a new device and choose a type (e.g. âD_BinaryLight1.xmlâ or âD_TemperatureSensor1.xmlâ).
2/ Reload LUUP engine.
3/ Change the attribut âid_parentâ with the id of the MQTT plugin device.
4/ Reload LUUP engine and refresh your browser.
5/ You should see variables âmqttTargetâ and âmqttTopicâ in your newly created device.
6/ Set the topic you want to subcribe to and the target (format: service,variable=(formula in LUA)).
7/ Reload LUUP engine.
If the payload of the received message is in JSON, the plugin will try to decode it and put it in the variable âpayloadâ in the context of the LUA formula.
examples :
Topic : Test/#
Target: urn:upnp-org:serviceId:SwitchPower1,Status=payload.value and ((payload.value==âalarmâ) and â1â or â0â)
On a message from topic âTest/Somethingâ with payload â{âvalueâ:âalarmâ}â, the switch will be powered on.
Topic : Test/+/Sensor
Target: urn:upnp-org:serviceId:TemperatureSensor1,CurrentTemperature=payload.temperature and (tonumber(payload.temperature) or â0â)
On a message from topic âTest/Something/Sensorâ with payload "{"temperature â:â15.2â, âhygrometryâ:â80â}â, the temperature will be set to 15,2.
[quote=âvosmont, post:85, topic:190658â]You can subscribe to a topic by creating a child device :
1/ Add a new device and choose a type (e.g. âD_BinaryLight1.xmlâ or âD_TemperatureSensor1.xmlâ).
2/ Reload LUUP engine.
3/ Change the attribut âid_parentâ with the id of the MQTT plugin device.
4/ Reload LUUP engine and refresh your browser.
5/ You should see variables âmqttTargetâ and âmqttTopicâ in your newly created device.
6/ Set the topic you want to subcribe to and the target (format: service,variable=(formula in LUA)).
7/ Reload LUUP engine.
If the payload of the received message is in JSON, the plugin will try to decode it and put it in the variable âpayloadâ in the context of the LUA formula.
examples :
Topic : Test/#
Target: urn:upnp-org:serviceId:SwitchPower1,Status=payload.value and ((payload.value==âalarmâ) and â1â or â0â)
On a message from topic âTest/Somethingâ with payload â{âvalueâ:âalarmâ}â, the switch will be powered on.
Topic : Test/+/Sensor
Target: urn:upnp-org:serviceId:TemperatureSensor1,CurrentTemperature=payload.temperature and (tonumber(payload.temperature) or â0â)
On a message from topic âTest/Something/Sensorâ with payload "{"temperature â:â15.2â, âhygrometryâ:â80â}â, the temperature will be set to 15,2.[/quote]
I have successfully started MQTT on OpenLuup installation, and sensors are reported to Mosquitto.
however Iâm not able to read anything via child devices.
creating child devices does not create variables which you mention so I use workaround:
do -- MQTT
local dev = luup.create_device ('', "System", "System", "D_TemperatureSensor1.xml")
local sid = "urn:schemas-upnp-org:device:TemperatureSensor:1"
luup.variable_set (sid, "CurrentTemperature", "", dev)
luup.variable_set (sid, "mqttTarget", "", dev)
luup.variable_set (sid, "mqttTopic", "", dev)
end
and I have device with two variables (nothing more)
how can I show temperature from MQTT?
message from other client
{"CurrentTemperature":28.3,"DeviceId":88,"DeviceName":"Temp.Kaloryfery","DeviceType":"urn:schemas-micasaverde-com:device:TemperatureSensor:1","OldCurrentTemperature":28.4,"RoomId":5,"RoomName":"KotĆownia","ServiceId":"urn:upnp-org:serviceId:TemperatureSensor1","Time":1483171789,"Variable":"CurrentTemperature"}
Could you please help in understanding your example on my specific case?
Hello Tommi,
[quote=âTommi, post:86, topic:190658â]I have successfully started MQTT on OpenLuup installation, and sensors are reported to Mosquitto.
however Iâm not able to read anything via child devices. [/quote]
I think you havenât linked the newly created device to the MQTT plugin.
You can try this :
do -- MQTT
local parentId = 999 -- The id of the device of the MQTT plugin
local internalId = "System" -- Has to be unique if you create several child devices
local dev = luup.create_device ('', internalId, "System", "D_TemperatureSensor1.xml", nil, nil, nil, nil, nil, parentId)
end
Reload your Luup engine, refresh your browser and you should see the new variables.
Then you can set these variables :
Topic (e.g.) : Vera/+/TemperatureSensor1/88
Target: urn:upnp-org:serviceId:TemperatureSensor1,CurrentTemperature=payload.CurrentTemperature and (tonumber(payload.CurrentTemperature) or â0â)
Iâve installed this using the great instructions provided but it is failing⊠anyone have any idea what this means:
01 01/12/17 22:33:26.347 LuaInterface::CallFunction_Startup-1 device 105 function startup failed [string âmodule(âL_SensorMqtt1â, package.seeall)âŠâ]:107: attempt to index field âclientâ (a nil value) <0x2bc43680>
01 01/12/17 22:33:26.347 LuImplementation::StartLua running startup code for 105 I_SensorMqtt1.xml failed <0x2bc43680>
Thanks!
[quote=âcastrov, post:88, topic:190658â]Iâve installed this using the great instructions provided but it is failing⊠anyone have any idea what this means:
01 01/12/17 22:33:26.347 LuaInterface::CallFunction_Startup-1 device 105 function startup failed [string âmodule(âL_SensorMqtt1â, package.seeall)âŠâ]:107: attempt to index field âclientâ (a nil value) <0x2bc43680>
01 01/12/17 22:33:26.347 LuImplementation::StartLua running startup code for 105 I_SensorMqtt1.xml failed <0x2bc43680>
Thanks![/quote]
I think that the MQTT library is not installed.
You have to copy the files âJSON.luaâ, âmqtt_library.luaâ and âutility.luaâ in â/usr/lib/luaâ.
If you get my modifications, you donât have to put the âJSON.luaâ file.
Iâve added action âPublishâ, to be able to publish from LUA code.
The files were in there originally⊠but I still receive this error.
Any other ideas? What do you mean by your modifications? I grabbed all files from GitHub - vosmont/vera-mqtt
Thanks!
root@MiOS:/usr/lib/lua# ls -l | grep âJan 12â
-rw-râr-- 1 root root 49510 Jan 12 20:56 JSON.lua
-rw-râr-- 1 root root 272996 Jan 12 20:56 mqtt_library.lua
-rw-râr-- 1 root root 93149 Jan 12 20:56 utility.lua
[quote=âvosmont, post:89, topic:190658â][quote=âcastrov, post:88, topic:190658â]Iâve installed this using the great instructions provided but it is failing⊠anyone have any idea what this means:
01 01/12/17 22:33:26.347 LuaInterface::CallFunction_Startup-1 device 105 function startup failed [string âmodule(âL_SensorMqtt1â, package.seeall)âŠâ]:107: attempt to index field âclientâ (a nil value) <0x2bc43680>
01 01/12/17 22:33:26.347 LuImplementation::StartLua running startup code for 105 I_SensorMqtt1.xml failed <0x2bc43680>
Thanks![/quote]
I think that the MQTT library is not installed.
You have to copy the files âJSON.luaâ, âmqtt_library.luaâ and âutility.luaâ in â/usr/lib/luaâ.
If you get my modifications, you donât have to put the âJSON.luaâ file.[/quote]
New version on github (check the loading of the MQTT library)
@castrov, can you try to copy again the dependencies ?
The file sizes are weird.
on my Vera :
root@MiOS_xx:/# ls -lrt /usr/lib/lua
...
lrwxrwxrwx 1 root root 28 Sep 24 21:23 dkjson.lua -> /mios/usr/lib/lua/dkjson.lua
-rw-r--r-- 1 root root 5989 Dec 5 23:28 utility.lua
-rw-r--r-- 1 root root 29819 Dec 5 23:28 mqtt_library.lua
[quote=âvosmont, post:85, topic:190658â]Some modifications :
You can subscribe to a topic by creating a child device :
1/ Add a new device and choose a type (e.g. âD_BinaryLight1.xmlâ or âD_TemperatureSensor1.xmlâ).
2/ Reload LUUP engine.
3/ Change the attribut âid_parentâ with the id of the MQTT plugin device.
4/ Reload LUUP engine and refresh your browser.
5/ You should see variables âmqttTargetâ and âmqttTopicâ in your newly created device.
6/ Set the topic you want to subcribe to and the target (format: service,variable=(formula in LUA)).
7/ Reload LUUP engine.
If the payload of the received message is in JSON, the plugin will try to decode it and put it in the variable âpayloadâ in the context of the LUA formula.
examples :
Topic : Test/#
Target: urn:upnp-org:serviceId:SwitchPower1,Status=payload.value and ((payload.value==âalarmâ) and â1â or â0â)
On a message from topic âTest/Somethingâ with payload â{âvalueâ:âalarmâ}â, the switch will be powered on.
Topic : Test/+/Sensor
Target: urn:upnp-org:serviceId:TemperatureSensor1,CurrentTemperature=payload.temperature and (tonumber(payload.temperature) or â0â)
On a message from topic âTest/Something/Sensorâ with payload "{"temperature â:â15.2â, âhygrometryâ:â80â}â, the temperature will be set to 15,2.[/quote]
Does the device type have to correspond to the Vera service we want to use? (Ex. If we want to trigger a light switch we have to use D_BinaryLight1.xml).
Also thanks for your work!
You take the device type you want. When a message is received, the plugin updates the given service/variable without checking that it was already defined in your device.
⊠so you can do what you want !
Hello, fabulous work on this client, it is amazing! I just added my first child device using your temperature sensor example (I have a remote temp sensor reporting via MQTT with a payload of â65.73â only (whatever the temp is). The temperature is not showing up on the child device, but it does show up under the Variables tab under the variable CurrentTemperature. At the top of the page I now have the blue bar and it says MQTT Client[111]: Running Lua Startup and it never goes away (it survives Lua reload and device restart). Any ideas?
EDIT: Checked through the LUA log and realized that temperature sensors do not have an implementation file, removed that and the blue bar went away, but the sensor is not showing the temperature on the main devices screen or anywhere inside the device. The parent (111, MQTT Client plugin) is receiving the temperature and tossing it in a variable. Should I just wait and see if it figures itself out?
Iâve checked on my VeraEdge and on openLuup : itâs ok.
Have you refreshed your browser ?
Check that target is âurn:upnp-org:serviceId:TemperatureSensor1,CurrentTemperature=somethingâ
Anyone try getting this to interface with Osramâs Lightify system? I saw someone posted Python code for MQTT for Lightify (GitHub - owagner/lightify2mqtt: OSRAM Lightify to MQTT gateway, following the mqtt-smarthome architecture)
[quote=âvosmont, post:96, topic:190658â]Iâve checked on my VeraEdge and on openLuup : itâs ok.
Have you refreshed your browser ?
Check that target is âurn:upnp-org:serviceId:TemperatureSensor1,CurrentTemperature=somethingâ[/quote]
Vosmont,
my mqttTopic is â/ESP_Office/Office TPH/Temperatureâ and the mqttTarget is âurn:upnp-org:serviceId:TemperatureSensor1,CurrentTemperature=payload.temperature and (tonumber(payload.temperature) or â0â)â. currentTemperature is currently populated with the value 66.76, which happened a long time ago (the most recent value in the parent plugin is mqttLastReceivedTopic â/ESP_Office/Office TPH/Temperatureâ and mqttLastReceivedPayload â69.08â. It seems that the parent plugin just isnât handing this down to the child. It has worked successfully at least once though, as that temperature is displayed on the devices page now.
The LUA formula is made for handling complex data in JSON.
If the message (payload) is just a string, you donât have to use the formula.
your setting could be :
mqttTopic : â/ESP_Office/Office TPH/Temperatureâ (it should be âESP_Office/Office TPH/Temperatureâ)
mqttTarget : âurn:upnp-org:serviceId:TemperatureSensor1,CurrentTemperature=â
I went ahead and removed the forward slash from the parent and the child. (is it necessary to click the checkbox below to make the edit successfully? I never understood what it doesâŠ) I hope Iâm just doing something dumb. I went ahead and attached the variables page from the client and the child. Thank you for your help!
Best Home Automation shopping experience. Shop at Ezlo!
© 2024 Ezlo Innovation, All Rights Reserved. Terms of Use | Privacy Policy | Forum Rules