Add all wm and td sensors to wd
This commit is contained in:
@ -11,7 +11,7 @@ from homeassistant.components.binary_sensor import (
|
||||
from homeassistant.config_entries import ConfigEntry
|
||||
from homeassistant.core import callback
|
||||
from .const import DOMAIN
|
||||
from .hon import HonCoordinator, HonEntity
|
||||
from .hon import HonCoordinator, HonEntity, unique_entities
|
||||
|
||||
_LOGGER = logging.getLogger(__name__)
|
||||
|
||||
@ -52,32 +52,6 @@ BINARY_SENSORS: dict[str, tuple[HonBinarySensorEntityDescription, ...]] = {
|
||||
on_value="1",
|
||||
translation_key="door_open",
|
||||
),
|
||||
),
|
||||
"TD": (
|
||||
HonBinarySensorEntityDescription(
|
||||
key="attributes.lastConnEvent.category",
|
||||
name="Connection",
|
||||
device_class=BinarySensorDeviceClass.CONNECTIVITY,
|
||||
on_value="CONNECTED",
|
||||
translation_key="connection",
|
||||
),
|
||||
HonBinarySensorEntityDescription(
|
||||
key="doorStatus",
|
||||
name="Door",
|
||||
device_class=BinarySensorDeviceClass.DOOR,
|
||||
on_value="1",
|
||||
translation_key="door_open",
|
||||
),
|
||||
),
|
||||
"WD": (
|
||||
HonBinarySensorEntityDescription(
|
||||
key="attributes.lastConnEvent.category",
|
||||
name="Remote Control",
|
||||
device_class=BinarySensorDeviceClass.CONNECTIVITY,
|
||||
on_value="CONNECTED",
|
||||
icon="mdi:remote",
|
||||
translation_key="remote_control",
|
||||
),
|
||||
HonBinarySensorEntityDescription(
|
||||
key="startProgram.prewash", name="Pre Wash", translation_key="prewash"
|
||||
),
|
||||
@ -96,6 +70,22 @@ BINARY_SENSORS: dict[str, tuple[HonBinarySensorEntityDescription, ...]] = {
|
||||
HonBinarySensorEntityDescription(
|
||||
key="acquaplus", name="Acqua Plus", translation_key="acqua_plus"
|
||||
),
|
||||
),
|
||||
"TD": (
|
||||
HonBinarySensorEntityDescription(
|
||||
key="attributes.lastConnEvent.category",
|
||||
name="Connection",
|
||||
device_class=BinarySensorDeviceClass.CONNECTIVITY,
|
||||
on_value="CONNECTED",
|
||||
translation_key="connection",
|
||||
),
|
||||
HonBinarySensorEntityDescription(
|
||||
key="doorStatus",
|
||||
name="Door",
|
||||
device_class=BinarySensorDeviceClass.DOOR,
|
||||
on_value="1",
|
||||
translation_key="door_open",
|
||||
),
|
||||
HonBinarySensorEntityDescription(
|
||||
key="anticrease", name="Anti-Crease", translation_key="anti_crease"
|
||||
),
|
||||
@ -208,6 +198,9 @@ BINARY_SENSORS: dict[str, tuple[HonBinarySensorEntityDescription, ...]] = {
|
||||
}
|
||||
|
||||
|
||||
BINARY_SENSORS["WD"] = unique_entities(BINARY_SENSORS["WM"], BINARY_SENSORS["TD"])
|
||||
|
||||
|
||||
async def async_setup_entry(hass, entry: ConfigEntry, async_add_entities) -> None:
|
||||
hon: Hon = hass.data[DOMAIN][entry.unique_id]
|
||||
coordinators = hass.data[DOMAIN]["coordinators"]
|
||||
@ -224,12 +217,8 @@ async def async_setup_entry(hass, entry: ConfigEntry, async_add_entities) -> Non
|
||||
for description in descriptions:
|
||||
if not device.get(description.key):
|
||||
continue
|
||||
appliances.extend(
|
||||
[
|
||||
HonBinarySensorEntity(
|
||||
hass, coordinator, entry, device, description
|
||||
)
|
||||
]
|
||||
appliances.append(
|
||||
HonBinarySensorEntity(hass, coordinator, entry, device, description)
|
||||
)
|
||||
|
||||
async_add_entities(appliances)
|
||||
|
@ -50,3 +50,12 @@ class HonCoordinator(DataUpdateCoordinator):
|
||||
|
||||
async def _async_update_data(self):
|
||||
await self._device.update()
|
||||
|
||||
|
||||
def unique_entities(base_entities, new_entities):
|
||||
result = list(base_entities)
|
||||
existing_entities = [entity.key for entity in base_entities]
|
||||
for entity in new_entities:
|
||||
if entity.key not in existing_entities:
|
||||
result.append(entity)
|
||||
return tuple(result)
|
||||
|
@ -15,7 +15,7 @@ from homeassistant.core import callback
|
||||
from homeassistant.helpers.entity import EntityCategory
|
||||
|
||||
from .const import DOMAIN
|
||||
from .hon import HonEntity, HonCoordinator
|
||||
from .hon import HonEntity, HonCoordinator, unique_entities
|
||||
|
||||
NUMBERS: dict[str, tuple[NumberEntityDescription, ...]] = {
|
||||
"WM": (
|
||||
@ -85,16 +85,6 @@ NUMBERS: dict[str, tuple[NumberEntityDescription, ...]] = {
|
||||
translation_key="dry_time",
|
||||
),
|
||||
),
|
||||
"WD": (
|
||||
NumberEntityDescription(
|
||||
key="startProgram.delayTime",
|
||||
name="Delay Time",
|
||||
icon="mdi:timer-plus",
|
||||
entity_category=EntityCategory.CONFIG,
|
||||
native_unit_of_measurement=UnitOfTime.MINUTES,
|
||||
translation_key="delay_time",
|
||||
),
|
||||
),
|
||||
"OV": (
|
||||
NumberEntityDescription(
|
||||
key="startProgram.delayTime",
|
||||
@ -166,6 +156,8 @@ NUMBERS: dict[str, tuple[NumberEntityDescription, ...]] = {
|
||||
),
|
||||
}
|
||||
|
||||
NUMBERS["WD"] = unique_entities(NUMBERS["WM"], NUMBERS["TD"])
|
||||
|
||||
|
||||
async def async_setup_entry(hass, entry: ConfigEntry, async_add_entities) -> None:
|
||||
hon: Hon = hass.data[DOMAIN][entry.unique_id]
|
||||
|
@ -14,7 +14,7 @@ from homeassistant.core import callback
|
||||
from homeassistant.helpers.entity import EntityCategory
|
||||
|
||||
from .const import DOMAIN
|
||||
from .hon import HonEntity, HonCoordinator
|
||||
from .hon import HonEntity, HonCoordinator, unique_entities
|
||||
|
||||
_LOGGER = logging.getLogger(__name__)
|
||||
|
||||
@ -66,14 +66,6 @@ SELECTS = {
|
||||
translation_key="dry_levels",
|
||||
),
|
||||
),
|
||||
"WD": (
|
||||
SelectEntityDescription(
|
||||
key="startProgram.program",
|
||||
name="Program",
|
||||
entity_category=EntityCategory.CONFIG,
|
||||
translation_key="programs_wm",
|
||||
),
|
||||
),
|
||||
"OV": (
|
||||
SelectEntityDescription(
|
||||
key="startProgram.program",
|
||||
@ -114,6 +106,8 @@ SELECTS = {
|
||||
),
|
||||
}
|
||||
|
||||
SELECTS["WD"] = unique_entities(SELECTS["WM"], SELECTS["TD"])
|
||||
|
||||
|
||||
async def async_setup_entry(hass, entry: ConfigEntry, async_add_entities) -> None:
|
||||
hon: Hon = hass.data[DOMAIN][entry.unique_id]
|
||||
|
@ -25,7 +25,7 @@ from homeassistant.const import PERCENTAGE
|
||||
|
||||
from . import const
|
||||
from .const import DOMAIN
|
||||
from .hon import HonCoordinator, HonEntity
|
||||
from .hon import HonCoordinator, HonEntity, unique_entities
|
||||
|
||||
_LOGGER = logging.getLogger(__name__)
|
||||
|
||||
@ -112,7 +112,7 @@ SENSORS: dict[str, tuple[SensorEntityDescription, ...]] = {
|
||||
name="Spin Speed",
|
||||
icon="mdi:speedometer",
|
||||
state_class=SensorStateClass.MEASUREMENT,
|
||||
native_unit_of_measurement=UnitOfTime.MINUTES,
|
||||
native_unit_of_measurement=REVOLUTIONS_PER_MINUTE,
|
||||
translation_key="spin_speed",
|
||||
),
|
||||
SensorEntityDescription(
|
||||
@ -238,12 +238,18 @@ SENSORS: dict[str, tuple[SensorEntityDescription, ...]] = {
|
||||
translation_key="energy_label",
|
||||
),
|
||||
SensorEntityDescription(
|
||||
key="steamLevel",
|
||||
key="startProgram.steamLevel",
|
||||
name="Steam level",
|
||||
icon="mdi:smoke",
|
||||
entity_category=EntityCategory.CONFIG,
|
||||
translation_key="steam_level",
|
||||
),
|
||||
SensorEntityDescription(
|
||||
key="steamLevel",
|
||||
name="Steam level",
|
||||
icon="mdi:smoke",
|
||||
translation_key="steam_level",
|
||||
),
|
||||
SensorEntityDescription(
|
||||
key="steamType",
|
||||
name="Steam Type",
|
||||
@ -251,120 +257,6 @@ SENSORS: dict[str, tuple[SensorEntityDescription, ...]] = {
|
||||
entity_category=EntityCategory.CONFIG,
|
||||
),
|
||||
),
|
||||
"WD": (
|
||||
SensorEntityDescription(
|
||||
key="totalElectricityUsed",
|
||||
name="Total Power",
|
||||
device_class=SensorDeviceClass.ENERGY,
|
||||
state_class=SensorStateClass.TOTAL_INCREASING,
|
||||
native_unit_of_measurement=UnitOfEnergy.KILO_WATT_HOUR,
|
||||
translation_key="energy_total",
|
||||
),
|
||||
SensorEntityDescription(
|
||||
key="totalWaterUsed",
|
||||
name="Total Water",
|
||||
device_class=SensorDeviceClass.WATER,
|
||||
state_class=SensorStateClass.TOTAL_INCREASING,
|
||||
native_unit_of_measurement=UnitOfVolume.LITERS,
|
||||
translation_key="water_total",
|
||||
),
|
||||
SensorEntityDescription(
|
||||
key="totalWashCycle",
|
||||
name="Total Wash Cycle",
|
||||
state_class=SensorStateClass.TOTAL_INCREASING,
|
||||
icon="mdi:counter",
|
||||
translation_key="cycles_total",
|
||||
),
|
||||
SensorEntityDescription(
|
||||
key="currentElectricityUsed",
|
||||
name="Current Electricity Used",
|
||||
state_class=SensorStateClass.MEASUREMENT,
|
||||
device_class=SensorDeviceClass.POWER,
|
||||
native_unit_of_measurement=UnitOfPower.KILO_WATT,
|
||||
icon="mdi:lightning-bolt",
|
||||
translation_key="energy_current",
|
||||
),
|
||||
SensorEntityDescription(
|
||||
key="currentWaterUsed",
|
||||
name="Current Water Used",
|
||||
state_class=SensorStateClass.MEASUREMENT,
|
||||
icon="mdi:water",
|
||||
translation_key="water_current",
|
||||
),
|
||||
SensorEntityDescription(
|
||||
key="startProgram.weight",
|
||||
name="Suggested weight",
|
||||
state_class=SensorStateClass.MEASUREMENT,
|
||||
entity_category=EntityCategory.CONFIG,
|
||||
native_unit_of_measurement=UnitOfMass.KILOGRAMS,
|
||||
icon="mdi:weight-kilogram",
|
||||
translation_key="suggested_load",
|
||||
),
|
||||
SensorEntityDescription(
|
||||
key="machMode",
|
||||
name="Machine Status",
|
||||
icon="mdi:information",
|
||||
device_class=SensorDeviceClass.ENUM,
|
||||
translation_key="washing_modes",
|
||||
options=list(const.MACH_MODE),
|
||||
),
|
||||
SensorEntityDescription(
|
||||
key="spinSpeed",
|
||||
name="Spin Speed",
|
||||
icon="mdi:fast-forward-outline",
|
||||
state_class=SensorStateClass.MEASUREMENT,
|
||||
native_unit_of_measurement=REVOLUTIONS_PER_MINUTE,
|
||||
translation_key="spin_speed",
|
||||
),
|
||||
SensorEntityDescription(
|
||||
key="remainingTimeMM",
|
||||
name="Remaining Time",
|
||||
icon="mdi:timer",
|
||||
state_class=SensorStateClass.MEASUREMENT,
|
||||
native_unit_of_measurement=UnitOfTime.MINUTES,
|
||||
translation_key="remaining_time",
|
||||
),
|
||||
SensorEntityDescription(
|
||||
key="prCode",
|
||||
name="Current Program",
|
||||
icon="mdi:tumble-dryer",
|
||||
translation_key="programs",
|
||||
),
|
||||
SensorEntityDescription(
|
||||
key="prPhase",
|
||||
name="Program Phase",
|
||||
icon="mdi:washing-machine",
|
||||
device_class=SensorDeviceClass.ENUM,
|
||||
translation_key="program_phases_wm",
|
||||
options=list(const.WASHING_PR_PHASE),
|
||||
),
|
||||
SensorEntityDescription(
|
||||
key="dryLevel",
|
||||
name="Dry level",
|
||||
icon="mdi:hair-dryer",
|
||||
translation_key="dry_levels",
|
||||
),
|
||||
SensorEntityDescription(
|
||||
key="dirtyLevel",
|
||||
name="Dirt level",
|
||||
icon="mdi:liquid-spot",
|
||||
translation_key="dirt_level",
|
||||
),
|
||||
SensorEntityDescription(
|
||||
key="steamLevel",
|
||||
name="Steam level",
|
||||
icon="mdi:smoke",
|
||||
translation_key="steam_level",
|
||||
),
|
||||
SensorEntityDescription(
|
||||
key="temp",
|
||||
name="Current Temperature",
|
||||
icon="mdi:thermometer",
|
||||
state_class=SensorStateClass.MEASUREMENT,
|
||||
native_unit_of_measurement=UnitOfTemperature.CELSIUS,
|
||||
translation_key="temperature",
|
||||
),
|
||||
),
|
||||
"OV": (
|
||||
SensorEntityDescription(
|
||||
key="remainingTimeMM",
|
||||
@ -501,6 +393,7 @@ SENSORS: dict[str, tuple[SensorEntityDescription, ...]] = {
|
||||
),
|
||||
),
|
||||
}
|
||||
SENSORS["WD"] = unique_entities(SENSORS["WM"], SENSORS["TD"])
|
||||
|
||||
|
||||
async def async_setup_entry(hass, entry: ConfigEntry, async_add_entities) -> None:
|
||||
|
@ -10,7 +10,7 @@ from pyhon.appliance import HonAppliance
|
||||
from pyhon.parameter.range import HonParameterRange
|
||||
|
||||
from .const import DOMAIN
|
||||
from .hon import HonCoordinator, HonEntity
|
||||
from .hon import HonCoordinator, HonEntity, unique_entities
|
||||
|
||||
_LOGGER = logging.getLogger(__name__)
|
||||
|
||||
@ -168,7 +168,7 @@ SWITCHES: dict[str, tuple[HonSwitchEntityDescription, ...]] = {
|
||||
"WD": (
|
||||
HonSwitchEntityDescription(
|
||||
key="active",
|
||||
name="Washing Machine",
|
||||
name="Washer Dryer",
|
||||
icon="mdi:washing-machine",
|
||||
turn_on_key="startProgram",
|
||||
turn_off_key="stopProgram",
|
||||
@ -176,7 +176,7 @@ SWITCHES: dict[str, tuple[HonSwitchEntityDescription, ...]] = {
|
||||
),
|
||||
HonSwitchEntityDescription(
|
||||
key="pause",
|
||||
name="Pause Washing Machine",
|
||||
name="Pause Washer Dryer",
|
||||
icon="mdi:pause",
|
||||
turn_on_key="pauseProgram",
|
||||
turn_off_key="resumeProgram",
|
||||
@ -296,6 +296,9 @@ SWITCHES: dict[str, tuple[HonSwitchEntityDescription, ...]] = {
|
||||
),
|
||||
}
|
||||
|
||||
SWITCHES["WD"] = unique_entities(SWITCHES["WD"], SWITCHES["WM"])
|
||||
SWITCHES["WD"] = unique_entities(SWITCHES["WD"], SWITCHES["TD"])
|
||||
|
||||
|
||||
async def async_setup_entry(hass, entry: ConfigEntry, async_add_entities) -> None:
|
||||
hon: Hon = hass.data[DOMAIN][entry.unique_id]
|
||||
|
Reference in New Issue
Block a user