Public Access
Add conversions for Home Assistant values: duration, time, own texts, auto unit
- Show as number (multiplier, decimals, auto unit W -> kW -> MW, without minus sign), duration (seconds/minutes/hours as 2h 21m, 2:21:00, 2:21 or smart), time (HA timestamps in local time, with weekday or date, or relative: over 34 min / 12 min geleden) or own texts per state. - Page format 3; version 2 pages are converted. Version 2.7.0. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
93b9bec69a
commit
87e242bf89
11 files changed
+601
-30
No files matched your search
@@ -9,6 +9,8 @@ static const char *const TYPES[] = {"clock", "date", "ha", "text", "countdown",
|
||||
static const char *const ALIGNS[] = {"left", "center", "right"};
|
||||
static const char *const OVERLAYS[] = {"top", "box", "invert"};
|
||||
static const char *const LANGUAGES[] = {"nl", "en"};
|
||||
static const char *const SHOWS[] = {"number", "duration", "time", "map"};
|
||||
static const char *const UNITS[] = {"s", "min", "h"};
|
||||
|
||||
template <size_t N> static int indexOf(const char *const (&names)[N], const char *name)
|
||||
{
|
||||
@@ -62,6 +64,11 @@ void pageToJson(const DynamicPage &page, JsonObject out)
|
||||
char target[17];
|
||||
formatTarget(e.target, target);
|
||||
o["target"] = String(target);
|
||||
o["show"] = SHOWS[(int)e.show];
|
||||
o["input_unit"] = UNITS[e.input_unit];
|
||||
o["auto_unit"] = e.auto_unit;
|
||||
o["absolute"] = e.absolute;
|
||||
o["map"] = withDegrees(e.map);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -114,6 +121,15 @@ const char *pageFromJson(JsonVariantConst in, DynamicPage &page)
|
||||
e.factor = o["factor"] | 1.0f;
|
||||
e.scroll_width = constrain(o["scroll_width"] | 0, 0, 255);
|
||||
e.scroll_speed = constrain(o["scroll_speed"] | 8, 0, 255);
|
||||
int show = indexOf(SHOWS, o["show"] | "number"), unit = indexOf(UNITS, o["input_unit"] | "s");
|
||||
if (show < 0 || unit < 0)
|
||||
return "Unknown Home Assistant value setting";
|
||||
e.show = (HaShow)show;
|
||||
e.input_unit = unit;
|
||||
e.auto_unit = o["auto_unit"] | false;
|
||||
e.absolute = o["absolute"] | false;
|
||||
if (!copyText(o["map"], e.map, sizeof(e.map)))
|
||||
return "The list of texts is too long (63 characters)";
|
||||
const char *target = o["target"] | "";
|
||||
if (e.type == ElementType::Countdown && !parseTarget(target, e.target))
|
||||
return "Countdown: enter a date and time";
|
||||
|
||||
Reference in new issue
Block a user