#day and night - automation

1 messages · Page 1 of 1 (latest)

jagged pebble
#

Does anyone have an automation that switches back and forth between day and night in an automation? I realise that it sounds simple, but I just can't get it to work. 🙂

azure edge
#

What do you mean by "switches back and forth between day and night"?

jagged pebble
#

I have created a helper which I have named input_boolean.tagnacht. Now I want to set the helper to True for day and False for night. But I would like to have both in one automation. (This is probably the easiest automation in the world but I can't get it to work)

azure edge
#

Gotcha.
The easiest way to do this is with the sun sensor. You could do it without the automation even - just a template sensor that checks it
EG. {{'night' if states('sun.sun') == 'below_horizon' else 'day' }}

jagged pebble
#

A template! Thank you for the obvious solution!!!

azure edge
#

No worries 🙂

subtle vault
#

Of use no helper and use only sun.sun

jagged pebble
#

I need it as a boolean and not as ON / OFF 🙂 how do I have to change the template for this?

jagged pebble
#

My helper now looks like this ... {{ 0 if states('sun.sun') == 'below_horizon' else 1 }} And this is what my knx.yml looks like. ... expose: - type: binary entity_id: binary_sensor.tagnacht address: "14/0/11" Thank you very much