Jump to content

Amazon Echo and ISY


madmartian

Recommended Posts

Posted (edited)

BlueMan2,

 

I indicated to the Author that perhaps he should make it more general allowing an arbitrary math expression to act on the value.

Something like ${intensity.math(<some math expression>)} or ${math.<some math expression>} . It should not be a lot of code.

 

As an example /CLISPC/${math.(2*X)}  where X is taken as what ever Echo passes as the spoken word

 

PS Did you mean  

        Set 'Thermostat - Mail' Cool Setpoint '$Air_Conditioner Degrees'

as opposed to

       Set 'Thermostat - Mail' Coll Setpoing '$Air_Conditioner Degrees'

 

??????

Edited by barrygordon
Posted

Yeah, my typing was pretty poor.  I corrected it.  

 

HOWEVER.......

 

I did not realize until I starting testing that dimmer only works in increments of 5!!  I was testing for 60, 65, 70 and it worked just fine.  But if you ask Alexa to set Air Conditioner to 72, she will give you 75.  This makes sense because you do not need to dim so precisely.  

 

Sooooo, we cannot use dimmer to control the AC.  I wonder if there is another variable that is used for climate devices which will return the actual number you give Alexa?

 

Darn, I was so close!

Posted

I can see why they did that when interpreting the spoken phrase.  When I get around to working on my "Alexa skill" I will probably have the code subscribe to the ISY so you can say things like up/down or warmer/cooler. That would work if the current temperature were known, hence the subscribe, and Alexa would then speak the current setpoint.  

Posted

I believe that the Echo can be made to pass along values such as temperature since that is a supported command.  Amazon is just doing pre-filtering of the number since it is for dimmers.  Maybe the BWS people can find a way to directly pass along a variable.  Maybe climate class devices would avoid this filtering?  

Posted

If the echo cannot do any conditional logic, can you have Echo send a 999 and -999 for Up and Down, respectively?

 

ISY could sort this out easily by filtering out ridiculous values and making exceptions like the values below to run a program that looks at the current setpoints or temperature, adds/subtracts half or one whole degree and changes that setpoint.

Posted

If you change the on and off URL's that the emulator sends in response to an on or off command you can send any sequence you want. The Echo, when hearing a number in what it thinks is a phrase to set a lights intensity value (brightness), will not send the number itself but the nearest multiple of 5 (or 10) to that number.  This makes it unsuitable to use for setting a thermostat.  If you write your own skill you can send any number you want but in your own skill you have to map out all the phrase's (Utterances) that Alexa will understand, that, I believe includes one for each number. I don't see how that is going to help you.  What do you believe the REST command should be when sending the 999 or -999 to the ISY?

Posted

.....  What do you believe the REST command should be when sending the 999 or -999 to the ISY?

Without having the syntax handy right now....

 

Just send the rest command to set the same variable to ISY setting it to -999 or 999. Setting the thermostat directly from Echo control would be suicide IMHO. That would be like putting your thermostat on the coffee table for every child and big kid to play with it. Good joke the rejected vacuum cleaner salesman setting your heat up to 40 degrees C just as he leaves your home.

 

ISY can sort out the value it gets in the variable, apply scaling factors, check for reasonability, interpret the values for special command like Up/Down, and apply situational logic (time of day) to values to further check reasonability.

Posted (edited)

I would prefer not to use a Skill, but rather the existing Alexa commands.  The reason is that there is a higher WAF for saying "Alexa, set AC to 72" rather than having to say "Alexa, tell Sandy to set AC to 72".  Just simpler.  Though I also agree I prefer to use my ISY to ensure the variable is not out of bounds or crazy.  For that, I would just have the Hue Emulator send the intensity value to a State Variable in the ISY, and use that to set the thermostat in a program.  That is what I tried to do, but the manipulation of the intensity.percent variable (rounding to 5) make this a no-go.

 

The question then is who is doing the manipulation of the intensity.percent value?  If it is Amazon, then we cannot use intensity.percent.  We would need to find another variable that is passed along without filtering.  If, on the other hand, Amazon is passing to the Hue Emulator the exact number, and it is the Hue Emulator that is adjusting the number (rounding to 5, making any value above 80=100, etc) then we would just need to adjust the Hue Emulator.  Maybe ask BWS to create a new {intensity.actual} value.  

 

Does anyone know if it is Amazon or the Emulator that is doing the current manipulation/change of the {intensity.percent} value????

Edited by blueman2
Posted (edited)

I am 99% sure that it is Amazon that sends the incorrect (adjusted) value. The emulator handles the scaling of the value as a byte (0-255) or as a percent (0-100).  I was told by an Amazon Echo specialist that the Echo always adjusted brightness in multiples of 10.  I have also seen the code in hue emulator that sets the value onto the onURL or offURL prior to sending it.

 

On the Git hub where BWS stores the emulator (Google "bwssystems git") are instructions.  The last, IIRC, instruction is how to turn on debugging.  Turn it on.  The log file will then show what was received from the Echo and what was sent to the end point.  There will be a lot of information in the log file, but it is just a text file.  Try Searching for something that looks like "bri":  The quotes are in the string since it is a JSON value of the form {"on":false|true, "bri":xx} where xx is the value the echo sends. The next line IIRC is what is sent to the endpoint. In JSON a property name (the part before the colon) is always quoted, while the value (the part after the colon) is also quoted unless it is literal such as true, false or a number. The curly braces delineate a JSON object.

 

Try speaking a lot of different values perhaps in a brightness phrase then look at the log and see what it says.  

Edited by barrygordon
Posted

I am able to get the Echo to pass the Hue Emulator any number including "73" as a percentage and I use that for temperature. 

 

I posted a video to youtube of it:

Amazon Echo Controlling ISY99i (Insteon), Nest Thermostat, RainMachine, and Logitech Harmony Hub 

Posted

I am able to get the Echo to pass the Hue Emulator any number including "73" as a percentage and I use that for temperature. 

 

 

 

Wow, Eric.  Thanks for the video.  But first, are you a 2 child home now?  Or is the baby still waiting to come out?  Good luck!!!

 

Now, on to your setup.  If you go to your Echo web app, and look at connected home devices, does your thermostat show as a Hue Light?  If so, then it would appear that Amazon does indeed pass along the entire intensity variable, unmodified, to the Hue for lights.  Can you confirm this?

 

I will look at your code (I am NOT an experienced coder, but I like to play) and try to better understand what you have done.  THANKS for giving us hope!

Posted (edited)

I just ran my own test use the emulator Debugger capability.

 

I set up a new device for the echo called thermostat.  The onURL is set to the following:

 

http:/userid:password@192.168.1.229:80/rest/nodes/20%2093%205%201/cmd/DON/${intensity.percent}

 

The device at 20 93 5 1 is an insteon dimmer/switch which controls my office ceiling lights.

 

The debugging output verifies that when using the following phrase to Alexa:

 

Alexa Set the thermostat to xx        where xx is a number,

 

the command sent to the isy has exactly the nunber I spoke.  I tried the following numbers 71, 75, 77, 53, 82, 27, 94

 

The Debug log from the emulator had the following entries among others:

 

... hue state change requested: cUQ6FpY9yemZY7OTVn3HPRaGeTy629GKLAdSXWCe from 192.168.1.91 body: {"on": true,"bri":181}
... Making outbound call in doHttpRequest: GET http://admin:admin@192.168.1.229:80/rest/nodes/20%2093%205%201/cmd/DON/71HTTP/1.1
 
... hue state change requested: cUQ6FpY9yemZY7OTVn3HPRaGeTy629GKLAdSXWCe from 192.168.1.90 body: {"on": true,"bri":191}
... Making outbound call in doHttpRequest: GET http://admin:admin@192.168.1.229:80/rest/nodes/20%2093%205%201/cmd/DON/75HTTP/1.1
 
... hue state change requested: cUQ6FpY9yemZY7OTVn3HPRaGeTy629GKLAdSXWCe from 192.168.1.91 body: {"on": true,"bri":196}
... Making outbound call in doHttpRequest: GET http://admin:admin@192.168.1.229:80/rest/nodes/20%2093%205%201/cmd/DON/77HTTP/1.1
 
... hue state change requested: cUQ6FpY9yemZY7OTVn3HPRaGeTy629GKLAdSXWCe from 192.168.1.90 body: {"on": true,"bri":135}
... Making outbound call in doHttpRequest: GET http://admin:admin@192.168.1.229:80/rest/nodes/20%2093%205%201/cmd/DON/53HTTP/1.1
 
... hue state change requested: cUQ6FpY9yemZY7OTVn3HPRaGeTy629GKLAdSXWCe from 192.168.1.91 body: {"on": true,"bri":209}
... Making outbound call in doHttpRequest: GET http://admin:admin@192.168.1.229:80/rest/nodes/20%2093%205%201/cmd/DON/82HTTP/1.1
 
... hue state change requested: cUQ6FpY9yemZY7OTVn3HPRaGeTy629GKLAdSXWCe from 192.168.1.90 body: {"on": true,"bri":68}
... Making outbound call in doHttpRequest: GET http://admin:admin@192.168.1.229:80/rest/nodes/20%2093%205%201/cmd/DON/27HTTP/1.1
 
... hue state change requested: cUQ6FpY9yemZY7OTVn3HPRaGeTy629GKLAdSXWCe from 192.168.1.91 body: {"on": true,"bri":239}
... Making outbound call in doHttpRequest: GET http://admin:admin@192.168.1.229:80/rest/nodes/20%2093%205%201/cmd/DON/94HTTP/1.1
 

 The above matches up perfectly with the spoken phrases and the office lights dimmed to the correct values.

 

I am waiting to hear from the author of the emulator if he can make the change to add a math capability in the ${} expression

Edited by barrygordon
Posted (edited)

OK, Something weird is going on.  I created a new device and it works perfectly for whatever number between 0 and 100 that I give it.  But then I made a minor change to its friendly name, updated and re-discovered, and it does not work anymore.  Also, if I say "Alexa, set Heater to 73", it will give me 75 by rounding. BUT if I say "Alexa, set THE heater to 73" it works, most of the time.  But sometimes gives me 100%.  So something needs to be set VERY precisely to make this work.  

 

This proves it CAN be done, but must be done exactly right.  

 

I am using the same emulator as Eric2XU for testing.  I will go back to the BWS one and see if it is the same.  But there is some promise here!!

Edited by blueman2
Posted (edited)

OK, I think I am finally there.  I changed the friendly name to Thermostat and it is working just right!!  (Thanks for the clue in your video, Eric!!).  I am using {intensity.percent} and sending that to my ISY as a state variable.  My command line is

http://user:pwd@<ISY IP address>/rest/vars/set/2/9/${intensity.percent}

This writes to the State Variable with ID 9.   So far, it is working every time.  I tried number from 1 to 100.  Above 100 it does not work.  It also will not take negative.  Of course, not an issue for temp, but just checking.

 

I can use "Alexa, set thermostat to 72" or "Alexa, set thermostat to 72 degrees" and both work every time so far (after about 50 tests).

 

Now to write the program that will filter the values to ones that are reasonable, and then send them to my thermostat in ISY.  (using 5.02 firmware)

Edited by blueman2
Posted (edited)

OK, I have it all working the way I want.  Using the friendly name "Thermostat" the Echo will provide an unmanipulated number between 1 and 100 every time using {intensity.percent} variable.  I also changed the device type to "Climate" but I am not sure that does anything.  

 

Setup:

======

Emulator: BWS's Hue Emulator version 0.4.4 running on RPi2

Mapper: Barry's AWS_config version 2.0.39

ISY firmware: 5.0.2 

 

In Barry's AWS_config:

===================

Friendly Name: Thermostat (IMPORTANT: use this name!!)

Device Type: Climate (I do not think this matters, but what the heck)

My On URL: /rest/vars/set/2/9/${intensity.percent}

 

I have a program that looks to see if the State Variable 9 is between 60-71 and, if so, sets the heat setpoint to that value and sets the thermostat to heat mode.  If between 72-80, it sets the cool setpoint to that value and sets the thermostat to cool mode.  I also created programs on my ISY that Alexa can trigger to turn off and on the heating and cooling modes by voice command.    

 

To use, I say "Alexa, set Thermostat to 72" and this will put my cool setpoint to 72 and enable the AC mode on my thermostat.  I can then say "Alexa, turn off AC" and it will go into off mode.  I can later say "Alexa, turn on AC" and it will re-enable cooling mode using the last temperature setpoint.  

 

So far, it is working perfectly!!!!  

 

Eric and Barry, thank you both for the help and direction!!!

Edited by blueman2
Posted

Can we get some example REST commands for the NEST?  i.e. code to set away, raise 1 degree, down 1 degree?

 

Thanks!

Start a new thread. Different topic and more will find it and possibly join in.

Posted

Does anyone know of a list of all Alexa commands/words that can be used with Home Automation currently?  Is it documented anywhere by Amazon?  Finding out that giving the name Thermostat allowed a device to pass actual values rather than rounded brightness levels makes me want to see what other easter eggs there are in terms of wording for Alexa.  

Posted

No, Have had the same thought and have not yet discovered an answer.  The fact that a family name of thermostat is surprising seems to do what it does is surprising.  What about things like Master Thermostat, Guest Thermostat, or variants for more than one thermostat

Posted (edited)

We are days away from baby #2 (hence why I still have time to make a video lol) :)

 

 

How the heck did I not know that, congrats!

Edited by smileyw
Posted

 

 

I have finished writing code that pulls together Alexa, Hue Emulator 0.2.1, Logitech Harmony, Google Nest, and RainMachine. 

 

Eric, I do not have one of the newer Harmony remotes.  Still using the old 900 version.  I see that there are 2 options now.  One is the regular Smart Remote, and the other is Home Control remote.  Will either one work to integrate with the Echo, or do I need the Home Control version.  I was not sure if the only difference was a few buttons or if they are fundamentally different.

 

Thanks

Posted

To be honest I am not sure. It also depends on what you want to do. I am pretty sure you need the fancier Home Control one if you want it to control lighting on the ISY, however I am unsure if a lesser model which still included the "hub" would allow Echo to control it. I think it would but again not sure. 

Posted

To be honest I am not sure. It also depends on what you want to do. I am pretty sure you need the fancier Home Control one if you want it to control lighting on the ISY, however I am unsure if a lesser model which still included the "hub" would allow Echo to control it. I think it would but again not sure. 

 

So do you have the Home Control model with the light/plug buttons?

Posted (edited)

Can ISY put a variable value into the body of a REST PUT command?  You could have echo put the requested temp value for a thermostat command into an ISY variable, and then have ISY send the REST command to NEST inserting the variable value...

 

Or is this something we are waiting for the 5.x firmware to support?

Edited by jruben4

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...