diff --git a/homeassistant/components/nam/const.py b/homeassistant/components/nam/const.py index 2e4d6b0c85a56..4b7b50b309ae3 100644 --- a/homeassistant/components/nam/const.py +++ b/homeassistant/components/nam/const.py @@ -20,6 +20,7 @@ ATTR_BMP280_TEMPERATURE: Final = "bmp280_temperature" ATTR_DHT22_HUMIDITY: Final = "dht22_humidity" ATTR_DHT22_TEMPERATURE: Final = "dht22_temperature" +ATTR_DS18B20_TEMPERATURE: Final = "ds18b20_temperature" ATTR_HECA_HUMIDITY: Final = "heca_humidity" ATTR_HECA_TEMPERATURE: Final = "heca_temperature" ATTR_MHZ14A_CARBON_DIOXIDE: Final = "mhz14a_carbon_dioxide" diff --git a/homeassistant/components/nam/sensor.py b/homeassistant/components/nam/sensor.py index 0f4647d071fd9..27fae62be8a7f 100644 --- a/homeassistant/components/nam/sensor.py +++ b/homeassistant/components/nam/sensor.py @@ -43,6 +43,7 @@ ATTR_BMP280_TEMPERATURE, ATTR_DHT22_HUMIDITY, ATTR_DHT22_TEMPERATURE, + ATTR_DS18B20_TEMPERATURE, ATTR_HECA_HUMIDITY, ATTR_HECA_TEMPERATURE, ATTR_MHZ14A_CARBON_DIOXIDE, @@ -145,6 +146,15 @@ class NAMSensorEntityDescription(SensorEntityDescription): state_class=SensorStateClass.MEASUREMENT, value=lambda sensors: sensors.bmp280_temperature, ), + NAMSensorEntityDescription( + key=ATTR_DS18B20_TEMPERATURE, + translation_key="ds18b20_temperature", + suggested_display_precision=1, + native_unit_of_measurement=UnitOfTemperature.CELSIUS, + device_class=SensorDeviceClass.TEMPERATURE, + state_class=SensorStateClass.MEASUREMENT, + value=lambda sensors: sensors.ds18b20_temperature, + ), NAMSensorEntityDescription( key=ATTR_HECA_HUMIDITY, translation_key="heca_humidity", diff --git a/homeassistant/components/nam/strings.json b/homeassistant/components/nam/strings.json index be41f50c7b6c9..c4921ec52f96b 100644 --- a/homeassistant/components/nam/strings.json +++ b/homeassistant/components/nam/strings.json @@ -75,6 +75,9 @@ "bmp280_temperature": { "name": "BMP280 temperature" }, + "ds18b20_temperature": { + "name": "DS18B20 temperature" + }, "heca_humidity": { "name": "HECA humidity" }, diff --git a/tests/components/nam/fixtures/nam_data.json b/tests/components/nam/fixtures/nam_data.json index 93a33d4a5529c..82dacbefb342d 100644 --- a/tests/components/nam/fixtures/nam_data.json +++ b/tests/components/nam/fixtures/nam_data.json @@ -15,6 +15,7 @@ { "value_type": "BME280_temperature", "value": "7.56" }, { "value_type": "BME280_humidity", "value": "45.69" }, { "value_type": "BME280_pressure", "value": "101101.17" }, + { "value_type": "DS18B20_temperature", "value": "12.56" }, { "value_type": "BMP_temperature", "value": "7.56" }, { "value_type": "BMP_pressure", "value": "103201.18" }, { "value_type": "BMP280_temperature", "value": "5.56" }, diff --git a/tests/components/nam/snapshots/test_diagnostics.ambr b/tests/components/nam/snapshots/test_diagnostics.ambr index a8072ee224ddc..c187dec2866ca 100644 --- a/tests/components/nam/snapshots/test_diagnostics.ambr +++ b/tests/components/nam/snapshots/test_diagnostics.ambr @@ -11,7 +11,7 @@ 'bmp280_temperature': 5.6, 'dht22_humidity': 46.2, 'dht22_temperature': 6.3, - 'ds18b20_temperature': None, + 'ds18b20_temperature': 12.6, 'heca_humidity': 50.0, 'heca_temperature': 8.0, 'mhz14a_carbon_dioxide': 865.0, diff --git a/tests/components/nam/snapshots/test_sensor.ambr b/tests/components/nam/snapshots/test_sensor.ambr index bbc655ecbb683..ea47998f3de37 100644 --- a/tests/components/nam/snapshots/test_sensor.ambr +++ b/tests/components/nam/snapshots/test_sensor.ambr @@ -532,6 +532,60 @@ 'state': '6.3', }) # --- +# name: test_sensor[sensor.nettigo_air_monitor_ds18b20_temperature-entry] + EntityRegistryEntrySnapshot({ + 'aliases': set({ + }), + 'area_id': None, + 'capabilities': dict({ + 'state_class': , + }), + 'config_entry_id': , + 'device_class': None, + 'device_id': , + 'disabled_by': None, + 'domain': 'sensor', + 'entity_category': None, + 'entity_id': 'sensor.nettigo_air_monitor_ds18b20_temperature', + 'has_entity_name': True, + 'hidden_by': None, + 'icon': None, + 'id': , + 'labels': set({ + }), + 'name': None, + 'options': dict({ + 'sensor': dict({ + 'suggested_display_precision': 1, + }), + }), + 'original_device_class': , + 'original_icon': None, + 'original_name': 'DS18B20 temperature', + 'platform': 'nam', + 'previous_unique_id': None, + 'supported_features': 0, + 'translation_key': 'ds18b20_temperature', + 'unique_id': 'aa:bb:cc:dd:ee:ff-ds18b20_temperature', + 'unit_of_measurement': , + }) +# --- +# name: test_sensor[sensor.nettigo_air_monitor_ds18b20_temperature-state] + StateSnapshot({ + 'attributes': ReadOnlyDict({ + 'device_class': 'temperature', + 'friendly_name': 'Nettigo Air Monitor DS18B20 temperature', + 'state_class': , + 'unit_of_measurement': , + }), + 'context': , + 'entity_id': 'sensor.nettigo_air_monitor_ds18b20_temperature', + 'last_changed': , + 'last_reported': , + 'last_updated': , + 'state': '12.6', + }) +# --- # name: test_sensor[sensor.nettigo_air_monitor_heca_humidity-entry] EntityRegistryEntrySnapshot({ 'aliases': set({