hello all,
i want a simple script, where every 60’, will toggle on and off a group of lights.
can someone help me, i’m a little new to this…
regards,
George.
hello all,
i want a simple script, where every 60’, will toggle on and off a group of lights.
can someone help me, i’m a little new to this…
regards,
George.
Hi. Look at adding this to your palette: node-red-contrib-looptimer
The help will show how to trigger something on a frequency. To over simplify, you could use 2 different loops. One for on and the other for off, each every 2 hrs. Of course there are more elegant ways too.
Good luck!
What you’re looking for is not a script
, in Home Assistant this is called automation
.
How to do this, you can lookup here:
And the trigger you’re looking for would be the time_pattern
trigger, where you can set an automation to run every X minutes, hours, days.
See here:
i think that i’m close enough, but i get a Message malformed: expected dictionary
my automation goes like this:
- alias: Toggle TH16
id: Toggle_TH16
trigger:
platform: time
hour: '/1'
minutes: 0
seconds: 0
condition:
- condition: time
after: '00:00:00'
before: '23:59:59'
- action:
service: light.toggle
target:
entity_id: light.th16_sensors
- delay: 00:00:05
service: light.toggle
target:
entity_id: light.th16_sensors
ok, i did it… i just have to expect some minutes to test
alias: Toggle TH16 every 1 hour
description: ''
trigger:
- platform: time_pattern
id: Toggle TH16
hours: '1'
minutes: '0'
seconds: '0'
condition:
- condition: time
after: '00:00:00'
before: '23:59:59'
weekday:
- mon
- tue
- wed
- thu
- fri
- sat
- sun
action:
- service: light.toggle
data: {}
target:
entity_id: light.th16_sensors
- delay:
hours: 0
minutes: 0
seconds: 2
milliseconds: 0
- service: light.toggle
data: {}
target:
entity_id: light.th16_sensors
mode: single
Yes you are
You need to look more on indentation and the general structure. But you’ll get there! The yaml in HA is structured in a “logical” manor. An automation needs two things: a trigger and an action. Optionally a condition, if necessary. So these are on the first level (indented by 2 spaces). Under trigger you specify the platform that is used for the trigger, so it is second level (indented by 4 spaces). Same goes for the action.
In the end it gives you this:
- alias: Toggle TH16
id: Toggle_TH16
trigger:
- platform: time_pattern
hour: '/1'
action:
- service: light.toggle
target:
entity_id: light.th16_sensors
- delay: '00:00:05'
- service: light.toggle
target:
entity_id: light.th16_sensors
I deleted the unnecessary parts like the time condition. Not needed if it should run every hour (every hour of the day is between 00:00 and 23:59). Same goes for the minutes and seconds - not needed, leave them out.
your version does not work for me, but this works…
thank you for the help
alias: Toggle TH16 every 1 hour
description: ''
trigger:
- platform: time_pattern
id: Toggle TH16
hours: '*'
minutes: '1'
condition: []
action:
- service: light.toggle
data: {}
target:
entity_id: light.th16_sensors
- delay:
hours: 0
minutes: 0
seconds: 2
milliseconds: 0
- service: light.toggle
data: {}
target:
entity_id: light.th16_sensors
mode: single
Totally right, I used the wrong trigger, it must be time_pattern
, not time
and had a typo in hour…
This should work now:
- alias: Toggle TH16
id: Toggle_TH16
trigger:
- platform: time_pattern
hours: '/1'
action:
- service: light.toggle
target:
entity_id: light.th16_sensors
- delay: '00:00:05'
- service: light.toggle
target:
entity_id: light.th16_sensors