refactor: send shade and group changes once per loop() pass

The p_* setters and emitState() no longer publish or emit straight away:
they set SHADE_CHANGED_* / GROUP_CHANGED_* bits on the shade or group.
At the end of every loop() pass SomfyShadeController::sendChanges()
publishes the MQTT topics whose bits are set and sends one shadeState or
groupState, then clears the bits. emitState(evt) with an event name and
emitState(num) for one client still go out at once.

publishShadeTopics() (ShadeChanges.cpp, tested natively) writes the topics
from a shade snapshot; publishState() on connect uses it too. That fixes
MQTT position and target, a constant 50 since c94819e, and direction, a
constant 0 on connect. position and tiltPosition are now retained when
they change, as they were on connect, and a group whose flags change sends
one groupState instead of two. somfy_flags_t moves to ShadeTypes.h.

8 new native tests, 327 in all. Flash: esp32devdbg +196 bytes, esp32dev
+228 bytes.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
cjkas 2026-10-16 10:40:44 +02:00
parent e70e499d75
commit 4c5bc01fe5
12 changed files with 268 additions and 51 deletions

View file

@ -35,6 +35,17 @@ enum class shade_types : byte {
cgate1 = 0x0F,
rgate1 = 0x10
};
// The bits of a shade's or group's flags.
enum class somfy_flags_t : byte {
SunFlag = 0x01,
SunSensor = 0x02,
DemoMode = 0x04,
Light = 0x08,
Windy = 0x10,
Sunny = 0x20,
Lighted = 0x40,
SimMy = 0x80
};
enum class tilt_types : byte {
none = 0x00,
tiltmotor = 0x01,