Script help with if else type logic

I’m very new to HA, less than a week.
Till now I have installed HA and Node-red(node red can’t communicate with HA yet).
I wanted to create a simple script in HA which then I’m planning to call from Automations.
Logic is simple if else. If one dimmer switch is on, do this otherwise do this.

scripttest:
  alias: scriptTest
  sequence:
  - condition: device
    type: is_off
    device_id: f9562e6ce45ff4a104fbc7166e6a8eef
    entity_id: light.sec_dimmer
    domain: light
  - type: turn_off
    device_id: 10fed43cb2bd874f602de2e0b76ad8f3
    entity_id: light.bedroom_light
    domain: light
  - condition: device
    type: is_on
    device_id: f9562e6ce45ff4a104fbc7166e6a8eef
    entity_id: light.sec_dimmer
    domain: light
  - type: turn_on
    device_id: 10fed43cb2bd874f602de2e0b76ad8f3
    entity_id: light.bedroom_light
    domain: light
    brightness_pct: 50
  mode: queued
  max: 10

Its not working, when my sec_dimmer is on and I manually execute this scrip it should turn on the bedroom light( or so I think).

Can anyone help me?

Hemanshu

You’ve misunderstood the logic of conditions in scripts.

Your first condition is that light.sec_dimmer is off. So if it is on the script will not proceed any further.

Please refer to the documentation for script syntax.

Thank You @anon43302295.
I am not finding much information about conditional logic where there are multiple conditions. I created this using UI and I don’t see anything there which allows if/else type in logic.

All I want is simple.
If light A is on, turn on OtherLight A
else if Light A is off, turn off OtherLight A

Hemanshu

" Unlike a trigger, which is always or , conditions are and by default - all conditions have to be true."

So, it looks like I can’t use conditions to implement if/else type logic.

OK, well - setting a light’s brightness to zero with the turn on service turns it off, so your entire script can be replaced with this…

scripttest:
  alias: scriptTest
  sequence:
    - service: light.turn_on
      data:
        entity_id: light.bedroom_light
        brightness_pct: "{{ 50 if is_state('light.sec_dimmer', 'on') else 0 }}"

But me writing this hasn’t really taught you anything, you need to spend some more time with the documentation because it is definitely all there.