MQTT Client Plugin

[quote=“stefaanbolle, post:71, topic:190658”]My openhab 1.8.3 is running on 192.168.1.40
Mosquitto is also running on 192.168.1.40
Vera is 192.168.1.251

Below my logs
Mosquitto

1473231011: New connection from 192.168.1.251 on port 1883.
1473231011: Sending CONNACK to 192.168.1.251 (0, 5)
1473231011: Socket error on client <unknown>, disconnecting.

vera

50	09/07/16 8:50:11.868	luup_log:188: SensorMqtt: Connecting to MQTT, mqttServerIp: 192.168.1.40 mqttServerPort: 1883... <0x2c2eb680>
35	09/07/16 8:50:11.869	luup_log:188: SensorMqtt: Authenticating with username: openhab <0x2c2eb680>
50	09/07/16 8:50:11.872	luup_log:188: SensorMqtt: Successfully connected to broker: 192.168.1.40 on port 1883 <0x2c2eb680>
50	09/07/16 8:50:11.873	luup_log:188: SensorMqtt: MQTT connection status changed from "Disconnected" to "Connected" <0x2c2eb680>
35	09/07/16 8:50:11.976	luup_log:188: SensorMqtt: Connection down: /usr/lib/lua/mqtt_library.lua:382: MQTT.client:handler(): Not connected <0x2c2eb680>
50	09/07/16 8:50:11.977	luup_log:188: SensorMqtt: MQTT connection status changed from "Connected" to "Disconnected" <0x2c2eb680>

35	09/07/16 8:50:32.127	luup_log:188: SensorMqtt: Watch event - device: 150 variable: Timestamp value Wed 08:41 => Wed 08:50 <0x32ceb680>
50	09/07/16 8:50:32.131	luup_log:188: SensorMqtt: Sending [Netatmo] Timestamp changed to Wed 08:50 from Wed 08:41 on topic {} <0x32ceb680>
35	09/07/16 8:50:32.131	luup_log:188: SensorMqtt: Publish topic: {} message:{"DeviceId":150,"DeviceName":"Netatmo","DeviceType":"urn:akbooer-com:device:Netatmo:1","OldTimestamp":"Wed 08:41","RoomId":9,"RoomName":"3-Netatmo","ServiceId":"urn:akbooer-com:serviceId:Netatmo1","Time":1473231032,"Timestamp":"Wed 08:50","Variable":"Timestamp"} <0x32ceb680>
50	09/07/16 8:50:32.132	luup_log:188: SensorMqtt: Connecting to MQTT, mqttServerIp: 192.168.1.40 mqttServerPort: 1883... <0x32ceb680>
35	09/07/16 8:50:32.133	luup_log:188: SensorMqtt: Authenticating with username: openhab <0x32ceb680>
50	09/07/16 8:50:32.136	luup_log:188: SensorMqtt: Successfully connected to broker: 192.168.1.40 on port 1883 <0x32ceb680>
50	09/07/16 8:50:32.137	luup_log:188: SensorMqtt: MQTT connection status changed from "Disconnected" to "Connected" <0x32ceb680>
35	09/07/16 8:50:36.125	luup_log:188: SensorMqtt: Connection down: socket_client:receive(): closed <0x332eb680>
50	09/07/16 8:50:36.126	luup_log:188: SensorMqtt: MQTT connection status changed from "Connected" to "Disconnected" <0x332eb680>

checksums (just reuploaded latest download from github page)

MD5(/usr/lib/lua/mqtt_library.lua)= d277c620e1d55b6981c905d0a336216f MD5(/usr/lib/lua/utility.lua)= 9bb0529b5a3d4368376a37ba9453dc4f[/quote]

After seeing this, I went back and scrubbed/inspected each and every client authentication step and found a typo in the variable name for the mqtt broker password! I have fixed that typo, added the mqtt client id to the info logging and committed the changes to git.

Please try the latest version of the plugin on GitHub including the dependency utility.lua (I didn’t update it but your checksum doesn’t match the GitHub checksum so perhaps you missed this one when I upgraded SensorMqtt to use the Paho 0.3 mqtt lua client. Here are the checksums for everything.

[code]
$ find . -type f -not -path ‘./.git/*’ -exec openssl dgst -md5 {} ;
MD5(./Dependencies/usr/lib/lua/JSON.lua)= 7df77af31f3854a8db9dc82fcf789dea
MD5(./Dependencies/usr/lib/lua/mqtt_library.lua)= d277c620e1d55b6981c905d0a336216f
MD5(./Dependencies/usr/lib/lua/utility.lua)= 70673ff99bbc4015803facd6fe6687b5
MD5(./Plugin/D_SensorMqtt1.json)= c7d8b12e2e5fe2d61edfd614b815f9e1
MD5(./Plugin/D_SensorMqtt1.xml)= 4326276bc240949c9914fb8bb1043c6b
MD5(./Plugin/I_SensorMqtt1.xml)= 3ff8c0074b14a9908586d70c3e507fc1
MD5(./Plugin/J_SensorMqtt1.js)= 5d63ee1c3e28221be85dea901c4a0993
MD5(./Plugin/L_SensorMqtt1.lua)= 9dce0494565d602abf15a89110aa27f5
MD5(./Plugin/S_SensorMqtt1.xml)= 23bc8fa230b8be8c29b130d6f9ce95c0

[code]

I really, really appreciate your patience in running numerous tests. Had I not been traveling, I would have set up an authenticated broker instance running 1.4.10 to mimic your config and dug in to find this on my own. I’m pretty sure we nailed it though and thanks again for all your help and patience![/code]

Hi Blacey, guess what…

MQTT IP: 192.168.1.40 MQTT Port: 1883 MQTT User: openhab MQTT Status: Connected MQTT Last Message: {"Payload":"{\"DeviceId\":150,\"DeviceName\":\"Netatmo\",\"DeviceType\":\"urn:akbooer-com:device:Netatmo:1\",\"OldTimestamp\":\"Wed 15:00\",\"RoomId\":9,\"RoomName\":\"3-Netatmo\",\"ServiceId\":\"urn:akbooer-com:serviceId:Netatmo1\",\"Time\":1473253666,\"Timestamp\":\"Wed 15:07\",\"Variable\":\"Timestamp\"}","Topic":"{}"}

I think the problem has been solved. Connection is established!
Thanks a lot for your support and quick response!
I’m looking forward to further developments of your plugin and I’m certainly willing to test if it can help you.

Subscribing to mqtt broker for reading values can be a great update since this could open the door to owntracks integration.

[quote=“stefaanbolle, post:73, topic:190658”]I think the problem has been solved. Connection is established!
Thanks a lot for your support and quick response!
I’m looking forward to further developments of your plugin and I’m certainly willing to test if it can help you.

Subscribing to mqtt broker for reading values can be a great update since this could open the door to owntracks integration.[/quote]

Awesome! :slight_smile: :slight_smile: :slight_smile: Thanks for your diligent and methodical testing and feedback.

Feel free to outline the owntracks use case that you envision to influence the direction of the plugin. :wink:

Owntracks reports it’s status/presence on Android/iOS using mqtt to a mqtt broker.
It would be great if a plugin in Vera would allow to use owntracks as presence tracker (kind of iphone locator plugin) and additionally shows any monitored device (ie kids) on a map in vera.
That’s in short my usecase.

Interesting Work! :smiley:

Would it be possible to share the Node-Red flow?

I got the plugin working. I documented the steps below. This guide assumes you have installed a MQTT-broker on a remote Raspberry Pi. The MQTT-Broker I’m using is Mosquitto. Check out https://www.youtube.com/watch?v=AsDHEDbyLfg for instructions on how to install it.

[code]#1 Download the zip from https://github.com/jonferreira/vera-mqtt to my MacBook

#2 Copy the Dependency-files to the Vera
#2.1 Terminal
#2.2 cd ~/Downloads/
#2.3 scp vera-mqtt-master.zip root@vera:
#2.4 ssh root@vera
#2.5 unzip vera-mqtt-master.zip
#2.6 cp vera-mqtt-master/Dependencies/usr/lib/lua/* /usr/lib/lua/

#3 Copy the Plugin-files to the Vera
#3.1 Terminal
#2.2 cd ~/Downloads/
#3.1.2 unzip vera-mqtt-master.zip
#3.2 Start up your FireFox-browser
#3.2.1 http://vera/cmh/#develop_apps
#3.2.2 Luup files -> Upload
#3.2.3 Select all files in the unpacked vera-mqtt-master/Plugin directory

#4 Create a new Device using the newly uploaded Plugin-files
http://vera/cmh/#develop_apps -> Create device ->
Description = “MQTT client”
Upnp Device FileName = “D_SensorMqtt1.xml”
Upnp Implementation Filename = “I_SensorMqtt1.xml”
-> Create device

#5 Reload luup
http://vera:3480/data_request?id=reload

#6 Wait a few moments, and the newly created device will popup at http://vera/cmh/#devices
However, the device fails with the error messsage “MQTT client[189]: Startup Lua Failed”
Okey, so we need to peek in the logs on the Vera

 ssh root@vera
 cat /tmp/log/cmh/LuaUPnP.log | grep '\(^01\|^02\|^35\|^50\).*SensorMqtt'

Doh! Reading the error message you now realize that you need to configure the plugin :stuck_out_tongue:

#7 http://vera/cmh/#devices -> MQTT client -> Advanced -> Variables tab
mqttServerIp = Raspberry_ip
mqttServerPort = 1883
mqttServerUser = username
mqttServerPassword = password

#8 Start a subscriber on the Raspberry, and verify the credentials you have provided above
mosquitto_sub -h 127.0.0.1 -p 1883 -u username -P password -t Vera/#
mosquitto_pub -h 127.0.0.1 -p 1883 -u username -P password -t Vera/Event/DeviceAlias -m “qwerty”

#9 Start pushing event changes from Vera-attached devices

 http://vera/cmh/#devices -> MQTT client -> WatchDog -> and checkbox the following
   * urn:upnp-org:serviceId:TemperatureSensor1     CurrentTemperature  CurrentTemperature
   * urn:micasaverde-com:serviceId:HumiditySensor1 CurrentLevel        CurrentLevel
   * urn:upnp-org:serviceId:SwitchPower1           Status              Status
   -> Save Changes

#10 Reload luup
http://vera:3480/data_request?id=reload

#11 Go into the Vera-gui and toggle a lightswitch
http://vera/cmh/#devices

#12 Go back to the scrubscriber that you started at step #8. You should now see the mqtt-message there.
[/code]

I got the Node-Red thing working on my Raspberry Pi 3 (RPI3). This guide assumes you have previously set up the MQTT-Broker ‘Mosquitto’ on the RPI3. Here’s how I did it:

[code]#--------------------------------

1. Install InfluxDb on the RPI3

#--------------------------------
ssh pi@raspberry_ip

sudo apt-get install apt-transport-https
curl -sL https://repos.influxdata.com/influxdb.key | sudo apt-key add - source /etc/os-release
echo “deb InfluxDB Repository jessie stable” | sudo tee /etc/apt/sources.list.d/influxdb.list
sudo apt-get update && sudo apt-get install influxdb
sudo systemctl start influxdb

→ InfluxDb Admin gui = http://raspberry_ip:8083/
→ InfluxDb data get/set via http = http://raspberry_ip:8086/

#----------------------

2. Configure InfluxDb

#----------------------
influx
CREATE DATABASE “vera_db”
SHOW DATABASES

CREATE USER “nodered” WITH PASSWORD ‘nodered’
GRANT WRITE ON vera_db TO nodered

CREATE USER “grafana” WITH PASSWORD ‘grafana’
GRANT READ ON vera_db TO grafana

SHOW USERS
SHOW GRANTS FOR nodered
SHOW GRANTS FOR grafana

#------------------------------------------------------------------------

3. Install Node Red on the RPI3

(Check out http://nodered.org/docs/hardware/raspberrypi for details)

#------------------------------------------------------------------------
ssh pi@raspberry_ip
sudo apt-get update
sudo apt-get install nodered
sudo apt-get install npm
sudo npm install -g npm@2.x
sudo apt-get install sense-hat

sudo systemctl enable nodered.service
sudo node-red-start

-> NodeRed web gui = http://raspberry_ip:1880

#---------------------------------

4. Create the ‘flow’ in Node-Red

#---------------------------------

4.1 - Drag/Drop an MQTT-inputnode and configure it:

Server = 127.0.0.1:1883
Topic = Vera/#
QoS = 2
Name = MQTT input on topic Vera/#

4.2 - Drag/Drop a Function-Node and configure it:

Name = Function converting MQTT msg to InfluxDB-format
Outputs = 1
Function =
//------------------------------------------------------------
// 1. Retrieve incoming values from the Mosquitto-MQTT message
//------------------------------------------------------------
var Topic = msg.topic;

         var Influx_Key    = "Unknown_key";
         var Inflex_KeyTag = "Unknown_tag";
         var Influx_Value  = "Unknown_value";
         
         var objJson = JSON.parse(msg.payload);
         var DeviceName         = objJson.DeviceName;
         var DeviceType         = objJson.DeviceType;
         var Variable           = objJson.Variable;
         var DeviceId           = objJson.DeviceId;
         var RoomName           = objJson.RoomName;
         var Time               = objJson.Time;
         
         //
         // Replace any spaces with underscore characters in DeviceNames
         //
         DeviceName=DeviceName.replace(/ /g,"_");
         
         //
         // We have different value-variables depending on the DeviceType that sent the msg
         // You need to extend this section for other sensors
         //
         if (DeviceType.indexOf("HumiditySensor") !=-1) 
         {
             Influx_Key    = "humidity";
             Influx_KeyTag = "device=" + DeviceName;
             Influx_Value  = "value="  + objJson.CurrentLevel;
         }
         if (DeviceType.indexOf("TemperatureSensor") !=-1) 
         {
             Influx_Key    = "temperature";
             Influx_KeyTag = "device=" + DeviceName;
             Influx_Value  = "value="  + objJson.CurrentTemperature;
         }

         //-----------------------------------------------------------
         // 2. Convert the retrieved data above into an InfluxDb-
         //    compatible format string.
         //
         //    Influx text based line protocol:
         //        [key] [fields] [timestamp]
         //
         //    Example: temperature,device=BedroomTemp value=11.3
         //-----------------------------------------------------------
         var InfluxFmtStr = Influx_Key + ',' + Influx_KeyTag + ' ' + Influx_Value;
         
         //-----------------------------------------------------------
         // 3. Create a new object containing our formatted InfluxDb
         //    string and return it, so it will be passed to the next
         //    component in the Node Red pipeline
         //-----------------------------------------------------------
         var DatabaseName = 'vera_db';
         var newMsg={};
         newMsg.payload = new Buffer(InfluxFmtStr);
         newMsg.url     = "http://127.0.0.1:8086/write?db=" + DatabaseName;
         return newMsg;

4.3 - Drag/Drop a http-inputnode and configure it

Method = POST
URL = http://127.0.0.1:8086/write?db=vera_db
Enable secure (SSL/TLS) connection = No
Use basic authentication = No
Return = a UTF-8 string
Name = http input req sending to InfluxDB

4.4 - Connect the device chain: MQTT → Function → HTTP

4.5 - Press the red Deploy-button

#------------------------------------------------------------------------------------

5. Test NodeRed-flow by publishing an MQTT message using the commandline tool

‘mosquitto_pub’. Verify the data is inserted in the InfluxDb database.

#------------------------------------------------------------------------------------
mosquitto_pub -t Vera/test -m ‘{“CurrentTemperature”:11.3,“DeviceId”:151,“DeviceName”:“BedroomTemp”,“DeviceType”:“urn:schemas-micasaverde-com:device:TemperatureSensor:1”,“OldCurrentTemperature”:11.4,“RoomId”:13,“RoomName”:“Bedroom”,“ServiceId”:“urn:upnp-org:serviceId:TemperatureSensor1”,“Time”:1478159673,“Variable”:“CurrentTemperature”}’

influx
use vera_db
show series
select * from temperature
select * from temperature where device=‘BedroomTemp’
[/code]

Here’s a screendump of my Node-Red flow.

[quote=“kodarn, post:76, topic:190658”]Interesting Work! :smiley:

Would it be possible to share the Node-Red flow?[/quote]

Hi @kodarn, it seems like you are making great progress on your MQTT deployment. In the spirit of sharing, here are a few pertinent details for my deployment and I am happy to provide any additional details that you would like… I am also using mosquitto to collect sensor measurements from 4 Veras running UI7 at different geographic locations. Each Vera reports into a local mqtt broker running on an RPI that is bridged to the central broker (SeapSpray) and they communicate using TLS/SSL over the Internet. The impetus is that the local MQTT broker will cache sensor readings whenever the Internet is down and then reconnect when the Internet is up at which point it will send all previous and current sensor readings/measurements to the central broker virtually eliminating any data loss.

To simplify the NodeRed transformation, I use the MQTT identifier Vera/(SerialNumber)/(ServiceName)/(DeviceId) so I can persist all measurements (i.e. ServiceNames) to separate InfluxDB named by SerialNumber. So I have a single measure transform for all incoming measures that are then split out into the respective databases.

I have attached a diagram of my deployment and NodeRed topology and here is the core measure transform:

// Transform MQTT payload into InfluxDB measure
// Topic is defined as Vera/(Serial)/(Service)/(DeviceId)
var measure = {};
var payload = new Array(2);

// Set the measurement for this measure (3rd element from topic)
// MQTT Client Topic Publish == Vera/(SerialNumber)/(ServiceName)/(DeviceId)
measure.measurement = msg.topic.split('/')[2];

data = msg.payload;

// Field first, with time converted to milliseconds
valueAsString = data[data.Variable];
if (!isNaN(parseFloat(valueAsString)) && isFinite(valueAsString)) {
    value = parseFloat(valueAsString);
} else {
    value = valueAsString;
}

payload[0] = {
    [data.Variable] : value,
    time            : data.Time + '000'
};

// Tags
payload[1] = {
    deviceId    : data.DeviceId,
    deviceName  : data.DeviceName,
    deviceType  : data.DeviceType.split(':').slice(-2)[0],
};

measure.topic = msg.topic;
measure.payload = payload;

// Update the status with the # of messages processed
var count = context.get('count')||0;
count += 1;
context.set('count', count);

node.status({text: count});

return measure;

Note, my core measure transform is designed to allow replay of external legacy events hence the ‘parseFloat()’ checks so not needed if you aren’t going to replay data and you don’t really need to create a new output measure, you can simply modify the input measure. This is working great for me so I haven’t taken the time to simplify further.

Cheers,
Bruce

Great work Bruce!

Thanks for sharing :slight_smile:

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 :slight_smile:
Currently I made:
Influxdb
Grafana (v4)
Node red
Mosquitto
This MQTT plugin
The guide is in Swedish, but google translate works “OK”

http://www.automatiserar.se/guide-raspberry-pi/

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:

  1. Should this work if I use a hostname and not an IP address for the message broker? It isn’t for me.
  2. If the broker is disconnected, will there be an issues in my general Vera usage if the broker can’t be connected to?

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 https://github.com/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]