MQTT Client Plugin

MQTT Client Plugin

This plugin provides the ability to publish out any user defined variable to an MQTT Broker.
It is based on the code found here
This is my first plugin so odds are there will be some bugs although so far seems to be working fine.

This plugin is designed for use on systems running UI7.

Features

[ul][li]User defined Variables to watch[/li]
[li]User defined Device Alias which makes Logic much more intuitive and makes it easier when replacing devices
[/li][/ul]

MQTT Message Example

{"Payload":{"DeviceId":45,"OldOnOff":"1","OnOff":"0","Time":1453209965},"Topic":"Vera/Events/TestSocket"}

Installation and Configuration

[ul][li]Upload the attached files[/li]
[li]Create a new device with device_file set to D_SensorMqtt1.xml[/li]
[li]Set desired variable watches on the Watchdog tab[/li]
li Set desired Alias on the Alias tab[/li]
[li]Have fun[/li][/ul]


Dependencies

There are a few dependencies that should be copied to /usr/lib/lua folder

Source code

Really nice, great!

Would be even nicer if some screenshots were added :slight_smile:

Thank you.

I shall try it out later :slight_smile:

I am stuck. How do I upload those files to the Vera?

I suppose you’re both talking about the dependencies

These need to be uploaded to /usr/lib/lua folder as explained on the first post.
You can do this via SSH or with WinSCP

[quote=“4integration, post:2, topic:190658”]Really nice, great!

Would be even nicer if some screenshots were added :)[/quote]

That’s the next step, just run out of time

[quote=“SchattenMann, post:5, topic:190658”]I suppose you’re both talking about the dependencies

These need to be uploaded to /usr/lib/lua folder as explained on the first post.
You can do this via SSH or with WinSCP[/quote]
But what is the ssh I’d and password then?
I’ve only ever logged on via the Web site.

[quote=“Snaxmuppet, post:7, topic:190658”][quote=“SchattenMann, post:5, topic:190658”]I suppose you’re both talking about the dependencies

These need to be uploaded to /usr/lib/lua folder as explained on the first post.
You can do this via SSH or with WinSCP[/quote]
But what is the ssh I’d and password then?
I’ve only ever logged on via the Web site.[/quote]

username is root and password is your Vera’s Wireless Password

UI screenshots attached

When I try to WS-FTP in to the Vera using SSH I get the following:

Error 842c0000 receiving sftp packet
error 842c0000 initializing sftp protocol
Sending channel close message for channel 0760a2ce
SSH Transport closed.

I can log in using SSH command line using Putty though.

Is there any documentation on this? I don’t want to have to keep pestering you all the time
 that isn’t fair on you :slight_smile:

[quote=“Snaxmuppet, post:10, topic:190658”]When I try to WS-FTP in to the Vera using SSH I get the following:

Error 842c0000 receiving sftp packet
error 842c0000 initializing sftp protocol
Sending channel close message for channel 0760a2ce
SSH Transport closed.

I can log in using SSH command line using Putty though.

Is there any documentation on this? I don’t want to have to keep pestering you all the time
 that isn’t fair on you :)[/quote]

Not sure if SFTP will work (never tested it myself) but WinSCP definitely does.

Beware though you have to disable “Secure my Vera” first under Users & Account Info - Unit Settings

Thx. Used WinSCP.

So I have uploaded the dependencies to the correct location and added the plugin files to the Luup files via the dashboard.

Now I am stuck again
 how do I create the device? I have tried via the Device Add process and I can see nothing to do with MQTT in the list of possible devices. I have tried to add a device via the develop apps but I don’t know what to enter for the various fields.

This is why I asked if there was some documentation on how to add new plugins.

Sorry to pester.

[quote=“Snaxmuppet, post:12, topic:190658”]Thx. Used WinSCP.

So I have uploaded the dependencies to the correct location and added the plugin files to the Luup files via the dashboard.

Now I am stuck again
 how do I create the device? I have tried via the Device Add process and I can see nothing to do with MQTT in the list of possible devices. I have tried to add a device via the develop apps but I don’t know what to enter for the various fields.

This is why I asked if there was some documentation on how to add new plugins.

Sorry to pester.[/quote]

Sorry, so used to this that I’ve forgotten to add that information.
screenshot attached

Right
 we are getting there.

So I now have the device in my devices list. What now?

How can I send a MQTT message to my MTTT broker with, say, the status of one of my Vera controlled devices?

How can I read a topic from the MQTT broker and then say, activate a device on the Vera?

Can I do these things?

You wouldn’t believe I am a very experienced software developer of 30+ years would you
 I feel like a total noob.

My apologies, I?d forgotten about the initial configuration (I?m planning to release a quick guide anytime soon but haven?t got the time yet)

On the Advanced ? Variables tab set your MQTT Broker IP (mqttServerIp) and Port (mqttServerPort)

Simply subscribe a device variable on the “Watchdog” Tab. Say you want to receive notifications when a Relay Is Turned On/Off - subscribe the urn:upnp-org:serviceId:SwitchPower1 - Status Variable

This Plugin is just for Publishing MQTT messages to a MQTT Broker

Hope this help

How then do I specify the MQTT topic and which device?

For now Topic is hard-coded (next on the to-do list pile)

It will either be Vera/Events/ or Vera/Events/

And you don’t need to specify which device you want to monitor, that’s just unnecessary work and a PITA if you have 100 devices.
You simply set which variables you want to monitor and all devices with those variables will publish status updates - you may then subscribe only the Topics you actually want to monitor but odds are if you need MQTT you’re using something like node-red for all your logic and this is a huge help

Fantastic!

All working.

Thank you for your efforts :slight_smile:

[quote=“Snaxmuppet, post:18, topic:190658”]Fantastic!

All working.

Thank you for your efforts :)[/quote]

glad you like it

I installed the dependencies and the plugin file and created the device.
The device state is ‘connected’ and I’ve selected a couple of parameters to monitor.
However, when subscribing to Vera/# I do not see any messages.
Any idea where I can troubleshoot/see logs for this plugin?