1
0
mirror of https://github.com/home-assistant/core.git synced 2026-04-02 08:26:41 +01:00

Add Govee H5140 CO2 monitor support to govee_ble (#164365)

Co-authored-by: J. Nick Koston <nick@koston.org>
This commit is contained in:
Norman Yee
2026-03-02 12:12:48 -08:00
committed by GitHub
parent 713b7cf36d
commit 5dba5fc79d
5 changed files with 54 additions and 1 deletions

View File

@@ -54,6 +54,10 @@
"connectable": false,
"local_name": "GVH5110*"
},
{
"connectable": false,
"local_name": "GV5140*"
},
{
"connectable": false,
"manufacturer_id": 1,

View File

@@ -21,6 +21,7 @@ from homeassistant.components.sensor import (
)
from homeassistant.const import (
CONCENTRATION_MICROGRAMS_PER_CUBIC_METER,
CONCENTRATION_PARTS_PER_MILLION,
PERCENTAGE,
SIGNAL_STRENGTH_DECIBELS_MILLIWATT,
UnitOfTemperature,
@@ -72,6 +73,12 @@ SENSOR_DESCRIPTIONS = {
native_unit_of_measurement=CONCENTRATION_MICROGRAMS_PER_CUBIC_METER,
state_class=SensorStateClass.MEASUREMENT,
),
(DeviceClass.CO2, Units.CONCENTRATION_PARTS_PER_MILLION): SensorEntityDescription(
key=f"{DeviceClass.CO2}_{Units.CONCENTRATION_PARTS_PER_MILLION}",
device_class=SensorDeviceClass.CO2,
native_unit_of_measurement=CONCENTRATION_PARTS_PER_MILLION,
state_class=SensorStateClass.MEASUREMENT,
),
}

View File

@@ -212,6 +212,11 @@ BLUETOOTH: Final[list[dict[str, bool | str | int | list[int]]]] = [
"domain": "govee_ble",
"local_name": "GVH5110*",
},
{
"connectable": False,
"domain": "govee_ble",
"local_name": "GV5140*",
},
{
"connectable": False,
"domain": "govee_ble",

View File

@@ -84,7 +84,6 @@ GVH5106_SERVICE_INFO = BluetoothServiceInfo(
source="local",
)
GV5125_BUTTON_0_SERVICE_INFO = BluetoothServiceInfo(
name="GV51255367",
address="C1:37:37:32:0F:45",
@@ -163,6 +162,16 @@ GV5123_CLOSED_SERVICE_INFO = BluetoothServiceInfo(
source="24:4C:AB:03:E6:B8",
)
# Encodes: temperature=21.6°C, humidity=67.8%, CO2=531 ppm, no error
GV5140_SERVICE_INFO = BluetoothServiceInfo(
name="GV5140EEFF",
address="AA:BB:CC:DD:EE:FF",
rssi=-63,
manufacturer_data={1: b"\x01\x01\x03\x4e\x66\x02\x13\x00"},
service_uuids=["0000ec88-0000-1000-8000-00805f9b34fb"],
service_data={},
source="local",
)
GVH5124_SERVICE_INFO = BluetoothServiceInfo(
name="GV51242F68",

View File

@@ -17,6 +17,7 @@ from homeassistant.core import HomeAssistant
from homeassistant.util import dt as dt_util
from . import (
GV5140_SERVICE_INFO,
GVH5075_SERVICE_INFO,
GVH5106_SERVICE_INFO,
GVH5178_PRIMARY_SERVICE_INFO,
@@ -163,6 +164,33 @@ async def test_gvh5178_multi_sensor(hass: HomeAssistant) -> None:
assert primary_temp_sensor.state == STATE_UNAVAILABLE
async def test_gv5140(hass: HomeAssistant) -> None:
"""Test setting up creates the sensors for a device with CO2."""
entry = MockConfigEntry(
domain=DOMAIN,
unique_id="AA:BB:CC:DD:EE:FF",
)
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()) == 0
inject_bluetooth_service_info(hass, GV5140_SERVICE_INFO)
await hass.async_block_till_done()
assert len(hass.states.async_all()) == 3
co2_sensor = hass.states.get("sensor.5140eeff_carbon_dioxide")
co2_sensor_attributes = co2_sensor.attributes
assert co2_sensor.state == "531"
assert co2_sensor_attributes[ATTR_FRIENDLY_NAME] == "5140EEFF Carbon Dioxide"
assert co2_sensor_attributes[ATTR_UNIT_OF_MEASUREMENT] == "ppm"
assert co2_sensor_attributes[ATTR_STATE_CLASS] == "measurement"
assert await hass.config_entries.async_unload(entry.entry_id)
await hass.async_block_till_done()
async def test_gvh5106(hass: HomeAssistant) -> None:
"""Test setting up creates the sensors for a device with PM25."""
entry = MockConfigEntry(