Create a fake Motion sensor device, trigger via indigo action to run an Alexa routine!
How to:
Http in node: Get. URL = "/fakemotion1. name = "fakemotion1" -->. (Add a http response node after this node AND to the json node)
json node, Convert between JSON String & Object -->
switch == {"power":"on"} --> 1. {"power":"off"} -->2
Change node for each leg of the switch. (set message to "ON", set message to "OFF") respectively... Both change nodes funnel to one function node -->
Function node (translates to something Alexa understands)
- Code: Select all
// Motion State
if (msg.payload == "ON") {
return { "payload" : { "state" : { "motion" : "DETECTED" } }, "acknowledge" : true };
}
else if (msg.payload == "OFF") {
return { "payload" : { "state" : { "motion" : "NOT_DETECTED" } }, "acknowledge" : true };
}
--> Alexa Smart home v3 state (select your fake motion detector you created.
on the indigo side.... action: execute embedded python: (substitute URL:Port with the url & port of your node red server:
- Code: Select all
import requests
r = requests.get('http://192.168.1.10:1880/fakemotion1?power=on')
r.raise_for_status()
EDIT The above script will leave the fake detector in a "DETECTED" state forever. Add a second action with a delay to the same action with the same code, but use power=off. Example use: (All my kids bedrooms have the GE Motion light switch and a Amazon Flex. In my teenager's room, if motion is detected, it runs the above script which node-red sends to Alexa to then trigger a routine to play a fart sound.
Here is a picture of the node order. Your's will look a little different, unless your name is Bill also.