Fix airflow fan power-href preference and unique_id collision risk

Opus review of the previous commit caught two real bugs. The airflow fan's
power writes preferred /power/vs/0, copied from the TP1X fan class -- but
that order is only harmless there because TP1X never reports /power/0 at
all. This family's dumps carry both hrefs, and the power_switch entity is
unconditionally bound to /power/0 when present, so the fan was writing to
a different resource than power_switch reads/writes, leaving the two
entities disagreeing until the next poll. Flipped to prefer /power/0,
matching the range hood's fan and common.POWER_GENERIC.

Also renamed the new FanDesc's key from 'fan' to 'airflow_fan': BoundEntity
unique_ids are derived from key alone, not href, so it collided with
air_purifier.FAN's own 'fan' key on the (currently unobserved, but
unenforced) possibility of a board reporting both.

Added a platform-level test file covering the power-href preference and
percentage<->speed-code mapping, mirroring test_range_hood_fan.py's harness.
This commit is contained in:
Marc Billow committed 2026-07-27 21:48:23 +00:00
1 parent d4583b3240
commit 2be742489b
6 files changed
+148 -24

No files matched your search

+1 -1
View File
@@ -1,5 +1,6 @@
{
"state_keys": [
"airflow_fan",
"alarm_code",
"clean_level",
"device_active",
@@ -10,7 +11,6 @@
"energy_last_month_kwh",
"energy_saved_kwh",
"energy_this_month_kwh",
"fan",
"fan_direction",
"filter_progress",
"fine_dust",