MQTT Client Plugin

Hi everyone,

[s]

Upload the attached files
Where on Vera FS should I put Plugin/_SensorMqtt1. files? I don’t see any info on that. Thanks!
Upd: Found Develop Apps/Luup files → Upload
[/s]

Client can not connect to mosquitto (mosquitto version 1.4.11 (build date 2017-04-21 14:26:22+0300)). Is it a supported version?
Plugin from master (GitHub - jonferreira/vera-mqtt)

client:

50 08/11/17 17:52:22.148 luup_log:14: SensorMqtt: Connecting as MQTT client: Vera-50104894 to mqttServerIp: 10.3.1.1 mqttServerPort: 1883... <0x774d4520> 06 08/11/17 17:52:22.151 Device_Variable::m_szValue_set device: 14 service: urn:upnp-sensor-mqtt-se:serviceId:SensorMqtt1 variable: mqttServerStatus was: Disconnected now: Connected #hooks: 0 upnp: 0 skip: 0 v:(nil)/NONE duplicate:0 <0x774d4520> 06 08/11/17 17:52:22.152 Device_Variable::m_szValue_set device: 14 service: urn:upnp-sensor-mqtt-se:serviceId:SensorMqtt1 variable: mqttServerConnected was: 0 now: 1 #hooks: 0 upnp: 0 skip: 0 v:(nil)/NONE duplicate:0 <0x774d4520> 06 08/11/17 17:52:22.155 Device_Variable::m_szValue_set device: 14 service: urn:upnp-sensor-mqtt-se:serviceId:SensorMqtt1 variable: mqttServerStatus was: Connected now: Disconnected #hooks: 0 upnp: 0 skip: 0 v:(nil)/NONE duplicate:0 <0x774d4520> 06 08/11/17 17:52:22.155 Device_Variable::m_szValue_set device: 14 service: urn:upnp-sensor-mqtt-se:serviceId:SensorMqtt1 variable: mqttServerConnected was: 1 now: 0 #hooks: 0 upnp: 0 skip: 0 v:(nil)/NONE duplicate:0 <0x774d4520>

server:

Aug 11 17:52:22 ubox mosquitto[39363]: 1502463142: New connection from 10.3.1.9 on port 1883. Aug 11 17:52:22 ubox mosquitto[39363]: New connection from 10.3.1.9 on port 1883. Aug 11 17:52:22 ubox mosquitto[39363]: 1502463142: Sending CONNACK to 10.3.1.9 (0, 5) Aug 11 17:52:22 ubox mosquitto[39363]: Sending CONNACK to 10.3.1.9 (0, 5) Aug 11 17:52:22 ubox mosquitto[39363]: 1502463142: Socket error on client <unknown>, disconnecting. Aug 11 17:52:22 ubox mosquitto[39363]: Socket error on client <unknown>, disconnecting.

so I am trying to get this to give me a report of the KWH used on my open energy monitor using MQTT values it provides

This work in OpenHab like this
Number emonpi_ct1 “Power 1 [%d W]” { mqtt=“<[mosquitto:emon/emonpi/power1:state:default]” }
Number emonpi_ct2 “Power 2 [%d W]” { mqtt=“<[mosquitto:emon/emonpi/power2:state:default]” }
Number emonpi_vrms “Voltage [%.1f VRMS]” { mqtt=“<[mosquitto:emon/emonpi/vrms:state:default]” }

I can see all the values using a spy with the below TOPIC

Topic : emon/#

and I see number values in

emon/emontxshield/power1

how do I rewrite the Topic/Target to show these values on the CHIILD node I have created already?

Topic : emon/emontxshield/power1
Target: urn:upnp-org:serviceId:PowerMeter,CurrentPower=payload.power and (tonumber(payload.power) or “0”)

Thanks

Hello dpackham,

if the payload is just a number (not json), you should use :

Target: urn:upnp-org:serviceId:PowerMeter,CurrentPower=

Just installed this great plug-in on a vea3-UI5, but getting:

50	10/01/17 3:51:34.332	luup_log:18: SensorMqtt: Loading plugin module L_SensorMqtt1 ... <0x2bdc7680>
50	10/01/17 3:51:34.489	luup_log:18: SensorMqtt: Plugin module L_SensorMqtt1 loaded __LEAK__ this:69632 start:151552 to 0xf18000 <0x2bdc7680>
50	10/01/17 3:51:34.489	luup_log:18: SensorMqtt: Initializing SensorMqtt <0x2bdc7680>
50	10/01/17 3:51:34.493	luup_log:18: SensorMqtt: Connecting as MQTT client: Vera-30002732 to mqttServerIp: 192.168.0.62 mqttServerPort: 1883... <0x2bdc7680>
50	10/01/17 3:51:34.507	luup_log:18: SensorMqtt: Successfully connected to broker: 192.168.0.62 on port 1883 __LEAK__ this:8192 start:172032 to 0xf1d000 <0x2bdc7680>
50	10/01/17 3:51:34.510	luup_log:18: SensorMqtt: MQTT connection status changed from "Disconnected" to "Connected" <0x2bdc7680>
01	10/01/17 3:51:34.513	LuaInterface::CallFunction_Startup-1 device 18 function startup failed [string "module("L_SensorMqtt1", package.seeall)..."]:372: attempt to call field 'decode' (a nil value) <0x2bdc7680>
01	10/01/17 3:51:34.513	LuImplementation::StartLua running startup code for 18 I_SensorMqtt1.xml failed <0x2bdc7680>

I’ve enabled:

[ul][li]urn:upnp-org:serviceId:SwitchPower1[/li]
[li]urn:upnp-org:serviceId:Dimming1[/li][/ul]

What am I missing?

Nobody can share me a clue, how to tackle this startup issue?

Thanks in advance!

Bruce, what node are you using for writing to the influxDB? the standard node-red-contrib-influxdb node does not like the format of your parser function. i’ve been trying to get all sensor data into the influxDB, but whenever i select any measurement it tells me the series is empty. i was looking over the format of the message sent to the influxDB node and all looks good.

{“measurement”:“TemperatureSensor1”,“topic”:“Vera/35#####/TemperatureSensor1/61”,“payload”:[{“CurrentTemperature”:72,“time”:“1512427106000”},{“deviceId”:61,“deviceName”:“DOWNSTAIRS_THERM”,“deviceType”:“HVAC_ZoneThermostat”}],“_msgid”:“f3927e65.9202e”}

Any clues?

Figured it out… was not setting the message correctly in my code.

Has anyone managed to use this with AWS or Azure IOT Hub? I’m currently using mysensors.org sensors/gateway (non-mqtt), and I’m looking at rebuilding all of this to send my data up to AWS (ideally) or Azure.

I need to not only publish data from the Vera to IOT Hub, but I also need to be able to subscribe to IOT hub and create devices on the Vera which get that data.

AWS yes. Azure I gave up on because I believe to make what I was doing work, I had to pay for their message hub or some middleware or something like that. I do prefer AWS.

For AWS I believe I did set up a bridge. On Linux that I already had running on a small board computer. RPi would work fine but I typically use Odroid XU4.

I tweaked the mqtt client code a little bit to suit my fancy. Nothing major.

I have several virtual devices that receive mqtt messages with effect. A switch, temperature, humidity, string container. It’s fun to mess with.

I have this setup for a lot of sensors and it all working great except one.
Device type: urn:schemas-micasaverde-com:device:DoorSensor:1
category_num: 4
subcategory_num: 1

It never gets Tripped, but on the dash board it shows like its tripped. Can’t understand why I don’t get anything from this device (and yes its activated under Alias)

Anyone know what this could be?

I have tried and tried to install MQTT using this instructions GitHub - vosmont/vera-mqtt
I added Dependencies and Plugin and verified that it’s in place.
I added a device following the instructions.
I restarted Vera Edge.

But every time it’s ends upp with this:

2/08/18 21:57:26.321 Device_LuaUPnP::LoadDeviceDoc ixmlParseBufferEx /etc/cmh-ludl//D_SensorMqtt1.xml size 41234 ret 106 <0x77daf000>
01 02/08/18 21:57:26.322 JobHandler_LuaUPnP::CreateDevice_LuaUPnP failed to load 187/D_SensorMqtt1.xml so device 187 is offline <0x77daf000>

Does anyone know what the problem can be?

//PerEric

I see the purpose of this plugin is to send events from Vera to MQTT. Is there a reverse plugin? I have another system that is sending to MQTT and I want Vera to grab those events and apply them to a Virtual Switch inside Vera that can then be used for created rules against.

The goal, is for switching or maintaining multiple systems. I’m coming from or trying to come from SmartThings. I can send SmartThings events to MQTT. Now I need to receive them with Vera and act upon them. I have this setup currently from SmartThings to Home Assistant and I would like to have Vera be the center of my Automations collecting from other sources if possible.

Otherwise, it may seem as though Home Assistant would be the choice to be the “Center” of everything and have other systems sending data to it. But then that leaves me with the question of what do I need Vera for then?

The plugin can receive events also. The payload can then be passed to a child device of the plugin. I have tested this using a binary switch, humidity sensor, temperature sensor, and a multi-string container. I did have to manually create the child devices and change the id_parent attribute to point to the plugin. The plugin then creates a few variables in the child device that you can configure with a topic, and what you want to do with the payload. In my case, for the thermometer, the topic is set to Vera/Topics/Thermometer and the target is configured with urn:upnp-org:serviceId:TemperatureSensor1,CurrentTemperature=payload.temperature and (tonumber(payload.temperature) or “0”)

Very interesting. I’ll have to take a closer look into the mqtt client then. It’s good that it’s bi-directional.

The plugin works good.
But I would like send a MQTT message by an another system like raspeberry/linux. For the test I use mosquitto_pub with the vera IP address and 3480 port number. The function return an error with this message ‘The connection was lost’.

Have you an idea ? It’s possible to send an external MQTT message to the Vera ?

Thanks in advance

Sorry for the delayed reply. I don’t visit the forum as much as I used to.

Yes you can. But the Vera MQTT Plugin is a client, not a broker, so you can’t point your mosquitto client (mosquitto_pub is a client) to it. A client must connect to a broker.

You can start and run your own broker on the Pi via the mosquitto package, or you can use the awesome and free Cloud MQTT broker service which is the same that I use (no affiliation whatsoever). Or any broker you are already using will work fine too.

There’s some fiddling to get everything set up between the Cloud MQTT endpoint, the Vera plugin, and your pub client on the Pi. So, to send the external MQTT message to the Vera, the mosquitto pub client on your Pi connects to the Cloud MQTT (or your own broker) and publishes a message to a topic that the Vera MQTT Plugin is listening on. Of course the Vera plugin has to connect to the same Cloud MQTT broker (or your own) and be listening on that topic.

Btw I also like to use the mqtt-spy software (Java package, runs on my Win7Pro and elsewhere I assume) to be able to monitor things when setting it all up. It’s a client too meaning you can use it to connect to your broker and monitor the same topics and also publish messages to topics if you want.

Hope this helps explain

Can anyone make sense of this log entry? It is connected to the broker but no pub/sub takes place.

Thanks in advance

root@MiOS_50003670:~# cat /tmp/log/cmh/LuaUPnP.log | grep '\(^01\|^02\|^35\|^50\).*SensorMqtt'
50	03/06/18 19:09:35.620	luup_log:168: SensorMqtt: Loading plugin module L_SensorMqtt1 ... <0x764d3520>
50	03/06/18 19:09:35.680	luup_log:168: SensorMqtt: Plugin module L_SensorMqtt1 loaded <0x764d3520>
50	03/06/18 19:09:35.680	luup_log:168: SensorMqtt: Initializing SensorMqtt <0x764d3520>
50	03/06/18 19:09:35.689	luup_log:168: SensorMqtt: Connecting as MQTT client: Vera-50003670 to mqttServerIp: mqtt.synology.me mqttServerPort: 1883... <0x764d3520>
50	03/06/18 19:09:35.917	luup_log:168: SensorMqtt: Successfully connected to broker: mqtt.synology.me on port 1883 <0x764d3520>
50	03/06/18 19:09:35.918	luup_log:168: SensorMqtt: MQTT connection status changed from "Disconnected" to "Connected" <0x764d3520>
01	03/06/18 19:09:35.921	LuaInterface::CallFunction_Startup-1 device 168 function startup failed [string "module("L_SensorMqtt1", package.seeall)..."]:377: bad argument #1 to 'pairs' (table expected, got nil) <0x764d3520>
01	03/06/18 19:09:35.922	LuImplementation::StartLua running startup code for 168 I_SensorMqtt1.xml failed <0x764d3520>

Hi,

I do not know the plugin but your log shows a LUA code error. File L_SensorMqtt1.lua line 377 should show a pairs command. Its variable does not have a value for some reason.

Happy debugging.

Cheers Rene

Yes I see the error I’m hoping someone can point me in the right direction to fix it. :slight_smile:

File L_SensorMqtt1.lua line 377 appears to be past the end of the file. But pairs (the function) does show up in 3 places in the file.

These instances are configuration related so hard to say more without knowing your configuration

The code is trying to iterate over a list of presumed name, value pairs or something similar and hits a nil result

What do you have set up in watchdog?

I reloaded the dependencies and now it works. Not sure why but it’s working. Thanks!