How to change window sensor state from on/off to open/closed

Hello,

I´m new to HA an try to make my config a little smarter for me. So I have problems to understand all the code stuff an think you can help me faster.

My question:

How can I change the output state from on/off to open/Closed. Also wan´t to change the windows icon of the sensor to open/closed and colour at open window icon…


type: custom:simple-thermostat
entity: climate.wohnzimmer
version: 3
step_size: 0.5
decimals: 1
sensors:
  - entity: climate.wohnzimmer
    id: state
    label: '{{"mdi:power-settings"|icon}}'
    template: >-
      {{hvac_action|translate('state_attributes.climate.hvac_action.')}}
      ({{state.text}})
  - entity: sensor.wohnzimmer_temperature
    id: temperature
    label: '{{"mdi:thermometer"|icon}}'
    template: '{{state.text|formatNumber}} {{unit_of_measurement}}'
  - entity: sensor.wohnzimmer_humidity
    label: '{{"mdi:water-percent"|icon}}'
    template: '{{state.text}} %'
  - entity: binary_sensor.lumi_lumi_sensor_magnet_e07a3105_on_off
    label: '{{"mdi:window-open"|icon}}'
    template: '{{state.text}}'
layout:
  step: row
  mode:
    names: true
    headings: false
    icons: true
control:
  hvac: true

Thanks for your help.

The actual state is only ever on/off, that’s the way it works.

You can set the device class of the entity to a window sensor, which will then mean that (by default) it’ll show as open/closed in the UI and with an icon that changes state.

Where an how?

The docs I linked to link to the instructions on customizing

Can you give me an example? Don´t now how. Thanks

Exactly as shown in the docs, use the cog:

sensor

That was already configured. But didn´t work

  - entity: binary_sensor.lumi_lumi_sensor_magnet_e07a3105_on_off
    label: '{{"mdi:window-open"|icon}}'
    template: '{{state.text}}'
    device_class: window

This also didn´t work.

Did you have a hint or solution for me?

Try next template to change on/off in open/close

template:
  - sensor:
      - name: "Window State"
        state: >
          {% if is_state('binary_sensor.lumi_lumi_sensor_magnet_e07a3105_on_off', 'on') %}
            open
          {% else %}
            close
          {% endif %}

The actual state is only ever on/off, that’s the way it works.

You can set the device class of the entity to a window sensor, which will then mean that (by default) it’ll show as open/closed in the UI and with an icon that changes state.

None of this changes the actual state, just what cards that support translations will show.

A template sensor, to wrap the entity, is the only way to “change” the actual state.