Let the on/off switch on a wide tile switch, instead of sending the opposite of what it shows (0.2.86)
A tap on the On/off switch of a wide or full-page tile moved the knob to on and back, and the light stayed off. Since firmware 0.2.59 control_event drew the new position first (Tile::optimistic writes it into state) and then asked key_action for the action, which read that new position: an off light got light.turn_off, an on light light.turn_on. A tap on the tile itself was never affected. tile_controls::press_key chooses the action first and then shows the new position; control_event uses it. Unit tests cover a light, a fan, a sensor and a cover key. Checked with tools/check.sh (471 Python tests, 19/19 C++) and compiled for both boards: CYD 1,677,504 B (91.4 %, +16 B), Guition 2,054,640 B (25.3 %). On Max's Guition Wallbox (OTA from this branch) every tap on the switch sent the right action and Home Assistant's logbook followed. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
This commit is contained in:
@@ -368,6 +368,14 @@ inline Action key_action(const Tile &t, int command, const std::string &arg = ""
|
||||
default: return {};
|
||||
}
|
||||
}
|
||||
// A tap on a key: the action follows the stand the tile had, and a toggle then shows its new stand at once. The order
|
||||
// matters, because Tile::optimistic writes the new stand into `state`: asked afterwards, key_action sent an off light
|
||||
// light.turn_off, so the knob flipped on and back while the light stayed off (firmware 0.2.59 to 0.2.71).
|
||||
inline Action press_key(Tile &t, int command, const std::string &arg = "") {
|
||||
Action a = key_action(t, command, arg);
|
||||
if (command == TOGGLE && a.valid()) t.optimistic(t.state != "on");
|
||||
return a;
|
||||
}
|
||||
// ---- Vacuum card rows (firmware 0.2.39+) ----
|
||||
// The value a row shows as chosen: the one just tapped while Home Assistant has not answered yet.
|
||||
inline const std::string &shown_value(const Tile &t, const runtime_tiles::Choice &c, uint32_t now) {
|
||||
|
||||
Reference in New Issue
Block a user