From 1c1bb057d79133bc376941ed36fde04108c51565 Mon Sep 17 00:00:00 2001 From: Robert Svensson Date: Fri, 1 Oct 2021 17:10:01 +0200 Subject: [PATCH] CLIPGenericFlag should be deCONZ sensor not binary sensor (#56901) --- .../components/deconz/binary_sensor.py | 2 -- homeassistant/components/deconz/sensor.py | 2 ++ tests/components/deconz/test_binary_sensor.py | 18 ++++++++++++++++-- tests/components/deconz/test_sensor.py | 18 ++++++++++++++++-- 4 files changed, 34 insertions(+), 6 deletions(-) diff --git a/homeassistant/components/deconz/binary_sensor.py b/homeassistant/components/deconz/binary_sensor.py index 96de780c137..33b68f25cab 100644 --- a/homeassistant/components/deconz/binary_sensor.py +++ b/homeassistant/components/deconz/binary_sensor.py @@ -4,7 +4,6 @@ from pydeconz.sensor import ( CarbonMonoxide, Fire, GenericFlag, - GenericStatus, OpenClose, Presence, Vibration, @@ -36,7 +35,6 @@ DECONZ_BINARY_SENSORS = ( CarbonMonoxide, Fire, GenericFlag, - GenericStatus, OpenClose, Presence, Vibration, diff --git a/homeassistant/components/deconz/sensor.py b/homeassistant/components/deconz/sensor.py index b486f6b8677..8b82c2fa7bf 100644 --- a/homeassistant/components/deconz/sensor.py +++ b/homeassistant/components/deconz/sensor.py @@ -4,6 +4,7 @@ from pydeconz.sensor import ( Battery, Consumption, Daylight, + GenericStatus, Humidity, LightLevel, Power, @@ -52,6 +53,7 @@ DECONZ_SENSORS = ( AirQuality, Consumption, Daylight, + GenericStatus, Humidity, LightLevel, Power, diff --git a/tests/components/deconz/test_binary_sensor.py b/tests/components/deconz/test_binary_sensor.py index 2a1b3c154f0..7f986ce4b81 100644 --- a/tests/components/deconz/test_binary_sensor.py +++ b/tests/components/deconz/test_binary_sensor.py @@ -181,6 +181,17 @@ async def test_allow_clip_sensor(hass, aioclient_mock): "config": {}, "uniqueid": "00:00:00:00:00:00:00:02-00", }, + "3": { + "config": {"on": True, "reachable": True}, + "etag": "fda064fca03f17389d0799d7cb1883ee", + "manufacturername": "Philips", + "modelid": "CLIPGenericFlag", + "name": "Clip Flag Boot Time", + "state": {"flag": True, "lastupdated": "2021-09-30T07:09:06.281"}, + "swversion": "1.0", + "type": "CLIPGenericFlag", + "uniqueid": "/sensors/3", + }, } } @@ -189,9 +200,10 @@ async def test_allow_clip_sensor(hass, aioclient_mock): hass, aioclient_mock, options={CONF_ALLOW_CLIP_SENSOR: True} ) - assert len(hass.states.async_all()) == 2 + assert len(hass.states.async_all()) == 3 assert hass.states.get("binary_sensor.presence_sensor").state == STATE_OFF assert hass.states.get("binary_sensor.clip_presence_sensor").state == STATE_OFF + assert hass.states.get("binary_sensor.clip_flag_boot_time").state == STATE_ON # Disallow clip sensors @@ -202,6 +214,7 @@ async def test_allow_clip_sensor(hass, aioclient_mock): assert len(hass.states.async_all()) == 1 assert not hass.states.get("binary_sensor.clip_presence_sensor") + assert not hass.states.get("binary_sensor.clip_flag_boot_time") # Allow clip sensors @@ -210,8 +223,9 @@ async def test_allow_clip_sensor(hass, aioclient_mock): ) await hass.async_block_till_done() - assert len(hass.states.async_all()) == 2 + assert len(hass.states.async_all()) == 3 assert hass.states.get("binary_sensor.clip_presence_sensor").state == STATE_OFF + assert hass.states.get("binary_sensor.clip_flag_boot_time").state == STATE_ON async def test_add_new_binary_sensor(hass, aioclient_mock, mock_deconz_websocket): diff --git a/tests/components/deconz/test_sensor.py b/tests/components/deconz/test_sensor.py index 33f9c8c6a2c..624a1bec7ff 100644 --- a/tests/components/deconz/test_sensor.py +++ b/tests/components/deconz/test_sensor.py @@ -196,6 +196,17 @@ async def test_allow_clip_sensors(hass, aioclient_mock): "config": {"reachable": True}, "uniqueid": "00:00:00:00:00:00:00:01-00", }, + "3": { + "config": {"on": True, "reachable": True}, + "etag": "a5ed309124d9b7a21ef29fc278f2625e", + "manufacturername": "Philips", + "modelid": "CLIPGenericStatus", + "name": "CLIP Flur", + "state": {"lastupdated": "2021-10-01T10:23:06.779", "status": 0}, + "swversion": "1.0", + "type": "CLIPGenericStatus", + "uniqueid": "/sensors/3", + }, } } with patch.dict(DECONZ_WEB_REQUEST, data): @@ -205,8 +216,9 @@ async def test_allow_clip_sensors(hass, aioclient_mock): options={CONF_ALLOW_CLIP_SENSOR: True}, ) - assert len(hass.states.async_all()) == 3 + assert len(hass.states.async_all()) == 4 assert hass.states.get("sensor.clip_light_level_sensor").state == "999.8" + assert hass.states.get("sensor.clip_flur").state == "0" # Disallow clip sensors @@ -217,6 +229,7 @@ async def test_allow_clip_sensors(hass, aioclient_mock): assert len(hass.states.async_all()) == 2 assert not hass.states.get("sensor.clip_light_level_sensor") + assert not hass.states.get("sensor.clip_flur") # Allow clip sensors @@ -225,8 +238,9 @@ async def test_allow_clip_sensors(hass, aioclient_mock): ) await hass.async_block_till_done() - assert len(hass.states.async_all()) == 3 + assert len(hass.states.async_all()) == 4 assert hass.states.get("sensor.clip_light_level_sensor").state == "999.8" + assert hass.states.get("sensor.clip_flur").state == "0" async def test_add_new_sensor(hass, aioclient_mock, mock_deconz_websocket):