From 257bac9d86ed4c8aee0ce6bbba92849f9d13cb55 Mon Sep 17 00:00:00 2001 From: "Dustin C. Hatch" Date: Sat, 1 May 2021 16:42:26 -0500 Subject: [PATCH] sensor: Add device metadata Associating sensor entities with a device improves organization within the Home Assistant UI. --- src/thermostat/sensor.py | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/src/thermostat/sensor.py b/src/thermostat/sensor.py index 3427711..da341bd 100644 --- a/src/thermostat/sensor.py +++ b/src/thermostat/sensor.py @@ -27,11 +27,20 @@ AVAILABILITY_TOPIC = f"{TOPIC}/availability" I2CPORT = 1 SENSOR_ADDR = 0x77 +DEVICE = { + "manufacturer": "Dustin C. Hatch", + "name": "RPi Thermostat Display", + "model": "RPi Thermostat Display", + "identifiers": [ + os.uname().nodename, + ], +} SENSOR_CONFIG = { "thermostat_temperature": { "device_class": "temperature", "name": "Thermostat Temperature", + "device": DEVICE, "state_topic": TOPIC, "availability_topic": AVAILABILITY_TOPIC, "unit_of_measurement": "°C", @@ -40,6 +49,7 @@ SENSOR_CONFIG = { "thermostat_pressure": { "device_class": "pressure", "name": "Thermostat Pressure", + "device": DEVICE, "state_topic": TOPIC, "availability_topic": AVAILABILITY_TOPIC, "unit_of_measurement": "hPa", @@ -48,6 +58,7 @@ SENSOR_CONFIG = { "thermostat_humidity": { "device_class": "humidity", "name": "Thermostat Humidity", + "device": DEVICE, "state_topic": TOPIC, "availability_topic": AVAILABILITY_TOPIC, "unit_of_measurement": "%",