mirror of
https://github.com/home-assistant/core.git
synced 2025-07-23 05:07:41 +00:00
Intellifire - Number Entity - Flame Height Control (#79901)
* Adding flame height control * oops * addressing comments * fix coverage file * addressing PR comments
This commit is contained in:
parent
731f618028
commit
ff2d762f55
@ -582,6 +582,7 @@ omit =
|
|||||||
homeassistant/components/intellifire/coordinator.py
|
homeassistant/components/intellifire/coordinator.py
|
||||||
homeassistant/components/intellifire/entity.py
|
homeassistant/components/intellifire/entity.py
|
||||||
homeassistant/components/intellifire/fan.py
|
homeassistant/components/intellifire/fan.py
|
||||||
|
homeassistant/components/intellifire/number.py
|
||||||
homeassistant/components/intellifire/sensor.py
|
homeassistant/components/intellifire/sensor.py
|
||||||
homeassistant/components/intellifire/switch.py
|
homeassistant/components/intellifire/switch.py
|
||||||
homeassistant/components/intesishome/*
|
homeassistant/components/intesishome/*
|
||||||
|
@ -24,6 +24,7 @@ PLATFORMS = [
|
|||||||
Platform.BINARY_SENSOR,
|
Platform.BINARY_SENSOR,
|
||||||
Platform.CLIMATE,
|
Platform.CLIMATE,
|
||||||
Platform.FAN,
|
Platform.FAN,
|
||||||
|
Platform.NUMBER,
|
||||||
Platform.SENSOR,
|
Platform.SENSOR,
|
||||||
Platform.SWITCH,
|
Platform.SWITCH,
|
||||||
]
|
]
|
||||||
|
77
homeassistant/components/intellifire/number.py
Normal file
77
homeassistant/components/intellifire/number.py
Normal file
@ -0,0 +1,77 @@
|
|||||||
|
"""Flame height number sensors."""
|
||||||
|
from __future__ import annotations
|
||||||
|
|
||||||
|
from dataclasses import dataclass
|
||||||
|
|
||||||
|
from homeassistant.components.number import (
|
||||||
|
NumberEntity,
|
||||||
|
NumberEntityDescription,
|
||||||
|
NumberMode,
|
||||||
|
)
|
||||||
|
from homeassistant.config_entries import ConfigEntry
|
||||||
|
from homeassistant.core import HomeAssistant
|
||||||
|
from homeassistant.helpers.entity_platform import AddEntitiesCallback
|
||||||
|
|
||||||
|
from .const import DOMAIN, LOGGER
|
||||||
|
from .coordinator import IntellifireDataUpdateCoordinator
|
||||||
|
from .entity import IntellifireEntity
|
||||||
|
|
||||||
|
|
||||||
|
async def async_setup_entry(
|
||||||
|
hass: HomeAssistant,
|
||||||
|
entry: ConfigEntry,
|
||||||
|
async_add_entities: AddEntitiesCallback,
|
||||||
|
) -> None:
|
||||||
|
"""Set up the fans."""
|
||||||
|
coordinator: IntellifireDataUpdateCoordinator = hass.data[DOMAIN][entry.entry_id]
|
||||||
|
|
||||||
|
description = NumberEntityDescription(
|
||||||
|
key="flame_control",
|
||||||
|
name="Flame control",
|
||||||
|
icon="mdi:arrow-expand-vertical",
|
||||||
|
)
|
||||||
|
|
||||||
|
async_add_entities(
|
||||||
|
[
|
||||||
|
IntellifireFlameControlEntity(
|
||||||
|
coordinator=coordinator, description=description
|
||||||
|
)
|
||||||
|
]
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
|
@dataclass
|
||||||
|
class IntellifireFlameControlEntity(IntellifireEntity, NumberEntity):
|
||||||
|
"""Flame height control entity."""
|
||||||
|
|
||||||
|
_attr_native_max_value: float = 5
|
||||||
|
_attr_native_min_value: float = 1
|
||||||
|
_attr_native_step: float = 1
|
||||||
|
_attr_mode: NumberMode = NumberMode.SLIDER
|
||||||
|
|
||||||
|
def __init__(
|
||||||
|
self,
|
||||||
|
coordinator: IntellifireDataUpdateCoordinator,
|
||||||
|
description: NumberEntityDescription,
|
||||||
|
) -> None:
|
||||||
|
"""Initilaize Flame height Sensor."""
|
||||||
|
super().__init__(coordinator, description)
|
||||||
|
|
||||||
|
@property
|
||||||
|
def native_value(self) -> float | None:
|
||||||
|
"""Return the current Flame Height segment number value."""
|
||||||
|
# UI uses 1-5 for flame height, backing lib uses 0-4
|
||||||
|
value = self.coordinator.read_api.data.flameheight + 1
|
||||||
|
return value
|
||||||
|
|
||||||
|
async def async_set_native_value(self, value: float) -> None:
|
||||||
|
"""Slider change."""
|
||||||
|
value_to_send: int = int(value) - 1
|
||||||
|
LOGGER.debug(
|
||||||
|
"%s set flame height to %d with raw value %s",
|
||||||
|
self._attr_name,
|
||||||
|
value,
|
||||||
|
value_to_send,
|
||||||
|
)
|
||||||
|
await self.coordinator.control_api.set_flame_height(height=value_to_send)
|
||||||
|
await self.coordinator.async_refresh()
|
@ -60,7 +60,8 @@ INTELLIFIRE_SENSORS: tuple[IntellifireSensorEntityDescription, ...] = (
|
|||||||
icon="mdi:fire-circle",
|
icon="mdi:fire-circle",
|
||||||
name="Flame Height",
|
name="Flame Height",
|
||||||
state_class=SensorStateClass.MEASUREMENT,
|
state_class=SensorStateClass.MEASUREMENT,
|
||||||
value_fn=lambda data: data.flameheight,
|
# UI uses 1-5 for flame height, backing lib uses 0-4
|
||||||
|
value_fn=lambda data: (data.flameheight + 1),
|
||||||
),
|
),
|
||||||
IntellifireSensorEntityDescription(
|
IntellifireSensorEntityDescription(
|
||||||
key="temperature",
|
key="temperature",
|
||||||
|
Loading…
x
Reference in New Issue
Block a user