How check if aircon is on / off?

I would like to have a toggle (helper) on/off depending if my aircon is on or off.

Here is what I allready have, but of course it’s not working (something to change in the trigger probably) :wink:

alias: Airco gang in werking
description: ''
trigger:
  - platform: state
    entity_id: climate.airco_gang
    id: hvac_modes
condition: []
action:
  - choose:
      - conditions:
          - condition: device
            device_id: 67455609e3c9d29e44adb86b16e0e855
            domain: climate
            entity_id: climate.airco_gang
            type: is_hvac_mode
            hvac_mode: 'off'
        sequence:
          - service: input_boolean.turn_off
            target:
              entity_id: input_boolean.toggle_airco_gang_in_werking
    default:
      - service: input_boolean.turn_on
mode: single

Found it : template sensor :upside_down_face:

Template binary sensor would be better suited for an on/off state.

That’s how I did it :

template:
  - sensor:
      - name: "airco_gang_hvac_modes"
        icon: "mdi:fan"
        state: "{{ states('climate.airco_gang')}}"
      - name: "airco_gang_is_on_or_off"
        icon: "mdi:fan"
        state: >
          {% if is_state('climate.airco_gang', 'off') %}
            off
          {% else %}
            on
          {% endif %}

How should you do it ?

Like this:

template:
  - sensor:
      - name: "airco_gang_hvac_modes"
        icon: "mdi:fan"
        state: "{{ states('climate.airco_gang') }}" # this seems like pointless duplication?
  - binary_sensor:
      - name: "airco_gang_is_on_or_off" # FYI you can use spaces and capital letters in names and friendly_names
        icon: "mdi:fan"
        state: "{{ not is_state('climate.airco_gang', 'off') }}" 

Not sure why you have that first sensor, unless you wanted to display the climate state without people being able to change it.

Thank you Tom, a lot shorter ! :+1: