Set binary sensor value to 'off' if unknown value

I use a number of binary sensors to trigger automations for ventilation. These are comparing values from different sensors. Sometimes I experience issues with Netatmo, resulting in unknown sensorvalues in Home Assistant. When this happens my binary sensors goes to β€œon” and triggers automations while this is not necessarely.

The binary sensor codes looks like this:

bathroom1_humidity_high:
  friendly_name: "Bathroom 1 high RH"
  icon_template: mdi:water-percent
  value_template: "{{ states('sensor.bathroom1_multisensor_6_relative_humidity') |int - states('sensor.netatmo_inside_humidity') |int > states('input_number.max_rh') |int }}"

Is it possible to define that the binary sensor should be set to β€œoff” if for example Netatmo fails, and the values there is unknown?

I asked the same question tonight. Try this:

1 Like

That did the job, thanks!