[SOLVED] Nest thermostat status home/away

I’m really sorry I don’t see why it’s not working.

I’m kind of new at this myself.

As far as I can tell everything should be formatted properly with the info you gave here.

try posting what you have as your template sensor maybe there is something weird there with the syntax.

Don’t worry, i’m new at it too.

I’ve been wrecking my brain over this and figured it out partially.

If you add the template sensor to your config with this:

{{ states.climate.downstairs.attributes.away_mode }}

The sensor shows up in States with the name sensor.away_mode. If you then run this in Templates:

{% if is_state('sensor.away_mode', 'off') %}
  Home
{% else %}
  Away
{% endif %}

It gives the expected feedback. Now i just need to figure out how to put this in my config because i think i need both. One to create the sensor and one to rename…

try some variation of the following:

{% if states.climate.downstairs.attributes.away_mode %}
  {% if is_state('sensor.away_mode', 'off') %}
    Home
  {% else %}
    Away
  {% endif %}
{% else %}
  unknown
{% endif %}

I’m not sure of the exact syntax that you would need tho. try it and see what happens

1 Like

FWIW, I use a template binary sensor to store the away mode to have it more in line with the underlying boolean value:

binary_sensor:
  - platform: template
    sensors:
      downstairs_thermostat_away_mode:
        friendly_name: "Downstairs Thermostat Away Mode"
        value_template: "{{ is_state_attr('climate.downstairs', 'away_mode', 'off') }}"

Another option instead of creating another sensor or storing the mode as Home/Away is to use custom UI to just change the frontend while leaving the sensor as a binary sensor. You can use a template attribute to change the way the binary sensor for away mode is shown in the UI:

homeassistant:
  customize:
    binary_sensor.downstairs_thermostat_away_mode:
      templates:
        _stateDisplay: if (state === 'off') return 'Home'; else return 'Away';

Binary sensor works as wel as the sensor. Still can’t get the home / away part working though.

Tried the customization, but it returns ‘off’ (instead of home).

image

Have you tried the template I posted above to see if it works yet?

You’ll need to install and activate andrey-git’s custom UI for that customization to work. I haven’t used a template attribute for it yet so I can’t tell you much more beyond that.

Yeah i did, i’m just fiddling to get it working in my config. I’ll keep you posted :slight_smile:

So far no luck. If i run it on templates in the webUI it gives the right state, but when i add it to the config it gives the wrong state… :frowning:

Almost there but not quite.

# Nest away sensor
  - platform: template
    sensors:
      away_mode:
        friendly_name: "Away mode sensor"
        value_template: "{% if states.climate.downstairs.attributes.away_mode %}
  {% if is_state('sensor.away_mode', 'off') %}
    Thuis
  {% else %}
    Weg
  {% endif %}
{% else %}
  unknown
{% endif %}"

check your syntax and indentations.

If you are using it the way it is posted above, it won’t work.

Using the custom UI works fine for me:
image

I did tweak my comment above a bit. Instead of setting state, I set _stateDisplay.

If you really want to do it in the sensors, you can just use a single template sensor:

- platform: template
  sensors:
    dining_room_thermostat_away_mode:
      value_template: >
        {% if is_state_attr('climate.dining_room', 'away_mode', 'off') %}
          Home
        {% else %}
          Away
        {% endif %}
1 Like

Thank you so much. This works!

# Nest away sensor
  - platform: template
    sensors:
      away_mode:
        friendly_name: "Thuis of weg"
        value_template: >
          {% if is_state_attr('climate.downstairs', 'away_mode', 'off') %}
            Thuis
          {% else %}
            Weg
          {% endif %}

What is the benefit of using the custom UI?

I just like having the sensor as a binary sensor so I can use it in automations as a boolean. I use Node-RED for automations and there’s cases where it’s just nice to have in boolean form. Then it’s just one less sensor that needs to be defined simply to display properly (separation of backend vs frontend responsibilities). The boolean sensor will also highlight the icon when it’s considered ‘on’, that may or may not be what you want.

If you really get into custom UI, you could probably get it to show the away mode on the climate entity’s card itself rather than needing a separate state card for it. That’s ultimately how I’d like to do it but I haven’t gotten around to it yet. For example, something like these would be nice, but they currently don’t work for climate.

If you don’t care about any of that, I don’t really know of any problem with just using the template sensor like that.

That slider is cool!

But i’m afraid it would cause me a lot of headache trying to set it up. I couldn’t even figure out this template :smiley:

I’m trying to keep it simple for now, get everything to work the way i like and leave the fine tuning for later (when i get the hang of it).

But thanks a lot for your help!

Hi tboyce1,
How did you get to this : put the humidit and away mode into climate card? Thanks.

They’re just three separate entities in a group: climate, humidity sensor (from Nest component), and a template sensor for the away_mode attribute of climate.

Like this:

  nest_thermostat:
    name: Thermostat
    view: no
    entities:
      - climate.downstairs
      - sensor.downstairs_thermostat_humidity
      - sensor.downstairs_thermostat_operation_mode
      - sensor.downstairs_thermostat_target
      - sensor.downstairs_thermostat_temperature
      - sensor.away_mode

@ tboyce1, Marie11e, Oh, yes, thank you very much!

Is any one else unable to change the the desired temp with the Nest controls?
The number changes bit it does not change the thermostat.