cancel
Showing results for 
Search instead for 
Did you mean: 

Scripting Help - Turn Eco Mode Off

timb0slice7
Community Member

Hello everyone,

I'm attempting to make my own set of Home/Away routines that can be interrupted in case we have a babysitter or guest staying over (so that all our lights and the heating/cooling doesn't shut off on them if we leave). I currently have the following Away Routine which works perfectly:

metadata:
  name: 1 Away Mode
  description: Turn off all the lights when we are away, except when Guest Mode "plug" is activated

automations:
  starters:
    - type: home.state.HomePresence
      state: homePresenceMode
      is: AWAY

  condition:
    type: device.state.OnOff
    state: on
    is: false
    device: Guest Mode - Guest

  actions:
    - type: assistant.command.OkGoogle
      okGoogle: Turn off all the lights
      devices: Family Room Audio - Family Room
    - type: device.command.OnOff # Turn the device on or off.
      on: true
      devices: Front Door Cam Plug - Kitchen
    - type: device.command.ThermostatSetMode # Set the target operating mode for a thermostat device.
      thermostatMode: eco
      devices: Thermostat - Dining Room

Where I am struggling is with the Home routine:

metadata:
  name: 1 Home Mode
  description: Turn the thermostat back on when returning home

automations:
  starters:
    - type: home.state.HomePresence
      state: homePresenceMode
      is: HOME

  actions:
    - type: device.command.ThermostatSetMode # Set the target operating mode for a thermostat device.
      thermostatMode: on
      devices: Thermostat - Dining Room

 

Right now the options for thermostatMode are on, off, eco, heat, cool, and heatcool. "eco" turns on eco mode, but there is no way to turn eco mode off. You have to specify heat, cool, or heatcool. On only turns the thermostat back on if it is off.

 

Right now, I'm just trying to remember that as we change modes, we need to manually update the script to match. But is there a way to just turn off eco mode, or remember the previous mode from the Away routine and reapply it to the Home routine?

1 Recommended Answer

timb0slice7
Community Member

For anyone else who has this issue. I was able to resolve it with the help of Samsung SmartThings. Since Google Home doesn't have the ability to store global variables, I use virtual switches. I made three switches modeheat, modecool, modeheatcool (named so that someone doesn't accidentally ask to turn on heat mode and activate them outside of the thermostat and they get out of sync).  I then made three rules in Samsung SmartThings that if one switch turns on, the others turn off.

 

Once SmartThings was setup, I had to make a couple of new scripts to sync everything:

 

#1 Three routines for syncing the switches to the thermostat state:

metadata:
  name: z Sync Thermostat Cool
  description: Whenever the thermostat changes modes, turn on the correct virtual switch

automations:
  starters:
    - type: device.state.TemperatureSetting
      state: thermostatMode
      is: cool
      device: Thermostat - Dining Room

  actions:
    - type: device.command.OnOff
      on: true
      devices: modecool - zAutomations

 

#2 A routine to turn off all switches if the thermostat is set to OFF

metadata:
  name: z Sync Thermostat Off
  description: Whenever the thermostat changes modes, turn on the correct virtual switch

automations:

  starters:
    - type: device.state.TemperatureSetting
      state: thermostatMode
      is: off
      device: Thermostat - Dining Room

  actions:
    - type: device.command.OnOff
      on: false
      devices: modeheat - zAutomations
    - type: device.command.OnOff
      on: false
      devices: modeheatcool - zAutomations
    - type: device.command.OnOff
      on: false
      devices: modecool - zAutomations

 

#3 Edit the Custom Home Routine to set the thermostat to the correct mode

metadata:
  name: 1 Home Mode
  description: When coming home, reactivate the thermostat and set it to the previous mode

automations:
  - starters:
      - type: home.state.HomePresence
        state: homePresenceMode
        is: HOME
    condition:
      type: device.state.OnOff
      device: modecool - zAutomations
      state: on
      is: true
    actions:
      - type: device.command.ThermostatSetMode
        devices: Thermostat - Dining Room
        thermostatMode: cool

  - starters:
      - type: home.state.HomePresence
        state: homePresenceMode
        is: HOME
    condition:
      type: device.state.OnOff
      device: modeheat - zAutomations
      state: on
      is: true
    actions:
      - type: device.command.ThermostatSetMode
        devices: Thermostat - Dining Room
        thermostatMode: heat

  - starters:
      - type: home.state.HomePresence
        state: homePresenceMode
        is: HOME
    condition:
      type: device.state.OnOff
      device: modeheatcool - zAutomations
      state: on
      is: true
    actions:
      - type: device.command.ThermostatSetMode
        devices: Thermostat - Dining Room
        thermostatMode: heatcool

 

Hopefully this helps someone else who has the same situation as me!

View Recommended Answer in original post

2 REPLIES 2

timb0slice7
Community Member

For anyone else who has this issue. I was able to resolve it with the help of Samsung SmartThings. Since Google Home doesn't have the ability to store global variables, I use virtual switches. I made three switches modeheat, modecool, modeheatcool (named so that someone doesn't accidentally ask to turn on heat mode and activate them outside of the thermostat and they get out of sync).  I then made three rules in Samsung SmartThings that if one switch turns on, the others turn off.

 

Once SmartThings was setup, I had to make a couple of new scripts to sync everything:

 

#1 Three routines for syncing the switches to the thermostat state:

metadata:
  name: z Sync Thermostat Cool
  description: Whenever the thermostat changes modes, turn on the correct virtual switch

automations:
  starters:
    - type: device.state.TemperatureSetting
      state: thermostatMode
      is: cool
      device: Thermostat - Dining Room

  actions:
    - type: device.command.OnOff
      on: true
      devices: modecool - zAutomations

 

#2 A routine to turn off all switches if the thermostat is set to OFF

metadata:
  name: z Sync Thermostat Off
  description: Whenever the thermostat changes modes, turn on the correct virtual switch

automations:

  starters:
    - type: device.state.TemperatureSetting
      state: thermostatMode
      is: off
      device: Thermostat - Dining Room

  actions:
    - type: device.command.OnOff
      on: false
      devices: modeheat - zAutomations
    - type: device.command.OnOff
      on: false
      devices: modeheatcool - zAutomations
    - type: device.command.OnOff
      on: false
      devices: modecool - zAutomations

 

#3 Edit the Custom Home Routine to set the thermostat to the correct mode

metadata:
  name: 1 Home Mode
  description: When coming home, reactivate the thermostat and set it to the previous mode

automations:
  - starters:
      - type: home.state.HomePresence
        state: homePresenceMode
        is: HOME
    condition:
      type: device.state.OnOff
      device: modecool - zAutomations
      state: on
      is: true
    actions:
      - type: device.command.ThermostatSetMode
        devices: Thermostat - Dining Room
        thermostatMode: cool

  - starters:
      - type: home.state.HomePresence
        state: homePresenceMode
        is: HOME
    condition:
      type: device.state.OnOff
      device: modeheat - zAutomations
      state: on
      is: true
    actions:
      - type: device.command.ThermostatSetMode
        devices: Thermostat - Dining Room
        thermostatMode: heat

  - starters:
      - type: home.state.HomePresence
        state: homePresenceMode
        is: HOME
    condition:
      type: device.state.OnOff
      device: modeheatcool - zAutomations
      state: on
      is: true
    actions:
      - type: device.command.ThermostatSetMode
        devices: Thermostat - Dining Room
        thermostatMode: heatcool

 

Hopefully this helps someone else who has the same situation as me!

timb0slice7
Community Member

One additional item, I had to change the name of the "Guest Mode" switch to "Away Mode". Apparently, there is a new guest mode for Nest Speakers that disables saving your history (and it terribly difficult to disable once it's been enabled!) With the new name, I had to switch the logic. "Away Mode" ON means do everything normally. "Away Mode" OFF means don't turn off all the lights on the babysitter.