9391d1b0ac
The airco tile stayed orange while the airco was off. The firmware kept its own short list of what turns grey and gave an off climate Home Assistant's orange, but Home Assistant has no colour for a climate that is off: its cards fall back to the inactive grey. Other tiles had the same fault: an off fan, a closed blind, a docked robot, a player in standby, an idle script, a paused timer and a camera that isn't streaming all kept their colour. Tile::active() is now a port of the frontend's stateActive() for the domains a tile can show, and every tile that is not active is grey. An airco that is off reads Off, with the room's temperature when the device reports one, as Home Assistant's tile does. tile_controls::accent() follows stateColorCss(): alarm binary sensors red, a battery green, orange or red by its charge, a running script or timer and a streaming camera amber, the weather per condition, the sun amber and indigo, someone in a zone blue. Scenes, selects, numbers and sensors keep their own colour per kind. A full-page tile lights up only for tiles that can be off (Tile::lights_up), and a closed blind's slider keeps its colour. The top bar's alarm classes are Home Assistant's eleven. Checked with tools/check.sh (471 Python tests, 19/19 C++ with 58 state cases and every colour rule) and compiled for both boards: CYD 1,677,488 B (91.4 %, +576 B), Guition 2,054,640 B (25.3 %). Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
46 lines
2.4 KiB
Python
46 lines
2.4 KiB
Python
"""An off light and an off binary sensor look off, as in Home Assistant (app 0.2.62 / firmware 0.2.53).
|
|
|
|
Home Assistant's own light icon is a bulb that is crossed out while off (`mdi:lightbulb-off`), and every entity that is
|
|
off is grey. An icon of its own, or one chosen in ESP Screens, stays the same and turns grey, as in Home Assistant.
|
|
"""
|
|
import sys
|
|
import unittest
|
|
from pathlib import Path
|
|
|
|
ROOT = Path(__file__).resolve().parents[1]
|
|
sys.path.insert(0, str(ROOT / 'tools'))
|
|
import profiles # noqa: E402
|
|
sys.path.insert(0, str(ROOT / 'screen_manager/app'))
|
|
import header_bar # noqa: E402
|
|
import tile_icons # noqa: E402
|
|
|
|
TILES = (ROOT / 'components/smart_display/runtime_tiles.h').read_text()
|
|
THEME = (ROOT / 'components/smart_display/theme.h').read_text()
|
|
|
|
|
|
class OffLook(unittest.TestCase):
|
|
def test_the_fonts_carry_the_bulb_that_is_off(self):
|
|
self.assertEqual(tile_icons.GLYPHS['lightbulb-off'], 'F0E4F')
|
|
for name in ('guition-4848s040.yaml', 'home-like-2432s028.yaml', 'packages/cyd.yaml', 'packages/guition.yaml'):
|
|
self.assertIn('"\\U000F0E4F" # lightbulb-off', profiles.text(name), name)
|
|
|
|
def test_the_screen_crosses_out_its_own_bulb_and_greys_what_is_off(self):
|
|
self.assertIn('if (d == "light" && tile.state == "off") return "\\U000F0E4F";', TILES)
|
|
# Since firmware 0.2.71 every tile follows Home Assistant's stateActive() (Tile::active), not a list of domains.
|
|
self.assertIn('bool on = t.builtin() || (fresh() && t.active());', TILES)
|
|
self.assertIn('uint32_t state_color=on?accent:theme::STATE_OFF;', TILES)
|
|
self.assertIn('constexpr uint32_t STATE_OFF = ha::GREY;', THEME)
|
|
self.assertIn('constexpr uint32_t GREY = 0x9E9E9E;', THEME)
|
|
|
|
def test_the_top_bar_does_the_same(self):
|
|
light = lambda state, **attrs: {'state': state, 'attributes': attrs}
|
|
self.assertEqual(header_bar.auto_icon('light.hall', light('off')), tile_icons.GLYPHS['lightbulb-off'])
|
|
self.assertEqual(header_bar.auto_icon('light.hall', light('on')), tile_icons.GLYPHS['lightbulb'])
|
|
self.assertEqual(header_bar.auto_icon('light.hall', light('unavailable')), tile_icons.GLYPHS['lightbulb'])
|
|
self.assertEqual(header_bar.auto_icon('light.lamp', light('off', icon='mdi:lamp')), tile_icons.GLYPHS['lamp'])
|
|
self.assertIsNone(header_bar.accent('light.hall', light('off')))
|
|
|
|
|
|
if __name__ == '__main__':
|
|
unittest.main()
|