IF....THEN.... possible?

Hello, can i add here a if-then query?

- alias: Pool_Chlor_5s_On
  trigger:
  - entity_id: switch.buero_ralf_stehlampe02
    platform: state
    to: 'on'
  - condition: numeric_state
    entity_id: sensor.wf_192_168_1_156_orp
    above: 700
    below: 720
  action:
  - data:
      entity_id: switch.pool_dosierung_chlor
    service: switch.turn_on
  - entity_id: timer.timer_5s
    service: timer.start

- alias: Pool_Chlor_5s_Off
  trigger:
  - event_data:
      entity_id: timer.timer_5s
    event_type: timer.finished
    platform: event
  action:
  - alias: ''
    entity_id: switch.pool_dosierung_chlor
    service: switch.turn_off

switch starts for 5s if the value is between 700 and 720

i want

if value 0 - 500
then timer = 30s

500 - 600
timer = 20s

600 - 700
timer = 10s

700 - 720
timer = 5s

720
timer = 0 / off

Also, you are missing the condition header in the first automation.

Trigger will be the state change of the value.

You may set if-then action based off the value. This is option in automation UI

I would use something like:

alias: Pool_Chlor_5s_On
trigger:
  - entity_id: switch.buero_ralf_stehlampe02
    platform: state
    to: "on"
actionp:
  - choose:
      - conditions: numeric_state
        entity_id: sensor.wf_192_168_1_156_orp
        above: 700
        below: 720
        sequence:
          - service: switch.turn_on
            data:
              entity_id: switch.pool_dosierung_chlor
          - delay:
              hours: 0
              minutes: 0
              seconds: 5
              milliseconds: 0
          - service: switch.turn_off
            data:
              entity_id: switch.pool_dosierung_chlor
      - conditions: numeric_state
        entity_id: sensor.wf_192_168_1_156_orp
        above: 600
        below: 700
        sequence:
          - service: switch.turn_on
            data:
              entity_id: switch.pool_dosierung_chlor
          - delay:
              hours: 0
              minutes: 0
              seconds: 10
              milliseconds: 0
          - service: switch.turn_off
            data:
              entity_id: switch.pool_dosierung_chlor
      - conditions: numeric_state
        entity_id: sensor.wf_192_168_1_156_orp
        above: 500
        below: 600
        sequence:
          - service: switch.turn_on
            data:
              entity_id: switch.pool_dosierung_chlor
          - delay:
              hours: 0
              minutes: 0
              seconds: 20
              milliseconds: 0
          - service: switch.turn_off
            data:
              entity_id: switch.pool_dosierung_chlor
etcetc

I probably haven’t got all parameters right, but hope you understood the general concept :wink:

guess you could shorten it a little bit by introducing a variable, but there is no real need for that :smiley: