Address review: per-item versions, writable threshold, unit_fn, gating

Per mbillow's review on PR #129 (CHANGES_REQUESTED). Items 1-7 + smaller.

1. INFO: expose each /information/vs/0 version item per (type, ordinal) instead
   of collapsing to a single first-Firmware value. Boards carry 1-3 Firmware
   items (separate MCUs) plus an Outdoor unit and (window AC) a Touch IC item;
   each is a distinct version string. _info_version(items, type_, ordinal)
   + _has_info_version exists_fn gate, so an item with no number (tp2x_rac_20k's
   second Firmware) suppresses the entity rather than binding unknown.

2. air_filter_threshold is locally writable, not cloud-only -- confirmed live
   on ARTIK051_PRAC: POST filterDesiredUsage=700 to /filter/airdustfilter/vs/0
   -> 2.04, read-back 700, persists; restored to 500. Converted from a
   read-only sensor to a SelectDesc keyed to the device's
   supportedFilterDesiredUsage enum (options_field), with a write_fn that
   POSTs the scalar field. Only binds where the enum is advertised; boards
   without it leave this writable field unexposed rather than guess the valid
   set (don't-guess).

3. air_filter_usage_hours uses unit_fn reading filterCapacityUnit ('Hour'->'h')
   instead of a hardcoded unit, so a board advertising a different unit doesn't
   mislabel a duration statistic.

4. air_filter_usage_hours state_class is total_increasing, not measurement --
   filterUsage is a lifetime hour counter that resets on filter replacement.

5. INFO and air_filter_threshold now carry exists_fn (AIR_QUALITY already did),
   so they don't bind a permanently-unknown entity when their item/field is
   absent. Also fixes the caww_tp2 golden nuance (filterDesiredUsage absent
   -> no threshold key, matching what HA would actually create).

6. AIR_QUALITY: CleanLevel is corroborated as numeric by a top-level
   x.com.samsung.da.cleanLevel scalar (tp1x_da_ac_rac_01011 reports both as
   '1'), so clean_level is now an int measurement; odor/dust/fine_dust stay
   string diagnostics. Reinstated the 2-element-array ambiguity note (Dust/
   FineDust/SuperFineDust report ['0','0']; v[1] meaning unconfirmed, v[0]
   taken as the reading). SuperFineDust is now modeled for consistency with
   Dust/FineDust (same shape), rather than skipped without reason.

7. _beep_write restores the last non-Mute Volume level on 'On' instead of
   forcing Volume_100, so an intermediate setting (e.g. Volume_50 set via
   the cloud) survives an off/on cycle; falls back to 100 when no prior level.

Smaller: test_air_quality now asserts the tp1x_da_ac_rac_01011 clean_level==1
non-zero reading (the one value_fn-regression catch in the corpus); renamed
by_type's _AC_IGNORED -> _IGNORED_LESS_INFO to resolve the two-meaning
collision with the capabilities module's _AC_IGNORED (href strings); golden
regenerated for the 8 AC fixtures + dehumidifier.

612 tests pass.
This commit is contained in:
blka committed 2026-07-27 22:22:56 +02:00
1 parent 3da01f80d0
commit 51fa1c5ea8
13 files changed
+302 -83

No files matched your search

+2 -1
View File
@@ -1,7 +1,6 @@
{
"state_keys": [
"air_filter_status",
"air_filter_threshold",
"air_filter_usage",
"air_filter_usage_hours",
"air_purify",
@@ -20,8 +19,10 @@
"firmware_version",
"humidity",
"odor",
"outdoor_unit_version",
"power_watts",
"software_version",
"super_fine_dust",
"tropical_night_mode"
]
}
+1 -1
View File
@@ -1,7 +1,6 @@
{
"state_keys": [
"air_filter_status",
"air_filter_threshold",
"air_filter_usage",
"air_filter_usage_hours",
"alarm_code",
@@ -17,6 +16,7 @@
"firmware_version",
"humidity",
"mute_once",
"outdoor_unit_version",
"power_watts",
"software_version",
"tropical_night_mode"
@@ -17,12 +17,15 @@
"fine_dust",
"firmware_update",
"firmware_version",
"firmware_version_2",
"firmware_version_3",
"humidity",
"mute_once",
"selfcheck_error",
"selfcheck_result",
"selfcheck_status",
"software_version",
"super_fine_dust",
"tropical_night_mode"
]
}
+2
View File
@@ -17,6 +17,8 @@
"energy_saved_kwh",
"firmware_update",
"firmware_version",
"firmware_version_2",
"firmware_version_3",
"mute_once",
"selfcheck_error",
"selfcheck_result",
@@ -1,7 +1,6 @@
{
"state_keys": [
"air_filter_status",
"air_filter_threshold",
"air_filter_usage",
"air_filter_usage_hours",
"alarm_code",
@@ -14,6 +13,7 @@
"energy_saved_kwh",
"firmware_update",
"firmware_version",
"firmware_version_2",
"humidity",
"mute_once",
"power_watts",
@@ -1,7 +1,6 @@
{
"state_keys": [
"air_filter_status",
"air_filter_threshold",
"air_filter_usage",
"air_filter_usage_hours",
"alarm_code",
+2 -1
View File
@@ -1,7 +1,6 @@
{
"state_keys": [
"air_filter_status",
"air_filter_threshold",
"air_filter_usage",
"air_filter_usage_hours",
"air_purify",
@@ -19,8 +18,10 @@
"firmware_version",
"humidity",
"odor",
"outdoor_unit_version",
"power_watts",
"software_version",
"super_fine_dust",
"tropical_night_mode"
]
}
+3 -2
View File
@@ -1,7 +1,6 @@
{
"state_keys": [
"air_filter_status",
"air_filter_threshold",
"air_filter_usage",
"air_filter_usage_hours",
"alarm_code",
@@ -16,10 +15,12 @@
"firmware_version",
"humidity",
"mute_once",
"outdoor_unit_version",
"power_watts",
"selfcheck_error",
"selfcheck_result",
"selfcheck_status",
"software_version"
"software_version",
"touch_ic_version"
]
}