Use motion sensor for refreshing

pull/10/head
Madelena Mak 2 years ago
parent 35844d638e
commit d649724de8

@ -23,6 +23,7 @@ api:
ota: ota:
# Global variables for detecting if the display needs to be refreshed. (Thanks @paviro!)
globals: globals:
- id: data_updated - id: data_updated
type: bool type: bool
@ -33,23 +34,35 @@ globals:
restore_value: no restore_value: no
initial_value: 'false' initial_value: 'false'
# Check whether the display needs to be refreshed every minute,
# based on whether new data is received or motion is detected. (Thanks @paviro!)
time: time:
- platform: homeassistant - platform: homeassistant
id: homeassistant_time id: homeassistant_time
on_time: on_time:
- seconds: 30 - seconds: 0
minutes: /1
then: then:
- if: - if:
condition: condition:
lambda: 'return id(data_updated) == true;' lambda: 'return id(data_updated) == true;'
then: then:
- lambda: 'id(initial_data_received) = true;' - lambda: 'id(initial_data_received) = true;'
- logger.log: "Sensor data updated: Refreshing display..." - if:
condition:
binary_sensor.is_on: motion_detected
then:
- logger.log: "Sensor data updated and activity in home detected: Refreshing display..."
- component.update: eink_display - component.update: eink_display
- lambda: 'id(data_updated) = false;' - lambda: 'id(data_updated) = false;'
else:
- logger.log: "Sensor data updated but no activity in home - skipping display refresh."
else: else:
- logger.log: "No sensors updated - skipping display refresh." - logger.log: "No sensors updated - skipping display refresh."
# Wifi information
wifi: wifi:
ssid: !secret wifi_ssid ssid: !secret wifi_ssid
password: !secret wifi_password password: !secret wifi_password
@ -135,7 +148,14 @@ font:
# type: BINARY # type: BINARY
# Call Subway and Weather sensors from HA # Check if motion is detected in the living room.
binary_sensor:
- platform: homeassistant
entity_id: binary_sensor.weatherman_motion_detected
id: motion_detected
# Call Subway and Weather sensors from HA.
sensor: sensor:
- platform: homeassistant - platform: homeassistant
entity_id: sensor.gtfs_mta_subway_manhattan entity_id: sensor.gtfs_mta_subway_manhattan
@ -182,6 +202,7 @@ sensor:
on_value: on_value:
then: then:
- lambda: 'id(data_updated) = true;' - lambda: 'id(data_updated) = true;'
- platform: homeassistant - platform: homeassistant
entity_id: sensor.weatherman_data entity_id: sensor.weatherman_data
attribute: weather_temperature_1 attribute: weather_temperature_1
@ -189,6 +210,7 @@ sensor:
on_value: on_value:
then: then:
- lambda: 'id(data_updated) = true;' - lambda: 'id(data_updated) = true;'
- platform: homeassistant - platform: homeassistant
entity_id: sensor.weatherman_data entity_id: sensor.weatherman_data
attribute: weather_temperature_2 attribute: weather_temperature_2
@ -196,6 +218,7 @@ sensor:
on_value: on_value:
then: then:
- lambda: 'id(data_updated) = true;' - lambda: 'id(data_updated) = true;'
- platform: homeassistant - platform: homeassistant
entity_id: sensor.weatherman_data entity_id: sensor.weatherman_data
attribute: weather_temperature_3 attribute: weather_temperature_3
@ -313,6 +336,7 @@ text_sensor:
on_value: on_value:
then: then:
- lambda: 'id(data_updated) = true;' - lambda: 'id(data_updated) = true;'
- platform: homeassistant - platform: homeassistant
entity_id: sensor.weatherman_data entity_id: sensor.weatherman_data
attribute: train_status attribute: train_status

Loading…
Cancel
Save