MQTT - Node Red - Smartthings

OK so you have all the pieces in place then

  1. You can query ST for the state of the Switches (update command as above)
  2. You can capture changes sent from the ST switches (as per my previous flow with replacing the the inject nodes with the ST VT switch node)
  3. You can query the Aqualink for its state and capture state changes sent from the unit
  4. What you want to do is to seperate out the physcial from the virtual

The way i would do this is to first write a flow that captured the state of the ST Virtual switches and updated so flow variables using change nodes

So setup an inject node that runs every 10s an sends a query to all of your ST Virtual switches for their current state (update command)

Capture the replies from the ST switches and send that to a change node that writes them to Context flow variables

Set that up and paste up your flow so we can see how you go and then we can add to it.

Unfortunately as i do not have ST i can not build this for you so you will have to do some of the work

Craig

I believe i captured what you recommended. when i toggle the ST switch in the ST app, it successfully toggles the aqualinkd switch. here is the flow:

[{"id":"bcb783a573d4acc5","type":"tab","label":"Flow 3","disabled":false,"info":"","env":[]},{"id":"17bc015e.d3238f","type":"switch","z":"bcb783a573d4acc5","name":"Check for ST Turn on/off ","property":"payload.value","propertyType":"msg","rules":[{"t":"eq","v":"0","vt":"num"},{"t":"eq","v":"1","vt":"str"}],"checkall":"true","repair":false,"outputs":2,"x":330,"y":120,"wires":[["9838a3f3.19757"],["dfe441c8.bfdfa"]]},{"id":"9838a3f3.19757","type":"change","z":"bcb783a573d4acc5","name":"Output Off to Aqualink","rules":[{"t":"set","p":"payload","pt":"msg","to":"0","tot":"str"},{"t":"set","p":"topic","pt":"msg","to":"aqualinkd/Aux_4/set","tot":"str"}],"action":"","property":"","from":"","to":"","reg":false,"x":580,"y":80,"wires":[["3e17efff.6b27a"]]},{"id":"dfe441c8.bfdfa","type":"change","z":"bcb783a573d4acc5","name":"Send on to Aqualink","rules":[{"t":"set","p":"payload","pt":"msg","to":"1","tot":"str"},{"t":"set","p":"topic","pt":"msg","to":"aqualinkd/Aux_4/set","tot":"str"}],"action":"","property":"","from":"","to":"","reg":false,"x":580,"y":160,"wires":[["3e17efff.6b27a"]]},{"id":"3e17efff.6b27a","type":"mqtt out","z":"bcb783a573d4acc5","name":"","topic":"","qos":"0","retain":"false","respTopic":"","contentType":"","userProps":"","correl":"","expiry":"","broker":"ccadb55043586ba6","x":790,"y":120,"wires":[]},{"id":"182d3082e436daa7","type":"inject","z":"bcb783a573d4acc5","name":"","props":[{"p":"topic","vt":"str"}],"repeat":"10","crontab":"","once":false,"onceDelay":0.1,"topic":"update","x":140,"y":320,"wires":[["c3278d3c65a6b7d5"]]},{"id":"c3278d3c65a6b7d5","type":"smartthings-node-onoff","z":"bcb783a573d4acc5","conf":"dee375c5b1c0d67d","name":"Pool Light","device":"c4318d7e-e3ef-4520-8352-47c3a77ef863","x":350,"y":320,"wires":[["85dd5c7622f35720"]]},{"id":"02e6b4869bf323b7","type":"debug","z":"bcb783a573d4acc5","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"payload","targetType":"msg","statusVal":"","statusType":"auto","x":790,"y":320,"wires":[]},{"id":"85dd5c7622f35720","type":"change","z":"bcb783a573d4acc5","name":"","rules":[{"t":"set","p":"myData","pt":"flow","to":"payload","tot":"msg"}],"action":"","property":"","from":"","to":"","reg":false,"x":540,"y":320,"wires":[["02e6b4869bf323b7"]]},{"id":"99794189d07fbf74","type":"smartthings-node-onoff","z":"bcb783a573d4acc5","conf":"dee375c5b1c0d67d","name":"Pool Light","device":"c4318d7e-e3ef-4520-8352-47c3a77ef863","x":120,"y":120,"wires":[["17bc015e.d3238f"]]},{"id":"ccadb55043586ba6","type":"mqtt-broker","name":"AqualinkD","broker":"192.168.1.70","port":"1883","clientid":"","autoConnect":true,"usetls":false,"protocolVersion":"4","keepalive":"60","cleansession":true,"birthTopic":"","birthQos":"0","birthPayload":"","birthMsg":{},"closeTopic":"","closeQos":"0","closePayload":"","closeMsg":{},"willTopic":"","willQos":"0","willPayload":"","willMsg":{},"sessionExpiry":""},{"id":"dee375c5b1c0d67d","type":"smartthings-config","name":"McAlister","token":"d03e883a-82cc-4da0-9a76-6eee5518e217"}]

We will need some pictures - none of us has the Aqualink or ST nodes so we can not deploy your flows - so we need them posted but alos pictures, debug and description

Craig

here is what the flow currently looks like

the initial flow is the same as you shared before but with the ST switch in place of the simulated inject nodes

here is the inject node with update topic every 10 seconds along with debug

here is the change node with context

thank you.

OK that looks pretty good - now you have the make a decision who is going to be the "Source of truth" in the system.

Lets say someone turns on the Pool fountain through a ST virtual switch - this will come into NR and then you will send it out to Aqualink and all good - but lets say an automation kicks in just after that in Aqualink and turns the Fountain off - you then query that through NR and find the fountain is off - but you know you just turned it on - should NR turn the fountain back on - or report it back to ST - where the user then sees on the ST dashboard that the fountain is now turned off and thinks what is going on ??

i suppose i would prefer aqualink to be the source of truth. my primary goal is to have the status of the device consistent across both platforms and be able to control from either platform. most of the aqualink automation is for freeze protection, schedules for pumps, modes (i.e spa mode that changes the valves and turns on the heater) so the actions are predictable. thanks

OK so the next thing you need to be able to do is query the Aqualink for its state using the MQTT commands.

What you need to do is decouple the connection between ST and the Aqualink and use NR as the middleman between them.

So you need to continually query Aqualink for its status and then write each of the elements to context variables.

One a regular basis you then need to read those variables and update them in ST so that the ST Virtual switches reflect the current state of Aqualink, if someone then changes a ST virtual switch - you need to update the Context variable that corresponds to the Virtual Switch and then push that out through MQTT to Aqualink

Craig

Thanks @craigcurtin. I will need to do more reading and learning of NR to figure out how to implement each of those things you recommended.

In the meantime, i built this flow based on the flow you initially provided and reversed it for the aqualink side. everything seems to be working as desired. however, i recognize if status were to change on either side of the flow and "lost', the polling method would recover the correct status. if i have luck, i will provide an update. thank you again for your help.

OK keep the questions coming as you progress - happy to keep helping out

Craig

This topic was automatically closed 60 days after the last reply. New replies are no longer allowed.