mirror of
https://github.com/randybb/esphome-configs.git
synced 2026-12-06 09:06:52 +01:00
The display runs the ptaru/nspanel-terminal TFT and ESPHome draws the UI with LVGL (component from a local checkout for now, see PR ptaru/nspanel-terminal#1). Pages: home (clock, weather, forecast, temperatures), lights, outside, irrigation, thermostat, gate, status/boot screen; light detail with brightness, colour temperature or hue on long press. Grid tiles come from packages in common/nspanel_terminal/ that add themselves to a page. Unavailable entities are greyed out, OTA progress shows on the status page, sleep dim and the notify/show_info actions match the other panels.
26 lines
991 B
C++
26 lines
991 B
C++
#pragma once
|
|
#include <string>
|
|
#include <vector>
|
|
|
|
// HA list attribute as sent to ESPHome, "['none', 'away']" or '["none", "away"]' -> items
|
|
inline std::vector<std::string> parse_list(const std::string &s) {
|
|
std::vector<std::string> out;
|
|
for (size_t p = 0; (p = s.find_first_of("'\"", p)) != std::string::npos;) {
|
|
size_t end = s.find(s[p], p + 1);
|
|
if (end == std::string::npos) break;
|
|
out.push_back(s.substr(p + 1, end - p - 1));
|
|
p = end + 1;
|
|
}
|
|
return out;
|
|
}
|
|
|
|
// Display name for a climate preset; unknown presets are shown as they come
|
|
inline std::string preset_name(const std::string &p) {
|
|
static const char *const NAMES[][2] = {{"none", "Žiadny"}, {"home", "Doma"}, {"away", "Preč"},
|
|
{"eco", "Eco"}, {"comfort", "Komfort"}, {"sleep", "Spánok"},
|
|
{"activity", "Aktivita"}, {"boost", "Boost"}};
|
|
for (auto &n : NAMES)
|
|
if (p == n[0]) return n[1];
|
|
return p;
|
|
}
|