From 6093b57f761750ec376a21f2486c00f284f6d1b5 Mon Sep 17 00:00:00 2001 From: Andre Basche Date: Sat, 8 Apr 2023 04:44:47 +0200 Subject: [PATCH] Merge branch 'main' into oven --- custom_components/hon/binary_sensor.py | 44 +++++++++++-- custom_components/hon/number.py | 12 +++- custom_components/hon/select.py | 17 ++++- custom_components/hon/sensor.py | 72 +++++++++++++++++++--- custom_components/hon/switch.py | 21 +++++++ custom_components/hon/translations/bg.json | 1 + custom_components/hon/translations/en.json | 1 + 7 files changed, 151 insertions(+), 17 deletions(-) diff --git a/custom_components/hon/binary_sensor.py b/custom_components/hon/binary_sensor.py index 178fc91..a2f75c0 100644 --- a/custom_components/hon/binary_sensor.py +++ b/custom_components/hon/binary_sensor.py @@ -59,7 +59,43 @@ BINARY_SENSORS: dict[str, tuple[HonBinarySensorEntityDescription, ...]] = { on_value="1", ), ), - + "WD": ( + HonBinarySensorEntityDescription( + key="attributes.lastConnEvent.category", + name="Remote Control", + device_class=BinarySensorDeviceClass.CONNECTIVITY, + on_value="CONNECTED", + icon="mdi:remote" + ), + HonBinarySensorEntityDescription( + key="startProgram.prewash", + name="Pre Wash", + ), + HonBinarySensorEntityDescription( + key="extraRinse1", + name="Extra Rinse 1", + ), + HonBinarySensorEntityDescription( + key="extraRinse2", + name="Extra Rinse 2", + ), + HonBinarySensorEntityDescription( + key="extraRinse3", + name="Extra Rinse 3", + ), + HonBinarySensorEntityDescription( + key="goodNight", + name="Good Night Mode", + ), + HonBinarySensorEntityDescription( + key="acquaplus", + name="Acqua Plus", + ), + HonBinarySensorEntityDescription( + key="anticrease", + name="Anti-Crease", + ), + ), "OV": ( HonBinarySensorEntityDescription( key="attributes.lastConnEvent.category", @@ -68,7 +104,6 @@ BINARY_SENSORS: dict[str, tuple[HonBinarySensorEntityDescription, ...]] = { on_value="CONNECTED", icon="mdi:wifi" ), - HonBinarySensorEntityDescription( key="attributes.parameters.remoteCtrValid", name="On", @@ -83,8 +118,7 @@ BINARY_SENSORS: dict[str, tuple[HonBinarySensorEntityDescription, ...]] = { on_value="1", icon="mdi:power-cycle" ), - - ) + ), } @@ -103,7 +137,7 @@ async def async_setup_entry(hass, entry: ConfigEntry, async_add_entities) -> Non if descriptions := BINARY_SENSORS.get(device.appliance_type): for description in descriptions: if not device.get(description.key): - _LOGGER.info("Can't setup %s", description.key) + _LOGGER.warning("[%s] Can't setup %s", device.appliance_type, description.key) continue appliances.extend([ HonBinarySensorEntity(hass, coordinator, entry, device, description)] diff --git a/custom_components/hon/number.py b/custom_components/hon/number.py index e486655..6335961 100644 --- a/custom_components/hon/number.py +++ b/custom_components/hon/number.py @@ -74,7 +74,15 @@ NUMBERS: dict[str, tuple[NumberEntityDescription, ...]] = { entity_category=EntityCategory.CONFIG ), ), - + "WD": ( + NumberEntityDescription( + key="startProgram.delayTime", + name="Delay Time", + icon="mdi:timer-plus", + entity_category=EntityCategory.CONFIG, + native_unit_of_measurement=UnitOfTime.MINUTES + ), + ), "OV": ( NumberEntityDescription( key="startProgram.delayTime", @@ -98,7 +106,7 @@ NUMBERS: dict[str, tuple[NumberEntityDescription, ...]] = { icon="mdi:timelapse", native_unit_of_measurement=UnitOfTime.MINUTES ), - ) + ), } diff --git a/custom_components/hon/select.py b/custom_components/hon/select.py index a602d8c..c492661 100644 --- a/custom_components/hon/select.py +++ b/custom_components/hon/select.py @@ -1,5 +1,7 @@ from __future__ import annotations +import logging + from pyhon import HonConnection from pyhon.device import HonDevice from pyhon.parameter import HonParameterFixed @@ -13,6 +15,8 @@ from homeassistant.helpers.entity import EntityCategory from .const import DOMAIN from .hon import HonEntity, HonCoordinator +_LOGGER = logging.getLogger(__name__) + SELECTS = { "WM": ( SelectEntityDescription( @@ -51,20 +55,26 @@ SELECTS = { unit_of_measurement=UnitOfTime.MINUTES ), ), + "WD": ( + SelectEntityDescription( + key="startProgram.program", + name="Program", + entity_category=EntityCategory.CONFIG, + translation_key="programs" + ), + ), "OV": ( SelectEntityDescription( key="startProgram.program", name="Program", entity_category=EntityCategory.CONFIG, ), - SelectEntityDescription( key="startProgram.preheatStatus", name="Preheat", entity_category=EntityCategory.CONFIG ), - - ) + ), } @@ -83,6 +93,7 @@ async def async_setup_entry(hass, entry: ConfigEntry, async_add_entities) -> Non if descriptions := SELECTS.get(device.appliance_type): for description in descriptions: if not device.get(description.key): + _LOGGER.warning("[%s] Can't setup %s", device.appliance_type, description.key) continue appliances.extend([ HonSelectEntity(hass, coordinator, entry, device, description)] diff --git a/custom_components/hon/sensor.py b/custom_components/hon/sensor.py index 65e26d6..aad957b 100644 --- a/custom_components/hon/sensor.py +++ b/custom_components/hon/sensor.py @@ -9,7 +9,15 @@ from homeassistant.components.sensor import ( SensorEntityDescription, ) from homeassistant.config_entries import ConfigEntry -from homeassistant.const import UnitOfEnergy, UnitOfVolume, UnitOfMass, UnitOfPower, UnitOfTime +from homeassistant.const import ( + REVOLUTIONS_PER_MINUTE, + UnitOfEnergy, + UnitOfVolume, + UnitOfMass, + UnitOfPower, + UnitOfTime, + UnitOfTemperature +) from homeassistant.core import callback from homeassistant.helpers.entity import EntityCategory from homeassistant.helpers.typing import StateType @@ -142,7 +150,60 @@ SENSORS: dict[str, tuple[SensorEntityDescription, ...]] = { translation_key="tumbledryertemplevel" ), ), - + "WD": ( + SensorEntityDescription( + key="machMode", + name="Machine Status", + icon="mdi:information", + translation_key="mode" + ), + SensorEntityDescription( + key="spinSpeed", + name="Spin Speed", + icon="mdi:fast-forward-outline", + state_class=SensorStateClass.MEASUREMENT, + native_unit_of_measurement=REVOLUTIONS_PER_MINUTE, + ), + SensorEntityDescription( + key="remainingTimeMM", + name="Remaining Time", + icon="mdi:timer", + state_class=SensorStateClass.MEASUREMENT, + native_unit_of_measurement=UnitOfTime.MINUTES, + ), + SensorEntityDescription( + key="prCode", + name="Current Program", + icon="mdi:tumble-dryer", + ), + SensorEntityDescription( + key="prPhase", + name="Program Phase", + icon="mdi:tumble-dryer", + ), + SensorEntityDescription( + key="dryLevel", + name="Dry level", + icon="mdi:hair-dryer", + ), + SensorEntityDescription( + key="dirtyLevel", + name="Dirt level", + icon="mdi:liquid-spot", + ), + SensorEntityDescription( + key="steamLevel", + name="Steam level", + icon="mdi:smoke", + ), + SensorEntityDescription( + key="temp", + name="Current Temperature", + icon="mdi:thermometer", + state_class=SensorStateClass.MEASUREMENT, + native_unit_of_measurement=UnitOfTemperature.CELSIUS, + ), + ), "OV": ( SensorEntityDescription( key="remainingTimeMM", @@ -154,22 +215,18 @@ SENSORS: dict[str, tuple[SensorEntityDescription, ...]] = { key="delayTime", name="Start Time", icon="mdi:clock-start", - native_unit_of_measurement=UnitOfTime.MINUTES, ), - SensorEntityDescription( key="temp", name="Temperature", icon="mdi:thermometer", ), - SensorEntityDescription( key="tempSel", name="Temperature Selected", icon="mdi:thermometer", ), - ) - + ), } @@ -188,6 +245,7 @@ async def async_setup_entry(hass, entry: ConfigEntry, async_add_entities) -> Non if descriptions := SENSORS.get(device.appliance_type): for description in descriptions: if not device.get(description.key): + _LOGGER.warning("[%s] Can't setup %s", device.appliance_type, description.key) continue appliances.extend([ HonSensorEntity(hass, coordinator, entry, device, description)] diff --git a/custom_components/hon/switch.py b/custom_components/hon/switch.py index 5b2243a..7dbf3a4 100644 --- a/custom_components/hon/switch.py +++ b/custom_components/hon/switch.py @@ -1,3 +1,5 @@ +import logging + from dataclasses import dataclass from typing import Any @@ -10,6 +12,7 @@ from pyhon.device import HonDevice from .const import DOMAIN from .hon import HonCoordinator, HonEntity +_LOGGER = logging.getLogger(__name__) @dataclass class HonSwitchEntityDescriptionMixin: @@ -69,6 +72,22 @@ SWITCHES: dict[str, tuple[HonSwitchEntityDescription, ...]] = { turn_off_key="resumeProgram", ), ), + "WD": ( + HonSwitchEntityDescription( + key="active", + name="Washing Machine", + icon="mdi:washing-machine", + turn_on_key="startProgram", + turn_off_key="stopProgram", + ), + HonSwitchEntityDescription( + key="pause", + name="Pause Washing Machine", + icon="mdi:pause", + turn_on_key="pauseProgram", + turn_off_key="resumeProgram", + ), + ), } @@ -90,6 +109,8 @@ async def async_setup_entry(hass, entry: ConfigEntry, async_add_entities) -> Non appliances.extend([ HonSwitchEntity(hass, coordinator, entry, device, description)] ) + else: + _LOGGER.warning("[%s] Can't setup %s", device.appliance_type, description.key) async_add_entities(appliances) diff --git a/custom_components/hon/translations/bg.json b/custom_components/hon/translations/bg.json index 81e67a3..ef4c662 100644 --- a/custom_components/hon/translations/bg.json +++ b/custom_components/hon/translations/bg.json @@ -377,6 +377,7 @@ "single_item_steam": "Single Item + Steam", "smart_wash": "Smart Wash", "soft_care": "Soft Care", + "soft_care_steam": "Soft Care + Steam", "soft_care_steam_title": "Soft Care + Steam", "special_39": "Special 39'", "special_39_full_load": "Special 39'", diff --git a/custom_components/hon/translations/en.json b/custom_components/hon/translations/en.json index c920857..f0a21a0 100644 --- a/custom_components/hon/translations/en.json +++ b/custom_components/hon/translations/en.json @@ -377,6 +377,7 @@ "single_item_steam": "Single Item + Steam", "smart_wash": "Smart Wash", "soft_care": "Soft Care", + "soft_care_steam": "Soft Care + Steam", "soft_care_steam_title": "Soft Care + Steam", "special_39": "Special 39'", "special_39_full_load": "Special 39'",