Shades, rooms, and groups are kept in fixed-size arrays, and each record
has an id that the API, MQTT, and the Home Assistant integration use to
refer to it. `addShade`, `addRoom`, and `addGroup` give a new record the
lowest unused id and store it at index `id - 1`, which assumes a
record's index always matches its id.
That stops being true once a record has been deleted and the controller
restarts. The configuration file only holds the records that exist, and
loading it fills each array from the start, so every record after a gap
moves down a slot. Index `id - 1` for the lowest unused id then belongs
to the record that used to be one id higher, and adding a record
overwrites it. Each overwrite frees up another id, so every later add
replaces another record.
For example, with shades 1 through 5, deleting shade 3 and restarting
loads shades 4 and 5 into slots 2 and 3. Adding a shade then takes id 3
and replaces shade 4 in slot 2.
Store new records in the first empty slot instead. Lookups by id
already scan every slot, and restoring a backup fills the arrays the
same way booting does, so nothing else relies on a record's index
matching its id.
Fixes#494.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
* Fixed issue with my position setting out of order when the flip position bit is set.
* Fixed issue with changes to the my labels when a tilt type changes.
* Fixed issue with isAtPosition method to accommodate both tilt and lift capabilities.
* Ensure target position is always the end position during movement checks. Previously, this was only an approximation.