
When the sun goes below the horizon, the porch and garden lights must turn on.

The following example shows how a single automation can control entities that aren’t related to each other but have in common the same trigger. wait_for_trigger : - platform : event event_type : ifttt_webhook_received event_data : action : connected_to_network timeout : minutes : " " sequence : - service : script.left_home # Wait for IFTTT event or abort after specified timeout. For all the different possibilities, have a look at the service calls page. The most important one is the action to call a service.

If you run test2, you will see 'hi' right away ( setTimeout is non blocking) and after 3 seconds you will see the alert 'hello'.# Example script integration containing script syntax script : example_script : sequence : # This is written using the Script Syntax - alias : " Turn on ceiling light" service : light.turn_on target : entity_id : light.ceiling - alias : " Notify that ceiling light is turned on" service : notify.notify data : message : " Turned on the ceiling light!" 3 seconds and go to next line of code. defer the execution of anonymous function for

Unfortunately, there is no sleep function like that in JavaScript. If you run the above function, you will have to wait for 3 seconds ( sleep method call is blocking) before you see the alert 'hi'. let's say JavaScript did have a sleep function. Remember, this is completely different from how sleep method, if it existed, would behave. it will run after 3 seconds (3000 milliseconds) if you have defined a function named myFunction setTimeout will let you defer execution of a function for x milliseconds. If you are looking to block the execution of code with call to sleep, then no, there is no method for that in JavaScript.
