Help Turning Nest auto_awary into an occupancy sensor

I want to turn the nest auto_away status into a occupancy sensor but I am having no luck… When home the auto_away state should be off as per the attributes so I want to invert that when making an occupancy sensor.

{
  "away_mode": "off",
  "current_temperature": 22.4,
  "friendly_name": "Thermostat Main",
  "max_temp": 35,
  "min_temp": 17.1,
  "operation_list": [
    "off",
    "heat"
  ],
  "operation_mode": "heat",
  "temperature": 21.7,
  "unit_of_measurement": "°C"
}

So I created a binary sensor template, however instead of showing on it always shows off…

  - platform: template
    sensors:
      nest_main_floor_home_away:
        value_template: "{% if states.climate.main_floor.away_mode.state == 'off' %}on{% else %}off{% endif %}"
        sensor_class: occupancy

Figured it out:

value_template: “{{ is_state_attr(‘climate.main_floor’, ‘away_mode’, ‘off’) }}”

1 Like