Show a live picture on a camera tile, run an action from the alert button, roll long media titles, and keep full-page tiles in their own colour (0.2.91)
Live picture (issue #4): a camera or image tile on a Guition takes Display -> Live picture with a pace of 15 or 30 s. The camera tiles of a page share one download: the screen asks ESP Screens for them together (esphome.screen_camera with tiles, size and bg) and the app serves one BMP, a strip of squares with the corners rounded over each tile's own colour; every tile draws its square out of it with LVGL's image offset (LV_IMAGE_ALIGN_TOP_LEFT: the default centres a taller source). A third online_image on the Guition holds the strip; it loads after the alert's picture, a cover and the camera full screen, never under a card, in standby or under a finger. The strip is served whole every time: ESPHome's http_request logs a 304 as a failed request. Firmware 0.2.77. Alert button: esp_screens_show_alert takes action and data; the app performs the action once when the button's report (esphome.screen_alert, ok) comes from any screen. show_alert keeps its seven fields, so every firmware from 0.2.31 has it. Media card and full-page media tile: a title or artist line that is too wide rolls by (LV_LABEL_LONG_SCROLL_CIRCULAR) instead of ending in dots. Full-page tiles are white or their own pastel like every other tile; the tint in the state colour of firmware 0.2.62 to 0.2.76 is gone. Host harness (27 checks) and bench Guition + local add-on on the Yellow: docs/TEST_RESULTS_0291.md. CYD firmware 1,633,728 B, 89.0 %. Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
This commit is contained in:
@@ -54,6 +54,18 @@ inline bool valid_entity(const std::string &entity) {
|
||||
if (domain == allowed) return true;
|
||||
return false;
|
||||
}
|
||||
// A comma-separated list of entities (a page's live camera tiles, firmware 0.2.77+); an empty item stands for a tile
|
||||
// without a picture.
|
||||
inline bool valid_entity_list(const std::string &list) {
|
||||
if (list.empty() || list.size() > 400) return false;
|
||||
for (size_t start = 0;; ) {
|
||||
const size_t comma = list.find(',', start);
|
||||
const std::string item = list.substr(start, comma == std::string::npos ? std::string::npos : comma - start);
|
||||
if (!item.empty() && !valid_entity(item)) return false;
|
||||
if (comma == std::string::npos) return true;
|
||||
start = comma + 1;
|
||||
}
|
||||
}
|
||||
// An action as Home Assistant names it (domain.action: lowercase letters, digits, underscores), of any integration.
|
||||
inline bool valid_action(const std::string &action) {
|
||||
if (action.size() > 64) return false;
|
||||
@@ -201,6 +213,10 @@ struct Tile {
|
||||
bool has_hs_color = false;
|
||||
int saturation = 0;
|
||||
std::string tap = "auto", display = "standard", inline_control = "none";
|
||||
// A camera tile's live picture (firmware 0.2.77+): "display": "live" puts a small picture of the camera in the
|
||||
// icon's place, loaded again every `refresh` seconds.
|
||||
uint16_t refresh = 15;
|
||||
bool live() const { const auto d = domain(); return display == "live" && (d == "camera" || d == "image"); }
|
||||
// Double width takes a row; full (firmware 0.2.62+) takes the whole page, all six slots, and is also wide.
|
||||
bool wide = false, full = false;
|
||||
// Direct control set on a wide card (firmware 0.2.19+); empty keeps the plain card.
|
||||
@@ -348,16 +364,6 @@ struct Tile {
|
||||
if (d == "camera") return state == "streaming" || state == "recording";
|
||||
return true;
|
||||
}
|
||||
// A card over the whole page lights up in its state colour while it is on (firmware 0.2.62+): only a tile that can
|
||||
// be off, closed, docked or away, and only while active() calls it active (firmware 0.2.71+). Sensors, numbers,
|
||||
// selects, scenes, buttons, images, the weather and the sun are always active in Home Assistant and stay plain.
|
||||
bool lights_up() const {
|
||||
const auto d = domain();
|
||||
for (const char *on_off : {"light", "switch", "input_boolean", "climate", "fan", "cover", "media_player", "vacuum",
|
||||
"script", "timer", "camera", "person", "binary_sensor"})
|
||||
if (d == on_off) return active();
|
||||
return false;
|
||||
}
|
||||
// A slider shows the card's colour like Home Assistant's tile sliders: grey only while the entity is inactive
|
||||
// (active() above), such as an off light or fan and a media player that is off or in standby. A number with a
|
||||
// value is active there, and a closed cover's position slider keeps the cover's colour so it never looks
|
||||
|
||||
Reference in New Issue
Block a user