Compare commits

...

16 Commits

Author SHA1 Message Date
Madelena Mak a2717048e5 Add Last Refreshed Timestamp on the display
1 year ago
Madelena Mak b611d8fc28 Add comments
1 year ago
Madelena Mak d91463f004 Rename buttons
1 year ago
Madelena Mak d359dd0f6b Indent fixes
1 year ago
Madelena Mak 6153541fcc
Merge pull request #15 from paviro/main
1 year ago
Madelena Mak 310134fdc2
Merge branch 'main' into main
1 year ago
Madelena Mak c3343ccf45 Sensor name small changes
1 year ago
Madelena Mak 8b62148f4d Add hyphen to font glyphs
1 year ago
Madelena Mak 39077eff6f
Merge pull request #17 from pehses/main
1 year ago
Philipp Ehses b73f1e0455 Fixes day/night detection and an indentation bug
1 year ago
Paul-Vincent Roll 8f79df5c3d
Added diagnostic flag to WiFi sensor
1 year ago
Paul-Vincent Roll 3671a83dca
Improved display sensors
1 year ago
Paul-Vincent Roll e2181c2e3f Added sensor for last screen refresh and total display refreshs
1 year ago
Paul-Vincent Roll 6b25b5e3cc Added update_screen script and button
1 year ago
Paul-Vincent Roll 42d39dcdd7 Added reboot and shutdown buttons
1 year ago
Paul-Vincent Roll f38598a854 Improved initial data handling
1 year ago

@ -84,7 +84,7 @@ template:
{% set next_setting = as_timestamp(state_attr('sun.sun', 'next_setting')) %}
{% set next_rising = as_timestamp(state_attr('sun.sun', 'next_rising')) %}
{% set cond0_time = as_timestamp(state_attr('weather.valhalla_hourly', 'forecast')[0].datetime) %}
{% if cond0_time > next_setting and cond0_time < next_rising %}
{% if cond0_time < next_rising and next_rising < next_setting %}
{% if cond0 == 'sunny' %} night {% elif cond0 == 'partlycloudy' %} night-partly-cloudy {% else %} {{ cond0 }} {% endif %}
{% else %}
{{ cond0 }}
@ -99,7 +99,7 @@ template:
{% set next_setting = as_timestamp(state_attr('sun.sun', 'next_setting')) %}
{% set next_rising = as_timestamp(state_attr('sun.sun', 'next_rising')) %}
{% set cond1_time = as_timestamp(state_attr('weather.valhalla_hourly', 'forecast')[1].datetime) %}
{% if cond1_time > next_setting and cond1_time < next_rising %}
{% if cond1_time < next_rising and next_rising < next_setting %}
{% if cond1 == 'sunny' %} night {% elif cond1 == 'partlycloudy' %} night-partly-cloudy {% else %} {{ cond1 }} {% endif %}
{% else %}
{{ cond1 }}
@ -114,7 +114,7 @@ template:
{% set next_setting = as_timestamp(state_attr('sun.sun', 'next_setting')) %}
{% set next_rising = as_timestamp(state_attr('sun.sun', 'next_rising')) %}
{% set cond2_time = as_timestamp(state_attr('weather.valhalla_hourly', 'forecast')[2].datetime) %}
{% if cond2_time > next_setting and cond2_time < next_rising %}
{% if cond2_time < next_rising and next_rising < next_setting %}
{% if cond2 == 'sunny' %} night {% elif cond2 == 'partlycloudy' %} night-partly-cloudy {% else %} {{ cond2 }} {% endif %}
{% else %}
{{ cond2 }}
@ -129,7 +129,7 @@ template:
{% set next_setting = as_timestamp(state_attr('sun.sun', 'next_setting')) %}
{% set next_rising = as_timestamp(state_attr('sun.sun', 'next_rising')) %}
{% set cond3_time = as_timestamp(state_attr('weather.valhalla_hourly', 'forecast')[3].datetime) %}
{% if cond3_time > next_setting and cond3_time < next_rising %}
{% if cond3_time < next_rising and next_rising < next_setting %}
{% if cond3 == 'sunny' %} night {% elif cond3 == 'partlycloudy' %} night-partly-cloudy {% else %} {{ cond3 }} {% endif %}
{% else %}
{{ cond3 }}

@ -9,12 +9,21 @@ esphome:
priority: 200.0
then:
- 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:
board: esp32dev
framework:
type: arduino
# Enable logging
logger:
@ -23,6 +32,19 @@ api:
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!)
globals:
- id: data_updated
@ -33,7 +55,21 @@ globals:
type: bool
restore_value: no
initial_value: 'false'
- id: recorded_display_refresh
type: int
restore_value: yes
initial_value: '0'
# Script for updating screen - Refresh display and publish refresh count and time. (Thanks @paviro!)
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,
# based on whether new data is received or motion is detected. (Thanks @paviro!)
@ -48,15 +84,13 @@ time:
condition:
lambda: 'return id(data_updated) == true;'
then:
- lambda: 'id(initial_data_received) = true;'
- 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
- lambda: 'id(data_updated) = false;'
else:
- script.execute: update_screen
else:
- logger.log: "Sensor data updated but no activity in home - skipping display refresh."
else:
- logger.log: "No sensors updated - skipping display refresh."
@ -155,21 +189,36 @@ binary_sensor:
id: motion_detected
# Call Subway and Weather sensors from HA.
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
entity_id: sensor.gtfs_mta_subway_manhattan
id: train_manhattan_due_in
on_value:
then:
- lambda: 'id(data_updated) = true;'
- lambda: 'id(data_updated) = true;'
- platform: homeassistant
entity_id: sensor.gtfs_mta_subway_canarsie
id: train_canarsie_due_in
on_value:
then:
- lambda: 'id(data_updated) = true;'
- lambda: 'id(data_updated) = true;'
- platform: homeassistant
entity_id: sensor.gtfs_mta_subway_manhattan
@ -177,7 +226,7 @@ sensor:
id: train_manhattan_next_train_due_in
on_value:
then:
- lambda: 'id(data_updated) = true;'
- lambda: 'id(data_updated) = true;'
- platform: homeassistant
entity_id: sensor.gtfs_mta_subway_canarsie
@ -185,7 +234,7 @@ sensor:
id: train_canarsie_next_train_due_in
on_value:
then:
- lambda: 'id(data_updated) = true;'
- lambda: 'id(data_updated) = true;'
- platform: homeassistant
entity_id: weather.hourly
@ -193,7 +242,7 @@ sensor:
id: weather_temperature
on_value:
then:
- lambda: 'id(data_updated) = true;'
- lambda: 'id(data_updated) = true;'
- platform: homeassistant
entity_id: sensor.weatherman_data
@ -201,7 +250,7 @@ sensor:
id: weather_temperature_0
on_value:
then:
- lambda: 'id(data_updated) = true;'
- lambda: 'id(data_updated) = true;'
- platform: homeassistant
entity_id: sensor.weatherman_data
@ -209,7 +258,7 @@ sensor:
id: weather_temperature_1
on_value:
then:
- lambda: 'id(data_updated) = true;'
- lambda: 'id(data_updated) = true;'
- platform: homeassistant
entity_id: sensor.weatherman_data
@ -217,7 +266,7 @@ sensor:
id: weather_temperature_2
on_value:
then:
- lambda: 'id(data_updated) = true;'
- lambda: 'id(data_updated) = true;'
- platform: homeassistant
entity_id: sensor.weatherman_data
@ -225,11 +274,12 @@ sensor:
id: weather_temperature_3
on_value:
then:
- lambda: 'id(data_updated) = true;'
- lambda: 'id(data_updated) = true;'
- platform: wifi_signal
name: "WiFi Signal Sensor"
id: wifisignal
entity_category: "diagnostic"
update_interval: 60s
@ -240,7 +290,7 @@ text_sensor:
id: train_manhattan_due_at
on_value:
then:
- lambda: 'id(data_updated) = true;'
- lambda: 'id(data_updated) = true;'
- platform: homeassistant
entity_id: sensor.gtfs_mta_subway_canarsie
@ -248,7 +298,7 @@ text_sensor:
id: train_canarsie_due_at
on_value:
then:
- lambda: 'id(data_updated) = true;'
- lambda: 'id(data_updated) = true;'
- platform: homeassistant
entity_id: sensor.gtfs_mta_subway_manhattan
@ -256,7 +306,7 @@ text_sensor:
id: train_manhattan_next_train_due_at
on_value:
then:
- lambda: 'id(data_updated) = true;'
- lambda: 'id(data_updated) = true;'
- platform: homeassistant
entity_id: sensor.gtfs_mta_subway_canarsie
@ -264,14 +314,14 @@ text_sensor:
id: train_canarsie_next_train_due_at
on_value:
then:
- lambda: 'id(data_updated) = true;'
- lambda: 'id(data_updated) = true;'
- platform: homeassistant
entity_id: weather.valhalla_hourly
id: weather_state
on_value:
then:
- lambda: 'id(data_updated) = true;'
- lambda: 'id(data_updated) = true;'
- platform: homeassistant
entity_id: sensor.weatherman_data
@ -279,63 +329,63 @@ text_sensor:
id: weather_condition_now
on_value:
then:
- lambda: 'id(data_updated) = true;'
- lambda: 'id(data_updated) = true;'
- platform: homeassistant
entity_id: sensor.weatherman_data
attribute: weather_condition_0
id: weather_condition_0
on_value:
then:
- lambda: 'id(data_updated) = true;'
- lambda: 'id(data_updated) = true;'
- platform: homeassistant
entity_id: sensor.weatherman_data
attribute: weather_timestamp_0
id: weather_timestamp_0
on_value:
then:
- lambda: 'id(data_updated) = true;'
- lambda: 'id(data_updated) = true;'
- platform: homeassistant
entity_id: sensor.weatherman_data
attribute: weather_condition_1
id: weather_condition_1
on_value:
then:
- lambda: 'id(data_updated) = true;'
- lambda: 'id(data_updated) = true;'
- platform: homeassistant
entity_id: sensor.weatherman_data
attribute: weather_timestamp_1
id: weather_timestamp_1
on_value:
then:
- lambda: 'id(data_updated) = true;'
- lambda: 'id(data_updated) = true;'
- platform: homeassistant
entity_id: sensor.weatherman_data
attribute: weather_condition_2
id: weather_condition_2
on_value:
then:
- lambda: 'id(data_updated) = true;'
- lambda: 'id(data_updated) = true;'
- platform: homeassistant
entity_id: sensor.weatherman_data
attribute: weather_timestamp_2
id: weather_timestamp_2
on_value:
then:
- lambda: 'id(data_updated) = true;'
- lambda: 'id(data_updated) = true;'
- platform: homeassistant
entity_id: sensor.weatherman_data
attribute: weather_condition_3
id: weather_condition_3
on_value:
then:
- lambda: 'id(data_updated) = true;'
- lambda: 'id(data_updated) = true;'
- platform: homeassistant
entity_id: sensor.weatherman_data
attribute: weather_timestamp_3
id: weather_timestamp_3
on_value:
then:
- lambda: 'id(data_updated) = true;'
- lambda: 'id(data_updated) = true;'
- platform: homeassistant
entity_id: sensor.weatherman_data
@ -343,21 +393,21 @@ text_sensor:
id: train_status
on_value:
then:
- lambda: 'id(data_updated) = true;'
- lambda: 'id(data_updated) = true;'
- platform: homeassistant
entity_id: sensor.weatherman_data
attribute: train_status_manhattan
id: train_status_manhattan
on_value:
then:
- lambda: 'id(data_updated) = true;'
- lambda: 'id(data_updated) = true;'
- platform: homeassistant
entity_id: sensor.weatherman_data
attribute: train_status_canarsie
id: train_status_canarsie
on_value:
then:
- lambda: 'id(data_updated) = true;'
- lambda: 'id(data_updated) = true;'
# Define colors
@ -481,6 +531,13 @@ display:
it.printf(330, 652, id(font_medium_bold), color_text, TextAlign::TOP_CENTER, "%2.0f MIN", id(train_canarsie_next_train_due_in).state);
it.printf(150, 684, id(font_small_book), color_text, TextAlign::TOP_CENTER, "%s", id(train_manhattan_next_train_due_at).state.c_str());
it.printf(330, 684, id(font_small_book), color_text, TextAlign::TOP_CENTER, "%s", id(train_canarsie_next_train_due_at).state.c_str());
// Refresh Timestamp
// Code by EnsconcE from https://community.home-assistant.io/t/esphome-show-time/348903
char str[17];
time_t currTime = id(homeassistant_time).now().timestamp;
strftime(str, sizeof(str), "%H:%M", localtime(&currTime));
it.printf(240, 710, id(font_small_book), color_text, TextAlign::TOP_CENTER, "REFRESHED AT %s", str);
}
captive_portal:

Loading…
Cancel
Save