pnbruckner / ha-sun2

Home Assistant Sun2 Sensor

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Documentation not clear (to me)

stevegroom opened this issue · comments

Hello,
I used the Sun2 integration to turn on a light at Civil Twilight using a node red flow. Then a few weeks ago it stopped working. Coming back to the Readme.md I can't find any relevant information to help me debug the situation.

I can see some sensors are updated with the next time a sun state will occur, but can't see how to trigger an action at that time. "Trigger" does not appear in the doc.

I updated the yaml and it creates a local sunset sensor, which is updated every midnight. How do I go from that to trigger an action?

If I can get this working, I can contribute an update to the docs.

How did it work before? I've never used node red, so I can't really help with that part. Was it using a HA entity, and was that an entity created by the sun2 integration? If so, which entity? Can you share the sun2 configuration that had been working for you? When you say, "at Civil Twilight", exactly what do you mean, since Civil Twilight is not a moment in time, but a span of time (i.e., when the sun is between 0.833 and 6 degrees below the horizon. See https://www.timeanddate.com/astronomy/civil-twilight.html#Civil%20Twilight).

I'm not exactly sure what you're asking or what you think is unclear. The sun2 integration can create one or more HA entities, that update based on the type of sensor(s) chosen. "Trigger" is a HA automation concept, not a sun2 integration concept. You trigger an automation from a sun2 entity just like you'd do with any other type of entity. You just have to determine what you're basing the trigger on, e.g., a state change, or an attribute change, etc.

If you want to trigger an automation (either natively in HA with an automation, or in node red) that turns on a light when Civil Twilight starts, which would be at sunset, or when Civil Twilight ends, which would be at dusk, based on a sun2 entity, then the way to do that is to create an appropriate sun2 entity and trigger the automation on the appropriate state or attribute.

One way would be to use the Sun Phase sensor, and then trigger the automation when the entity's state changes to "Civil Twilight" (i.e., at sunset), or when it changes from "Civil Twilight" (i.e., dusk.)

Another way would be to use an elevation binary sensor (with an elevation value for the event you're interested in) and trigger the automation on the state becoming "off" (i.e., the sun goes below that value.)

Hi,
thank you for the information - that is helpful. I'm not sure how it worked before because I overwrote the automation whilst trying to repair it.

For triggers, if they are fired when an attribute changes, when does this sun2.dusk trigger occur?:

image

I interpret this as updating (setting the value to 18:35) at midnight.

Anyway I'll try the sensor.dusk state change to see what happens (at 18:35).

The dusk sensor is not very helpful for what you're trying to do. Its state is the time today when dusk occurs, and yes, it updates every day at midnight. That does not directly cause any state changes at dusk. That is why I suggested using either the sun phase sensor, which does change state at dusk (and at other times), or the elevation binary sensor, which, with the appropriate settings, can also change state at dusk. Either of those would be easy to use as an automation trigger.

You might still be able to use the dusk sensor as a trigger, but it might require using a template trigger. The others, like I say, would be much easier.

@stevegroom do you still need help?