Author Topic: Nest Thermostat and Nest Protect - Command Collection  (Read 10874 times)

0 Members and 1 Guest are viewing this topic.

jitterjames

  • Administrator
  • Hero Member
  • *****
  • Posts: 7714
  • Karma: 116
    • View Profile
    • VoxCommando
Nest Thermostat and Nest Protect - Command Collection
« on: January 17, 2015, 12:28:25 PM »
Here is a tutorial and demonstration showing how to voice control (or automate) your Nest devices using VoxCommando version 2.1.3.6 or later: Downloads



The command collection is attached to this post.  Save the xml file and then drag it into your VoxCommando command editor window.

15-Aug-2015 update: Changes to Nest site required updates to 2 commands for generating payload XML files for Protects and thermostats.

2-Mar-2016 update: Fixed some typos, added command to get target temp, fixed Protect battery health command, and made sure Nest data is refreshed in commands retrieving current data.
« Last Edit: March 02, 2016, 03:29:14 PM by nime5ter »

Soda97

  • Contributor
  • ***
  • Posts: 69
  • Karma: 1
    • View Profile
Re: Nest Thermostat and Nest Protect - Command Collection
« Reply #1 on: January 18, 2015, 12:03:03 AM »
AWESOME!

I have a few problems tho. I could get the current temp and set thermostat to heat or cool but I'm unable to get status report and set it to away.  I have attached a log file (I edited out some info).

Also, is "more" mean you going to make a Fahrenheit version?  ;D


Haddood

  • $upporter
  • Hero Member
  • *****
  • Posts: 688
  • Karma: 22
    • View Profile
Re: Nest Thermostat and Nest Protect - Command Collection
« Reply #2 on: January 18, 2015, 04:14:08 AM »
 :clap :clap :clap :clap :clap :clap
When Voice command gets tough, use hand gestures

jitterjames

  • Administrator
  • Hero Member
  • *****
  • Posts: 7714
  • Karma: 116
    • View Profile
    • VoxCommando
Re: Nest Thermostat and Nest Protect - Command Collection
« Reply #3 on: January 19, 2015, 10:03:13 PM »
I updated the xml attached to the first post.  There were a few bugs that did not affect my particular setup that are hopefully resolved now.

Soda97

  • Contributor
  • ***
  • Posts: 69
  • Karma: 1
    • View Profile
Re: Nest Thermostat and Nest Protect - Command Collection
« Reply #4 on: January 20, 2015, 01:08:47 AM »
thanks, it all works now.

I just figured out the structure id under generate device list too but you beat me to it.  :P

nime5ter

  • Administrator
  • Hero Member
  • *****
  • Posts: 1999
  • Karma: 61
    • View Profile
    • Getting Started with VoxCommando
Re: Nest Thermostat and Nest Protect - Command Collection
« Reply #5 on: January 20, 2015, 08:58:49 AM »
@Soda97, internally Nest stores temp data in Celsius so you'll need to convert to and from Celsius in your commands if you want them to be in Fahrenheit.

There's already info on the forum on how to use one line of Python directly in a command to do simple math, so it should be possible for American VC users to do this themselves. Just search the forum for "Fahrenheit" or "simple math" or terms like that.

The main "trick" is that currently when we pass temperatures we're adding a decimal place in the Scrape action. That extra ".0" in the Scrape actions should be deleted in Fahrenheit versions (actually, it's not really needed in the Celsius version either).

Obviously it would be great if someone were to post the Fahrenheit commands once they've made them for their own configuration.
« Last Edit: January 20, 2015, 12:38:42 PM by nime5ter »
TIPS: POST VC VERSION #. Explain what you want VC to do. Say what you've tried & what happened, or post a video demo. Attach VC log. Link to instructions followed.  Post your command (xml)

Soda97

  • Contributor
  • ***
  • Posts: 69
  • Karma: 1
    • View Profile
Re: Nest Thermostat and Nest Protect - Command Collection
« Reply #6 on: January 20, 2015, 03:28:27 PM »
Thank you so much guys, I hope this is the correct way.

Here's the Fahrenheit for American users.

Code: [Select]
<?xml version="1.0" encoding="utf-16"?>
<!--VoxCommando 2.1.3.6-->
<command id="1237" name="Get current temperature" enabled="true" alwaysOn="False" confirm="False" requiredConfidence="80" loop="False" loopDelay="0" loopMax="0" description="">
  <action>
    <cmdType>File.Read</cmdType>
    <params>
      <param>Nest\Nest_dev_status.txt</param>
    </params>
    <cmdRepeat>1</cmdRepeat>
  </action>
  <action>
    <cmdType>Results.RegEx</cmdType>
    <params>
      <param>shared".*?"{1}".*?"current.temperature".(.*?),</param>
    </params>
    <cmdRepeat>1</cmdRepeat>
  </action>
  <action>
    <cmdType>PY.ExecString</cmdType>
    <params>
      <param>result=int({Match.1}*1.8+32)</param>
    </params>
    <cmdRepeat>1</cmdRepeat>
  </action>
  <action>
    <cmdType>OSD.ShowText</cmdType>
    <params>
      <param>{PF.1} shows a current temperature of {LastResult} degrees.</param>
    </params>
    <cmdRepeat>1</cmdRepeat>
  </action>
  <action>
    <cmdType>TTSMS.Speak</cmdType>
    <params>
      <param>{PF.1} shows a current temperature of {LastResult} degrees.</param>
    </params>
    <cmdRepeat>1</cmdRepeat>
  </action>
  <phrase>Get current temperature of</phrase>
  <phrase optional="true">the</phrase>
  <payloadFromXML phraseOnly="False" use2partPhrase="False" phraseConnector="by" Phrase2wildcard="anyone" optional="False">Nest\thermoList.xml</payloadFromXML>
</command>

nime5ter

  • Administrator
  • Hero Member
  • *****
  • Posts: 1999
  • Karma: 61
    • View Profile
    • Getting Started with VoxCommando
Re: Nest Thermostat and Nest Protect - Command Collection
« Reply #7 on: January 20, 2015, 03:59:18 PM »
Yup, good stuff, thanks for posting. The same method can be used with the two "set temperature" commands as well (but in reverse, of course).

I think you'll find that if you use round(x) instead of int(x) you'll more often get a result that matches what your Nest thermostat is showing you.
TIPS: POST VC VERSION #. Explain what you want VC to do. Say what you've tried & what happened, or post a video demo. Attach VC log. Link to instructions followed.  Post your command (xml)

Soda97

  • Contributor
  • ***
  • Posts: 69
  • Karma: 1
    • View Profile
Re: Nest Thermostat and Nest Protect - Command Collection
« Reply #8 on: January 20, 2015, 05:04:13 PM »
thanks, nim5star.

Fahrenheit version.

Get current temperture,

Code: [Select]
<?xml version="1.0" encoding="utf-16"?>
<!--VoxCommando 2.1.3.6-->
<command id="1237" name="Get current temperature" enabled="true" alwaysOn="False" confirm="False" requiredConfidence="80" loop="False" loopDelay="0" loopMax="0" description="">
  <action>
    <cmdType>File.Read</cmdType>
    <params>
      <param>Nest\Nest_dev_status.txt</param>
    </params>
    <cmdRepeat>1</cmdRepeat>
  </action>
  <action>
    <cmdType>Results.RegEx</cmdType>
    <params>
      <param>shared".*?"{1}".*?"current.temperature".(.*?),</param>
    </params>
    <cmdRepeat>1</cmdRepeat>
  </action>
  <action>
    <cmdType>PY.ExecString</cmdType>
    <params>
      <param>result=round({Match.1}*1.8+32)</param>
    </params>
    <cmdRepeat>1</cmdRepeat>
  </action>
  <action>
    <cmdType>OSD.ShowText</cmdType>
    <params>
      <param>{PF.1} shows a current temperature of {LastResult} degrees.</param>
    </params>
    <cmdRepeat>1</cmdRepeat>
  </action>
  <action>
    <cmdType>TTSMS.Speak</cmdType>
    <params>
      <param>{PF.1} shows a current temperature of {LastResult} degrees.</param>
    </params>
    <cmdRepeat>1</cmdRepeat>
  </action>
  <phrase>Get current temperature of</phrase>
  <phrase optional="true">the</phrase>
  <payloadFromXML phraseOnly="False" use2partPhrase="False" phraseConnector="by" Phrase2wildcard="anyone" optional="False">Nest\thermoList.xml</payloadFromXML>
</command>

Set temperature.
Code: [Select]
<?xml version="1.0" encoding="utf-16"?>
<!--VoxCommando 2.1.3.6-->
<command id="1262" name="Set temperature of {1} to {2}" enabled="true" alwaysOn="False" confirm="False" requiredConfidence="80" loop="False" loopDelay="0" loopMax="0" description="">
  <action>
    <cmdType>TTS.Speak</cmdType>
    <params>
      <param>Setting {PF.1} to {2} degrees.</param>
    </params>
    <cmdRepeat>1</cmdRepeat>
  </action>
  <action>
    <cmdType>OSD.ShowText</cmdType>
    <params>
      <param>Setting {PF.1} to {2} degrees.</param>
    </params>
    <cmdRepeat>1</cmdRepeat>
  </action>
  <action>
    <cmdType>PY.ExecString</cmdType>
    <params>
      <param>result=round(({2}-32)/1.8)</param>
    </params>
    <cmdRepeat>1</cmdRepeat>
  </action>
  <action>
    <cmdType>Scrape.Post</cmdType>
    <params>
      <param>{M:Nest.transport_url}/v2/put/shared.{1}</param>
      <param>{"target_change_pending":true,"target_temperature":{LastResult}.0}</param>
      <param />
      <param />
      <param>application/json</param>
      <param>Authorization: Basic {M:Nest.access_token}</param>
      <param>X-nl-protocol-version: 1</param>
    </params>
    <cmdRepeat>1</cmdRepeat>
  </action>
  <phrase>Set</phrase>
  <payloadFromXML phraseOnly="False" use2partPhrase="False" phraseConnector="by" Phrase2wildcard="anyone" optional="False">Nest\thermoList.xml</payloadFromXML>
  <phrase>to</phrase>
  <payloadRange>50,90</payloadRange>
  <phrase optional="true">degrees, degrees Fahrenheit</phrase>
</command>

Set max/min temperature.
Code: [Select]
<?xml version="1.0" encoding="utf-16"?>
<!--VoxCommando 2.1.3.6-->
<command id="1257" name="Set max/min temperature of {2} to {3}" enabled="true" alwaysOn="False" confirm="False" requiredConfidence="80" loop="False" loopDelay="0" loopMax="0" description="">
  <action>
    <cmdType>TTS.Speak</cmdType>
    <params>
      <param>Setting {PF.2}'s {1} to {3} degrees.</param>
    </params>
    <cmdRepeat>1</cmdRepeat>
  </action>
  <action>
    <cmdType>OSD.ShowText</cmdType>
    <params>
      <param>Setting {PF.2}'s {1} to {3} degrees.</param>
    </params>
    <cmdRepeat>1</cmdRepeat>
  </action>
  <action>
    <cmdType>PY.ExecString</cmdType>
    <params>
      <param>result=round(({3}-32)/1.8)</param>
    </params>
    <cmdRepeat>1</cmdRepeat>
  </action>
  <action>
    <cmdType>Scrape.Post</cmdType>
    <params>
      <param>{M:Nest.transport_url}/v2/put/shared.{2}</param>
      <param>{"target_temperature_{1}":{LastResult}.0}</param>
      <param />
      <param />
      <param>application/json</param>
      <param>Authorization: Basic {M:Nest.access_token}</param>
      <param>X-nl-protocol-version: 1</param>
    </params>
    <cmdRepeat>1</cmdRepeat>
  </action>
  <phrase>Set</phrase>
  <payloadFromXML phraseOnly="False" use2partPhrase="False" phraseConnector="by" Phrase2wildcard="anyone" optional="False">Nest\Nest_therm_max-min.xml</payloadFromXML>
  <phrase optional="true">temp, temperature</phrase>
  <phrase>of</phrase>
  <payloadFromXML phraseOnly="False" use2partPhrase="False" phraseConnector="by" Phrase2wildcard="anyone" optional="False">Nest\thermoList.xml</payloadFromXML>
  <phrase>to</phrase>
  <payloadRange>50,90</payloadRange>
  <phrase optional="true">degrees, degress Fahrenheit</phrase>
</command>

MrWolf

  • $upporter
  • Sr. Member
  • *****
  • Posts: 209
  • Karma: 4
    • View Profile
Re: Nest Thermostat and Nest Protect - Command Collection
« Reply #9 on: August 14, 2015, 04:39:15 PM »
Hi guys,

Just decided to set this up, but I'm getting stuck.  I've tried following the instructions from the YouTube video a few times but I'm getting the same issue every time.

Steps:
Import XML using drag and drop
Create nest folder using "Create Nest Folder" XML (confirmed folder is successfully created with 1 XML file therein)Enter my login details to Nest authorisation XML
Save the XML without executing the command
Restart Vox
Execute "Login to Nest" command vocally

...This is where it goes wrong.  If I open the thermolist XML file that this generates then I can see it has not populated my details, it has what I presume is an example in there...

<?xml version="1.0" encoding="UTF-8"?>

<!--A VoxCommando Payload file-->

-<PayloadsRoot>


-<payload>

<value>02AA01AC041500BA</value>

<phrase>Basement</phrase>

</payload>

</PayloadsRoot>


I definitely don't have an area/thermostat called "Basement" in my Nest account, the only Thermostat I can see when I login to the Nest web portal is called Bedroom and has a label of Bedroom.

Weirdly the commands for "Basement" control the "Bedroom" if I test them.  Any idea why Vox would be scraping the word Basement in place of the word bedroom?

Attached is the log.  My tiny mind can comprehend just about enough of it to remove my login details, but that's as far as my comprehension will take me, I can see errors about invalid files but I don't know why that would be.  Any help as always is much appreciated...

[Post edited to delete log with private data --nime5ter]
« Last Edit: August 14, 2015, 07:02:45 PM by nime5ter »
Home automation guides for idiots like me by an idiot (me)...
https://www.youtube.com/user/wolfsweb

Kalle

  • $upporter
  • Hero Member
  • *****
  • Posts: 2320
  • Karma: 47
    • View Profile
Re: Nest Thermostat and Nest Protect - Command Collection
« Reply #10 on: August 14, 2015, 06:04:20 PM »
Hi Paul, so far I can see your log file show in the scrape result basement, bedroom, master bedroom, kitchen ... , so it looks like the bedroom ID is assigned to the basement ID.
***********  get excited and make things  **********

nime5ter

  • Administrator
  • Hero Member
  • *****
  • Posts: 1999
  • Karma: 61
    • View Profile
    • Getting Started with VoxCommando
Re: Nest Thermostat and Nest Protect - Command Collection
« Reply #11 on: August 14, 2015, 06:29:10 PM »
Nest has changed its website slightly so the regex we use when scraping the Nest site in order to generate the device payload XML files give the wrong device names, but the device IDs are still correct -- at least for me the device IDs are still correct.

Assuming you don't have a million devices, you can manually edit your payload xml.

Log into the Nest website in your browser. Click on each device. The device ID should show up at the end of the URL. You can compare this to the payload XML, and change the device names accordingly.

I didn't test all the commands, but the ones I tested seem to work.
TIPS: POST VC VERSION #. Explain what you want VC to do. Say what you've tried & what happened, or post a video demo. Attach VC log. Link to instructions followed.  Post your command (xml)

nime5ter

  • Administrator
  • Hero Member
  • *****
  • Posts: 1999
  • Karma: 61
    • View Profile
    • Getting Started with VoxCommando
Re: Nest Thermostat and Nest Protect - Command Collection
« Reply #12 on: August 15, 2015, 08:43:23 AM »
@Paul

Please replace the 'thermostat payload generator' command with the version below and let us know whether this is working correctly for you.

Code: [Select]
<?xml version="1.0" encoding="utf-16"?>
<!--VoxCommando 2.2.0.7-->
<command id="1224" name="thermostat payload generator" enabled="true" alwaysOn="False" confirm="False" requiredConfidence="0" loop="False" loopDelay="0" loopMax="0" description="">
  <action>
    <cmdType>PayloadXML.GetPhrase</cmdType>
    <params>
      <param>Nest\thermoList.xml</param>
      <param>{1}</param>
    </params>
    <cmdRepeat>1</cmdRepeat>
  </action>
  <if ifBlockDisabled="False" ifNot="False">
    <ifType>LastActionSuccess</ifType>
    <ifParams>&amp;&amp;</ifParams>
    <then>
      <action>
        <cmdType>VC.StopMacro</cmdType>
        <params />
        <cmdRepeat>1</cmdRepeat>
      </action>
    </then>
    <else>
      <action>
        <cmdType>File.Read</cmdType>
        <params>
          <param>Nest\Nest_dev_status.txt</param>
        </params>
        <cmdRepeat>1</cmdRepeat>
      </action>
      <action>
        <cmdType>Results.RegEx</cmdType>
        <params>
          <param>},"shared.*?"{1}".*?"name":"(.*?)"</param>
        </params>
        <cmdRepeat>1</cmdRepeat>
      </action>
      <action>
        <cmdType>PayloadXML.AddPair</cmdType>
        <params>
          <param>Nest\thermoList.xml</param>
          <param>{1}</param>
          <param>{Match.1}</param>
        </params>
        <cmdRepeat>1</cmdRepeat>
      </action>
    </else>
  </if>
  <event>devLabelTherm</event>
</command>

Thanks for the alert about the change to Nest. It's hard to keep everything up-to-date when you don't use those programs or devices.

I will update the full collection in the first post as well.
TIPS: POST VC VERSION #. Explain what you want VC to do. Say what you've tried & what happened, or post a video demo. Attach VC log. Link to instructions followed.  Post your command (xml)

MrWolf

  • $upporter
  • Sr. Member
  • *****
  • Posts: 209
  • Karma: 4
    • View Profile
Re: Nest Thermostat and Nest Protect - Command Collection
« Reply #13 on: August 16, 2015, 04:28:27 PM »
You guys are the best.

I'll give it a go tomorrow and let you know.

Xxx
Home automation guides for idiots like me by an idiot (me)...
https://www.youtube.com/user/wolfsweb

MrWolf

  • $upporter
  • Sr. Member
  • *****
  • Posts: 209
  • Karma: 4
    • View Profile
Re: Nest Thermostat and Nest Protect - Command Collection
« Reply #14 on: August 17, 2015, 11:51:38 AM »
Yep, nailed it.  Thanks guys!

xxx
Home automation guides for idiots like me by an idiot (me)...
https://www.youtube.com/user/wolfsweb