Hi, I tried this project, but I can’t really get it to work properly.
This display works, if I change the brightness in the code, the brightness of my display changes, but it’s not receiving any (weather) data, though the HA sensors do have data.
My configs:
esphome:
esphome:
name: esp_weather01
platform: ESP8266
board: d1_mini
wifi:
ssid: !secret esphome_wifi_ssid
password: !secret esphome_wifi_password
api:
password: !secret esphome_api_password
ota:
password: !secret esphome_ota_password
web_server:
port: 80
logger:
baud_rate: 0 # Disable UART logging (pins GPIO1/3 are used for Nextion communication)
uart:
rx_pin: D1
tx_pin: D2
baud_rate: 9600
time:
- platform: sntp
id: sntp_time
sensor:
- platform: homeassistant # Inside temperature
id: temperature_inside
entity_id: sensor.woonkamer_temperatuur
- platform: homeassistant # Outside temperature
id: temperature_outside
entity_id: sensor.nefit_outdoor_temperature
- platform: homeassistant # Swimming pool
id: temperature_pool
entity_id: sensor.hue_outdoor_sensor_carport_temperature
- platform: homeassistant # Forecast minimal temperature
id: today_min
entity_id: sensor.today_min
- platform: homeassistant # Forecast maximal temperature
id: today_max
entity_id: sensor.today_max
- platform: homeassistant # Forecast precipitation
id: today_rain
entity_id: sensor.today_rain
- platform: homeassistant # Forecast icon
id: today_icon
entity_id: sensor.today_icon
binary_sensor:
- platform: homeassistant
id: somebody_home
entity_id: sensor.anybody_home_binary
globals:
- id: first_page # First page of the display?
type: bool
restore_value: no
- id: display_on # Is display on?
type: bool
restore_value: no
display:
- platform: nextion
id: teplomer
update_interval: 5s
lambda: |-
// Turn display on when somebody is home. Only update when display on.
if (id(somebody_home).state) {
if (!id(display_on)) {
it.set_backlight_brightness(50);
id(display_on)=true;
}
// Swich first/second page on each update (every 5 seconds)
if (id(first_page)) {
it.goto_page("forecast");
it.send_command_printf("%s.pic=%.0f", "weather",id(today_icon).state);
it.set_component_text_printf("minmax","%.0f/%.0f",id(today_min).state,id(today_max).state);
if (isnan(id(today_rain).state)) {
it.set_component_text("rain","-");
} else {
it.set_component_text_printf("rain","%.0f",id(today_rain).state);
}
auto time = id(sntp_time).now();
it.set_component_text_printf("hour","%02d",time.hour);
it.set_component_text_printf("minute","%02d",time.minute);
} else {
it.goto_page("temperature");
it.set_component_text_printf("inside","%2.1f",id(temperature_inside).state);
it.set_component_text_printf("outside","%2.1f",id(temperature_outside).state);
it.set_component_text_printf("pool","%2.1f",id(temperature_pool).state);
}
id(first_page) = !id(first_page); // Switch page
} else {
// Turn off the display if nobody is home.
if (id(display_on)) {
it.set_backlight_brightness(0);
id(display_on)=false;
}
}
HA:
weather:
- platform: darksky
api_key: !secret darksky_api_key
mode: daily
sensor:
######## darksky #########
- platform: darksky
api_key: !secret darksky_api_key
monitored_conditions:
- precip_probability
- precip_intensity
- precip_intensity_max
- nearest_storm_distance
- nearest_storm_bearing
- temperature
- apparent_temperature_high
- temperature_high
- platform: template
sensors:
sun_elevation:
friendly_name: "Sun Elevation"
unit_of_measurement: 'degrees'
value_template: "{{ state_attr('sun.sun', 'elevation') }}"
- platform: template
sensors:
today_min:
value_template: "{{ state_attr('weather.dark_sky','forecast')[0].templow | default('0') }}"
friendly_name: Today's maximal temperature
today_max:
value_template: "{{ state_attr('weather.dark_sky','forecast')[0].temperature | default('0') }}"
friendly_name: Today's minimal temperature
today_rain:
value_template: "{{ state_attr('weather.dark_sky','forecast')[0].precipitation | default('0') }}"
friendly_name: Today's rain forecast
today_icon:
value_template: >-
{% if state_attr("weather.dark_sky","forecast")[0].condition =='clear-night' %}
3
{% elif state_attr("weather.dark_sky","forecast")[0].condition =='cloudy' %}
5
{% elif state_attr("weather.dark_sky","forecast")[0].condition =='fog' %}
16
{% elif state_attr("weather.dark_sky","forecast")[0].condition =='hail' %}
6
{% elif state_attr("weather.dark_sky","forecast")[0].condition =='lightning' %}
13
{% elif state_attr("weather.dark_sky","forecast")[0].condition =='lightning-rainy' %}
17
{% elif state_attr("weather.dark_sky","forecast")[0].condition =='partlycloudy' %}
8
{% elif state_attr("weather.dark_sky","forecast")[0].condition =='pouring' %}
18
{% elif state_attr("weather.dark_sky","forecast")[0].condition =='rainy' %}
9
{% elif state_attr("weather.dark_sky","forecast")[0].condition =='snowy' %}
11
{% elif state_attr("weather.dark_sky","forecast")[0].condition =='snowy-rainy' %}
7
{% elif state_attr("weather.dark_sky","forecast")[0].condition =='windy' %}
14
{% elif state_attr("weather.dark_sky","forecast")[0].condition =='windy-variant' %}
14
{% else %}
12
{% endif %}
friendly_name: Today weather forecast