Add support for govee H5124 vibration sensors (#122562)
parent
cde22a44db
commit
a94e9d472b
|
@ -35,6 +35,11 @@ MOTION_DESCRIPTION = EventEntityDescription(
|
|||
event_types=["motion"],
|
||||
device_class=EventDeviceClass.MOTION,
|
||||
)
|
||||
VIBRATION_DESCRIPTION = EventEntityDescription(
|
||||
key="vibration",
|
||||
event_types=["vibration"],
|
||||
translation_key="vibration",
|
||||
)
|
||||
|
||||
|
||||
class GoveeBluetoothEventEntity(EventEntity):
|
||||
|
@ -95,6 +100,8 @@ async def async_setup_entry(
|
|||
sensor_type = model_info.sensor_type
|
||||
if sensor_type is SensorType.MOTION:
|
||||
descriptions = [MOTION_DESCRIPTION]
|
||||
elif sensor_type is SensorType.VIBRATION:
|
||||
descriptions = [VIBRATION_DESCRIPTION]
|
||||
elif sensor_type is SensorType.BUTTON:
|
||||
button_count = model_info.button_count
|
||||
descriptions = BUTTON_DESCRIPTIONS[0:button_count]
|
||||
|
|
|
@ -0,0 +1,9 @@
|
|||
{
|
||||
"entity": {
|
||||
"event": {
|
||||
"vibration": {
|
||||
"default": "mdi:vibrate"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
|
@ -26,6 +26,10 @@
|
|||
"local_name": "GV5123*",
|
||||
"connectable": false
|
||||
},
|
||||
{
|
||||
"local_name": "GV5124*",
|
||||
"connectable": false
|
||||
},
|
||||
{
|
||||
"local_name": "GV5125*",
|
||||
"connectable": false
|
||||
|
|
|
@ -29,6 +29,16 @@
|
|||
}
|
||||
}
|
||||
},
|
||||
"vibration": {
|
||||
"name": "Vibration",
|
||||
"state_attributes": {
|
||||
"event_type": {
|
||||
"state": {
|
||||
"vibration": "Vibration"
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
"button_0": {
|
||||
"name": "Button 1",
|
||||
"state_attributes": {
|
||||
|
|
|
@ -152,6 +152,11 @@ BLUETOOTH: Final[list[dict[str, bool | str | int | list[int]]]] = [
|
|||
"domain": "govee_ble",
|
||||
"local_name": "GV5123*",
|
||||
},
|
||||
{
|
||||
"connectable": False,
|
||||
"domain": "govee_ble",
|
||||
"local_name": "GV5124*",
|
||||
},
|
||||
{
|
||||
"connectable": False,
|
||||
"domain": "govee_ble",
|
||||
|
|
|
@ -162,3 +162,28 @@ GV5123_CLOSED_SERVICE_INFO = BluetoothServiceInfo(
|
|||
service_uuids=[],
|
||||
source="24:4C:AB:03:E6:B8",
|
||||
)
|
||||
|
||||
|
||||
GVH5124_SERVICE_INFO = BluetoothServiceInfo(
|
||||
name="GV51242F68",
|
||||
address="D3:32:39:37:2F:68",
|
||||
rssi=-67,
|
||||
manufacturer_data={
|
||||
61320: b"\x08\xa2\x00\x01%\xc2YW\xfdzu\x0e\xf24\xa2\x18\xbb\x15F|[s{\x04"
|
||||
},
|
||||
service_data={},
|
||||
service_uuids=[],
|
||||
source="local",
|
||||
)
|
||||
|
||||
GVH5124_2_SERVICE_INFO = BluetoothServiceInfo(
|
||||
name="GV51242F68",
|
||||
address="D3:32:39:37:2F:68",
|
||||
rssi=-67,
|
||||
manufacturer_data={
|
||||
61320: b"\x08\xa2\x00\x13^Sso\xaeC\x9aU\xcf\xd8\x02\x1b\xdf\xd5\xded;+\xd6\x13"
|
||||
},
|
||||
service_data={},
|
||||
service_uuids=[],
|
||||
source="local",
|
||||
)
|
||||
|
|
|
@ -9,6 +9,8 @@ from . import (
|
|||
GV5121_MOTION_SERVICE_INFO_2,
|
||||
GV5125_BUTTON_0_SERVICE_INFO,
|
||||
GV5125_BUTTON_1_SERVICE_INFO,
|
||||
GVH5124_2_SERVICE_INFO,
|
||||
GVH5124_SERVICE_INFO,
|
||||
)
|
||||
|
||||
from tests.common import MockConfigEntry
|
||||
|
@ -73,3 +75,34 @@ async def test_button(hass: HomeAssistant) -> None:
|
|||
|
||||
assert await hass.config_entries.async_unload(entry.entry_id)
|
||||
await hass.async_block_till_done()
|
||||
|
||||
|
||||
async def test_vibration_sensor(hass: HomeAssistant) -> None:
|
||||
"""Test setting up creates the vibration sensor."""
|
||||
entry = MockConfigEntry(
|
||||
domain=DOMAIN,
|
||||
unique_id=GVH5124_SERVICE_INFO.address,
|
||||
data={CONF_DEVICE_TYPE: "H5124"},
|
||||
)
|
||||
entry.add_to_hass(hass)
|
||||
|
||||
assert await hass.config_entries.async_setup(entry.entry_id)
|
||||
await hass.async_block_till_done()
|
||||
|
||||
assert len(hass.states.async_all()) == 1
|
||||
inject_bluetooth_service_info(hass, GVH5124_SERVICE_INFO)
|
||||
await hass.async_block_till_done()
|
||||
assert len(hass.states.async_all()) == 2
|
||||
|
||||
motion_sensor = hass.states.get("event.h5124_vibration")
|
||||
first_time = motion_sensor.state
|
||||
assert motion_sensor.state != STATE_UNKNOWN
|
||||
|
||||
inject_bluetooth_service_info(hass, GVH5124_2_SERVICE_INFO)
|
||||
await hass.async_block_till_done()
|
||||
|
||||
motion_sensor = hass.states.get("event.h5124_vibration")
|
||||
assert motion_sensor.state != first_time
|
||||
assert motion_sensor.state != STATE_UNKNOWN
|
||||
assert await hass.config_entries.async_unload(entry.entry_id)
|
||||
await hass.async_block_till_done()
|
||||
|
|
Loading…
Reference in New Issue