Skip to content

Default characterisic value is generating errors in HA logs when unsupported #473

@MoFtZ

Description

@MoFtZ

BACKGROUND

My HA setup is using HomeKit Bridge to expose an Alarm to HomeKit.

The HA logs contain the following errors:

Logger: pyhap.characteristic
Source: components/homekit/type_security_systems.py:125
First occurred: 21:12:49 (1 occurrences)
Last logged: 21:12:49

SecuritySystemCurrentState: value=0 is an invalid value.
Logger: pyhap.characteristic
Source: components/homekit/type_security_systems.py:134
First occurred: 21:12:49 (1 occurrences)
Last logged: 21:12:49

SecuritySystemTargetState: value=0 is an invalid value.

When I enable debug logging, I get the following:

2024-08-23 21:12:49.123 DEBUG (MainThread) [homeassistant.components.homekit.accessories] Add "alarm_control_panel.alarm" as "SecuritySystem"
2024-08-23 21:12:49.123 DEBUG (MainThread) [pyhap.characteristic] set_value: Name to Alarm
2024-08-23 21:12:49.123 DEBUG (MainThread) [pyhap.characteristic] set_value: SerialNumber to default
2024-08-23 21:12:49.123 DEBUG (MainThread) [pyhap.characteristic] set_value: FirmwareRevision to 2024.7.4
2024-08-23 21:12:49.123 DEBUG (MainThread) [pyhap.characteristic] set_value: Manufacturer to Home Assistant Alarm Control Panel
2024-08-23 21:12:49.123 DEBUG (MainThread) [pyhap.characteristic] set_value: Model to Alarm Control Panel
2024-08-23 21:12:49.123 DEBUG (MainThread) [pyhap.characteristic] set_value: SerialNumber to alarm_control_panel.alarm
2024-08-23 21:12:49.123 ERROR (MainThread) [pyhap.characteristic] SecuritySystemCurrentState: value=0 is an invalid value.
2024-08-23 21:12:49.123 DEBUG (MainThread) [pyhap.characteristic] set_value: SecuritySystemCurrentState to 3
2024-08-23 21:12:49.123 ERROR (MainThread) [pyhap.characteristic] SecuritySystemTargetState: value=0 is an invalid value.
2024-08-23 21:12:49.123 DEBUG (MainThread) [pyhap.characteristic] set_value: SecuritySystemTargetState to 3
2024-08-23 21:12:49.123 DEBUG (MainThread) [pyhap.characteristic] set_value: SecuritySystemCurrentState to 3
2024-08-23 21:12:49.123 DEBUG (MainThread) [homeassistant.components.homekit.type_security_systems] alarm_control_panel.alarm: Updated current state to disarmed (3)
2024-08-23 21:12:49.123 DEBUG (MainThread) [pyhap.characteristic] set_value: SecuritySystemTargetState to 3

PROBLEM

The two errors in the HA logs refer to the following code:
https://github.com/home-assistant/core/blob/611723e44bd22bbf43226897fc4632af42f69bf0/homeassistant/components/homekit/type_security_systems.py#L125
https://github.com/home-assistant/core/blob/611723e44bd22bbf43226897fc4632af42f69bf0/homeassistant/components/homekit/type_security_systems.py#L134

I believe the issue is that the default value for the characteristic (value 0) is not supported. The call to configure_char will eventually reach code that throws a ValueError exception, and that gets caught and handled. The exception handler will then return a sane value.

EXPECTED BEHAVIOUR

Exceptions that are handled and ignored should not be writing to the HA logs.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions