MQTT Client Plugin

Well, There you go. Congrats!!

Thanks, now I have finally gotten the child device receiving the mqtt messages from Node Red, it turns on and off in the vera UI as expected but I can’t for the life of me see how I get it to turn off the light I want to control. The parent id is the mqtt plug in so how can I tell the child device what light to switch on an off?

Thanks!

The child devices are virtual (if created that way), that is, they don’t represent a physical device such as a switch. What you need is a scene that is triggered by the virtual switch, that then transfers the desired action to a physical switch or device.

For example (a working example), my virtual switch is called Mqtt Triggered Binary Switch, which is of course a child of the parent Mqtt device. My ‘on’ trigger is ‘when the Mqtt triggered binary switch is turned on’. And the action is ‘Garage door opener SetTarget to 0’, which opens the door. A second scene handles the ‘off’ trigger which is just the opposite trigger and target.

I work in AltUI so my scene/trigger/action descriptions will be a little different than in Vera native. And note that in openLuup you have to use watches instead of triggers. Though I haven’t played with that much.

One thing I have never tried is to take an actual switch or device, and configure its parent as the Mqtt plugin. I wonder if it would then accept the mqtt variables for mqttTarget and mqttTopic, and then respond directly to Mqtt messages as you might expect. Will have to try that one day.

@dklinkman, if you take a working switch, managed by the Vera, and change its parentId
 it will work no more, as the Vera won’t be able to control it.

@vosmont, Thank you for saving me from a potential forehead slap moment. I’m not sure I would have actually tried it. Was more of a random idea.

[quote=“dklinkman, post:143, topic:190658”]The child devices are virtual (if created that way), that is, they don’t represent a physical device such as a switch. What you need is a scene that is triggered by the virtual switch, that then transfers the desired action to a physical switch or device.

Thanks exactly what I needed to know!!

One thing I have never tried is to take an actual switch or device, and configure its parent as the Mqtt plugin. I wonder if it would then accept the mqtt variables for mqttTarget and mqttTopic, and then respond directly to Mqtt messages as you might expect. Will have to try that one day.

I have tried that and can tell you it does not work![/quote]

Thanks a ton for this plugin. I have 4 iPads wall mounted around the house and I have created an IOS APP to control everything.
The plugin allowed me to move from a poll implementation to a push implementation in order to update the devices status. This saves a lot of computation.

The only issue I have is that I do not get any MQTT message when a scene is triggered. Ideally I would like to get that as well (example: when I run “leaving home scene” all the iPads will dimm the screen to 0%), but no matter what I select, no MQTT messages are sent when a scene is triggered.

Is there any way to do that? Can this functionality be added?
Thanks a ton again!

This plugin (specifically, from GitHub - vosmont/vera-mqtt ) seems to be exactly what I’m looking for, and I managed to get it installed, and my MQTT broker is already up and working for other stuff, but I’m having trouble with a few things from the README:

  • “Set desired variable watches on the Watchdog tab” I didn’t know what “Watchdog tab” refers to - but I see in the Variables tab a var called mqttWatches - which I assume is where to set a variable watch. An example here would be helpful
 I’m sure I’ll figure it out eventually. EDIT: after playing around for a few minutes, a “Watchdog” tab miraculously appeared. Huh.

  • likewise an example of setting and using Alias would be helpful too.

the subscription examples seem better, though there are some pieces missing that probably make sense to someone who has worked more closely with lua and devices (specifically the urn).

There seems to be a lot of info scattered throughout this thread - I’m still combing through it, but a Quickstart guide would be really, really helpful.

I have not yet actually gotten Vera to connect to my MQTT broker, but I’m hopeful! Thanks again @vosmont and @SchattenMann and all the others who have contributed over the last couple years.

[quote=“riz94107, post:148, topic:190658”]This plugin (specifically, from GitHub - vosmont/vera-mqtt ) seems to be exactly what I’m looking for, and I managed to get it installed, and my MQTT broker is already up and working for other stuff, but I’m having trouble with a few things from the README:

  • “Set desired variable watches on the Watchdog tab” I didn’t know what “Watchdog tab” refers to - but I see in the Variables tab a var called mqttWatches - which I assume is where to set a variable watch. An example here would be helpful
 I’m sure I’ll figure it out eventually. EDIT: after playing around for a few minutes, a “Watchdog” tab miraculously appeared. Huh.

  • likewise an example of setting and using Alias would be helpful too.

the subscription examples seem better, though there are some pieces missing that probably make sense to someone who has worked more closely with lua and devices (specifically the urn).

There seems to be a lot of info scattered throughout this thread - I’m still combing through it, but a Quickstart guide would be really, really helpful.

I have not yet actually gotten Vera to connect to my MQTT broker, but I’m hopeful! Thanks again @vosmont and @SchattenMann and all the others who have contributed over the last couple years.[/quote]

It has connected to the broker, and I can see various Vera/Event/* updates, and figured out the Alias stuff. I’m getting stuck on getting a working virtual device which reflects MQTT topic changes.

I created a device (from Apps->Develop Apps->Create Device - is there a better place?) which has the SensorMQTT device id in the parent ID. I appear to have gotten the device to subscribe to the topic I’m interested in (the broker is sending topic messages to Vera, so I assume that bit is set up), but I’m not sure where to look for troubleshooting my virtual device.

I set it up using D_MotionSensor1.xml, as it’s a motion detector (I wrote the firmware on this device and can change as needed). The Message it sends is either { “Status”: 0 } or { “Status”: 1 }, depending whether it’s triggered or not. I’ve got mqttTarget set to

[font=courier]urn:micasaverde-com:serviceId:SecuritySensor1,Tripped=payload.Status and ((payload.Status==“1”) and “1” or “0”)
[/font]
and mqttTopic is sensor/motion, which is correct, and caused the broker to start sending messages on that topic.


but as far as I can tell, nothing ever changes with the device, even though I can see the messages being sent. Where do I look for more debugging info?

EDIT: Would still love more debugging info, but after I changed mqttTarget to [font=courier]urn:micasaverde-com:serviceId:SecuritySensor1,Tripped=payload.Status
[/font] things started working.

Hi,

I would like to replace the payload answer from number to string and additionally put some if clauses. Is it possible using only MQTT target field?

For example :
received payload=1, put into variable 1=“Heat”
received payload=2, put into variable 1=“Standby”

I have tried below, but failed.

urn:upnp-org:serviceId:VContainer1,Variable1=payload and payload=="Grzanie" or "20" and payload=="Dupa" or "30" and payload=="Zamarzanie"

Please suggest some solution

EDIT : Case closed. Workaroud applied.

Hi,

The plugin works pretty stable and OK.

There is only one problem. The Client will not automatiacally reconnect to broker after restart of broker. It needs to be done manually using “Engine Restart”.

Can you please help to solve this?

What could be the potential solutions for that?

Hello,

First of all thanks for the fantastic plugin, I’ve used it for a couple of months and everything worked wonderfully.

But in the last few days I had a problem.
I moved the Vera on a 4G router because at the moment my isp’s network is not working properly, but the Vera doesn’t seem to send any of the message. I connected and tested the internet connection and it works fine, but when I can’t receive any message from the controller.

Have someone experienced this before? Do you know how to solve this problem?

PS. Sorry if my english is not flawless, but it’s not my first language.

Thank you in advance for the reply and have a nice day,
Simon

Hi, how to use lua code to publish mqtt message?
I successfully to set the scene for Virtual Switch and add the “MQTT publish” in Action,
but I want to use lua code to publish message.
my mqtt topic is “mysensors-in/3/2/1/0/2”
payload is “1” = ON, “2” = OFF

Thanks
Eric

Hi vosmont thank you for creating the plugin. I am just wondering if there is any video out there that will provide a step by step installation for this very useful plugin? If not, any kind sole out there will create on.

I am sure it will be very popular video as there is lots of interest on MQTT.

I am using Home Assistant and hadashboard, I found that mqtt switches respond and update status very quick; almost immediately on hadashboard; but zwave smart switches using vera lite running ui7 update status very very slow!

Thanks in advance!

I know this post is fairly old. The plugin is working great. My only issue is trying to capture metrics from my nest thermostats. I am trying to use the following code. If I use each metric separately, the values get placed into influx. If I nest the if statements, I only get one metric. Any ideas?

if (DeviceType.indexOf(“HVAC_ZoneThermostat”) !=-1)
{
Influx_Key = “FurnaceControl”;
Influx_KeyTag = “device=” + DeviceName;

if (objJson.ModeState !== null) {
if (objJson.ModeState == “Idle”)
Influx_Value = “ModeState=0”;
else if (objJson.ModeState == “Heating”)
Influx_Value = “ModeState=1”;
}
else if (objJson.CurrentSetpoint !== null)
{
Influx_Value = “CurrentSetpoint=” + objJson.CurrentSetpoint;
}
else if (objJson.CurrentTemperature !== null)
{
Influx_Value = “CurrentTemperature=” + objJson.CurrentTemperature;
}
}

Is it possible to publish a message with the retain flag to true?

Thanks in advance.
Zagreo

1 Like

Hi , Sorry for posting a question on such an old thread.

Hopefully someone can answer this for me please.

This is working.
The MQTT plugin is working , I can publish a variable as a string to the broker from my arduino.
Vera can read it via the MQTT plugin. I have created a new temperature device and have populated the variables as required.
mqttTopic Temp/Temp1
mqttTarget urn:upnp-sensor-mqtt-se:serviceId:SensorMqtt1,CurrentTemperature=
If I publish a string from my arduino, it appears in the CurrentTemperature variable when i look at the device under advanced.

This is not working. The Vera GUI does not show the temperature on the device (pic attached.) What am I missing here please?

Never Mind, I found a fix. I run this scene every 60 seconds it copies the Variable CurretTemperature from the MQTT sensor device 55 to the TemperatureSensor1 device 55. This second one updates the UI with the temp and can be used to trigger other scenes and notifications. Seems to work fine.

local CurrentTemp = luup.variable_get(“urn:upnp-sensor-mqtt-se:serviceId:SensorMqtt1”, “CurrentTemperature”, 55)

luup.variable_set(“urn:upnp-org:serviceId:TemperatureSensor1”, “CurrentTemperature”, CurrentTemp, 55)

Regards
Brett

Hi! Just started using vera-mqtt and it seems very good. The only feature that i am missing is to be able to use multiple payload values in one topic, in one device. Like the miflora. batterty, moisture and such. Is this possible somehow already?

Just make sure that the variables you would like published to the broker are checked under “Watch Dog” for the MQTT Client. So in other words, as long as the MQTT client is observing changes in “battery, moisture, and such”, the values will be published to the MQTT broker. That said, each variable change is published as a separate message on the same topic that is defined using reasonable defaults however the client’s topic strings can be configured if desired.

This is for subscribe function in vera-mqtt.

you can only subscribe to one topic and use one service-id and variable in the mqttTarget field (per Device)

{“temperature”: 22.2, “battery”: 100, “light”: 1311, “conductivity”: 1265, “moisture”: 54}

But there is only support to use one of those in the device.

“urn:micasaverde-com:serviceId:HumiditySensor1,CurrentLevel=payload.moisture” this is the mqttTarget field and it is not possible to have multiple values.

I would like to atleast be able to use both moisture and battery values in same device.