Add Wi-Fi roaming and connection status display
This commit is contained in:
@@ -22,10 +22,18 @@ network:
|
||||
enable_ipv6: true
|
||||
|
||||
wifi:
|
||||
ssid: "Voltage-legacy"
|
||||
networks:
|
||||
- ssid: "Voltage-legacy"
|
||||
password: !secret voltage_legacy_psk
|
||||
priority: 10
|
||||
- ssid: "Moppelkotze"
|
||||
password: !secret moppelkotze_psk
|
||||
priority: 5
|
||||
on_connect:
|
||||
- lambda: id(wifi_connected) = true;
|
||||
on_disconnect:
|
||||
- lambda: id(wifi_connected) = false;
|
||||
power_save_mode: high
|
||||
fast_connect: on
|
||||
min_auth_mode: WPA2
|
||||
ap:
|
||||
ssid: "Energymonitor Fallback Hotspot"
|
||||
@@ -92,6 +100,25 @@ display:
|
||||
lambda: |-
|
||||
it.fill(Color::BLACK);
|
||||
|
||||
// Four bars show RSSI quality; a crossed outline means Wi-Fi is disconnected.
|
||||
if (id(wifi_connected)) {
|
||||
int bars = 1;
|
||||
if (id(wifi_rssi).has_state()) {
|
||||
const float rssi = id(wifi_rssi).state;
|
||||
bars = rssi >= -55 ? 4 : rssi >= -67 ? 3 : rssi >= -75 ? 2 : 1;
|
||||
}
|
||||
for (int index = 0; index < 4; index++) {
|
||||
const int height = 5 + index * 5;
|
||||
const Color color = index < bars ? Color(64, 255, 64) : Color(48, 48, 48);
|
||||
it.filled_rectangle(290 + index * 5, 30 - height, 3, height, color);
|
||||
}
|
||||
} else {
|
||||
const Color disconnected_color = Color(255, 80, 80);
|
||||
it.rectangle(290, 10, 19, 19, disconnected_color);
|
||||
it.line(290, 10, 308, 28, disconnected_color);
|
||||
it.line(308, 10, 290, 28, disconnected_color);
|
||||
}
|
||||
|
||||
if (id(page_index) == 0) {
|
||||
it.printf(12, 12, id(font_small), Color::WHITE, "Netzleistung");
|
||||
if (id(grid_power).has_state()) {
|
||||
@@ -130,8 +157,16 @@ globals:
|
||||
type: int
|
||||
restore_value: true
|
||||
initial_value: '0'
|
||||
- id: wifi_connected
|
||||
type: bool
|
||||
restore_value: false
|
||||
initial_value: 'false'
|
||||
|
||||
sensor:
|
||||
- platform: wifi_signal
|
||||
id: wifi_rssi
|
||||
internal: true
|
||||
update_interval: 10s
|
||||
- platform: homeassistant
|
||||
id: grid_power
|
||||
entity_id: sensor.netzleistung
|
||||
|
||||
Reference in New Issue
Block a user