Indigo / Node-Red / Alexa

Posted on
Thu May 21, 2020 2:05 pm
whmoorejr offline
User avatar
Posts: 356
Joined: Jan 15, 2013
Location: Houston, TX

Re: Indigo / Node-Red / Alexa

classicmac wrote:
I have an Insteon Fan Controller that Indigo has built in settings of Off, Low, Medium, and High for. Is it possible to trigger those levels using Node-RED? I'm hoping for a simple solution since I have multiple fan controllers.


Sorta. You can create a Alexa fan device, lets call it "Living Room Fan"
Alexa will understand, set Living Room Fan to: (Hi, Medium, Low, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10). Alexa does not recognize the On or Off command for a fan device. <-- pretty lame IMO.

If you speak Low, that translates to 1. Medium translates to 5. High Translates to 10.

On node red, you will add the "Living Room Fan" Alexa device and a Switch. When you edit the switch, you will just add a new split and "1", "2", "3" etc. to correspond with the translation of your command. If you only want Low, Medium, High.... then you only need to map "1", "5", "10" to acton groups in indigo that control the fan.

I had issues trying to directly associate my instean fan with it... so I had to use actions groups instead.

So this will help you to adjust the setting of your fan..... but not to turn it on or off. You could add an "on" command inline with the action group, but that still doesn't help you (or me) with turning the fan off.

Hopefully someone else has has better luck incorporating a fan with this.

Bill

Posted on
Thu May 21, 2020 10:19 pm
classicmac offline
Posts: 8
Joined: Jan 09, 2007

Re: Indigo / Node-Red / Alexa

I was hoping I wouldn't need to use Action Groups since I have 4 fans. So that will be 20 additional action groups. I guess it could be worse but I was hoping there would be an easier solution. Thanks for taking the time to reply. I appreciate it!

Posted on
Thu May 21, 2020 11:14 pm
mundmc offline
User avatar
Posts: 720
Joined: Sep 14, 2012

Re: Indigo / Node-Red / Alexa

whmoorejr wrote:
siclark wrote:
using a third party server until me or someone works out how to self host.


I'd feel more comfortable releasing the claymore once we can self host or have an actual indigo / Alexa integration.
This is gold.

Also, we still meed a “Like” button.

Posted on
Fri May 22, 2020 12:00 am
classicmac offline
Posts: 8
Joined: Jan 09, 2007

Re: Indigo / Node-Red / Alexa

classicmac wrote:
I have an Insteon Fan Controller that Indigo has built in settings of Off, Low, Medium, and High for. Is it possible to trigger those levels using Node-RED? I'm hoping for a simple solution since I have multiple fan controllers.


I was able to come up with a solution that I think is reasonable. It allows me to set my fan to on, off, low, medium or high. On the Indigo side it only involves the creation of 1 trigger and 1 variable.

This is what I ended up doing.

1. In Node-RED (https://red.cb-net.co.uk/) set the device type to "Advanced/Other" then checked off the "Power" and "Range" Interface checkboxes. This allows the Echo to process on/off and "High, Medium, Low" commands.

2. Create a variable in Indigo to store the NodeRED command.

3. In Node-RED connect the Alexa device node to indigo set variable node

4. Created a Indigo trigger that executes when the variable value changes. Set the action to Server Actions > Script and File Actions > Execute Script

Used a python script that processes the variable and sets the fan speed to the appropriate level. If you use this script make sure to set the indigo variable ID (1417480906 on my system) to the ID of the variable you create. Also set FanControllerID to the ID of your Fan Controller. In Indigo fan controller speak value 0 is off, 1 is low, 2 is medium, and 3 is high.

Code: Select all
Speed = indigo.variables[1417480906]
FanControllerID = 1872483759
if hasattr(Speed, 'value'):
   Speed = Speed.value
if Speed == 'OFF':
   indigo.speedcontrol.setSpeedIndex(FanControllerID, value=0)
if Speed == 'ON':
   indigo.speedcontrol.setSpeedIndex(FanControllerID, value=3)
if Speed == '0':
   indigo.speedcontrol.setSpeedIndex(FanControllerID, value=0)
if Speed == '1':
   indigo.speedcontrol.setSpeedIndex(FanControllerID, value=1)
if Speed == '5':
   indigo.speedcontrol.setSpeedIndex(FanControllerID, value=2)
if Speed == '10':
   indigo.speedcontrol.setSpeedIndex(FanControllerID, value=3)


Hope this helps someone

Posted on
Fri May 22, 2020 1:49 am
siclark offline
Posts: 1333
Joined: Jun 13, 2017
Location: UK

Re: Indigo / Node-Red / Alexa

classicmac wrote:
I was hoping I wouldn't need to use Action Groups since I have 4 fans. So that will be 20 additional action groups. I guess it could be worse but I was hoping there would be an easier solution. Thanks for taking the time to reply. I appreciate it!


Couldnt you send a command over the web api to indigo from node-red? Then you setup the first fan in node red, and copy / edit the device id. Would keep your indigo neater that way without all the extra action groups.

Posted on
Fri May 22, 2020 7:55 am
jalves offline
Posts: 592
Joined: Jun 16, 2013

Re: Indigo / Node-Red / Alexa

whmoorejr wrote:
siclark wrote:
using a third party server until me or someone works out how to self host.


I'd feel more comfortable releasing the claymore once we can self host or have an actual indigo / Alexa integration.

When I was in 11B training I was amused by the moulded warning on the Claymore.

Running Indigo 7.4.1 on a 27" iMac (mid-2017), 40G memory, 1T Fusion Drive, OS X 10.15.6
Jeff

Posted on
Fri May 22, 2020 8:04 am
whmoorejr offline
User avatar
Posts: 356
Joined: Jan 15, 2013
Location: Houston, TX

Re: Indigo / Node-Red / Alexa

classicmac wrote:
It allows me to set my fan to on, off, low, medium or high. On the Indigo side it only involves the creation of 1 trigger and 1 variable.


Interesting. I just added one of my fans as an Advanced/Other device with power and range. Alexa understands "On, Off, High & Medium"....
Alexa, set fan to "Low" = "I don't know how to set LivingRoom Fan to that setting". <- Obstacle #1

Obstacle #2:
siclark wrote:
couldnt you send a command over the web api to indigo from node-red? Then you setup the first fan in node red, and copy / edit the device id. Would keep your indigo neater that way without all the extra action groups.


Ideally, like with the lights I've added through node-red, yes. For fans, I'm running into a language barrier. On Node-Red, Connecting the Alexa device directly to the set Indigo device doesn't work. Makes sense since the indigo fan is looking for "0,1,2 or3" and the Alexa device msg.payload is "On, Off, 1, 5, 10"

I added a switch to change the msg.payload. Nothing I have tried has worked yet. Using Medium as an example: Change msg.payload, Search for for number 5, Replace with...
string 2
number 2
string 2E 00 00 09 08 00 00 00 00 00 00 00 00 00 00 00 <- Reading the raw instead command from log for medium
number 2E 00 00 09 08 00 00 00 00 00 00 00 00 00 00 00
string medium
string med
string set motor speed to medium
I tried the same variations for low and high and the result is the same. request to turn off device "Living Room - Fan"

Bill

Posted on
Fri May 22, 2020 9:31 am
siclark offline
Posts: 1333
Joined: Jun 13, 2017
Location: UK

Re: Indigo / Node-Red / Alexa

Screenshot 2020-05-22 at 15.45.48.png
Screenshot 2020-05-22 at 15.45.48.png (197.67 KiB) Viewed 245 times
Are you using the debug green icon? Useful to put after the alexa device to see what payload she is sending per each voice request.

Also then try the inject tool to inject a known value, ie 0 or '0' etc into the tool you use to control the indigo device. If that works, you can then work out the node-red logic to translate between teh 2.

I have had a quick play and have it sorted for you.

You need to setup the device as advanced on the cb-net site.

Screenshot 2020-05-22 at 15.40.55.png
Screenshot 2020-05-22 at 15.40.55.png (372.65 KiB) Viewed 245 times


Then I had a few different thoughts about how to do this, but I think this is the quickest and uses least nodes, using the RestAPI to communicte to Indigo.

I used debug to confirm how it was responding, with ON and OFF as string, and 1,2,3 as numbers
Screenshot 2020-05-22 at 15.44.08.png
Screenshot 2020-05-22 at 15.44.08.png (79.71 KiB) Viewed 245 times


I then used the inject tools to push the message payloads I wanted, rather than having to keep using voice to alexa.

In the end I split the message payload based on string or number. For ON/OFF I did 2 seperate http nodes as quicker, changing the value in each, but you could be a bit more clever there.
For the speed I used a range mapping to go from 1-10 to 1-3 and then a template to set the http command.

Screenshot 2020-05-22 at 16.23.24.png
Screenshot 2020-05-22 at 16.23.24.png (116.16 KiB) Viewed 245 times


These are the formats of the http, switch and template nodes
Screenshot 2020-05-22 at 16.24.26.png
Screenshot 2020-05-22 at 16.24.26.png (45.78 KiB) Viewed 245 times

Screenshot 2020-05-22 at 16.24.36.png
Screenshot 2020-05-22 at 16.24.36.png (41.51 KiB) Viewed 245 times

Screenshot 2020-05-22 at 16.24.55.png
Screenshot 2020-05-22 at 16.24.55.png (35.98 KiB) Viewed 245 times


Finally, neatened up, it looks like this.
Screenshot 2020-05-22 at 16.28.29.png
Screenshot 2020-05-22 at 16.28.29.png (38.31 KiB) Viewed 245 times


and you should be able to import to node-red by pasting this in.

Code: Select all
[{"id":"2c8e0cbe.6d85f4","type":"tab","label":"Flow 2","disabled":false,"info":""},{"id":"bdeb2d15.6dcd4","type":"alexa-smart-home-v3","z":"2c8e0cbe.6d85f4","conf":"8582379b.f9e3f8","device":"12819","acknowledge":true,"name":"living room fan","topic":"","x":440,"y":400,"wires":[["a17016ed.9746d8"]]},{"id":"a17016ed.9746d8","type":"switch","z":"2c8e0cbe.6d85f4","name":"","property":"payload","propertyType":"msg","rules":[{"t":"istype","v":"string","vt":"string"},{"t":"istype","v":"number","vt":"number"}],"checkall":"true","repair":false,"outputs":2,"x":610,"y":400,"wires":[["5f2cdf72.a1346"],["92663a3b.c95418"]]},{"id":"92663a3b.c95418","type":"range","z":"2c8e0cbe.6d85f4","minin":"1","maxin":"10","minout":"1","maxout":"3","action":"scale","round":true,"property":"payload","name":"","x":790,"y":460,"wires":[["c43e1b4a.f25ae8"]]},{"id":"5f2cdf72.a1346","type":"switch","z":"2c8e0cbe.6d85f4","name":"","property":"payload","propertyType":"msg","rules":[{"t":"eq","v":"ON","vt":"str"},{"t":"eq","v":"OFF","vt":"str"}],"checkall":"true","repair":false,"outputs":2,"x":770,"y":360,"wires":[["51c58441.1eb7bc"],["9213eb53.f3e5c8"]]},{"id":"51c58441.1eb7bc","type":"http request","z":"2c8e0cbe.6d85f4","name":"","method":"PUT","ret":"txt","paytoqs":false,"url":"http://127.0.0.1:8176/devices/Hall-Lamp-socket?isOn=1&_method=put","tls":"","persist":false,"proxy":"","authType":"digest","x":1150,"y":340,"wires":[[]]},{"id":"9213eb53.f3e5c8","type":"http request","z":"2c8e0cbe.6d85f4","name":"","method":"PUT","ret":"txt","paytoqs":false,"url":"http://127.0.0.1:8176/devices/Hall-Lamp-socket?isOn=0&_method=put","tls":"","persist":false,"proxy":"","authType":"digest","x":1150,"y":400,"wires":[[]]},{"id":"4a0b9eb8.05436","type":"http request","z":"2c8e0cbe.6d85f4","name":"","method":"POST","ret":"txt","paytoqs":true,"url":"{{{payload}}}","tls":"","persist":false,"proxy":"","authType":"digest","x":1150,"y":460,"wires":[[]]},{"id":"c43e1b4a.f25ae8","type":"template","z":"2c8e0cbe.6d85f4","name":"","field":"payload","fieldType":"msg","format":"handlebars","syntax":"mustache","template":"http://127.0.0.1:8176/devices/office-ceiling-fan?speedIndex={{payload}}&_method=put","output":"str","x":980,"y":460,"wires":[["4a0b9eb8.05436"]]},{"id":"8582379b.f9e3f8","type":"alexa-smart-home-v3-conf","z":"","username":"xxxxx","xxxxx":"mq-red.cb-net.co.uk","webapiurl":"red.cb-net.co.uk"}]

Posted on
Fri May 22, 2020 9:35 am
siclark offline
Posts: 1333
Joined: Jun 13, 2017
Location: UK

Re: Indigo / Node-Red / Alexa

Hop[e that makes sense.. ask if not. Put a debug after the http nodes and you will see error messages in the debug window if the credentials are wrong for example.

Posted on
Fri May 22, 2020 10:37 am
whmoorejr offline
User avatar
Posts: 356
Joined: Jan 15, 2013
Location: Houston, TX

Re: Indigo / Node-Red / Alexa

siclark wrote:
Hop[e that makes sense.. ask if not. Put a debug after the http nodes and you will see error messages in the debug window if the credentials are wrong for example.


90% success on my end. 2 quirks...

1) The range node didn't work for me..... I swapped that node out with a "Change" node. 5=2, 10=3.

2) On my end, Alexa still doesn't recognize "low" as an option.... so the verbal command never gets passed on to Node-Red.

Working: On, Off, Medium, High (and Low if I say, Alexa, set Living Room Fan to 1.

Thank you Sir!!!

FYI: I'm in Houston.... setting my fan to "Low" never happens anyway.

Bill

Posted on
Fri May 22, 2020 10:39 am
siclark offline
Posts: 1333
Joined: Jun 13, 2017
Location: UK

Re: Indigo / Node-Red / Alexa

That’s strange. What is the range converting 10 to?
Also strange about Low. It worked for me. Did Alexa not like the command or it did send something else? Did the debug show you anything?

Posted on
Fri May 22, 2020 11:35 am
whmoorejr offline
User avatar
Posts: 356
Joined: Jan 15, 2013
Location: Houston, TX

Re: Indigo / Node-Red / Alexa

siclark wrote:
That’s strange. What is the range converting 10 to?

Double Strange, I just re-drew the line from the switch node to the range node, watched the payload and it worked just fine. (got the same result as the change node.)


siclark wrote:
Also strange about Low. It worked for me. Did Alexa not like the command or it did send something else? Did the debug show you anything?

Alexa just didn't like the command. Nothing got sent, nothing in debug. "I don't know how to set Living Room Fan to that setting". I tried a couple other commands, "Slow" "down" "soft"

Commands that work(ish) for low are: dim, decrease, increase, one

dim = msg.payload -1 (at first switch node), = 1 after range node = Fan Motor Low
decrease = -1 = 1 after range node = Fan Motor Low
increase = 1 = Fan Motor Low
one = 1 = Fan Motor Low

Interestingly, if you pass a "-1" through to the http request it just rotates through the speeds in descending order.

Not sure why "Low" isn't in the American English Alexa vocabulary. I've heard there are device differences across regions/countries/languages.

jalves wrote:
When I was in 11B training I was amused by the moulded warning on the Claymore.
Even when the Army makes stuff Idiot proof "front toward enemy", a bigger idiot will come along. ~ SSG USA RET 37F / 38A

Bill

Posted on
Fri May 22, 2020 12:01 pm
siclark offline
Posts: 1333
Joined: Jun 13, 2017
Location: UK

Re: Indigo / Node-Red / Alexa

That is strange. Well glad you have it working well enough and hopefully learnt a bit more about node-red. I did. I’ve already taken the template and used in controlling a zigbee bulb.

Posted on
Fri May 22, 2020 1:19 pm
Guest offline

Re: Indigo / Node-Red / Alexa

whmoorejr wrote:
Not sure why "Low" isn't in the American English Alexa vocabulary. I've heard there are device differences across regions/countries/languages.


That is weird. I am using American English and my Echo is able to set my fan to low. It sends a 1 when I issue the command "Set the office fan to low."

I will admit that sometimes my Echo doesn't seem to understand the low and medium commands. If yours never understand i wonder if it is worth deleting the device from https://red.cb-net.co.uk/login and from Alexa then discovering it again?

Posted on
Tue May 26, 2020 5:09 pm
whmoorejr offline
User avatar
Posts: 356
Joined: Jan 15, 2013
Location: Houston, TX

Re: Indigo / Node-Red / Alexa

Guest wrote:
whmoorejr wrote:
deleting the device from https://red.cb-net.co.uk/login and from Alexa then discovering it again?


Still no dice. Created a new flow for another fan.... "Set bedroom fan to Low".... Alexa Replies "I don't know how to set bedroom fan to that setting". The data doesn't make it past the echo (nothing happens from my collection of debug nodes.)

Bill

Who is online

Users browsing this forum: No registered users and 1 guest