From 5fab8e8ff0c46ff24bd7ed2f09d3403eed135adc Mon Sep 17 00:00:00 2001 From: Raphael Hehl <7577984+RaHehl@users.noreply.github.com> Date: Mon, 16 Nov 2026 14:27:15 +0100 Subject: [PATCH] Keep ConfiguredName, IsConfigured and DisplayOrder writable The regenerated catalog made them read-only, as in Apple's metadata, so with the enforced permissions a write to them is refused, e.g. renaming a TV input. 5.2.0 and HAP-NodeJS have them writable; they are back as overrides. --- pyhap/resources/characteristics.json | 3 +++ scripts/hap_manual_overrides.json | 37 ++++++++++++++++++++++++++-- tests/test_accessory_driver.py | 23 +++++++++++++++++ tests/test_loader.py | 13 ++++++++++ 4 files changed, 74 insertions(+), 2 deletions(-) diff --git a/pyhap/resources/characteristics.json b/pyhap/resources/characteristics.json index 43ed7861..dd354062 100644 --- a/pyhap/resources/characteristics.json +++ b/pyhap/resources/characteristics.json @@ -447,6 +447,7 @@ "Format": "string", "Permissions": [ "pr", + "pw", "ev" ], "UUID": "000000E3-0000-1000-8000-0026BB765291" @@ -737,6 +738,7 @@ "Format": "tlv8", "Permissions": [ "pr", + "pw", "ev" ], "UUID": "00000136-0000-1000-8000-0026BB765291" @@ -983,6 +985,7 @@ "Format": "uint8", "Permissions": [ "pr", + "pw", "ev" ], "UUID": "000000D6-0000-1000-8000-0026BB765291", diff --git a/scripts/hap_manual_overrides.json b/scripts/hap_manual_overrides.json index 2e86af94..5a989665 100644 --- a/scripts/hap_manual_overrides.json +++ b/scripts/hap_manual_overrides.json @@ -25,8 +25,10 @@ " - CurrentTemperature minValue -270 (spec minimum; the metadata says 0,", " which makes HAP-python clamp negative readings to 0);", " - LockLastKnownAction values 9/10 from the newer HAP spec.", - "Deliberately NOT mirrored from HAP-NodeJS: write perm on", - "ConfiguredName/IsConfigured/DisplayOrder (HAP-python never had it),", + " - write permission on ConfiguredName/IsConfigured/DisplayOrder (the", + " metadata has them read-only; HAP-NodeJS and the HAP-python releases", + " up to 5.2.0 have them writable, and write permissions are enforced).", + "Deliberately NOT mirrored from HAP-NodeJS:", "read-only PairingFeatures (kept writable for compatibility), and", "SiriInputType maxValue 0 (kept at the metadata value 1)." ], @@ -317,6 +319,15 @@ ], "UUID": "0000021D-0000-1000-8000-0026BB765291" }, + "ConfiguredName": { + "Format": "string", + "Permissions": [ + "pr", + "pw", + "ev" + ], + "UUID": "000000E3-0000-1000-8000-0026BB765291" + }, "CurrentTemperature": { "Format": "float", "Permissions": [ @@ -338,6 +349,15 @@ ], "UUID": "00000138-0000-1000-8000-0026BB765291" }, + "DisplayOrder": { + "Format": "tlv8", + "Permissions": [ + "pr", + "pw", + "ev" + ], + "UUID": "00000136-0000-1000-8000-0026BB765291" + }, "EventSnapshotsActive": { "Format": "uint8", "Permissions": [ @@ -366,6 +386,19 @@ "Enable": 1 } }, + "IsConfigured": { + "Format": "uint8", + "Permissions": [ + "pr", + "pw", + "ev" + ], + "UUID": "000000D6-0000-1000-8000-0026BB765291", + "ValidValues": { + "Configured": 1, + "NotConfigured": 0 + } + }, "LockLastKnownAction": { "Format": "uint8", "Permissions": [ diff --git a/tests/test_accessory_driver.py b/tests/test_accessory_driver.py index 7ecd4312..2a89947c 100644 --- a/tests/test_accessory_driver.py +++ b/tests/test_accessory_driver.py @@ -454,6 +454,29 @@ def test_write_with_write_permission( assert char.value == 5 +def test_write_configured_name(driver: AccessoryDriver) -> None: + """A controller's write to the configured name of an input is applied.""" + acc = Accessory(driver, "Television") + char = acc.add_preload_service("InputSource").get_characteristic("ConfiguredName") + driver.add_accessory(acc) + + result = driver.set_characteristics( + { + HAP_REPR_CHARS: [ + { + HAP_REPR_AID: acc.aid, + HAP_REPR_IID: acc.iid_manager.get_iid(char), + HAP_REPR_VALUE: "HDMI 2", + } + ] + }, + ("1.2.3.4", 5), + ) + + assert result is None + assert char.value == "HDMI 2" + + def test_write_with_subscribe_without_write_permission( driver: AccessoryDriver, ) -> None: diff --git a/tests/test_loader.py b/tests/test_loader.py index a38f1426..447118c4 100644 --- a/tests/test_loader.py +++ b/tests/test_loader.py @@ -46,6 +46,19 @@ def test_loader_get_char_error() -> None: loader.get_char("Char") +@pytest.mark.parametrize("name", ["ConfiguredName", "DisplayOrder", "IsConfigured"]) +def test_loader_chars_a_controller_configures(name: str) -> None: + """Test a controller may write them, though Apple's metadata says read-only. + + The releases up to 5.2.0 had them writable. + """ + assert set(Loader().get_char(name).properties[PROP_PERMISSIONS]) == { + "pr", + "pw", + "ev", + } + + def test_loader_service() -> None: """Test if method returns a Service object.""" loader = Loader()