CLIPGenericFlag should be deCONZ sensor not binary sensor (#56901)

This commit is contained in:
Robert Svensson 2021-10-01 17:10:01 +02:00 committed by GitHub
parent 061c335673
commit 1c1bb057d7
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 34 additions and 6 deletions

View File

@ -4,7 +4,6 @@ from pydeconz.sensor import (
CarbonMonoxide, CarbonMonoxide,
Fire, Fire,
GenericFlag, GenericFlag,
GenericStatus,
OpenClose, OpenClose,
Presence, Presence,
Vibration, Vibration,
@ -36,7 +35,6 @@ DECONZ_BINARY_SENSORS = (
CarbonMonoxide, CarbonMonoxide,
Fire, Fire,
GenericFlag, GenericFlag,
GenericStatus,
OpenClose, OpenClose,
Presence, Presence,
Vibration, Vibration,

View File

@ -4,6 +4,7 @@ from pydeconz.sensor import (
Battery, Battery,
Consumption, Consumption,
Daylight, Daylight,
GenericStatus,
Humidity, Humidity,
LightLevel, LightLevel,
Power, Power,
@ -52,6 +53,7 @@ DECONZ_SENSORS = (
AirQuality, AirQuality,
Consumption, Consumption,
Daylight, Daylight,
GenericStatus,
Humidity, Humidity,
LightLevel, LightLevel,
Power, Power,

View File

@ -181,6 +181,17 @@ async def test_allow_clip_sensor(hass, aioclient_mock):
"config": {}, "config": {},
"uniqueid": "00:00:00:00:00:00:00:02-00", "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} 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.presence_sensor").state == STATE_OFF
assert hass.states.get("binary_sensor.clip_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 # Disallow clip sensors
@ -202,6 +214,7 @@ async def test_allow_clip_sensor(hass, aioclient_mock):
assert len(hass.states.async_all()) == 1 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_presence_sensor")
assert not hass.states.get("binary_sensor.clip_flag_boot_time")
# Allow clip sensors # Allow clip sensors
@ -210,8 +223,9 @@ async def test_allow_clip_sensor(hass, aioclient_mock):
) )
await hass.async_block_till_done() 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_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): async def test_add_new_binary_sensor(hass, aioclient_mock, mock_deconz_websocket):

View File

@ -196,6 +196,17 @@ async def test_allow_clip_sensors(hass, aioclient_mock):
"config": {"reachable": True}, "config": {"reachable": True},
"uniqueid": "00:00:00:00:00:00:00:01-00", "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): 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}, 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_light_level_sensor").state == "999.8"
assert hass.states.get("sensor.clip_flur").state == "0"
# Disallow clip sensors # Disallow clip sensors
@ -217,6 +229,7 @@ async def test_allow_clip_sensors(hass, aioclient_mock):
assert len(hass.states.async_all()) == 2 assert len(hass.states.async_all()) == 2
assert not hass.states.get("sensor.clip_light_level_sensor") assert not hass.states.get("sensor.clip_light_level_sensor")
assert not hass.states.get("sensor.clip_flur")
# Allow clip sensors # Allow clip sensors
@ -225,8 +238,9 @@ async def test_allow_clip_sensors(hass, aioclient_mock):
) )
await hass.async_block_till_done() 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_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): async def test_add_new_sensor(hass, aioclient_mock, mock_deconz_websocket):