Jump to content

Query Alexa for device status


Recommended Posts

Posted

I've looked and looked but can't seem to find a way to get this to work. I just want to be able to ask Alexa "what is the status of my garage door?" I know you can have Alexa announce when the garage opens or closes. But I want to be able to query the status at any time. 

Posted

If I recollect correctly.  Create a state variable for the garage door, create an additional state variable that would read the existing value of the garage door variable.  Then create an alexa routine that using a voice prompt would trigger a program on the ISY that would change the second variable to the existing garage door variable, then set the second variable up in portal as a contact switch with a spoken assigned.  Lastly create aa alexa routine that when that spoken is open makes an announcement.  So in essence you say is garage door open, alexa runs grage door state program, that programs assigns the variable to garage door query program, which basically cahnges the value from 0 closed to 1 open, when the variable changes to 1 alexa sees it and announces your message or text.  I think I got alll the steps in, I can check later when I get home and follow up.  Oh, and you need to reset the second variable back to 0.  So say I use a window sensor.  Program would be if window sensor ON then $sWindow Var=1 Else $sWindow Var=0.  Or you could say after 15 seconds set window var to =-1. 

Posted
28 minutes ago, kfrazack said:

But wait, I can’t see a way for an Alexa voice prompt to trigger a program. 

You will require ISY Portal to make the connection easily.

Posted (edited)

@kfrazack     OK, if you haven't figure it out yet here is what you need.  I don't have a garage door so I am using a window as an example.

First create 2 state variables, I use state variables, not sure if integers would work.  $s.KR_Window_Open and   $s.KR_Window_Closed

Then create 3 Programs like below:  (all 3 are NOT ENABLED) so they will not fire on their own.

I am using 0 and 1 for values where 0 is false and 1 is true.  These are based on a window sensor being open TRUE or closed FALSE.  Both values are 1 because we are looking for it to be true whether it is opened or closed for the virtual sensor we will set up in Alexa.

______________________________________________________________PROGRAM 1

window query - [ID 00A8][Parent 00A3][Not Enabled]

If
   - No Conditions - (To add one, press 'Schedule' or 'Condition')
 
Then
        Run Program 'window open' (If)
 
Else
   - No Actions - (To add one, press 'Action')

_______________________________________________________________PROGRAM 2

window open - [ID 00A9][Parent 00A3][Not Enabled]

If
        'Security / Windows / KR Side Window-Opened' Status is On
 
Then
        $s.KR_Window_Open  = 1
        Wait  30 seconds
        $s.KR_Window_Open -= 1
 
Else
        Run Program 'window closed' (If)
_______________________________________________________________PROGRAM 3

window closed - [ID 00AA][Parent 00A3][Not Enabled]

If
        'Security / Windows / KR Side Window-Opened' Status is Off
 
Then
        $s.KR_Window_Closed  = 1
        Wait  30 seconds
        $s.KR_Window_Closed -= 1
 
Else
   - No Actions - (To add one, press 'Action')
 

Now we go to the ISY Portal and select >connectivity>amazon alexa.  Then we will select the variable tab, find your first variable in the list, in this case KR_Window_Open, pick the category as CONTACT SENSOR and give it a closed value of 0, then give it a spoken, this is what the device will be called in the alexa app so you can find it easily, then do it for the second variable you created, mine are simply window open and window closed.  Don't forget to save.  Then go to the Programs tab and find your first program select category as scene and assign it a spoken, then save.

Now we go to the alexa app.  First discover devices.  Then we will create 3 routines

The first routine when this happens:  Pick VOICE and enter the phrase you would like to use like, "What is status of Window"  Next we add the action pick smart home and then Control Scene, pick the program you just named in the portal.  We use it as a scene because when alexa turns on the scene it runs the THEN statement of your program,  If you turned it off it would run the ELSE statement.  For this example we are turning your Program now a scene on so it will fire the THEN statement of your first program.

Now we need to get alexa to talk back to us so we will use the 2 virtual contact switches to trigger her response.  first make a routine that WHEN THIS HAPPENS you pick device and choose the switch you made for window in your case door open, then choose when this opens option.  Next you will pick the action which will be MESSAGING, now you can pick to have it announce over your Alexa devices or send you a text or both, pick the one you want and type in the response you want In my case it is WIDOW IS OPEN.  Now do the same for the second switch you created, mine is Window is closed.

Whew, think we'redone.  So when you say WHAT IS THE GARAGE DOOR STATUS alexa will execute Program 1, which will run the if in program 2, so if the  door is open it will set the variable to 1 and alexa will see it as a switch turning on and announce your message DOOR IS OPEN.  If the door is closed then program 2 will run program 3 and if door is closed then that variable goes high and and alexa sees that switch turn on and announce DOOR CLOSED.

 

Hope this helps and I didn't miss anything.

Tom

 

Edited by TomL
Posted

TomL

This is genius! Took awhile to figure out how it's working. But if you don't mind me picking your brain... why not build it all into one program? The query program is simply running the open program and the open program else clause is calling the closed program. Why not just call the open program and have it as this?

window open - [ID 00A9][Parent 00A3][Not Enabled]

If
        'Security / Windows / KR Side Window-Opened' Status is On
 
Then
        $s.KR_Window_Open  = 1
        Wait  30 seconds
        $s.KR_Window_Open -= 1
 
Else
        $s.KR_Window_Closed  = 1
        Wait  30 seconds
        $s.KR_Window_Closed -= 1

Posted

TomL

I just ran across this:

  • An Alexa contact sensor can be queried this way:
    • Alexa, is <device> opened?
    • Alexa, is <device> closed?
  • This works for ISY devices, ELK zones, or state variables.
  • If Alexa responds with an error message, please try a different spoken. Alexa is a bit picky on the spoken used, especially for querying the contact sensor.
  • For motion sensors, it seems that there is no way to query by voice. You can however query the state in the Alexa app.

 

However, you're programming examples helped me better understand the whole state variable thing. 

Posted

@kfrazack, there may be more elegant streamlined ways to go about this, I am not a programmer by far, more of a trial and error guy.  I was unaware of the contact sensor query, thanks for the info.  I have spent countless hours reading through posts and getting help from the much more advanced persons on this site, it is full of great information and very kind and helpful users.  I am just recently delving into the use of variables and not truly versed in them yet, but am learning and rewriting various programs to make them more streamlined.  My example above is how I got things to work, as I said there are probably simpler ways to do it.  Either way the important thing is that you get the manipulation of data that you need or want.  Hope you got it going, there is much to learn and many things that the ISY will do that I never thought of before reading through the posts on this site.

My goal is to make the house more autonomous with as little manual intervention as possible, several people on here have systems and programming that I can only dream of, but hopefully will get there someday.

Thanks

Tom

Posted

I think I see why having separate programs is needed. It has to do with the states of variables and devices. I made a program that would open the garage door if you told it to, but would do nothing if the door was already opened. Same for close. But it didn't work properly until I disabled all the programs. Otherwise they were always looking for a true clause. I never understood the point of disabling a program until now. It basically makes the program a subroutine that runs only when called. 

TomL, I'm the same way. I've combed through these posts to set up my ISY and some basic programs. But when I got the Alexa it opened up a whole new world. Definitely having fun figuring this stuff out. Thanks for all of your help.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.


×
×
  • Create New...