Correct IF & OR statement script

HI All,

Please confirm if this is the correct format for IF & OR statement automation, I basically want to execute the following;
At 11:00 If the select.victron_vebus_mode_227 is INVERTER AND the battery SOC is above 30% switch on Geyser.
If the battery SOC is below 30% and the mode is INVERTER, do not switch on the geyser.
If the select.victron_vebus_mode_227 is ON, switch on the geyser regardless of the battery SOC.


alias: Geyser -> Auto ON
description: ""
trigger:
  - platform: time
    at: "11:00:00"
condition:
  - condition: or
    conditions:
      - condition: state
        entity_id: select.victron_vebus_mode_227
        state: INVERTER
      - condition: and
        conditions:
          - condition: numeric_state
            entity_id: sensor.victron_battery_soc
            above: 30
      - condition: or
        conditions:
          - condition: state
            entity_id: select.victron_vebus_mode_227
            state: "ON"
action:
  - service: switch.turn_on
    target:
      entity_id: switch.sonoff_10021f7cbd
    data: {}
mode: single

No, that’s not right. I think you want this (with the or and and shorthand):

condition:
  - or:
    - and:
      - condition: state
        entity_id: select.victron_vebus_mode_227
        state: INVERTER
      - condition: numeric_state
        entity_id: sensor.victron_battery_soc
        above: 30
    - condition: state
      entity_id: select.victron_vebus_mode_227
      state: "ON"

Your version is a three-way or:

  • victron is INVERTER
  • SOC above 30 (as a one-element and)
  • victron is ON (as a one-element or)

You need to re-order your “thinking words”:

I want it to trigger at 11:00 if one or the other of these is true:

  • victron is INVERTER and SOC is above 30
  • victron is ON

You can build it with the UI. Looks like this for me, riddled with errors as I don’t have your entities:

Thank you so much, it is working fine!