Use new device class in arwn (#83406)
parent
75c5137e77
commit
65b391e651
|
@ -6,12 +6,7 @@ import logging
|
|||
|
||||
from homeassistant.components import mqtt
|
||||
from homeassistant.components.sensor import SensorDeviceClass, SensorEntity
|
||||
from homeassistant.const import (
|
||||
DEGREE,
|
||||
PRECIPITATION_INCHES,
|
||||
TEMP_CELSIUS,
|
||||
TEMP_FAHRENHEIT,
|
||||
)
|
||||
from homeassistant.const import DEGREE, UnitOfPrecipitationDepth, UnitOfTemperature
|
||||
from homeassistant.core import HomeAssistant, callback
|
||||
from homeassistant.helpers.entity_platform import AddEntitiesCallback
|
||||
from homeassistant.helpers.typing import ConfigType, DiscoveryInfoType
|
||||
|
@ -36,9 +31,9 @@ def discover_sensors(topic, payload):
|
|||
if domain == "temperature":
|
||||
name = parts[2]
|
||||
if unit == "F":
|
||||
unit = TEMP_FAHRENHEIT
|
||||
unit = UnitOfTemperature.FAHRENHEIT
|
||||
else:
|
||||
unit = TEMP_CELSIUS
|
||||
unit = UnitOfTemperature.CELSIUS
|
||||
return ArwnSensor(
|
||||
topic, name, "temp", unit, device_class=SensorDeviceClass.TEMPERATURE
|
||||
)
|
||||
|
@ -51,21 +46,43 @@ def discover_sensors(topic, payload):
|
|||
topic,
|
||||
"Rain Since Midnight",
|
||||
"since_midnight",
|
||||
PRECIPITATION_INCHES,
|
||||
"mdi:water",
|
||||
UnitOfPrecipitationDepth.INCHES,
|
||||
device_class=SensorDeviceClass.PRECIPITATION,
|
||||
)
|
||||
return (
|
||||
ArwnSensor(topic + "/total", "Total Rainfall", "total", unit, "mdi:water"),
|
||||
ArwnSensor(topic + "/rate", "Rainfall Rate", "rate", unit, "mdi:water"),
|
||||
ArwnSensor(
|
||||
topic + "/total",
|
||||
"Total Rainfall",
|
||||
"total",
|
||||
unit,
|
||||
device_class=SensorDeviceClass.PRECIPITATION,
|
||||
),
|
||||
ArwnSensor(
|
||||
topic + "/rate",
|
||||
"Rainfall Rate",
|
||||
"rate",
|
||||
unit,
|
||||
device_class=SensorDeviceClass.PRECIPITATION,
|
||||
),
|
||||
)
|
||||
if domain == "barometer":
|
||||
return ArwnSensor(topic, "Barometer", "pressure", unit, "mdi:thermometer-lines")
|
||||
if domain == "wind":
|
||||
return (
|
||||
ArwnSensor(
|
||||
topic + "/speed", "Wind Speed", "speed", unit, "mdi:speedometer"
|
||||
topic + "/speed",
|
||||
"Wind Speed",
|
||||
"speed",
|
||||
unit,
|
||||
device_class=SensorDeviceClass.WIND_SPEED,
|
||||
),
|
||||
ArwnSensor(
|
||||
topic + "/gust",
|
||||
"Wind Gust",
|
||||
"gust",
|
||||
unit,
|
||||
device_class=SensorDeviceClass.WIND_SPEED,
|
||||
),
|
||||
ArwnSensor(topic + "/gust", "Wind Gust", "gust", unit, "mdi:speedometer"),
|
||||
ArwnSensor(
|
||||
topic + "/dir", "Wind Direction", "direction", DEGREE, "mdi:compass"
|
||||
),
|
||||
|
|
Loading…
Reference in New Issue