Help creating template sensors from multiple HVAC attributes

Hey folks, having an issue converting some attributes from my AC into sensors. I’ve got a few working but the main setting (hvac_modes) that shows whether the AC is cooling or off etc is causing me issues.

Here’s what I have so far:

template:
  - sensor:
      - name: Edwin's Office AC Fan Mode
        state: "{{ state_attr('climate.edwin_s_office', 'fan_mode') }}"
      - name: Edwin's Office AC Swing Mode
        state: "{{ state_attr('climate.edwin_s_office', 'swing_mode') }}"
      - name: Edwin's Office AC Current Temperature
        state: "{{ state_attr('climate.edwin_s_office', 'current_temperature') }}"
      - name: Edwin's Office AC Cool Mode
        state: "{{ state_attr('climate.edwin_s_office', 'hvacmode.cool') }}"
      - name: Edwin's Office AC HVAC Mode
        state: "{{ state_attr('climate.edwin_s_office') }}"

The first three return their correct states as sensors, the last two were my attempts to show hvac_modes as a sensor. As you can see, it’s currently showing as ‘off’ on this page.

I’ve checked for states and this is what it’s returning:

Ultimately, trying to set an automation to look for a change in sensor state in order to turn off a timer and some other things. I’ve looked around and other solutions seemed to be using an older format of value templates that I don’t think would work here.

Total beginner (and not a coder) here, help is much appreciated :slight_smile:

This one won’t work as there is no such attribute.

The last one isn’t really required.

      - name: Edwin's Office AC HVAC Mode
        state: "{{ state_attr('climate.edwin_s_office') }}"

You want the state, not a state attribute but you already can get that with the climate entity…

If you really want a separate sensor, this should work:

      - name: Edwin's Office AC HVAC Mode
        state: "{{ states('climate.edwin_s_office') }}"
1 Like

THANK YOU! That’s perfect. Didn’t realise you could do just ‘states’ there.