diff --git a/homeassistant/components/govee_ble/manifest.json b/homeassistant/components/govee_ble/manifest.json index 1bfd73e875f..ed1518be6cc 100644 --- a/homeassistant/components/govee_ble/manifest.json +++ b/homeassistant/components/govee_ble/manifest.json @@ -54,6 +54,10 @@ "connectable": false, "local_name": "GVH5110*" }, + { + "connectable": false, + "local_name": "GV5140*" + }, { "connectable": false, "manufacturer_id": 1, diff --git a/homeassistant/components/govee_ble/sensor.py b/homeassistant/components/govee_ble/sensor.py index fa0b828176c..848268ae61f 100644 --- a/homeassistant/components/govee_ble/sensor.py +++ b/homeassistant/components/govee_ble/sensor.py @@ -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, + ), } diff --git a/homeassistant/generated/bluetooth.py b/homeassistant/generated/bluetooth.py index 51709a3b548..3b558100903 100644 --- a/homeassistant/generated/bluetooth.py +++ b/homeassistant/generated/bluetooth.py @@ -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", diff --git a/tests/components/govee_ble/__init__.py b/tests/components/govee_ble/__init__.py index 66c5b0b832c..25721b08e05 100644 --- a/tests/components/govee_ble/__init__.py +++ b/tests/components/govee_ble/__init__.py @@ -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", diff --git a/tests/components/govee_ble/test_sensor.py b/tests/components/govee_ble/test_sensor.py index 2410b5dbbde..65dc1060b2a 100644 --- a/tests/components/govee_ble/test_sensor.py +++ b/tests/components/govee_ble/test_sensor.py @@ -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(