-
Notifications
You must be signed in to change notification settings - Fork 2
/
display-trial.yaml
183 lines (155 loc) · 5.01 KB
/
display-trial.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
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
substitutions: #substitute your own values in this section
device_name: display-trial
static_ip: 192.168.1.245
gateway: 192.168.1.1
subnet: 255.255.255.0
internal_temp_sensor: sensor.air_quality_meter_temperature #entity from Home Assistant
outside_temp_sensor: sensor.outside_temperature #entity from Home Assistant
weather_entity: weather.smhi_home #entity from Home Assistant
todays_forecast_high_entity: sensor.todays_forecast_high #entity from Home Assistant
todays_forecast_low_entity: sensor.todays_forecast_low #entity from Home Assistant
sda_pin: D3
scl_pin: D4
#---------------------------------------------------------------------------------------------
esphome:
name: '${device_name}'
platform: ESP8266
board: d1_mini
wifi:
ssid: !secret wifi_ssid
password: !secret wifi_password
manual_ip:
static_ip: $static_ip
gateway: $gateway
subnet: $subnet
# Enable fallback hotspot (captive portal) in case wifi connection fails
ap:
ssid: '${device_name}'
password: !secret fallback_password
# Enable logging
logger:
# Enable Home Assistant API
api:
password: !secret esphome_api_password
ota:
safe_mode: true
reboot_timeout: 10min
num_attempts: 5
captive_portal:
web_server:
port: 80
auth:
username: !secret esphome_web_username
password: !secret esphome_web_password
time:
- platform: homeassistant
id: esptime
binary_sensor:
- platform: status
name: "Display Status"
sensor:
- platform: homeassistant
id: inside_temperature
entity_id: $internal_temp_sensor
internal: true
- platform: homeassistant
id: outside_temperature
entity_id: $outside_temp_sensor
internal: true
- platform: homeassistant
id: todays_forecast_high
entity_id: $todays_forecast_high_entity
internal: true
- platform: homeassistant
id: todays_forecast_low
entity_id: $todays_forecast_low_entity
internal: true
text_sensor:
- platform: homeassistant
id: weather_state
name: "Current Weather Icon"
entity_id: $weather_entity
internal: true
font:
- file: 'SourceSansPro-Light.ttf'
id: font1
size: 16
- file: 'SourceSansPro-Light.ttf'
id: font2
size: 26
- file: 'materialdesignicons-webfont.ttf'
id: font3
size: 18
glyphs:
- "\U000F13D5" #mdi:home-minus-outline
- file: 'materialdesignicons-webfont.ttf'
id: font4
size: 40
glyphs:
- "\U000F0594" #"clear-night"
- "\U000F0590" #"cloudy"
- "\U000F0591" #"fog"
- "\U000F0592" #"hail"
- "\U000F0593" #"lightning"
- "\U000F067E" #"lightning-rainy"
- "\U000F0595" #"partlycloudy"
- "\U000F0596" #"pouring"
- "\U000F0597" #"rainy"
- "\U000F0598" #"snowy"
- "\U000F067F" #"snowy-rainy"
- "\U000F0599" #"sunny"
- "\U000F059D" #"windy"
- "\U000F059E" #"windy-variant"
i2c:
sda: $sda_pin
scl: $scl_pin
scan: false
display:
- platform: ssd1306_i2c
model: "SSD1306 128x64"
reset_pin: D0
address: 0x3C
lambda: |-
if (id(weather_state).has_state()) {
std::map<std::string, std::string> weather_icon_map
{
{"clear-night", "\U000F0594"},
{"cloudy", "\U000F0590"},
{"fog", "\U000F0591"},
{"hail", "\U000F0592"},
{"lightning", "\U000F0593"},
{"lightning-rainy", "\U000F067E"},
{"partlycloudy", "\U000F0595"},
{"pouring", "\U000F0596"},
{"rainy", "\U000F0597"},
{"snowy", "\U000F0598"},
{"snowy-rainy", "\U000F067F"},
{"sunny", "\U000F0599"},
{"windy", "\U000F059D"},
{"windy-variant", "\U000F059E"},
};
it.printf(0, it.get_height(), id(font4), TextAlign::BASELINE_LEFT, weather_icon_map[id(weather_state).state.c_str()].c_str());
}
// Print time in HH:MM format
it.strftime(0, 0, id(font1), TextAlign::TOP_LEFT, "%H:%M %a", id(esptime).now());
//Print day of week
//it.strftime(40, 0, id(font1), TextAlign::TOP_LEFT, "%a", id(esptime).now());
it.line(0, 20, it.get_width(), 20);
//Print home icon
//it.printf(70, 0, id(font3), "\U000F13D5");
// Print inside temperature (from homeassistant sensor)
if (id(inside_temperature).has_state()) {
it.printf(it.get_width(), 0, id(font1), TextAlign::TOP_RIGHT , "%7.1f°", id(inside_temperature).state);
}
// Print outside temperature (from homeassistant sensor)
if (id(outside_temperature).has_state()) {
it.printf(42, 32, id(font2), "%.1f°", id(outside_temperature).state);
}
// Print Forecast High
if (id(todays_forecast_high).has_state()) {
it.printf(it.get_width(), 32, id(font1), TextAlign::TOP_RIGHT, "%7.1f°", id(todays_forecast_high).state);
}
// Print Forecast Low
if (id(todays_forecast_low).has_state()) {
it.printf(it.get_width(), 48, id(font1), TextAlign::TOP_RIGHT, "%7.1f°", id(todays_forecast_low).state);
}