Created
August 1, 2022 10:10
-
-
Save chunkysteveo/c9468b4e4d4ca87ef7093fd400514c8a to your computer and use it in GitHub Desktop.
Badgy 02 Weather - Vertical
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| substitutions: | |
| display_name: 'EPaper Display Badgy 02' | |
| device_description: 'EPaper Display Badgy 01. The Blue one!' | |
| friendly_name: 'EPaper Display Badgy 02' # displayed in HA.. Whatever name you'd like | |
| device_name: epaper-display-02 | |
| node_name: epaper_display_02 | |
| esphome: | |
| name: ${device_name} | |
| comment: ${device_description} | |
| platform: ESP8266 | |
| board: nodemcuv2 | |
| on_boot: | |
| - priority: -100.0 | |
| then: | |
| - script.execute: deep_sleep_evaluation | |
| - priority: 800.0 | |
| then: | |
| # - component.update: ${node_name}_uptime_raw | |
| - component.update: wifisignal | |
| #- component.update: epaper # Don't do this - seems to crash it? Reset Pin? | |
| # - priority: -100.0 | |
| # then: | |
| # - component.update: epaper | |
| # Enable logging | |
| logger: | |
| # Enable Home Assistant API | |
| api: | |
| # encryption: | |
| # key: "RCTqKVg4GhXDzd18GtYK4G3IWC4brgJXI4Pi+Q1UNi8=" | |
| ota: | |
| password: "caf76e73df5608b7facc075639985e97" | |
| safe_mode: true | |
| reboot_timeout: 10min | |
| num_attempts: 5 | |
| wifi: | |
| ssid: !secret wifi_ssid | |
| password: !secret wifi_password | |
| # Enable fallback hotspot (captive portal) in case wifi connection fails | |
| ap: | |
| ssid: "Epaper-Display-02" | |
| password: "IhPmXwynEjxf" | |
| captive_portal: | |
| #web_server: | |
| # port: 80 | |
| deep_sleep: | |
| id: deep_sleep_enabled | |
| #run_duration: 30sec # move this value to -delay- deep_sleep_evaluation script parameter | |
| sleep_duration: 10min | |
| time: | |
| - platform: homeassistant | |
| id: homeassistant_time | |
| # on_time: | |
| # Every 1 minutes | |
| # - seconds: 0 | |
| # then: | |
| # - component.update: epaper | |
| script: | |
| - id: deep_sleep_evaluation | |
| mode: queued | |
| then: | |
| - delay: 30s | |
| - if: | |
| condition: | |
| binary_sensor.is_on: disable_deep_sleep | |
| then: | |
| - logger.log: 'Deep Sleep Disabled' | |
| else: | |
| - deep_sleep.enter: deep_sleep_enabled | |
| - script.execute: deep_sleep_evaluation | |
| #light: | |
| # - platform: status_led | |
| # name: ${display_name} Onboard LED | |
| # pin: | |
| # number: GPIO2 | |
| # inverted: true | |
| text_sensor: | |
| - platform: wifi_info | |
| ip_address: | |
| name: ${display_name} IP Address | |
| ssid: | |
| name: ${display_name} Connected SSID | |
| bssid: | |
| name: ${display_name} Connected BSSID | |
| # - platform: template | |
| # name: ${friendly_name} Uptime | |
| # id: ${node_name}_uptime | |
| # icon: mdi:clock-start | |
| - platform: homeassistant | |
| entity_id: weather.home_hourly | |
| id: weather_state | |
| - platform: homeassistant | |
| entity_id: sensor.weatherman_data | |
| attribute: weather_condition_now | |
| id: weather_condition_now | |
| - platform: homeassistant | |
| entity_id: sensor.weatherman_data | |
| attribute: weather_condition_0 | |
| id: weather_condition_0 | |
| - platform: homeassistant | |
| entity_id: sensor.weatherman_data | |
| attribute: weather_timestamp_0 | |
| id: weather_timestamp_0 | |
| - platform: homeassistant | |
| entity_id: sensor.weatherman_data | |
| attribute: weather_condition_1 | |
| id: weather_condition_1 | |
| - platform: homeassistant | |
| entity_id: sensor.weatherman_data | |
| attribute: weather_timestamp_1 | |
| id: weather_timestamp_1 | |
| - platform: homeassistant | |
| entity_id: sensor.weatherman_data | |
| attribute: weather_condition_2 | |
| id: weather_condition_2 | |
| - platform: homeassistant | |
| entity_id: sensor.weatherman_data | |
| attribute: weather_timestamp_2 | |
| id: weather_timestamp_2 | |
| - platform: homeassistant | |
| entity_id: sensor.weatherman_data | |
| attribute: weather_condition_3 | |
| id: weather_condition_3 | |
| - platform: homeassistant | |
| entity_id: sensor.weatherman_data | |
| attribute: weather_timestamp_3 | |
| id: weather_timestamp_3 | |
| binary_sensor: | |
| - platform: homeassistant | |
| id: disable_deep_sleep | |
| entity_id: input_boolean.disable_deep_sleep | |
| - platform: status | |
| name: ${display_name} Status | |
| - platform: gpio | |
| pin: | |
| number: GPIO3 | |
| mode: INPUT_PULLUP | |
| inverted: true | |
| name: ${display_name} SW LEFT | |
| filters: | |
| - delayed_on: 10ms | |
| #on_press: | |
| # then: | |
| # - logger.log: "SW UP" | |
| - platform: gpio | |
| pin: | |
| number: GPIO1 | |
| mode: INPUT_PULLUP | |
| inverted: true | |
| name: ${display_name} SW DOWN | |
| filters: | |
| - delayed_on: 10ms | |
| - platform: gpio | |
| pin: | |
| number: GPIO10 | |
| mode: INPUT_PULLUP | |
| inverted: true | |
| name: ${display_name} SW UP | |
| filters: | |
| - delayed_on: 10ms | |
| - platform: gpio | |
| pin: | |
| number: GPIO12 | |
| mode: INPUT_PULLUP | |
| inverted: true | |
| name: ${display_name} SW RIGHT | |
| filters: | |
| - delayed_on: 10ms | |
| - platform: gpio | |
| pin: | |
| number: GPIO5 | |
| mode: INPUT_PULLUP | |
| inverted: true | |
| name: ${display_name} SW CENTRE | |
| filters: | |
| - delayed_on: 10ms | |
| sensor: | |
| - platform: wifi_signal | |
| name: ${display_name} WiFi Singal Strength | |
| id: wifisignal | |
| update_interval: 120s | |
| # - platform: uptime | |
| # name: "${friendly_name} Uptime Sensor" | |
| # id: ${node_name}_uptime_raw | |
| # update_interval: 60s | |
| # on_raw_value: | |
| # then: | |
| # - logger.log: | |
| # format: "Raw Value of Uptime sensor: %f, %f" | |
| # args: ['id(${node_name}_uptime_raw).raw_state', 'id(${node_name}_uptime_raw).state'] | |
| # level: INFO | |
| # - text_sensor.template.publish: | |
| # id: ${node_name}_uptime | |
| # state: !lambda |- | |
| # int seconds = round(id(${node_name}_uptime_raw).raw_state); | |
| # int days = seconds / (24 * 3600); | |
| # seconds = seconds % (24 * 3600); | |
| # int hours = seconds / 3600; | |
| # seconds = seconds % 3600; | |
| # int minutes = seconds / 60; | |
| # seconds = seconds % 60; | |
| # return ( | |
| # (days ? String(days) + "d " : "") + | |
| # (hours ? String(hours) + "h " : "") + | |
| # (minutes ? String(minutes) + "m " : "") + | |
| # (String(seconds) + "s") | |
| # ).c_str(); | |
| - platform: homeassistant | |
| entity_id: weather.home_hourly | |
| attribute: temperature | |
| id: weather_temperature | |
| on_value: | |
| then: | |
| - component.update: epaper | |
| - platform: homeassistant | |
| entity_id: sensor.weatherman_data | |
| attribute: weather_temperature_0 | |
| id: weather_temperature_0 | |
| - platform: homeassistant | |
| entity_id: sensor.weatherman_data | |
| attribute: weather_temperature_1 | |
| id: weather_temperature_1 | |
| - platform: homeassistant | |
| entity_id: sensor.weatherman_data | |
| attribute: weather_temperature_2 | |
| id: weather_temperature_2 | |
| - platform: homeassistant | |
| entity_id: sensor.weatherman_data | |
| attribute: weather_temperature_3 | |
| id: weather_temperature_3 | |
| button: | |
| - platform: restart | |
| name: ${display_name} Restart | |
| # Include custom fonts | |
| font: | |
| - file: 'fonts/GothamRnd-Bold.ttf' | |
| id: font_tiny_bold | |
| size: 12 | |
| - file: 'fonts/GothamRnd-Bold.ttf' | |
| id: font_large_bold | |
| size: 42 | |
| glyphs: [' ', '°', '0', '1', '2', '3', '4', '5', '6', '7', '8', '9', 'C'] | |
| - file: 'fonts/GothamRnd-Bold.ttf' | |
| id: font_medium_bold | |
| size: 30 | |
| # glyphs: [' ', '0', '1', '2', '3', '4', '5', '6', '7', '8', '9', 'M', 'I', 'N'] | |
| - file: 'fonts/GothamRnd-Bold.ttf' | |
| id: font_small_bold | |
| 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' | |
| id: font_mdi_large | |
| size: 100 | |
| glyphs: &mdi-weather-glyphs | |
| - "\U000F0590" # mdi-weather-cloudy | |
| - "\U000F0F2F" # mdi-weather-cloudy-alert | |
| - "\U000F0E6E" # mdi-weather-cloudy-arrow-right | |
| - "\U000F0591" # mdi-weather-fog | |
| - "\U000F0592" # mdi-weather-hail | |
| - "\U000F0F30" # mdi-weather-hazy | |
| - "\U000F0898" # mdi-weather-hurricane | |
| - "\U000F0593" # mdi-weather-lightning | |
| - "\U000F067E" # mdi-weather-lightning-rainy | |
| - "\U000F0594" # mdi-weather-night | |
| - "\U000F0F31" # mdi-weather-night-partly-cloudy | |
| - "\U000F0595" # mdi-weather-partly-cloudy | |
| - "\U000F0F32" # mdi-weather-partly-lightning | |
| - "\U000F0F33" # mdi-weather-partly-rainy | |
| - "\U000F0F34" # mdi-weather-partly-snowy | |
| - "\U000F0F35" # mdi-weather-partly-snowy-rainy | |
| - "\U000F0596" # mdi-weather-pouring | |
| - "\U000F0597" # mdi-weather-rainy | |
| - "\U000F0598" # mdi-weather-snowy | |
| - "\U000F0F36" # mdi-weather-snowy-heavy | |
| - "\U000F067F" # mdi-weather-snowy-rainy | |
| - "\U000F0599" # mdi-weather-sunny | |
| - "\U000F0F37" # mdi-weather-sunny-alert | |
| - "\U000F14E4" # mdi-weather-sunny-off | |
| - "\U000F059A" # mdi-weather-sunset | |
| - "\U000F059B" # mdi-weather-sunset-down | |
| - "\U000F059C" # mdi-weather-sunset-up | |
| - "\U000F0F38" # mdi-weather-tornado | |
| - "\U000F059D" # mdi-weather-windy | |
| - "\U000F059E" # mdi-weather-windy-variant | |
| - file: 'fonts/materialdesignicons-webfont.ttf' | |
| id: font_mdi_medium | |
| size: 36 | |
| glyphs: *mdi-weather-glyphs | |
| # Define colors | |
| # This design is white on black so this is necessary. | |
| color: | |
| - id: color_black | |
| red: 0% | |
| green: 0% | |
| blue: 0% | |
| white: 0% | |
| - id: color_white | |
| red: 0% | |
| green: 0% | |
| blue: 0% | |
| white: 100% | |
| spi: | |
| clk_pin: GPIO14 | |
| mosi_pin: GPIO13 #DIN | |
| display: | |
| - platform: waveshare_epaper | |
| id: epaper | |
| cs_pin: GPIO15 | |
| dc_pin: GPIO0 | |
| busy_pin: GPIO4 | |
| reset_pin: GPIO2 | |
| model: 2.90in | |
| #296*128 | |
| #rotation: 180° | |
| #full_update_every: 1 | |
| update_interval: 6min | |
| lambda: |- | |
| // Map weather states to MDI characters. | |
| std::map<std::string, std::string> weather_icon_map | |
| { | |
| {"cloudy", "\U000F0590"}, | |
| {"cloudy-alert", "\U000F0F2F"}, | |
| {"cloudy-arrow-right", "\U000F0E6E"}, | |
| {"fog", "\U000F0591"}, | |
| {"hail", "\U000F0592"}, | |
| {"hazy", "\U000F0F30"}, | |
| {"hurricane", "\U000F0898"}, | |
| {"lightning", "\U000F0593"}, | |
| {"lightning-rainy", "\U000F067E"}, | |
| {"night", "\U000F0594"}, | |
| {"night-partly-cloudy", "\U000F0F31"}, | |
| {"partlycloudy", "\U000F0595"}, | |
| {"partly-lightning", "\U000F0F32"}, | |
| {"partly-rainy", "\U000F0F33"}, | |
| {"partly-snowy", "\U000F0F34"}, | |
| {"partly-snowy-rainy", "\U000F0F35"}, | |
| {"pouring", "\U000F0596"}, | |
| {"rainy", "\U000F0597"}, | |
| {"snowy", "\U000F0598"}, | |
| {"snowy-heavy", "\U000F0F36"}, | |
| {"snowy-rainy", "\U000F067F"}, | |
| {"sunny", "\U000F0599"}, | |
| {"sunny-alert", "\U000F0F37"}, | |
| {"sunny-off", "\U000F14E4"}, | |
| {"sunset", "\U000F059A"}, | |
| {"sunset-down", "\U000F059B"}, | |
| {"sunset-up", "\U000F059C"}, | |
| {"tornado", "\U000F0F38"}, | |
| {"windy", "\U000F059D"}, | |
| {"windy-variant", "\U000F059E"}, | |
| }; | |
| // Fill background in black. | |
| //it.fill(color_black); | |
| if(id(weather_temperature).has_state()) { | |
| it.printf(64, 0, id(font_mdi_large), color_white, TextAlign::TOP_CENTER, "%s", weather_icon_map[id(weather_condition_now).state.c_str()].c_str()); | |
| it.printf(64, 95, id(font_large_bold), color_white, TextAlign::TOP_CENTER, "%2.0f°C", id(weather_temperature).state); | |
| it.printf(32, 140, id(font_tiny_bold), color_white, TextAlign::TOP_CENTER, "%s", id(weather_timestamp_0).state.c_str()); | |
| it.printf(32, 155, id(font_mdi_medium), color_white, TextAlign::TOP_CENTER, "%s", weather_icon_map[id(weather_condition_0).state.c_str()].c_str()); | |
| it.printf(32, 190, id(font_small_bold), color_white, TextAlign::TOP_CENTER, "%2.0f°C", id(weather_temperature_0).state); | |
| it.printf(96, 140, id(font_tiny_bold), color_white, TextAlign::TOP_CENTER, "%s", id(weather_timestamp_1).state.c_str()); | |
| it.printf(96, 155, id(font_mdi_medium), color_white, TextAlign::TOP_CENTER, "%s", weather_icon_map[id(weather_condition_1).state.c_str()].c_str()); | |
| it.printf(96, 190, id(font_small_bold), color_white, TextAlign::TOP_CENTER, "%2.0f°C", id(weather_temperature_1).state); | |
| it.printf(32, 215, id(font_tiny_bold), color_white, TextAlign::TOP_CENTER, "%s", id(weather_timestamp_2).state.c_str()); | |
| it.printf(32, 230, id(font_mdi_medium), color_white, TextAlign::TOP_CENTER, "%s", weather_icon_map[id(weather_condition_2).state.c_str()].c_str()); | |
| it.printf(32, 265, id(font_small_bold), color_white, TextAlign::TOP_CENTER, "%2.0f°C", id(weather_temperature_2).state); | |
| it.printf(96, 215, id(font_tiny_bold), color_white, TextAlign::TOP_CENTER, "%s", id(weather_timestamp_3).state.c_str()); | |
| it.printf(96, 230, id(font_mdi_medium), color_white, TextAlign::TOP_CENTER, "%s", weather_icon_map[id(weather_condition_3).state.c_str()].c_str()); | |
| it.printf(96, 265, id(font_small_bold), color_white, TextAlign::TOP_CENTER, "%2.0f°C", id(weather_temperature_3).state); | |
| } | |
| #interval: | |
| # - interval: 5s | |
| # then: | |
| # - display.page.show_next: epaper | |
| # - component.update: epaper | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment