Merge pull request #15 from paviro/main

Added screen statistic sensors and new buttons
main
Madelena Mak 2 years ago committed by GitHub
commit 6153541fcc
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -9,6 +9,14 @@ esphome:
priority: 200.0 priority: 200.0
then: then:
- component.update: eink_display - component.update: eink_display
- wait_until:
condition:
lambda: 'return id(data_updated) == true;'
# Wait a bit longer so all the items are received
- delay: 5s
- logger.log: "Initial sensor data received: Refreshing display..."
- lambda: 'id(initial_data_received) = true;'
- script.execute: update_screen
esp32: esp32:
board: esp32dev board: esp32dev
@ -23,6 +31,19 @@ api:
ota: ota:
button:
- platform: shutdown
name: "weatherman: Shutdown"
- platform: 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
@ -33,6 +54,20 @@ globals:
type: bool type: bool
restore_value: no restore_value: no
initial_value: 'false' initial_value: 'false'
- id: recorded_display_refresh
type: int
restore_value: yes
initial_value: '0'
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,
@ -48,14 +83,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:
@ -155,8 +188,23 @@ binary_sensor:
id: motion_detected id: motion_detected
# Call Subway and Weather sensors from HA.
sensor: sensor:
- platform: template
name: "Weatherman - Display Last Update"
device_class: timestamp
entity_category: "diagnostic"
id: display_last_update
- platform: template
name: "Weatherman - Recorded Display Refresh"
accuracy_decimals: 0
unit_of_measurement: "Refreshs"
state_class: "total_increasing"
entity_category: "diagnostic"
lambda: 'return id(recorded_display_refresh);'
# Call Subway and Weather sensors from HA.
- platform: homeassistant - platform: homeassistant
entity_id: sensor.gtfs_mta_subway_manhattan entity_id: sensor.gtfs_mta_subway_manhattan
id: train_manhattan_due_in id: train_manhattan_due_in
@ -230,6 +278,7 @@ sensor:
- platform: wifi_signal - platform: wifi_signal
name: "WiFi Signal Sensor" name: "WiFi Signal Sensor"
id: wifisignal id: wifisignal
entity_category: "diagnostic"
update_interval: 60s update_interval: 60s

Loading…
Cancel
Save