From ec0671a64db2766e3f894e0d73c387611489f381 Mon Sep 17 00:00:00 2001 From: Madelena Mak Date: Mon, 7 Nov 2022 23:52:55 -0500 Subject: [PATCH 1/8] Use text instead of image for titles. Saves space! --- weatherman.yaml | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/weatherman.yaml b/weatherman.yaml index 28030cb..0ed0428 100644 --- a/weatherman.yaml +++ b/weatherman.yaml @@ -59,6 +59,7 @@ wifi: ssid: "Esphome-Web-901078" password: "2JOrpBYEHQsV" + # Include custom fonts font: - file: 'fonts/GothamRnd-Book.ttf' @@ -68,6 +69,10 @@ font: id: font_large_bold size: 108 glyphs: [' ', '°', '0', '1', '2', '3', '4', '5', '6', '7', '8', '9', 'C'] + - file: 'fonts/GothamRnd-Bold.ttf' + id: font_title + size: 54 + glyphs: ['W', 'E', 'A', 'T', 'H', 'R', 'L', 'I', 'N', ' '] - file: 'fonts/GothamRnd-Bold.ttf' id: font_medium_bold size: 30 @@ -77,6 +82,7 @@ font: size: 18 # glyphs: ['°', '0', '1', '2', '3', '4', '5', '6', '7', '8', '9', 'C', 'M', 'I', 'N'] + # Include Material Design Icons font # Thanks to https://community.home-assistant.io/t/display-materialdesign-icons-on-esphome-attached-to-screen/199790/16 - file: 'fonts/materialdesignicons-webfont.ttf' @@ -415,7 +421,8 @@ display: it.printf(0, 420, id(font_small_bold), color_white, TextAlign::TOP_CENTER, "Waiting for data..."); } else { // Weather Section - it.image(0, 88, id(title_weather)); + // it.image(0, 88, id(title_weather)); + it.printf(240, 84, id(font_title), color_text, TextAlign::TOP_CENTER, "WEATHER"); it.printf(100, 158, id(font_mdi_large), color_white, TextAlign::TOP_CENTER, "%s", weather_icon_map[id(weather_condition_now).state.c_str()].c_str()); @@ -438,8 +445,8 @@ display: it.printf(375, 354, id(font_small_bold), color_white, TextAlign::TOP_CENTER, "%2.0f°C", id(weather_temperature_3).state); // Train Service Section - it.image(0, 420, id(title_train)); - it.printf(240, 480, id(font_medium_bold), color_white, TextAlign::TOP_CENTER, "%s", id(train_status).state.c_str()); + // it.image(0, 420, id(title_train)); + it.printf(240, 408, id(font_title), color_text, TextAlign::TOP_CENTER, "L TRAIN"); it.print(150, 536, id(font_small_bold), color_white, TextAlign::TOP_CENTER, "TO MANHATTAN"); it.print(330, 536, id(font_small_bold), color_white, TextAlign::TOP_CENTER, "TO CANARSIE"); From d2595f52f346bd364d325165809b1886792808e0 Mon Sep 17 00:00:00 2001 From: Madelena Mak Date: Mon, 7 Nov 2022 23:53:24 -0500 Subject: [PATCH 2/8] Invert bg and text colors --- weatherman.yaml | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/weatherman.yaml b/weatherman.yaml index 0ed0428..1caeb92 100644 --- a/weatherman.yaml +++ b/weatherman.yaml @@ -346,16 +346,16 @@ text_sensor: # Define colors # This design is white on black so this is necessary. color: - - id: color_black + - id: color_bg red: 0% green: 0% blue: 0% - white: 50% - - id: color_white + white: 0% + - id: color_text red: 0% green: 0% blue: 0% - white: 0% + white: 100% # Pins for Waveshare ePaper ESP Board @@ -411,8 +411,8 @@ display: {"windy-variant", "\U000F059E"}, }; - // Fill background in black. - it.fill(color_black); + // Fill background. + // it.fill(color_bg); if (id(initial_data_received) == false) { // ATTENTION! From 2ee725ff9ddcd1e142407b583b6410c7b7b84973 Mon Sep 17 00:00:00 2001 From: Madelena Mak Date: Mon, 7 Nov 2022 23:55:24 -0500 Subject: [PATCH 3/8] Add direction bound service change notices for trains --- weatherman.yaml | 17 +++++++---------- 1 file changed, 7 insertions(+), 10 deletions(-) diff --git a/weatherman.yaml b/weatherman.yaml index 1caeb92..644582a 100644 --- a/weatherman.yaml +++ b/weatherman.yaml @@ -244,14 +244,7 @@ text_sensor: - lambda: 'id(data_updated) = true;' - platform: homeassistant - entity_id: sensor.mta_subway_l_service_status - id: train_service_status - on_value: - then: - - lambda: 'id(data_updated) = true;' - - - platform: homeassistant - entity_id: weather.hourly + entity_id: weather.valhalla_hourly id: weather_state on_value: then: @@ -448,8 +441,12 @@ display: // it.image(0, 420, id(title_train)); it.printf(240, 408, id(font_title), color_text, TextAlign::TOP_CENTER, "L TRAIN"); - it.print(150, 536, id(font_small_bold), color_white, TextAlign::TOP_CENTER, "TO MANHATTAN"); - it.print(330, 536, id(font_small_bold), color_white, TextAlign::TOP_CENTER, "TO CANARSIE"); + it.printf(240, 472, id(font_medium_bold), color_text, TextAlign::TOP_CENTER, "%s", id(train_status).state.c_str()); + + it.print(150, 524, id(font_small_bold), color_text, TextAlign::TOP_CENTER, "TO MANHATTAN"); + it.printf(150, 546, id(font_small_book), color_text, TextAlign::TOP_CENTER, "%s", id(train_status_manhattan).state.c_str()); + it.print(330, 524, id(font_small_bold), color_text, TextAlign::TOP_CENTER, "TO CANARSIE"); + it.printf(330, 546, id(font_small_book), color_text, TextAlign::TOP_CENTER, "%s", id(train_status_canarsie).state.c_str()); it.printf(150, 576, id(font_medium_bold), color_white, TextAlign::TOP_CENTER, "%2.0f MIN", id(train_manhattan_due_in).state); it.printf(330, 576, id(font_medium_bold), color_white, TextAlign::TOP_CENTER, "%2.0f MIN", id(train_canarsie_due_in).state); From f61317ac912d1bd861463cdf8d5ba615f5f0bdf3 Mon Sep 17 00:00:00 2001 From: Madelena Mak Date: Mon, 7 Nov 2022 23:56:32 -0500 Subject: [PATCH 4/8] Disable image loading --- weatherman.yaml | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/weatherman.yaml b/weatherman.yaml index 644582a..d7469e1 100644 --- a/weatherman.yaml +++ b/weatherman.yaml @@ -126,13 +126,13 @@ font: # Include Custom Titles -image: - - file: "images/weatherman-title-train.png" - id: title_train - type: BINARY - - file: "images/weatherman-title-weather.png" - id: title_weather - type: BINARY +# image: +# - file: "images/weatherman-title-train.png" +# id: title_train +# type: BINARY +# - file: "images/weatherman-title-weather.png" +# id: title_weather +# type: BINARY # Call Subway and Weather sensors from HA From 35844d638e01937ab6853c7b6ef02b01ad363ab4 Mon Sep 17 00:00:00 2001 From: Madelena Mak Date: Mon, 7 Nov 2022 23:57:37 -0500 Subject: [PATCH 5/8] Invert colors --- weatherman.yaml | 54 ++++++++++++++++++++++++------------------------- 1 file changed, 27 insertions(+), 27 deletions(-) diff --git a/weatherman.yaml b/weatherman.yaml index d7469e1..f58aac0 100644 --- a/weatherman.yaml +++ b/weatherman.yaml @@ -407,35 +407,34 @@ display: // Fill background. // it.fill(color_bg); + // Show loading screen before data is received. if (id(initial_data_received) == false) { - // ATTENTION! - // Please adjust coordinates I have a different display! - // ATTENTION! - it.printf(0, 420, id(font_small_bold), color_white, TextAlign::TOP_CENTER, "Waiting for data..."); + it.printf(240, 390, id(font_small_bold), color_text, TextAlign::TOP_CENTER, "WAITING FOR DATA..."); } else { + // Weather Section // it.image(0, 88, id(title_weather)); it.printf(240, 84, id(font_title), color_text, TextAlign::TOP_CENTER, "WEATHER"); - it.printf(100, 158, id(font_mdi_large), color_white, TextAlign::TOP_CENTER, "%s", weather_icon_map[id(weather_condition_now).state.c_str()].c_str()); + it.printf(100, 158, id(font_mdi_large), color_text, TextAlign::TOP_CENTER, "%s", weather_icon_map[id(weather_condition_now).state.c_str()].c_str()); - it.printf(300, 158, id(font_large_bold), color_white, TextAlign::TOP_CENTER, "%2.0f°C", id(weather_temperature).state); + it.printf(300, 158, id(font_large_bold), color_text, TextAlign::TOP_CENTER, "%2.0f°C", id(weather_temperature).state); - it.printf(105, 282, id(font_small_book), color_white, TextAlign::TOP_CENTER, "%s", id(weather_timestamp_0).state.c_str()); - it.printf(105, 306, id(font_mdi_medium), color_white, TextAlign::TOP_CENTER, "%s", weather_icon_map[id(weather_condition_0).state.c_str()].c_str()); - it.printf(105, 354, id(font_small_bold), color_white, TextAlign::TOP_CENTER, "%2.0f°C", id(weather_temperature_0).state); + it.printf(105, 282, id(font_small_book), color_text, TextAlign::TOP_CENTER, "%s", id(weather_timestamp_0).state.c_str()); + it.printf(105, 306, id(font_mdi_medium), color_text, TextAlign::TOP_CENTER, "%s", weather_icon_map[id(weather_condition_0).state.c_str()].c_str()); + it.printf(105, 354, id(font_small_bold), color_text, TextAlign::TOP_CENTER, "%2.0f°C", id(weather_temperature_0).state); - it.printf(195, 282, id(font_small_book), color_white, TextAlign::TOP_CENTER, "%s", id(weather_timestamp_1).state.c_str()); - it.printf(195, 306, id(font_mdi_medium), color_white, TextAlign::TOP_CENTER, "%s", weather_icon_map[id(weather_condition_1).state.c_str()].c_str()); - it.printf(195, 354, id(font_small_bold), color_white, TextAlign::TOP_CENTER, "%2.0f°C", id(weather_temperature_1).state); + it.printf(195, 282, id(font_small_book), color_text, TextAlign::TOP_CENTER, "%s", id(weather_timestamp_1).state.c_str()); + it.printf(195, 306, id(font_mdi_medium), color_text, TextAlign::TOP_CENTER, "%s", weather_icon_map[id(weather_condition_1).state.c_str()].c_str()); + it.printf(195, 354, id(font_small_bold), color_text, TextAlign::TOP_CENTER, "%2.0f°C", id(weather_temperature_1).state); - it.printf(285, 282, id(font_small_book), color_white, TextAlign::TOP_CENTER, "%s", id(weather_timestamp_2).state.c_str()); - it.printf(285, 306, id(font_mdi_medium), color_white, TextAlign::TOP_CENTER, "%s", weather_icon_map[id(weather_condition_2).state.c_str()].c_str()); - it.printf(285, 354, id(font_small_bold), color_white, TextAlign::TOP_CENTER, "%2.0f°C", id(weather_temperature_2).state); + it.printf(285, 282, id(font_small_book), color_text, TextAlign::TOP_CENTER, "%s", id(weather_timestamp_2).state.c_str()); + it.printf(285, 306, id(font_mdi_medium), color_text, TextAlign::TOP_CENTER, "%s", weather_icon_map[id(weather_condition_2).state.c_str()].c_str()); + it.printf(285, 354, id(font_small_bold), color_text, TextAlign::TOP_CENTER, "%2.0f°C", id(weather_temperature_2).state); - it.printf(375, 282, id(font_small_book), color_white, TextAlign::TOP_CENTER, "%s", id(weather_timestamp_3).state.c_str()); - it.printf(375, 306, id(font_mdi_medium), color_white, TextAlign::TOP_CENTER, "%s", weather_icon_map[id(weather_condition_3).state.c_str()].c_str()); - it.printf(375, 354, id(font_small_bold), color_white, TextAlign::TOP_CENTER, "%2.0f°C", id(weather_temperature_3).state); + it.printf(375, 282, id(font_small_book), color_text, TextAlign::TOP_CENTER, "%s", id(weather_timestamp_3).state.c_str()); + it.printf(375, 306, id(font_mdi_medium), color_text, TextAlign::TOP_CENTER, "%s", weather_icon_map[id(weather_condition_3).state.c_str()].c_str()); + it.printf(375, 354, id(font_small_bold), color_text, TextAlign::TOP_CENTER, "%2.0f°C", id(weather_temperature_3).state); // Train Service Section // it.image(0, 420, id(title_train)); @@ -448,14 +447,15 @@ display: it.print(330, 524, id(font_small_bold), color_text, TextAlign::TOP_CENTER, "TO CANARSIE"); it.printf(330, 546, id(font_small_book), color_text, TextAlign::TOP_CENTER, "%s", id(train_status_canarsie).state.c_str()); - it.printf(150, 576, id(font_medium_bold), color_white, TextAlign::TOP_CENTER, "%2.0f MIN", id(train_manhattan_due_in).state); - it.printf(330, 576, id(font_medium_bold), color_white, TextAlign::TOP_CENTER, "%2.0f MIN", id(train_canarsie_due_in).state); - it.printf(150, 608, id(font_small_book), color_white, TextAlign::TOP_CENTER, "%s", id(train_manhattan_due_at).state.c_str()); - it.printf(330, 608, id(font_small_book), color_white, TextAlign::TOP_CENTER, "%s", id(train_canarsie_due_at).state.c_str()); + it.printf(150, 584, id(font_medium_bold), color_text, TextAlign::TOP_CENTER, "%2.0f MIN", id(train_manhattan_due_in).state); + it.printf(330, 584, id(font_medium_bold), color_text, TextAlign::TOP_CENTER, "%2.0f MIN", id(train_canarsie_due_in).state); + it.printf(150, 616, id(font_small_book), color_text, TextAlign::TOP_CENTER, "%s", id(train_manhattan_due_at).state.c_str()); + it.printf(330, 616, id(font_small_book), color_text, TextAlign::TOP_CENTER, "%s", id(train_manhattan_due_at).state.c_str()); - it.printf(150, 652, id(font_medium_bold), color_white, TextAlign::TOP_CENTER, "%2.0f MIN", id(train_manhattan_next_train_due_in).state); - it.printf(330, 652, id(font_medium_bold), color_white, TextAlign::TOP_CENTER, "%2.0f MIN", id(train_canarsie_next_train_due_in).state); - it.printf(150, 684, id(font_small_book), color_white, TextAlign::TOP_CENTER, "%s", id(train_manhattan_next_train_due_at).state.c_str()); - it.printf(330, 684, id(font_small_book), color_white, TextAlign::TOP_CENTER, "%s", id(train_canarsie_next_train_due_at).state.c_str()); + it.printf(150, 652, id(font_medium_bold), color_text, TextAlign::TOP_CENTER, "%2.0f MIN", id(train_manhattan_next_train_due_in).state); + 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()); } -captive_portal: \ No newline at end of file + +captive_portal: From d649724de84049088f42b932444a8189c215173c Mon Sep 17 00:00:00 2001 From: Madelena Mak Date: Mon, 7 Nov 2022 23:58:52 -0500 Subject: [PATCH 6/8] Use motion sensor for refreshing --- weatherman.yaml | 30 +++++++++++++++++++++++++++--- 1 file changed, 27 insertions(+), 3 deletions(-) diff --git a/weatherman.yaml b/weatherman.yaml index f58aac0..3ab0cf4 100644 --- a/weatherman.yaml +++ b/weatherman.yaml @@ -23,6 +23,7 @@ api: ota: +# Global variables for detecting if the display needs to be refreshed. (Thanks @paviro!) globals: - id: data_updated type: bool @@ -33,23 +34,35 @@ globals: restore_value: no 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: - platform: homeassistant id: homeassistant_time on_time: - - seconds: 30 + - seconds: 0 + minutes: /1 then: - if: condition: lambda: 'return id(data_updated) == true;' then: - 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 - lambda: 'id(data_updated) = false;' + else: + - logger.log: "Sensor data updated but no activity in home - skipping display refresh." else: - logger.log: "No sensors updated - skipping display refresh." + +# Wifi information wifi: ssid: !secret wifi_ssid password: !secret wifi_password @@ -135,7 +148,14 @@ font: # 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: - platform: homeassistant entity_id: sensor.gtfs_mta_subway_manhattan @@ -182,6 +202,7 @@ sensor: on_value: then: - lambda: 'id(data_updated) = true;' + - platform: homeassistant entity_id: sensor.weatherman_data attribute: weather_temperature_1 @@ -189,6 +210,7 @@ sensor: on_value: then: - lambda: 'id(data_updated) = true;' + - platform: homeassistant entity_id: sensor.weatherman_data attribute: weather_temperature_2 @@ -196,6 +218,7 @@ sensor: on_value: then: - lambda: 'id(data_updated) = true;' + - platform: homeassistant entity_id: sensor.weatherman_data attribute: weather_temperature_3 @@ -313,6 +336,7 @@ text_sensor: on_value: then: - lambda: 'id(data_updated) = true;' + - platform: homeassistant entity_id: sensor.weatherman_data attribute: train_status From 6778aee12cbc908ef15e69bd9bea3a098509b452 Mon Sep 17 00:00:00 2001 From: Madelena Mak Date: Mon, 7 Nov 2022 23:59:11 -0500 Subject: [PATCH 7/8] Add motion sensor binary sensor --- sensor.yaml | 81 ++++++++++++++++++++++++++++++----------------------- 1 file changed, 46 insertions(+), 35 deletions(-) diff --git a/sensor.yaml b/sensor.yaml index 46438ca..993c5a7 100644 --- a/sensor.yaml +++ b/sensor.yaml @@ -38,9 +38,28 @@ sensor: - "service_changes" -# Bundle up all the data to send over to Weatherman. template: + # Update screen only when occupancy is detected. + + - trigger: + platform: time_pattern + seconds: "/5" + binary_sensor: + - name: Weatherman Motion Detected + unique_id: "dfa78de7-d761-425f-9731-86f1af332eac" + device_class: "occupancy" + delay_off: 5min + state: >- + {%- if states('binary_sensor.living_room_hue_sensor_motion') == 'on' or states('binary_sensor.front_door_switchbot_contact_sensor_motion_detected') == 'on' or states('binary_sensor.kitchen_counter_motion_sensor_motion') == 'on' %} + on + {%- else -%} + off + {%- endif -%} + + + # Bundle up all the data to send over to Weatherman (ESPHome device). + - trigger: platform: time_pattern minutes: "/1" @@ -54,79 +73,71 @@ template: {{ state_attr('sensor.mta_subway_l_service_status', 'direction_statuses').north | upper }} train_status_canarsie: > {{ state_attr('sensor.mta_subway_l_service_status', 'direction_statuses').south | upper }} - + weather_condition_now: > - {% set cond_now = states('weather.hourly') %} + {% set cond_now = states('weather.valhalla_hourly') %} {% if states('sun.sun') == 'below_horizon' %} {% if cond_now == 'sunny' %} night {% elif cond_now == 'partlycloudy' %} night-partly-cloudy {% else %} {{ cond_now }} {% endif %} {% else %} {{ cond_now }} {% endif %} - + weather_condition_0: > - {% set cond0 = state_attr('weather.hourly', 'forecast')[0].condition %} + {% set cond0 = state_attr('weather.valhalla_hourly', 'forecast')[0].condition %} {% 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.hourly', 'forecast')[0].datetime) %} - {% if states('sun.sun') == 'above_horizon' and cond0_time > next_setting %} - {% if cond0 == 'sunny' %} night {% elif cond0 == 'partlycloudy' %} night-partly-cloudy {% else %} {{ cond0 }} {% endif %} - {% elif states('sun.sun') == 'below_horizon' and cond0_time < 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 == 'sunny' %} night {% elif cond0 == 'partlycloudy' %} night-partly-cloudy {% else %} {{ cond0 }} {% endif %} {% else %} {{ cond0 }} {% endif %} weather_temperature_0: > - {{ state_attr('weather.hourly', 'forecast')[0].temperature | round }} + {{ state_attr('weather.valhalla_hourly', 'forecast')[0].temperature | round }} weather_timestamp_0: > - {{ as_timestamp(state_attr('weather.hourly', 'forecast')[0].datetime) | timestamp_custom('%I') | int }} {{ as_timestamp(state_attr('weather.hourly', 'forecast')[0].datetime) | timestamp_custom('%p') }} - + {{ as_timestamp(state_attr('weather.valhalla_hourly', 'forecast')[0].datetime) | timestamp_custom('%I') | int }} {{ as_timestamp(state_attr('weather.valhalla_hourly', 'forecast')[0].datetime) | timestamp_custom('%p') }} + weather_condition_1: > - {% set cond1 = state_attr('weather.hourly', 'forecast')[1].condition %} + {% set cond1 = state_attr('weather.valhalla_hourly', 'forecast')[1].condition %} {% 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.hourly', 'forecast')[1].datetime) %} - {% if states('sun.sun') == 'above_horizon' and cond1_time > next_setting %} - {% if cond1 == 'sunny' %} night {% elif cond1 == 'partlycloudy' %} night-partly-cloudy {% else %} {{ cond1 }} {% endif %} - {% elif states('sun.sun') == 'below_horizon' and cond1_time < 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 == 'sunny' %} night {% elif cond1 == 'partlycloudy' %} night-partly-cloudy {% else %} {{ cond1 }} {% endif %} {% else %} {{ cond1 }} {% endif %} weather_temperature_1: > - {{ state_attr('weather.hourly', 'forecast')[1].temperature | round }} + {{ state_attr('weather.valhalla_hourly', 'forecast')[1].temperature | round }} weather_timestamp_1: > - {{ as_timestamp(state_attr('weather.hourly', 'forecast')[1].datetime) | timestamp_custom('%I') | int }} {{ as_timestamp(state_attr('weather.hourly', 'forecast')[1].datetime) | timestamp_custom('%p') }} - + {{ as_timestamp(state_attr('weather.valhalla_hourly', 'forecast')[1].datetime) | timestamp_custom('%I') | int }} {{ as_timestamp(state_attr('weather.valhalla_hourly', 'forecast')[1].datetime) | timestamp_custom('%p') }} + weather_condition_2: > - {% set cond2 = state_attr('weather.hourly', 'forecast')[2].condition %} + {% set cond2 = state_attr('weather.valhalla_hourly', 'forecast')[2].condition %} {% 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.hourly', 'forecast')[2].datetime) %} - {% if states('sun.sun') == 'above_horizon' and cond2_time > next_setting %} - {% if cond2 == 'sunny' %} night {% elif cond2 == 'partlycloudy' %} night-partly-cloudy {% else %} {{ cond2 }} {% endif %} - {% elif states('sun.sun') == 'below_horizon' and cond2_time < 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 == 'sunny' %} night {% elif cond2 == 'partlycloudy' %} night-partly-cloudy {% else %} {{ cond2 }} {% endif %} {% else %} {{ cond2 }} {% endif %} weather_temperature_2: > - {{ state_attr('weather.hourly', 'forecast')[2].temperature | round }} + {{ state_attr('weather.valhalla_hourly', 'forecast')[2].temperature | round }} weather_timestamp_2: > - {{ as_timestamp(state_attr('weather.hourly', 'forecast')[2].datetime) | timestamp_custom('%I') | int }} {{ as_timestamp(state_attr('weather.hourly', 'forecast')[2].datetime) | timestamp_custom('%p') }} - + {{ as_timestamp(state_attr('weather.valhalla_hourly', 'forecast')[2].datetime) | timestamp_custom('%I') | int }} {{ as_timestamp(state_attr('weather.valhalla_hourly', 'forecast')[2].datetime) | timestamp_custom('%p') }} + weather_condition_3: > - {% set cond3 = state_attr('weather.hourly', 'forecast')[3].condition %} + {% set cond3 = state_attr('weather.valhalla_hourly', 'forecast')[3].condition %} {% 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.hourly', 'forecast')[3].datetime) %} - {% if states('sun.sun') == 'above_horizon' and cond3_time > next_setting %} - {% if cond3 == 'sunny' %} night {% elif cond3 == 'partlycloudy' %} night-partly-cloudy {% else %} {{ cond3 }} {% endif %} - {% elif states('sun.sun') == 'below_horizon' and cond3_time < 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 == 'sunny' %} night {% elif cond3 == 'partlycloudy' %} night-partly-cloudy {% else %} {{ cond3 }} {% endif %} {% else %} {{ cond3 }} {% endif %} weather_temperature_3: > - {{ state_attr('weather.hourly', 'forecast')[3].temperature | round }} + {{ state_attr('weather.valhalla_hourly', 'forecast')[3].temperature | round }} weather_timestamp_3: > - {{ as_timestamp(state_attr('weather.hourly', 'forecast')[3].datetime) | timestamp_custom('%I') | int }} {{ as_timestamp(state_attr('weather.hourly', 'forecast')[3].datetime) | timestamp_custom('%p') }} + {{ as_timestamp(state_attr('weather.valhalla_hourly', 'forecast')[3].datetime) | timestamp_custom('%I') | int }} {{ as_timestamp(state_attr('weather.valhalla_hourly', 'forecast')[3].datetime) | timestamp_custom('%p') }} From 357dc80432dbddf138e858d05b782c5ca07e574a Mon Sep 17 00:00:00 2001 From: Madelena Mak Date: Mon, 7 Nov 2022 23:59:28 -0500 Subject: [PATCH 8/8] Formatting fix --- weatherman.yaml | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/weatherman.yaml b/weatherman.yaml index 3ab0cf4..b1a9bc4 100644 --- a/weatherman.yaml +++ b/weatherman.yaml @@ -384,13 +384,14 @@ spi: # Now render everything on the ePaper screen. display: - platform: waveshare_epaper + id: eink_display cs_pin: GPIO15 dc_pin: GPIO27 busy_pin: GPIO25 reset_pin: GPIO26 + reset_duration: 2ms model: 7.50inV2 update_interval: never - id: eink_display rotation: 90° lambda: |- // Map weather states to MDI characters.