From 1b42c0b3a3baa84c9fc365a3cc27ccf1fe613a91 Mon Sep 17 00:00:00 2001 From: Tony Stork Date: Thu, 13 Jan 2022 18:07:27 -0500 Subject: [PATCH] Add automation to set binary_sensor.night accurately on startup --- automations.yaml | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) diff --git a/automations.yaml b/automations.yaml index f4683d6..1a9bd0a 100644 --- a/automations.yaml +++ b/automations.yaml @@ -250,3 +250,28 @@ - light.living_room_lights - light.mud_room_overhead mode: single +- alias: Set State Night + description: Set the state of binary_sensor.night accurately on HA startup + trigger: + - platform: homeassistant + event: start + action: + - choose: + - conditions: + - condition: sun + after: sunset + before_offset: -00:30 + sequence: + - service: python_script.hass_entities + data: + action: set_state + entity_id: binary_sensor.night + state: 'on' + default: + - service: python_script.hass_entities + data: + action: set_state + entity_id: binary_sensor.night + state: 'off' + hide_entity: true + initial_state: 'on'