mirror of
https://github.com/home-assistant/core.git
synced 2025-07-23 13:17:32 +00:00
Link mold_indicator entity to device from humidity sensor (#125528)
This commit is contained in:
parent
2fa0f283ea
commit
3cc5a29c1b
@ -32,6 +32,7 @@ from homeassistant.core import (
|
|||||||
callback,
|
callback,
|
||||||
)
|
)
|
||||||
import homeassistant.helpers.config_validation as cv
|
import homeassistant.helpers.config_validation as cv
|
||||||
|
from homeassistant.helpers.device import async_device_info_to_link_from_entity
|
||||||
from homeassistant.helpers.entity_platform import AddEntitiesCallback
|
from homeassistant.helpers.entity_platform import AddEntitiesCallback
|
||||||
from homeassistant.helpers.event import async_track_state_change_event
|
from homeassistant.helpers.event import async_track_state_change_event
|
||||||
from homeassistant.helpers.typing import ConfigType, DiscoveryInfoType, StateType
|
from homeassistant.helpers.typing import ConfigType, DiscoveryInfoType, StateType
|
||||||
@ -82,6 +83,7 @@ async def async_setup_platform(
|
|||||||
async_add_entities(
|
async_add_entities(
|
||||||
[
|
[
|
||||||
MoldIndicator(
|
MoldIndicator(
|
||||||
|
hass,
|
||||||
name,
|
name,
|
||||||
hass.config.units is METRIC_SYSTEM,
|
hass.config.units is METRIC_SYSTEM,
|
||||||
indoor_temp_sensor,
|
indoor_temp_sensor,
|
||||||
@ -109,6 +111,7 @@ async def async_setup_entry(
|
|||||||
async_add_entities(
|
async_add_entities(
|
||||||
[
|
[
|
||||||
MoldIndicator(
|
MoldIndicator(
|
||||||
|
hass,
|
||||||
name,
|
name,
|
||||||
hass.config.units is METRIC_SYSTEM,
|
hass.config.units is METRIC_SYSTEM,
|
||||||
indoor_temp_sensor,
|
indoor_temp_sensor,
|
||||||
@ -131,6 +134,7 @@ class MoldIndicator(SensorEntity):
|
|||||||
|
|
||||||
def __init__(
|
def __init__(
|
||||||
self,
|
self,
|
||||||
|
hass: HomeAssistant,
|
||||||
name: str,
|
name: str,
|
||||||
is_metric: bool,
|
is_metric: bool,
|
||||||
indoor_temp_sensor: str,
|
indoor_temp_sensor: str,
|
||||||
@ -158,6 +162,10 @@ class MoldIndicator(SensorEntity):
|
|||||||
self._outdoor_temp: float | None = None
|
self._outdoor_temp: float | None = None
|
||||||
self._indoor_hum: float | None = None
|
self._indoor_hum: float | None = None
|
||||||
self._crit_temp: float | None = None
|
self._crit_temp: float | None = None
|
||||||
|
self._attr_device_info = async_device_info_to_link_from_entity(
|
||||||
|
hass,
|
||||||
|
indoor_humidity_sensor,
|
||||||
|
)
|
||||||
|
|
||||||
async def async_added_to_hass(self) -> None:
|
async def async_added_to_hass(self) -> None:
|
||||||
"""Register callbacks."""
|
"""Register callbacks."""
|
||||||
|
Loading…
x
Reference in New Issue
Block a user