Help to turn on/off lights with Big Timer (examples/screenshots included)

Pretty simple automation, but I can’t seem to get the time to trigger the turn_on service I’ve got configured in node-red. Bonus points if anyone can help in node-red where to configure the brightness_pct parameter for the entity

This works when manually invoked in Home Assistant:

Big Timer Config: (I also tried the time range node, but didn’t think that was as well suited as Big Timer). Times are hardcoded for now at the closest 15 minute interval until I can get it working, then will switch the times on dusk/dawn
image

Switch Config:
image

Call Service Node Config (where can I add the additional config to set brightness_pct?):

Wow - obviously still learning. I realized I needed to inject a timestamp (repeating every 1 minute) into either bigtimer or the time range node.

My goto for time/sun based flows triggers is node-red-contrib-eztimer.

[{"id":"36f00c2c.bd1454","type":"eztimer","z":"5eb3594f.d294b8","name":"","autoname":"dusk - dawn","suspended":false,"sendEventsOnSuspend":false,"timerType":"1","startupMessage":true,"ontype":"1","ontimesun":"dusk","ontimetod":"17:00","onproperty":"payload","onvaluetype":"json","onvalue":"{\"data\":{\"brightness_pct\":20}}","onoffset":0,"onrandomoffset":0,"offtype":"1","offtimesun":"dawn","offtimetod":"dusk","offduration":0,"offproperty":"payload","offvaluetype":"json","offvalue":"{\"service\":\"turn_off\"}","offoffset":0,"offrandomoffset":0,"mon":true,"tue":true,"wed":true,"thu":true,"fri":true,"sat":true,"sun":true,"x":310,"y":1808,"wires":[["c40f5edb.7b716"]]},{"id":"c40f5edb.7b716","type":"api-call-service","z":"5eb3594f.d294b8","name":"","service_domain":"light","service":"turn_on","data":"{\"entity_id\":\"light.front_porch_dimmer_switch_level\"}","mergecontext":"","output_location":"","output_location_type":"none","mustacheAltTags":false,"x":650,"y":1808,"wires":[[]]}]
2 Likes

Thanks @Kermit! I have it working as it is, but am all in for optimizations. Can you help me interpret how to use the eztimer for this type of scenario, where I’m controlling on & off (not just on)?

It can’t be as simple as having all my on/off events coming from the output of EZtimer? Or, would I need to split that eztimer output with the “switch” node?

Take a look at the example I posted above. You are able to customize the output of the eztimer payload.

In the call-service node set the default values:

Domain: light
Service: turn_on
Entity_id: light.front_porch_dimmer_switch_level

Then with the [on] event payload, we override the data field with the brightness.

We can use the same call-service node for the [off] event because you can then override the service with {"service": "turn_off"}

Another optimization you can do is combine all the entity_ids into one call-service node by having a comma-delimited list in the Entity Id field.

2 Likes

I appreciate your help. Would you be willing to spoon feed me how to import that code block you initially posted so I could see it happen? I’d like to combine all three entity_id’s into one, but struggling there, too.

I get what you’re saying on how to do it all in one call call-service node, but I’m not getting the syntax right.

I’ve tried the following below, as well as combining all the explicit entity_ids into one, but no go:

{
  "entity_id": "light.front_porch_dimmer_switch_level",
  "brightness_pct":20,
  "entity_id":"light.main_garage_exterior_dimmer_switch_level",
  "brightness_pct":20,
  "entity_id":"light.shop_exterior_dimmer_switch_level",
  "brightness_pct":20
}

and

{
  "entity_id": "light.front_porch_dimmer_switch_level","light.main_garage_exterior_dimmer_switch_level","light.main_garage_exterior_dimmer_switch_level",
  "brightness_pct":20
}

You just need a single set of quotes around entity id value.

{
  "entity_id": "light.front_porch_dimmer_switch_level,light.main_garage_exterior_dimmer_switch_level,light.main_garage_exterior_dimmer_switch_level",
  "brightness_pct":20
}

To import the below JSON click on the hamburger menu, the stacked three lines, in the top right corner of the node-red UI then Import and Clipboard. Then paste in the string below.

[{"id":"8a640f98.26ad7","type":"eztimer","z":"5eb3594f.d294b8","name":"","autoname":"dusk - dawn","suspended":false,"sendEventsOnSuspend":false,"timerType":"1","startupMessage":true,"ontype":"1","ontimesun":"dusk","ontimetod":"17:00","onproperty":"payload","onvaluetype":"json","onvalue":"{\"data\":{\"brightness_pct\":20}}","onoffset":0,"onrandomoffset":0,"offtype":"1","offtimesun":"dawn","offtimetod":"dusk","offduration":0,"offproperty":"payload","offvaluetype":"json","offvalue":"{\"service\":\"turn_off\"}","offoffset":0,"offrandomoffset":0,"mon":true,"tue":true,"wed":true,"thu":true,"fri":true,"sat":true,"sun":true,"x":246,"y":1376,"wires":[["afbea5e8.89f438"]]},{"id":"afbea5e8.89f438","type":"api-call-service","z":"5eb3594f.d294b8","name":"","service_domain":"light","service":"turn_on","data":"{\"entity_id\":\"light.front_porch_dimmer_switch_level,light.main_garage_exterior_dimmer_switch_level,light.shop_exterior_dimmer_switch_level\"}","mergecontext":"","output_location":"","output_location_type":"none","mustacheAltTags":false,"x":586,"y":1376,"wires":[[]]}]
1 Like

Got it - thank you!

@Kermit - Last question (I promise?) I’m not sure if the dawn event has to trigger first for the {“service”:“turn_off”} to execute, but I’m not sure how only specifying {"service":"turn_off"} will know what entity_ids to apply to?

I’m not able to take my JSON into Home Assistant’s services tool and have it execute.

Loving the compactness of this and can see it being re-used in several automations (assuming it is correct)

I’ve tried the following JSON in the [off] event of eztimer:

{
    "service": "turn_off"
}

and

{
    "entity_id": "light.front_porch_dimmer_switch_level,light.main_garage_exterior_dimmer_switch_level,light.main_garage_exterior_dimmer_switch_level",
    "service": "turn_off"
}

you define the entity ids in the call-service so you don’t need to define them in the eztimer payload.

2 Likes

Perfect just what I was looking for. Just never had much luck with bigtimer.

Thanks!

I am having problem. I am pretty new and just installed NODE-RED. I tried to configure my outside light patio and front house to come on when sunset and off on sunrise. that did not work. I tired using calendar did not work. and now trying big timer. but light come on and I cannot figure out how to make them go off. I am trying to follow the example I see above but I don’t understand much. if someone can explain I appreciate. I’m looking to set my outside lights to go on when it gets dark and off when it gets bright. But if I have to use time for example (front light switch to go On at 8:15pm and Patio to go on at 8:45pm them both patio and front switches can go off at 7am. Any help will be appreciate

I am working on the Red Selection but everything else was me trying different way but couldn’t figure out

Quite a few things since this original post. There are now sun rise and set sensors provided by HA. There is also the new time node. You can set these sensors to a time node to trigger sunrise and sunset, also dawn and dusk. Make sure the check the repeat box for it to repeat every day.

image