-
Notifications
You must be signed in to change notification settings - Fork 29
/
display_weather.yaml
115 lines (104 loc) · 3.52 KB
/
display_weather.yaml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
# This is ESPHome configuration file. This goes to the esphome folder
# You need to provide your WiFi ssis/password and passwords for API and OTA (or put them in your esphome/secrets.yaml)
esphome:
name: display_weather
platform: ESP8266
board: d1_mini_pro
wifi:
ssid: !secret wifi_ssid
password: !secret wifi_password
fast_connect: true
api:
password: !secret api_password
ota:
password: !secret ota_password
logger:
baud_rate: 0 # Disable UART logging (pins GPIO1/3 are used for Nextion communication)
uart:
rx_pin: D1
tx_pin: D2
baud_rate: 115200
time:
- platform: sntp
id: sntp_time
sensor:
- platform: homeassistant
id: sun_elevation
entity_id: sensor.sun_elevation
- platform: homeassistant # Inside temperature
id: temperature_inside
entity_id: sensor.temperature_inside
- platform: homeassistant # Outside temperature
id: temperature_outside
entity_id: sensor.temperature_outside
- platform: homeassistant # Swimming pool
id: temperature_pool
entity_id: sensor.temperature_pool
- 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: binary_sensor.somebody_home
globals:
- id: first_page # First page of the display?
type: bool
restore_value: no
- id: current_brightness # Is display on?
type: float
restore_value: no
initial_value: '-1.0'
display:
- platform: nextion
id: teplomer
update_interval: 5s
lambda: |-
// Turn display on when somebody is home. Only update when display on.
float br;
if (id(somebody_home).state) {
if (id(sun_elevation).state > 0) {
// Full brightness during the day
br=1.0;
} else {
// 50 percent at night
br=0.5;
}
// 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.
br=0.0;
}
// Change brightnes if it needs to be changed
if (id(current_brightness)!=br) {
it.set_backlight_brightness(br);
id(current_brightness)=br;
}