Can Node-Red AMI set a Custom Devstate?

Have been taking a peek at FreePBX->Node-Red–>xxx integration and have followed through @lgaetz two videos on the topic.

My particular interest (as per Lorne’s initial experimentations) was getting access to a few custom devstate hints that I’ve been using on my FreePBX for years and seeing them on my home automation system. Thankfully through those examples I have a good start at cobbling something together which I think will work. Have been using Node-Red for all of 45 minutes now so definitely going to need some tweaking :slight_smile:

Then (fortunately or unfortunately) in the middle of doing something simple (that I still know virtually nothing about) programming-brain kicks in and says if we will be able to see the status of these devices/hints in the home automation system… is there a way to in turn that around and use the automation system to set a custom device state rather than reading it? With the thought that I have dozens of BLF buttons on the sidecar of my phone which sit happily telling me when phones are on or off of the hook… why can’t I use one to see whether I forgot my garage door open?

So my question to those who have played with Node-Red-AMI for a little longer than I have is… is it possible to do this with this integration?

Cheers!
Mike

I’ve not done it myself, but you should be able to send the Setvar AMI command from Node-Red to Asterisk where you set the function DEVICE_STATE(Custom:XXXX) to the updated state (Idle, InUse, etc). How that translates to node-red is something you’ll have to figure out, but it will be something like

payload.action      SetVar
payload.Variable    DEVICE_STATE(Custom:XXXX) 
payload.Value       InUse
1 Like

Thanks for the insight @lgaetz, will add fiddling with that to my next caffeine fueled session :slight_smile:

1 Like

Just as a followup… I cobbled together a quick test and the code as posted works great.

1 Like