Toggle light switch

I have a motion light in my backyard and I want to have them stay on from dusk to dawn.

If I manually turn the z-wave switch for this light off and then back on (within 2 seconds), the lights change from motion operation to dusk to dawn operation.

Is there a way to do this action in a single automation rule, or do I need to create a script? My hesitance in using scripts is that I want to migrate to a docker setup and I’m not sure if I can do scripts in dockers.

Thank you in advance for your ideas.

the docker is just the virtual environment that the HA OS will run in.
Automations and scripts don’t care.
In fact you should do a snapshot of your system before you change so you can start from where you left off.
Why do you want motion activation during the day ?
And Why not just have them on motion activation ALL night ?
You can use the sunrise and sunset triggers for those time elements then use a delay for a 1 sec delay between turning off and then back on again.
Define what and when you want it and we’ll have a go

I’m assuming Sunset - on - 2 secs - off - one sec - on
Sunrise - off

Is that it ?

What is your entity id ?
Do you have sun.sun as a component ?

Hello Muttley,

I have a binary_sensor called low light level that I use to trigger turning on other lights around my house. I think I just add a delay to the actions section of my automation between the turn on and turn off commands?

Does this look correct?

  action:
    - service: homeassistant.turn_off
      entity_id: 
        - switch.ge_12722_on_off_relay_switch_switch
    - delay:
        seconds: 50
    - service: homeassistant.turn_on
      entity_id: 
        - switch.ge_12722_on_off_relay_switch_switch

Thanks again for your help,
John

You can try using the example you posted with a delay of 1 second. Theoretically, it should simulate the manual operation you described (turn off/on within 2 seconds).

In practice, you may (and I stress “may”) encounter the issue of propagation delays in the z-wave network (i.e. the time it takes to transmit a command to the device and for the device to reply with an acknowledgement … especially if many other commands were recently transmitted). It probably won’t happen but it’s good to be aware that there’s a slight chance of it.

He would only hit a problem if his communication propagation delay was > tha 1 sec. Say 1.2 to 1.8 secs
He could then try removing the delay, the actions would queue in the z-wave controller and go out say 1.2 to 1.8 secs apart.???
Dunno, I’m guessing.

Think about what happens if there’s a lot of traffic and so the queue has several commands waiting for their turn. That’s when the need to ensure the second command is received within 2 seconds of the first one might be jeopardized. My rule of thumb is to avoid expecting any lighting technology to provide sub-second responsiveness under all loading conditions. Therefore if I needed to perform a timing-critical operation, I would not expect 100% reliability when the required time-interval is close to 1 second.

I would agree, I’m just hoping there’s a ‘get out of jail card’ else he’ll have to go via MQTT with a iot device (or similar).
Worst case a second switch operating a timer relay 1 sec, though the wiring may be interesting (Chinese curse type) :rofl: