tmorse305 Posted June 21, 2017 Posted June 21, 2017 Hi, I wrote a simple program (below) which works fine when I manually press the button on the KPL, but when I try it through Alexa, the program will not run. Here is the program: Oxygen check - [iD 004E][Parent 0001][Not Enabled] If Control 'Darcies Room / Darcie's Light' is switched Off And Status 'Basement / Oxygen' is Off Then Set Scene 'Crosslinks / Oxygen Crosslink' On Send Notification to 'Text-Tim' content 'Oxygen Alert' Else - No Actions - (To add one, press 'Action') See also attached screen shot from the log file. The first highlighted section is using Alexa, the 2nd when I manually pressed the off button on the KPL. Disregard the grayed out section that is a manual turn on via a button press. It's seems like it should work with Alexa too. It there something I'm missing w/r to Alexa based commands? Thanks, Tim
stusviews Posted June 21, 2017 Posted June 21, 2017 The Echo cannot execute a condition. The only commands an Echo can run is On which runs Then and Off which runs Else. If you need to trigger a condition, then create a program with nothing in the If section and a run program command in the Then section.
tmorse305 Posted June 22, 2017 Author Posted June 22, 2017 Thanks stusviews, I guess I don't understand how the communication works. When you ask Echo to turn a device on doesn't it just pass that request on to ISY via the portal? When ISY executes the request I would think an ISY program would be able to detect that conditional change and respond. How does the communication work?
mwester Posted June 22, 2017 Posted June 22, 2017 To start, consider the first part of your program's condition: If CONTROL xyz is switched OFF This establishes what *triggers* the program to run -- specifically, it's the "Turn OFF" signal being sent from device xyz that causes the rest of the conditional to be evaluated. It doesn't matter if xyz is already off -- or on, or dimmed somewhere in-between, just that the switch itself sent the Insteon message code meaning "turn off". The only way to get this message sent is if the button/switch is mechanically operated -- using the admin console, or any other means to tell the button/switch to turn off will result in that button/switch turning off, but that button/switch will not send the message -- the message is only ever sent if the button/switch is physically operated. From the above, you can see that there's just no way to have Alexa operate that switch. Having Alexa send a "turn off" message to the switch is possible, and does exactly what turning off the switch does from the Admin Console -- the button/switch will turn off, but it will not send the "Turn OFF" message, and thus won't trigger the program on the ISY. Having Alexa run that program rather than operate that switch is more interesting -- but immediately you can see that evaluating the condition would fail -- the first part will never be true, because it's Alexa that's running the program, not a "Turn OFF" message coming from the switch. It's also rather vague syntactically -- telling Alexa to "turn on xyz" vs "turn OFF xyz" should do something different, but if both just ran the program starting with the "if" statement, they'd end up meaning the same thing. So instead, UDI built the integration so that Alexa doesn't run the "if" part of a program -- it doesn't make sense in many cases -- and instead Alexa runs the "then" part when you tell it to "turn on" and the "else" part when you tell it to "turn off". Finally, without understanding what you actually want to have happen, and what the devices involved really are, it's just guesswork -- but there IS a way to have a program run based on the *change* in status of a device regardless of why that status changed, rather than having the program run when the "Turn OFF" message is sent by the device. This has some subtle but important caveats -- for example, right now, if the switch is already off, and you wack the bottom of the paddle, it will send a "Turn OFF" message even though the light/load is *already* off. That can be very useful, and if you depend on this functionality, don't change anything. On the other hand, if you don't care about that, then you may consider changing the CONTROL to STATUS -- that change tells the ISY to run the program when the ISY's idea of the device's on/off state changes, without regard for what caused it to change. That'll trigger the program even if Alexa turns off that switch. However, if the device is already off, you can wack on the "off" side of the paddle all day long, and the switch will keep sending "Turn OFF" messages, but because the ISY is looking for a *STATUS* change (from ON to OFF), it won't run the program. 2
stusviews Posted June 22, 2017 Posted June 22, 2017 Alexa cannot run a program because Alexa can only issue On or Off commands (sometimes Open and Close work). A program does not understand On and Off. The result is the an Echo command of On runs the Then section of a program and Off runs Else. There are two solutions: 1. Ask Alexa to tell Izzy to run program_name. The program needs to have a spoken. 2. Create a new program with nothing in the If section and only the following in the Then section: Run Program 'new_program_name' (Then Path) Give the new program a unique new name. "Alexa, turn on new_program_name," will cause your original program to run after evaluating the trigger (i.e., If section). 1
tmorse305 Posted June 22, 2017 Author Posted June 22, 2017 mwester, thanks for your reply, For all the programs I've written using the Control command I did not realize it was limited to the actual device only. stusviews, thanks again I created 2 programs as suggested. It's obvious now that I understand the Control command operation.
Recommended Posts