From 49b07224bf481759128bad1d8149b704c0c48596 Mon Sep 17 00:00:00 2001 From: Steffen Ronalter Date: Fri, 15 Oct 2021 08:23:26 +0200 Subject: [PATCH] Add onewire support for DS2413 (#55921) --- .../components/onewire/binary_sensor.py | 9 ++++ homeassistant/components/onewire/switch.py | 9 ++++ tests/components/onewire/const.py | 52 +++++++++++++++++++ 3 files changed, 70 insertions(+) diff --git a/homeassistant/components/onewire/binary_sensor.py b/homeassistant/components/onewire/binary_sensor.py index 0b78988f7e1..0a57e0c1b19 100644 --- a/homeassistant/components/onewire/binary_sensor.py +++ b/homeassistant/components/onewire/binary_sensor.py @@ -57,6 +57,15 @@ DEVICE_BINARY_SENSORS: dict[str, tuple[OneWireBinarySensorEntityDescription, ... ) for id in DEVICE_KEYS_0_7 ), + "3A": tuple( + OneWireBinarySensorEntityDescription( + key=f"sensed.{id}", + entity_registry_enabled_default=False, + name=f"Sensed {id}", + read_mode=READ_MODE_BOOL, + ) + for id in DEVICE_KEYS_A_B + ), } diff --git a/homeassistant/components/onewire/switch.py b/homeassistant/components/onewire/switch.py index e8e790feab4..aadc1315712 100644 --- a/homeassistant/components/onewire/switch.py +++ b/homeassistant/components/onewire/switch.py @@ -84,6 +84,15 @@ DEVICE_SWITCHES: dict[str, tuple[OneWireEntityDescription, ...]] = { for id in DEVICE_KEYS_0_7 ] ), + "3A": tuple( + OneWireSwitchEntityDescription( + key=f"PIO.{id}", + entity_registry_enabled_default=False, + name=f"PIO {id}", + read_mode=READ_MODE_BOOL, + ) + for id in DEVICE_KEYS_A_B + ), } LOGGER = logging.getLogger(__name__) diff --git a/tests/components/onewire/const.py b/tests/components/onewire/const.py index 9c37442e2f7..7a39e70d4bc 100644 --- a/tests/components/onewire/const.py +++ b/tests/components/onewire/const.py @@ -656,6 +656,57 @@ MOCK_OWPROXY_DEVICES = { }, ], }, + "3A.111111111111": { + "inject_reads": [ + b"DS2413", # read device type + ], + "device_info": { + ATTR_IDENTIFIERS: {(DOMAIN, "3A.111111111111")}, + ATTR_MANUFACTURER: MANUFACTURER, + ATTR_MODEL: "DS2413", + ATTR_NAME: "3A.111111111111", + }, + BINARY_SENSOR_DOMAIN: [ + { + "entity_id": "binary_sensor.3a_111111111111_sensed_a", + "unique_id": "/3A.111111111111/sensed.A", + "injected_value": b" 1", + "result": STATE_ON, + ATTR_UNIT_OF_MEASUREMENT: None, + ATTR_DEVICE_CLASS: None, + "disabled": True, + }, + { + "entity_id": "binary_sensor.3a_111111111111_sensed_b", + "unique_id": "/3A.111111111111/sensed.B", + "injected_value": b" 0", + "result": STATE_OFF, + ATTR_UNIT_OF_MEASUREMENT: None, + ATTR_DEVICE_CLASS: None, + "disabled": True, + }, + ], + SWITCH_DOMAIN: [ + { + "entity_id": "switch.3a_111111111111_pio_a", + "unique_id": "/3A.111111111111/PIO.A", + "injected_value": b" 1", + "result": STATE_ON, + ATTR_UNIT_OF_MEASUREMENT: None, + ATTR_DEVICE_CLASS: None, + "disabled": True, + }, + { + "entity_id": "switch.3a_111111111111_pio_b", + "unique_id": "/3A.111111111111/PIO.B", + "injected_value": b" 0", + "result": STATE_OFF, + ATTR_UNIT_OF_MEASUREMENT: None, + ATTR_DEVICE_CLASS: None, + "disabled": True, + }, + ], + }, "3B.111111111111": { "inject_reads": [ b"DS1825", # read device type @@ -940,6 +991,7 @@ MOCK_SYSBUS_DEVICES = { ], }, "29-111111111111": {SENSOR_DOMAIN: []}, + "3A-111111111111": {SENSOR_DOMAIN: []}, "3B-111111111111": { "device_info": { ATTR_IDENTIFIERS: {(DOMAIN, "3B-111111111111")},