Setting light to come on 30 minutes before sunset

Hi there.

I am a beginner to HA and have found Node-Red to be an amazing bit of software to get things working, but I am still getting to grips with it.

At the moment, I have things up so that when the sun.sun entity ID changes to below_horizon, my kitchen light turns on.

However, I am finding that the kitchen is too dark by then and need the light on 30 minutes before the below_horizon trigger.

I have messed around with various options but just cannot work out how to do this - any pointers would be much appreciated.

If you install node-red-contrib-suncron, and use that node to trigger the flow, there is an offset in the the node that can be set.

1 Like

I have been doing this in my house based on sun elevation not time and I think it works well the key is to have it trigger when the sun is still above the horizon. I have found 10 degrees above the horizon works well for me. Here is the code, this will trigger then the sun elevation falls below 10deg above the horizon, kinds confusing.

alias: Lights on at sunset
description: ''
trigger:
  - platform: numeric_state
    entity_id: sun.sun
    attribute: elevation
    below: '10'
condition: []
1 Like

Thanks ever so much for your replies.

I cannot believe that I did not know that you can use the attributes of the sun.sun entity id. I literally thought that all you could do is use if for above and below the horizon. I thought the attributes were just for information, rather than being usable by the system.

This adds a whole new dimension to HA, now.

I am going to try both methods as I am finding that the best way of learning HA.

Raelx - can I just ask something about your method, please?

Which of the Node-Red nodes are you using to enter the above information?

Here is another example of automation:

- id: '1610118280188'
  alias: Switch on evening scene 20 min before sunset
  description: ''
  trigger:
  - platform: sun
    event: sunset
    offset: '-20'
  condition: []
  action:
  - service: scene.turn_on
    data: {}
    entity_id: scene.evening
  mode: single

Ahh i should have mentation Iā€™m not using NodeRed, i was never able to figure it out. So this is just an Automation in HA (Configuration > Automations)