Skip to content

Commit

Permalink
Add support for the DS18B20 temperature sensor to Nettigo Air Monitor…
Browse files Browse the repository at this point in the history
… integration (#118601)

Add support for DS18B20 temperature sensor

Co-authored-by: Maciej Bieniek <[email protected]>
  • Loading branch information
bieniu and bieniu authored Jun 2, 2024
1 parent 51394ce commit afc29fd
Show file tree
Hide file tree
Showing 6 changed files with 70 additions and 1 deletion.
1 change: 1 addition & 0 deletions homeassistant/components/nam/const.py
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
10 changes: 10 additions & 0 deletions homeassistant/components/nam/sensor.py
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -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",
Expand Down
3 changes: 3 additions & 0 deletions homeassistant/components/nam/strings.json
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,9 @@
"bmp280_temperature": {
"name": "BMP280 temperature"
},
"ds18b20_temperature": {
"name": "DS18B20 temperature"
},
"heca_humidity": {
"name": "HECA humidity"
},
Expand Down
1 change: 1 addition & 0 deletions tests/components/nam/fixtures/nam_data.json
Original file line number Diff line number Diff line change
Expand Up @@ -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" },
Expand Down
2 changes: 1 addition & 1 deletion tests/components/nam/snapshots/test_diagnostics.ambr
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
54 changes: 54 additions & 0 deletions tests/components/nam/snapshots/test_sensor.ambr
Original file line number Diff line number Diff line change
Expand Up @@ -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': <SensorStateClass.MEASUREMENT: 'measurement'>,
}),
'config_entry_id': <ANY>,
'device_class': None,
'device_id': <ANY>,
'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': <ANY>,
'labels': set({
}),
'name': None,
'options': dict({
'sensor': dict({
'suggested_display_precision': 1,
}),
}),
'original_device_class': <SensorDeviceClass.TEMPERATURE: 'temperature'>,
'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': <UnitOfTemperature.CELSIUS: '°C'>,
})
# ---
# 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': <SensorStateClass.MEASUREMENT: 'measurement'>,
'unit_of_measurement': <UnitOfTemperature.CELSIUS: '°C'>,
}),
'context': <ANY>,
'entity_id': 'sensor.nettigo_air_monitor_ds18b20_temperature',
'last_changed': <ANY>,
'last_reported': <ANY>,
'last_updated': <ANY>,
'state': '12.6',
})
# ---
# name: test_sensor[sensor.nettigo_air_monitor_heca_humidity-entry]
EntityRegistryEntrySnapshot({
'aliases': set({
Expand Down

0 comments on commit afc29fd

Please sign in to comment.