mirror of
https://github.com/home-assistant/core.git
synced 2025-07-19 03:07:37 +00:00
Use new device class in arwn (#83406)
This commit is contained in:
parent
75c5137e77
commit
65b391e651
@ -6,12 +6,7 @@ import logging
|
|||||||
|
|
||||||
from homeassistant.components import mqtt
|
from homeassistant.components import mqtt
|
||||||
from homeassistant.components.sensor import SensorDeviceClass, SensorEntity
|
from homeassistant.components.sensor import SensorDeviceClass, SensorEntity
|
||||||
from homeassistant.const import (
|
from homeassistant.const import DEGREE, UnitOfPrecipitationDepth, UnitOfTemperature
|
||||||
DEGREE,
|
|
||||||
PRECIPITATION_INCHES,
|
|
||||||
TEMP_CELSIUS,
|
|
||||||
TEMP_FAHRENHEIT,
|
|
||||||
)
|
|
||||||
from homeassistant.core import HomeAssistant, callback
|
from homeassistant.core import HomeAssistant, callback
|
||||||
from homeassistant.helpers.entity_platform import AddEntitiesCallback
|
from homeassistant.helpers.entity_platform import AddEntitiesCallback
|
||||||
from homeassistant.helpers.typing import ConfigType, DiscoveryInfoType
|
from homeassistant.helpers.typing import ConfigType, DiscoveryInfoType
|
||||||
@ -36,9 +31,9 @@ def discover_sensors(topic, payload):
|
|||||||
if domain == "temperature":
|
if domain == "temperature":
|
||||||
name = parts[2]
|
name = parts[2]
|
||||||
if unit == "F":
|
if unit == "F":
|
||||||
unit = TEMP_FAHRENHEIT
|
unit = UnitOfTemperature.FAHRENHEIT
|
||||||
else:
|
else:
|
||||||
unit = TEMP_CELSIUS
|
unit = UnitOfTemperature.CELSIUS
|
||||||
return ArwnSensor(
|
return ArwnSensor(
|
||||||
topic, name, "temp", unit, device_class=SensorDeviceClass.TEMPERATURE
|
topic, name, "temp", unit, device_class=SensorDeviceClass.TEMPERATURE
|
||||||
)
|
)
|
||||||
@ -51,21 +46,43 @@ def discover_sensors(topic, payload):
|
|||||||
topic,
|
topic,
|
||||||
"Rain Since Midnight",
|
"Rain Since Midnight",
|
||||||
"since_midnight",
|
"since_midnight",
|
||||||
PRECIPITATION_INCHES,
|
UnitOfPrecipitationDepth.INCHES,
|
||||||
"mdi:water",
|
device_class=SensorDeviceClass.PRECIPITATION,
|
||||||
)
|
)
|
||||||
return (
|
return (
|
||||||
ArwnSensor(topic + "/total", "Total Rainfall", "total", unit, "mdi:water"),
|
ArwnSensor(
|
||||||
ArwnSensor(topic + "/rate", "Rainfall Rate", "rate", unit, "mdi:water"),
|
topic + "/total",
|
||||||
|
"Total Rainfall",
|
||||||
|
"total",
|
||||||
|
unit,
|
||||||
|
device_class=SensorDeviceClass.PRECIPITATION,
|
||||||
|
),
|
||||||
|
ArwnSensor(
|
||||||
|
topic + "/rate",
|
||||||
|
"Rainfall Rate",
|
||||||
|
"rate",
|
||||||
|
unit,
|
||||||
|
device_class=SensorDeviceClass.PRECIPITATION,
|
||||||
|
),
|
||||||
)
|
)
|
||||||
if domain == "barometer":
|
if domain == "barometer":
|
||||||
return ArwnSensor(topic, "Barometer", "pressure", unit, "mdi:thermometer-lines")
|
return ArwnSensor(topic, "Barometer", "pressure", unit, "mdi:thermometer-lines")
|
||||||
if domain == "wind":
|
if domain == "wind":
|
||||||
return (
|
return (
|
||||||
ArwnSensor(
|
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(
|
ArwnSensor(
|
||||||
topic + "/dir", "Wind Direction", "direction", DEGREE, "mdi:compass"
|
topic + "/dir", "Wind Direction", "direction", DEGREE, "mdi:compass"
|
||||||
),
|
),
|
||||||
|
Loading…
x
Reference in New Issue
Block a user