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 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_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..34fe3cb 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.2"], + "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 @@ 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/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