From 2802bcad25bba45e84d39e66bcbe832a7ee3da49 Mon Sep 17 00:00:00 2001 From: Andre Basche Date: Sun, 7 May 2023 00:52:54 +0200 Subject: [PATCH] Fix errors, bump pyhon --- README.md | 2 ++ custom_components/hon/climate.py | 6 +++--- custom_components/hon/const.py | 20 ++++++++++++-------- custom_components/hon/manifest.json | 4 ++-- custom_components/hon/number.py | 2 +- custom_components/hon/select.py | 3 ++- custom_components/hon/sensor.py | 9 +++++++++ custom_components/hon/switch.py | 2 +- info.md | 1 + requirements_dev.txt | 3 +++ 10 files changed, 36 insertions(+), 16 deletions(-) create mode 100644 requirements_dev.txt diff --git a/README.md b/README.md index 22a39b9..1a0630d 100644 --- a/README.md +++ b/README.md @@ -12,6 +12,7 @@ Home Assistant integration for Haier hOn: support for Haier/Candy/Hoover home ap - [Oven](https://github.com/Andre0512/hon#oven) - [Hob](https://github.com/Andre0512/hon#hob) - [Dish Washer](https://github.com/Andre0512/hon#dish-washer) +- [Air conditioner](https://github.com/Andre0512/hon#air-conditioner) [BETA] ## Installation **Method 1:** [![Open your Home Assistant instance and open a repository inside the Home Assistant Community Store.](https://my.home-assistant.io/badges/hacs_repository.svg)](https://my.home-assistant.io/redirect/hacs_repository/?owner=Andre0512&repository=hon&category=integration) @@ -323,6 +324,7 @@ I moved the api related stuff into the package [pyhOn](https://github.com/Andre0 | Main Wash Time | `clock-start` | `number` | `startProgram.mainWashTime` | | Powder Detergent Dose | `cup` | `sensor` | `startProgram.powderDetergentDose` | | Program | | `select` | `startProgram.program` | +| Remaining Time | `timer` | `sensor` | `startProgram.remainingTime` | | Rinse Iterations | `rotate-right` | `number` | `startProgram.rinseIterations` | | Soak Prewash Selection | `tshirt-crew` | `switch` | `startProgram.haier_SoakPrewashSelection` | | Spin speed | `numeric` | `select` | `startProgram.spinSpeed` | diff --git a/custom_components/hon/climate.py b/custom_components/hon/climate.py index 7a972d5..ef4c520 100644 --- a/custom_components/hon/climate.py +++ b/custom_components/hon/climate.py @@ -23,8 +23,8 @@ from homeassistant.core import callback from pyhon import Hon from pyhon.appliance import HonAppliance -from custom_components.hon.const import HON_HVAC_MODE, HON_FAN, HON_HVAC_PROGRAM, DOMAIN -from custom_components.hon.hon import HonEntity, HonCoordinator +from .const import HON_HVAC_MODE, HON_FAN, HON_HVAC_PROGRAM, DOMAIN +from .hon import HonEntity, HonCoordinator _LOGGER = logging.getLogger(__name__) @@ -47,7 +47,7 @@ async def async_setup_entry(hass, entry: ConfigEntry, async_add_entities) -> Non if descriptions := CLIMATES.get(device.appliance_type): for description in descriptions: - if not device.settings.get(description.key): + if description.key not in device.available_settings: continue appliances.extend( [HonClimateEntity(hass, coordinator, entry, device, description)] diff --git a/custom_components/hon/const.py b/custom_components/hon/const.py index 6a852a0..44b39d2 100644 --- a/custom_components/hon/const.py +++ b/custom_components/hon/const.py @@ -1,6 +1,10 @@ -from homeassistant.components.climate import HVACMode - -from custom_components.hon import climate +from homeassistant.components.climate import ( + HVACMode, + FAN_LOW, + FAN_MEDIUM, + FAN_HIGH, + FAN_AUTO, +) DOMAIN = "hon" @@ -33,9 +37,9 @@ HON_HVAC_PROGRAM = { } HON_FAN = { - "1": climate.FAN_HIGH, - "2": climate.FAN_MEDIUM, - "3": climate.FAN_LOW, - "4": climate.FAN_AUTO, - "5": climate.FAN_AUTO, + "1": FAN_HIGH, + "2": FAN_MEDIUM, + "3": FAN_LOW, + "4": FAN_AUTO, + "5": FAN_AUTO, } diff --git a/custom_components/hon/manifest.json b/custom_components/hon/manifest.json index 0545a37..8713a73 100644 --- a/custom_components/hon/manifest.json +++ b/custom_components/hon/manifest.json @@ -6,6 +6,6 @@ "documentation": "https://github.com/Andre0512/hon/", "iot_class": "cloud_polling", "issue_tracker": "https://github.com/Andre0512/hon/issues", - "requirements": ["pyhOn==0.9.1"], - "version": "0.7.0-beta.7" + "requirements": ["pyhOn==0.10.3"], + "version": "0.7.0-beta.8" } diff --git a/custom_components/hon/number.py b/custom_components/hon/number.py index 3983d45..5ee087b 100644 --- a/custom_components/hon/number.py +++ b/custom_components/hon/number.py @@ -162,7 +162,7 @@ async def async_setup_entry(hass, entry: ConfigEntry, async_add_entities) -> Non if descriptions := NUMBERS.get(device.appliance_type): for description in descriptions: - if not device.settings.get(description.key): + if description.key not in device.available_settings: continue appliances.extend( [HonNumberEntity(hass, coordinator, entry, device, description)] diff --git a/custom_components/hon/select.py b/custom_components/hon/select.py index 9c76e82..66150e2 100644 --- a/custom_components/hon/select.py +++ b/custom_components/hon/select.py @@ -1,6 +1,7 @@ from __future__ import annotations import logging +import time from pyhon import Hon from pyhon.appliance import HonAppliance @@ -128,7 +129,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.settings.get(description.key): + if description.key not in device.available_settings: continue appliances.extend( [HonSelectEntity(hass, coordinator, entry, device, description)] diff --git a/custom_components/hon/sensor.py b/custom_components/hon/sensor.py index a04b5ba..8eee227 100644 --- a/custom_components/hon/sensor.py +++ b/custom_components/hon/sensor.py @@ -131,6 +131,15 @@ SENSORS: dict[str, tuple[SensorEntityDescription, ...]] = { entity_category=EntityCategory.CONFIG, translation_key="det_dust", ), + SensorEntityDescription( + key="startProgram.remainingTime", + name="Remaining Time", + icon="mdi:timer", + state_class=SensorStateClass.MEASUREMENT, + native_unit_of_measurement=UnitOfTime.MINUTES, + entity_category=EntityCategory.CONFIG, + translation_key="remaining_time", + ), ), "TD": ( SensorEntityDescription( diff --git a/custom_components/hon/switch.py b/custom_components/hon/switch.py index dc2218c..b3393b7 100644 --- a/custom_components/hon/switch.py +++ b/custom_components/hon/switch.py @@ -271,7 +271,7 @@ async def async_setup_entry(hass, entry: ConfigEntry, async_add_entities) -> Non for description in descriptions: if ( device.get(description.key) is not None - or device.commands.get(description.key) is not None + or description.key in device.available_settings ): appliances.extend( [HonSwitchEntity(hass, coordinator, entry, device, description)] diff --git a/info.md b/info.md index 031620c..19a323f 100644 --- a/info.md +++ b/info.md @@ -11,6 +11,7 @@ Support for home appliances of Haier's mobile app hOn. - [Oven](https://github.com/Andre0512/hon#oven) - [Hob](https://github.com/Andre0512/hon#hob) - [Dish Washer](https://github.com/Andre0512/hon#dish-washer) +- [Air conditioner](https://github.com/Andre0512/hon#air-conditioner) [BETA] ## Tested Appliances - Haier WD90-B14TEAM5 diff --git a/requirements_dev.txt b/requirements_dev.txt new file mode 100644 index 0000000..ba9cd59 --- /dev/null +++ b/requirements_dev.txt @@ -0,0 +1,3 @@ +pyhOn +black +homeassistant