Turn on bedside lamp if lightswitch (quickly) toggled on/off within 2 seconds

Hello, trying to get a bedside lamp to turn on by quickly switching my shelly light switch on then off within two seconds. I’m sure I’m very close but here is my YAML file… if anyone could advise what I’ve got wrong here that’d be excellent.

`
alias: Light switch lamp turn on
description: “”
trigger:

  • platform: device
    type: turned_on
    device_id: ec014c49ff8b4eed11870259575539622
    entity_id: switch.master_bedroom_light
    domain: switch
    for:
    hours: 0
    minutes: 0
    seconds: “<2”
    condition: []
    action:
  • type: turn_on
    device_id: 63d655a6de649dc40dc2a486d1ce1499
    entity_id: switch.smartplug2
    domain: switch
    mode: single
    `

Please remember to use the code block when posting yaml.

You need a wait for trigger to wait for the light to go off.

description: ""
mode: single
trigger:
  - platform: state
    entity_id:
      - switch.master_bedroom_light
    to: "on"
condition: []
action:
  - wait_for_trigger:
      - platform: state
        entity_id:
          - switch.master_bedroom_light
        to: "off"
        from: "on"
    timeout:
      hours: 0
      minutes: 0
      seconds: 2
      milliseconds: 0
    continue_on_timeout: false
  - service: switch.turn_on
    data: {}
    target:
      entity_id: switch.smartplug2

that did it! thanks @Hellis81 (and yes, will use code from from hereon; still getting hang of this and coding in general!)

I’ve now just realised the physical light switch doesn’t link with the shelly toggle within it (so only works within HA rather than flicking actial light switch), so now I need to find a way to find it recognise the physical switch

So the plugs light doesn’t come on?
That must be a bug in the device firmware.
I don’t have any shelly plugs so I can’t help with this.

Yes, the lamp came on when I quickly turned on and off my Shelly switch via my HA interface (so the code works as it should) however I need it to recognise the physical switch on/off I do at the switch, in HA rather than the on/off button toggle I use via HA dashboard. I’ll need to investigate this bit separately. Thanks again for help with code :grinning: