Or condition not work

Hello,

I would like to atomize a fan whose speed should be increased when one of two conditions is met.

Either the temperature is via a set value of a helper entity

         entity_id: sensor.temperatur_am_kronendach
        above: input_number.max_temperatur_nacht

or
the sensor-humidity is above that of a set helper-max-humidity-entity

         entity_id: sensor.luftfeuchtigkeit
        above: input_number.max_luftfeuchtigkeit_nacht

it is like that,
that if only the first condition is not met, the entire script will probably no longer be processed.
Although the second condition is fulfilled, he probably won’t get to this point at all

Does anyone see the error?

alias: EC-Luefter_AirControler_Nacht_SpeedUp
description: ""
trigger:
  - platform: time_pattern
    minutes: /5
condition:
  - condition: numeric_state
    entity_id: sensor.led_lichtstarke_in_lux_am_kronendach
    below: 50
  - condition: or
    conditions:
      - condition: numeric_state
        entity_id: sensor.temperatur_am_kronendach
        above: input_number.max_temperatur_nacht
  - condition: or
    conditions:
      - condition: numeric_state
        entity_id: sensor.luftfeuchtigkeit
        above: input_number.max_luftfeuchtigkeit_nacht
action:
  - service: fan.increase_speed
    metadata: {}
    data:
      percentage_step: 10
    target:
      entity_id: fan.dimm_lti_ec_lufter_abluft
  - service: fan.turn_on
    metadata: {}
    data: {}
    target:
      entity_id: fan.dimm_abluft_bigbox
  - service: fan.set_percentage
    metadata: {}
    data:
      percentage: 75
    target:
      entity_id: fan.dimm_abluft_bigbox
mode: single

All conditions that are being “or”-ed need to be nested under the same Or…

condition:
  - condition: numeric_state
    entity_id: sensor.led_lichtstarke_in_lux_am_kronendach
    below: 50
  - condition: or
    conditions:
      - condition: numeric_state
        entity_id: sensor.temperatur_am_kronendach
        above: input_number.max_temperatur_nacht
      - condition: numeric_state
        entity_id: sensor.luftfeuchtigkeit
        above: input_number.max_luftfeuchtigkeit_nacht

looks like exactly that what you wrote…
if i change the code directly in the yaml-file looksokay…
but i think to use the visual editor is a little tricky…

No, mine only has 1 Or condition, with 2 Numeric State conditions nested underneath it. The original you posted has 2 Or conditions, each with only 1 Numeric State.

You just have to click the correct “+ Add Condition”:

Clicking the one inside the box of the Or condition makes it one of the “or”-ed tests, clicking outside the box of the Or condition creates a new box because it is a completely different condition not related to the Or.

Also, take a look at the alias/descriptions of the Or conditions. The default alias states how many conditions are being “or”-ed.

your code and @Didgeridrew’s is not the same… i’m sure he’ll explain. but i wanted to respond to i think to use the visual editor is a little tricky

if you don’t want to use the visual editor to write the code, you should still write the code inside the ui’s yaml editor.

image

if you really want to write raw yaml, do it in that mode. then after you write it but before you run it, switch it to visual editor mode and see if it reads like you expect… home assistant will check a bunch of things about your code, and will barf at a bunch of mistakes… catching a bunch of issues.

it would have highlighted the “or” issue you had in your code.

Thats also a good idea… i try that and see something was wrong

The last screenshoots …
is that so
thats works only if the first condition If with 2 matches (one of this have to be true) are true and the second condition have also to be true

right?

Yes, though my main point was to show how the conditions are separated visually and that the auto-generated aliases for the condition building blocks will tell you how many conditions they are affecting. There is no good reason to have an Or condition with only 1 option.

An Or condition that only has 1 option is essentially the same as not having the Or. This was the flaw of the original post. Because they weren’t in the same Or, neither of those Or’s was doing anything…

The following are functionally equivalent
#1: from the original post:
  - condition: or
    conditions:
      - condition: numeric_state
        entity_id: sensor.temperatur_am_kronendach
        above: input_number.max_temperatur_nacht
  - condition: or
    conditions:
      - condition: numeric_state
        entity_id: sensor.luftfeuchtigkeit
        above: input_number.max_luftfeuchtigkeit_nacht


2:
  - condition: numeric_state
    entity_id: sensor.temperatur_am_kronendach
    above: input_number.max_temperatur_nacht
  - condition: numeric_state
    entity_id: sensor.luftfeuchtigkeit
    above: input_number.max_luftfeuchtigkeit_nacht

what uses what its very new for me to can see all clear
If I use If, ​​then, else and further nest the else statement with further If queries, I can see this pretty quickly. At least it’s easier… I still have to get used to the conditions and instructions