How do I get MQTT status in line?

While I wait for my Inovelli Blue’s, I am still in the planning phase and wanted to make the software ready for as seamless a transition from HE nodes to MQTT nodes (and hopefully seamless again to CORE nodes). With that said, a lot of my flows pull the status of another device and use that as part of the logic for the sequence (see screenshot). Any idea how to do this? The MQTT nodes only seem to be in and out, I can’t seem to find any inout nodes.

image

You would want to set variables to track the status of those devices and use a change or switch node to reference the current status in your flow.

Let me look around the forum as I know both April and myself have gone over this before.

oh boy, I was worried someone was going to say that, context variables here I come I guess…there has got to be a more efficient way to do this right?

Thats the best part of NR, there are usually 100 different ways to do something :slight_smile:

Depending on the type of device there is often a Node-Red palette specifically for that device type, and they usually keep the status in internal context so you could access it the way you currently are without the need for adding variables, BUT then you lose the ability to access that information in a central location in a uniform formatting.

Actually, I just realized for this exact situation, I would be using Z2M nodes which have a get node that would do what I want it seems. But for anything else that needs us to use raw MQTT this will still be an issue. Can you guys speak on what the CORE nodes will be more like? Z2M or raw MQTT?

Markus can say for sure, BUT I am fairly certain the CORE nodes will keep track of status for you to allow you to poll them directly.

1 Like

Happy to host a teams meeting for anyone that requires some assistance with globals and usage. How and where to create them. Some functions that will automatically do this for you. Any beta users who are interested please comment on the topic I will be creating in a few moments and I’ll fire things up.

1 Like

I’ve not used the Get node but I just looked at its side-panel doc and it won’t help with a situation I have.

I have a dozen of Iman’s sensors and the illuminance doesn’t always fall to zero when the space goes dark. This renders my NR flow which uses this value to decide if it’s already light enough to disable the motion lighting unreliable.

When the same automation was done with HE and the nodes for HE I was able to send a “refresh” to the sensor to prompt it to send updated values but the z2m nodes don’t have that ability because the underlying z2m doesn’t support refreshing any attribute other than “state” for Iman’s sensors.

To (hopefully) remedy this I raised an issue with the dev. Another dev addressed it partially but his PR has not made it into a release yet so I can’t say if it fixes it for me or not. Notice also that I gave the z2m nodes dev a heads-up that I’ll be asking him for a refresh command if/when the z2m project supports it.

So my journey is almost exactly like Cjkeenan’s. Move over to node-red using the HE palette and slowly convert to the native nodes (I’m moving to a second zigbee mesh and also currently have a secondary controller on zwave).

I came to the same problem of getting MQTT status which is unlike the inline HE status. I tried to minimize writing too much code and came up with the below sequence using the mqtt-in node and setting a flow variable. Even though the sequence seems to work great, I want to make sure it is semi-correct and won’t cause wide-spread problems. Is there a better/optimized way?

1 Like

Pro tip: While the screenshot is helpful to have, exporting the flow and pasting here is much more useful because we can’t see how your nodes are configured with just a screenshot. We’ll be much more able to assist you if we can import your flow even though we won’t have the same config.

In NR select all the nodes in your screenshot and press ctrl-e to bring up the export dialog:

Select the JSON tab and click on “compact” near the bottom-right. Then click “Copy to clipboard”.

Back here click on the “</>” in the toolbar above and then paste your flow there.

[{"id":"8da98ad099647901","type":"debug","z":"eafde75f.b6f5f8","name":"on","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"true","targetType":"full","statusVal":"","statusType":"auto","x":480,"y":2050,"wires":[]},{"id":"4e719ffa780275fa","type":"debug","z":"eafde75f.b6f5f8","name":"Injput Monitor","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"true","targetType":"full","statusVal":"","statusType":"auto","x":560,"y":2130,"wires":[]},{"id":"072eca0205774e11","type":"debug","z":"eafde75f.b6f5f8","name":"GDO","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"true","targetType":"full","statusVal":"","statusType":"auto","x":260,"y":2030,"wires":[]},{"id":"aef85b0d7d1aaba2","type":"debug","z":"eafde75f.b6f5f8","name":"off","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"true","targetType":"full","statusVal":"","statusType":"auto","x":350,"y":2090,"wires":[]},{"id":"eeead7f39694cebc","type":"inject","z":"eafde75f.b6f5f8","name":"on","props":[{"p":"payload"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"on","payloadType":"str","x":340,"y":2130,"wires":[[]]},{"id":"a252fd65853c04ef","type":"inject","z":"eafde75f.b6f5f8","name":"off","props":[{"p":"payload"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"off","payloadType":"str","x":340,"y":2170,"wires":[[]]}]

And it will look as I’ve shown here (don’t bother importing this, it’s just some Inject and Debug nodes) and then we all can see whatcha got. If you have any tokens, passwords, or other security-related items in your JSON it would be best to delete them.

1 Like

Yep, thought about it but noticed too many passwords in the export (yes I’d miss some or forget to sanitize). Figured my question was generic enough (and visible in the screenshot) to get some thoughts without needing the nodes.