Added update_screen script and button

pull/23/head
Paul-Vincent Roll 2 years ago
parent 42d39dcdd7
commit 6b25b5e3cc

@ -37,6 +37,13 @@ button:
name: "weatherman: Shutdown" name: "weatherman: Shutdown"
- platform: restart - platform: restart
name: "weatherman: Restart" name: "weatherman: Restart"
- platform: template
name: "weatherman: Refresh Screen"
entity_category: config
on_press:
- script.execute: update_screen
# Global variables for detecting if the display needs to be refreshed. (Thanks @paviro!) # Global variables for detecting if the display needs to be refreshed. (Thanks @paviro!)
globals: globals:
- id: data_updated - id: data_updated
@ -49,6 +56,16 @@ globals:
initial_value: 'false' initial_value: 'false'
script:
- id: update_screen
then:
- lambda: 'id(data_updated) = false;'
- component.update: eink_display
- lambda: 'id(recorded_display_refresh) += 1;'
- lambda: 'id(display_last_update).publish_state(id(homeassistant_time).now().timestamp);'
# Check whether the display needs to be refreshed every minute, # Check whether the display needs to be refreshed every minute,
# based on whether new data is received or motion is detected. (Thanks @paviro!) # based on whether new data is received or motion is detected. (Thanks @paviro!)
time: time:
@ -62,14 +79,12 @@ time:
condition: condition:
lambda: 'return id(data_updated) == true;' lambda: 'return id(data_updated) == true;'
then: then:
- lambda: 'id(initial_data_received) = true;'
- if: - if:
condition: condition:
binary_sensor.is_on: motion_detected binary_sensor.is_on: motion_detected
then: then:
- logger.log: "Sensor data updated and activity in home detected: Refreshing display..." - logger.log: "Sensor data updated and activity in home detected: Refreshing display..."
- component.update: eink_display - script.execute: update_screen
- lambda: 'id(data_updated) = false;'
else: else:
- logger.log: "Sensor data updated but no activity in home - skipping display refresh." - logger.log: "Sensor data updated but no activity in home - skipping display refresh."
else: else:

Loading…
Cancel
Save