mirror of
https://github.com/Andre0512/hon.git
synced 2024-01-19 02:50:19 +00:00
Use fan entity for wind speed
This commit is contained in:
parent
5bc3120000
commit
79b43b8695
51
README.md
51
README.md
|
@ -61,42 +61,18 @@ Translation of internal names like programs are available for all languages whic
|
|||
|
||||
## Supported Models
|
||||
Support has been confirmed for these models, but many more will work. Please add already supported devices [with this form to complete the list](https://forms.gle/bTSD8qFotdZFytbf8).
|
||||
- Haier AD105S2SM3FA
|
||||
- Haier AS20HPL1HRA
|
||||
- Haier AS25PBAHRA
|
||||
- Haier AS25S2SF1FA-WH
|
||||
- Haier AS25TADHRA-2
|
||||
- Haier AS35TADHRA-2
|
||||
- Haier EG9012B19SU1JD
|
||||
- Haier HA2MTSJ68MC
|
||||
- Haier HADG6DS46BWIFI
|
||||
- Haier HD80-A3959
|
||||
- Haier HW90-B14TEAM5
|
||||
- Haier HW100-B14959U1
|
||||
- Haier HWD100-B14979
|
||||
- Haier HWO60SM2F3XH
|
||||
- Haier XIB 3B2SFS-80
|
||||
- Haier XIB 6B2D3FB
|
||||
- Candy BCTDH7A1TE
|
||||
- Candy CCE4T620EWU
|
||||
- Candy CIS633SCTTWIFI
|
||||
- Candy CSOE C10DE-80
|
||||
- Candy RO44 1286DWMC4-07
|
||||
- Candy ROE H9A3TCEX-S
|
||||
- Candy RPW41066BWMR/1-S
|
||||
- Hoover H-WASH 500
|
||||
- Hoover H-DRY 500
|
||||
- Hoover H7W4 48MBC-S
|
||||
- Hoover H9A3TCBEXS-S
|
||||
- Hoover HFB 6B2S3FX
|
||||
- Hoover HLE C10DCE-80
|
||||
- Hoover HSOT3161WG
|
||||
- Hoover HW 68AMC/1-80
|
||||
- Hoover HWPD 69AMBC/1-S
|
||||
- Hoover HWPS4954DAMR-11
|
||||
- Hoover NDE H10A2TCE-80
|
||||
- Hoover NDE H9A2TSBEXS-S
|
||||
- Hoover NDPHY10A2TCBEXSS
|
||||
|
||||
| | **Haier** | **Hoover** | **Candy** |
|
||||
|--------------------|------------------------------------------------------------------------------------------------------------------|-----------------------------------------------------------------------------------------------------------------------|-----------------------------------------------------|
|
||||
| **Washing Machine** | HW90-B14TEAM5 <br/> HW100-B14959U1 | H-WASH 500 <br/> H7W4 48MBC-S | RO44 1286DWMC4-07 <br/> HW 68AMC/1-80 <br/> HWPD 69AMBC/1-S |
|
||||
| **Tumble Dryer** | HD80-A3959 | H-DRY 500 <br/> H9A3TCBEXS-S <br/> HLE C10DCE-80 <br/> NDE H10A2TCE-80 <br/> NDE H9A2TSBEXS-S <br/> NDPHY10A2TCBEXSS | BCTDH7A1TE <br/> CSOE C10DE-80 <br/> ROE H9A3TCEX-S |
|
||||
| **Washer Dryer** | HWD100-B14979 | HWPS4954DAMR-11 | RPW41066BWMR/1-S |
|
||||
| **Oven** | HWO60SM2F3XH | HSOT3161WG | |
|
||||
| **Dish Washer** | XIB 3B2SFS-80 <br/> XIB 6B2D3FB | HFB 6B2S3FX | |
|
||||
| **Air conditioner** | AD105S2SM3FA <br/> AS20HPL1HRA <br/> AS25PBAHRA <br/> AS25S2SF1FA-WH <br/> AS25TADHRA-2 <br/> AS35TADHRA-2 <br/> | | |
|
||||
| **Fridge** | HFW7720ENMB | | CCE4T620EWU |
|
||||
| **Hob** | HA2MTSJ68MC | | CIS633SCTTWIFI |
|
||||
| **Hood** | HADG6DS46BWIFI | | |
|
||||
|
||||
## Contribute
|
||||
Any kind of contribution is welcome!
|
||||
|
@ -237,11 +213,11 @@ For every device exists a hidden button which can be used to log all infos of yo
|
|||
| --- | --- | --- | --- |
|
||||
| Start Program | `hvac` | `button` | `startProgram` |
|
||||
| Stop Program | `hvac-off` | `button` | `stopProgram` |
|
||||
| Wind Speed | | `fan` | `settings.windSpeed` |
|
||||
#### Configs
|
||||
| Name | Icon | Entity | Key |
|
||||
| --- | --- | --- | --- |
|
||||
| Light status | `lightbulb` | `number` | `startProgram.lightStatus` |
|
||||
| Wind speed | `fan` | `number` | `startProgram.windSpeed` |
|
||||
#### Sensors
|
||||
| Name | Icon | Entity | Key |
|
||||
| --- | --- | --- | --- |
|
||||
|
@ -257,7 +233,6 @@ For every device exists a hidden button which can be used to log all infos of yo
|
|||
| Quick Delay Time Status | | `sensor` | `quickDelayTimeStatus` |
|
||||
| RGB Light Color | `lightbulb` | `sensor` | `rgbLightColors` |
|
||||
| RGB Light Status | `lightbulb` | `sensor` | `rgbLightStatus` |
|
||||
| Wind Speed | `fan` | `sensor` | `windSpeed` |
|
||||
|
||||
### Hob
|
||||
#### Controls
|
||||
|
|
|
@ -213,7 +213,7 @@ class HonACClimateEntity(HonEntity, ClimateEntity):
|
|||
|
||||
|
||||
class HonClimateEntity(HonEntity, ClimateEntity):
|
||||
entity_description = HonClimateEntityDescription
|
||||
entity_description: HonClimateEntityDescription
|
||||
|
||||
def __init__(self, hass, entry, device: HonAppliance, description) -> None:
|
||||
super().__init__(hass, entry, device, description)
|
||||
|
|
|
@ -17,6 +17,7 @@ PLATFORMS = [
|
|||
"button",
|
||||
"binary_sensor",
|
||||
"climate",
|
||||
"fan",
|
||||
]
|
||||
|
||||
HON_HVAC_MODE = {
|
||||
|
|
122
custom_components/hon/fan.py
Normal file
122
custom_components/hon/fan.py
Normal file
|
@ -0,0 +1,122 @@
|
|||
import logging
|
||||
import math
|
||||
from dataclasses import dataclass
|
||||
from typing import Any
|
||||
|
||||
from homeassistant.components.fan import (
|
||||
FanEntityDescription,
|
||||
FanEntity,
|
||||
FanEntityFeature,
|
||||
)
|
||||
from homeassistant.config_entries import ConfigEntry
|
||||
from homeassistant.core import callback
|
||||
from homeassistant.util.percentage import (
|
||||
percentage_to_ranged_value,
|
||||
ranged_value_to_percentage,
|
||||
)
|
||||
from pyhon.appliance import HonAppliance
|
||||
from pyhon.parameter.range import HonParameterRange
|
||||
|
||||
from .const import DOMAIN
|
||||
from .hon import HonEntity
|
||||
|
||||
_LOGGER = logging.getLogger(__name__)
|
||||
|
||||
|
||||
@dataclass
|
||||
class HonFanEntityDescription(FanEntityDescription):
|
||||
pass
|
||||
|
||||
|
||||
FANS = {
|
||||
"HO": (
|
||||
HonFanEntityDescription(
|
||||
key="settings.windSpeed",
|
||||
name="Wind Speed",
|
||||
translation_key="air_extraction",
|
||||
),
|
||||
),
|
||||
}
|
||||
|
||||
|
||||
async def async_setup_entry(hass, entry: ConfigEntry, async_add_entities) -> None:
|
||||
entities = []
|
||||
for device in hass.data[DOMAIN][entry.unique_id].appliances:
|
||||
for description in FANS.get(device.appliance_type, []):
|
||||
if isinstance(description, HonFanEntityDescription):
|
||||
if description.key not in device.available_settings or not device.get(
|
||||
description.key.split(".")[-1]
|
||||
):
|
||||
continue
|
||||
entity = HonFanEntity(hass, entry, device, description)
|
||||
else:
|
||||
continue
|
||||
await entity.coordinator.async_config_entry_first_refresh()
|
||||
entities.append(entity)
|
||||
async_add_entities(entities)
|
||||
|
||||
|
||||
class HonFanEntity(HonEntity, FanEntity):
|
||||
entity_description: HonFanEntityDescription
|
||||
|
||||
def __init__(self, hass, entry, device: HonAppliance, description) -> None:
|
||||
self._attr_supported_features = FanEntityFeature.SET_SPEED
|
||||
self._wind_speed: HonParameterRange = device.settings.get(description.key)
|
||||
self._speed_range = (
|
||||
int(self._wind_speed.values[1]),
|
||||
int(self._wind_speed.values[-1]),
|
||||
)
|
||||
self._command, self._parameter = description.key.split(".")
|
||||
|
||||
super().__init__(hass, entry, device, description)
|
||||
self._handle_coordinator_update(update=False)
|
||||
|
||||
@property
|
||||
def percentage(self) -> int | None:
|
||||
"""Return the current speed."""
|
||||
value = int(self._device.get(self._parameter, "0"))
|
||||
return ranged_value_to_percentage(self._speed_range, value)
|
||||
|
||||
@property
|
||||
def speed_count(self) -> int:
|
||||
"""Return the number of speeds the fan supports."""
|
||||
return len(self._wind_speed.values[1:])
|
||||
|
||||
async def async_set_percentage(self, percentage: int) -> None:
|
||||
"""Set the speed percentage of the fan."""
|
||||
mode = math.ceil(percentage_to_ranged_value(self._speed_range, percentage))
|
||||
self._device.settings[self.entity_description.key].value = mode
|
||||
await self._device.commands[self._command].send()
|
||||
self.async_write_ha_state()
|
||||
|
||||
@property
|
||||
def is_on(self) -> bool | None:
|
||||
"""Return true if device is on."""
|
||||
mode = math.ceil(percentage_to_ranged_value(self._speed_range, self.percentage))
|
||||
return mode > self._wind_speed.min
|
||||
|
||||
async def async_turn_on(
|
||||
self,
|
||||
percentage: int | None = None,
|
||||
preset_mode: str | None = None,
|
||||
**kwargs: Any,
|
||||
) -> None:
|
||||
"""Turn the entity on."""
|
||||
if percentage is None:
|
||||
percentage = ranged_value_to_percentage(
|
||||
self._speed_range, int(self._wind_speed.values[1])
|
||||
)
|
||||
await self.async_set_percentage(percentage)
|
||||
|
||||
async def async_turn_off(self, **kwargs: Any) -> None:
|
||||
"""Turn the entity off."""
|
||||
self._device.settings[self.entity_description.key].value = 0
|
||||
await self._device.commands[self._command].send()
|
||||
self.async_write_ha_state()
|
||||
|
||||
@callback
|
||||
def _handle_coordinator_update(self, update=True) -> None:
|
||||
self._wind_speed = self._device.settings.get(self.entity_description.key)
|
||||
self._attr_percentage = self.percentage
|
||||
if update:
|
||||
self.async_write_ha_state()
|
|
@ -163,12 +163,6 @@ NUMBERS: dict[str, tuple[NumberEntityDescription, ...]] = {
|
|||
),
|
||||
),
|
||||
"HO": (
|
||||
HonNumberEntityDescription(
|
||||
key="startProgram.windSpeed",
|
||||
name="Wind speed",
|
||||
icon="mdi:fan",
|
||||
entity_category=EntityCategory.CONFIG,
|
||||
),
|
||||
HonNumberEntityDescription(
|
||||
key="startProgram.lightStatus",
|
||||
name="Light status",
|
||||
|
|
|
@ -593,11 +593,6 @@ SENSORS: dict[str, tuple[SensorEntityDescription, ...]] = {
|
|||
name="RGB Light Status",
|
||||
icon="mdi:lightbulb",
|
||||
),
|
||||
HonSensorEntityDescription(
|
||||
key="windSpeed",
|
||||
name="Wind Speed",
|
||||
icon="mdi:fan",
|
||||
),
|
||||
),
|
||||
}
|
||||
SENSORS["WD"] = unique_entities(SENSORS["WM"], SENSORS["TD"])
|
||||
|
|
|
@ -1979,6 +1979,11 @@
|
|||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
"fan": {
|
||||
"air_extraction": {
|
||||
"name": "Odsávání vzduchu"
|
||||
}
|
||||
}
|
||||
},
|
||||
"config": {
|
||||
|
|
|
@ -1979,6 +1979,11 @@
|
|||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
"fan": {
|
||||
"air_extraction": {
|
||||
"name": "Dunstabzug"
|
||||
}
|
||||
}
|
||||
},
|
||||
"config": {
|
||||
|
|
|
@ -1979,6 +1979,11 @@
|
|||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
"fan": {
|
||||
"air_extraction": {
|
||||
"name": "Εξαγωγή αέρα"
|
||||
}
|
||||
}
|
||||
},
|
||||
"config": {
|
||||
|
|
|
@ -2056,6 +2056,11 @@
|
|||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
"fan": {
|
||||
"air_extraction": {
|
||||
"name": "Air extraction"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
|
@ -1979,6 +1979,11 @@
|
|||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
"fan": {
|
||||
"air_extraction": {
|
||||
"name": "Extracción de aire"
|
||||
}
|
||||
}
|
||||
},
|
||||
"config": {
|
||||
|
|
|
@ -1979,6 +1979,11 @@
|
|||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
"fan": {
|
||||
"air_extraction": {
|
||||
"name": "Extraction de l'air"
|
||||
}
|
||||
}
|
||||
},
|
||||
"config": {
|
||||
|
|
|
@ -1065,6 +1065,11 @@
|
|||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
"fan": {
|
||||
"air_extraction": {
|
||||
"name": "Air extraction"
|
||||
}
|
||||
}
|
||||
},
|
||||
"config": {
|
||||
|
|
|
@ -1979,6 +1979,11 @@
|
|||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
"fan": {
|
||||
"air_extraction": {
|
||||
"name": "Odvođenje zraka"
|
||||
}
|
||||
}
|
||||
},
|
||||
"config": {
|
||||
|
|
|
@ -2031,6 +2031,11 @@
|
|||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
"fan": {
|
||||
"air_extraction": {
|
||||
"name": "Aspirazione aria"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
|
@ -1979,6 +1979,11 @@
|
|||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
"fan": {
|
||||
"air_extraction": {
|
||||
"name": "Luchtafvoer"
|
||||
}
|
||||
}
|
||||
},
|
||||
"config": {
|
||||
|
|
|
@ -1979,6 +1979,11 @@
|
|||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
"fan": {
|
||||
"air_extraction": {
|
||||
"name": "Wyciąg powietrza"
|
||||
}
|
||||
}
|
||||
},
|
||||
"config": {
|
||||
|
|
|
@ -1979,6 +1979,11 @@
|
|||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
"fan": {
|
||||
"air_extraction": {
|
||||
"name": "Extração de ar"
|
||||
}
|
||||
}
|
||||
},
|
||||
"config": {
|
||||
|
|
|
@ -1979,6 +1979,11 @@
|
|||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
"fan": {
|
||||
"air_extraction": {
|
||||
"name": "Extracția aerului"
|
||||
}
|
||||
}
|
||||
},
|
||||
"config": {
|
||||
|
|
|
@ -1979,6 +1979,11 @@
|
|||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
"fan": {
|
||||
"air_extraction": {
|
||||
"name": "Отвод воздуха"
|
||||
}
|
||||
}
|
||||
},
|
||||
"config": {
|
||||
|
|
|
@ -1979,6 +1979,11 @@
|
|||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
"fan": {
|
||||
"air_extraction": {
|
||||
"name": "Odsávanie vzduchu"
|
||||
}
|
||||
}
|
||||
},
|
||||
"config": {
|
||||
|
|
|
@ -1979,6 +1979,11 @@
|
|||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
"fan": {
|
||||
"air_extraction": {
|
||||
"name": "Odvajanje zraka"
|
||||
}
|
||||
}
|
||||
},
|
||||
"config": {
|
||||
|
|
|
@ -1979,6 +1979,11 @@
|
|||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
"fan": {
|
||||
"air_extraction": {
|
||||
"name": "Usisavanje vazduha"
|
||||
}
|
||||
}
|
||||
},
|
||||
"config": {
|
||||
|
|
|
@ -1979,6 +1979,11 @@
|
|||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
"fan": {
|
||||
"air_extraction": {
|
||||
"name": "Hava tahliyesi"
|
||||
}
|
||||
}
|
||||
},
|
||||
"config": {
|
||||
|
|
|
@ -1979,6 +1979,11 @@
|
|||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
"fan": {
|
||||
"air_extraction": {
|
||||
"name": "抽气"
|
||||
}
|
||||
}
|
||||
},
|
||||
"config": {
|
||||
|
|
48
info.md
48
info.md
|
@ -50,42 +50,18 @@ Translation of internal names like programs are available for all languages whic
|
|||
|
||||
## Supported Models
|
||||
Support has been confirmed for these models, but many more will work. Please add already supported devices [with this form to complete the list](https://forms.gle/bTSD8qFotdZFytbf8).
|
||||
- Haier AD105S2SM3FA
|
||||
- Haier AS20HPL1HRA
|
||||
- Haier AS25PBAHRA
|
||||
- Haier AS25S2SF1FA-WH
|
||||
- Haier AS25TADHRA-2
|
||||
- Haier AS35TADHRA-2
|
||||
- Haier EG9012B19SU1JD
|
||||
- Haier HA2MTSJ68MC
|
||||
- Haier HADG6DS46BWIFI
|
||||
- Haier HD80-A3959
|
||||
- Haier HW90-B14TEAM5
|
||||
- Haier HW100-B14959U1
|
||||
- Haier HWD100-B14979
|
||||
- Haier HWO60SM2F3XH
|
||||
- Haier XIB 3B2SFS-80
|
||||
- Haier XIB 6B2D3FB
|
||||
- Candy BCTDH7A1TE
|
||||
- Candy CCE4T620EWU
|
||||
- Candy CIS633SCTTWIFI
|
||||
- Candy CSOE C10DE-80
|
||||
- Candy RO44 1286DWMC4-07
|
||||
- Candy ROE H9A3TCEX-S
|
||||
- Candy RPW41066BWMR/1-S
|
||||
- Hoover H-WASH 500
|
||||
- Hoover H-DRY 500
|
||||
- Hoover H7W4 48MBC-S
|
||||
- Hoover H9A3TCBEXS-S
|
||||
- Hoover HFB 6B2S3FX
|
||||
- Hoover HLE C10DCE-80
|
||||
- Hoover HSOT3161WG
|
||||
- Hoover HW 68AMC/1-80
|
||||
- Hoover HWPD 69AMBC/1-S
|
||||
- Hoover HWPS4954DAMR-11
|
||||
- Hoover NDE H10A2TCE-80
|
||||
- Hoover NDE H9A2TSBEXS-S
|
||||
- Hoover NDPHY10A2TCBEXSS
|
||||
|
||||
| | **Haier** | **Hoover** | **Candy** |
|
||||
|--------------------|------------------------------------------------------------------------------------------------------------------|-----------------------------------------------------------------------------------------------------------------------|-----------------------------------------------------|
|
||||
| **Washing Machine** | HW90-B14TEAM5 <br/> HW100-B14959U1 | H-WASH 500 <br/> H7W4 48MBC-S | RO44 1286DWMC4-07 <br/> HW 68AMC/1-80 <br/> HWPD 69AMBC/1-S |
|
||||
| **Tumble Dryer** | HD80-A3959 | H-DRY 500 <br/> H9A3TCBEXS-S <br/> HLE C10DCE-80 <br/> NDE H10A2TCE-80 <br/> NDE H9A2TSBEXS-S <br/> NDPHY10A2TCBEXSS | BCTDH7A1TE <br/> CSOE C10DE-80 <br/> ROE H9A3TCEX-S |
|
||||
| **Washer Dryer** | HWD100-B14979 | HWPS4954DAMR-11 | RPW41066BWMR/1-S |
|
||||
| **Oven** | HWO60SM2F3XH | HSOT3161WG | |
|
||||
| **Dish Washer** | XIB 3B2SFS-80 <br/> XIB 6B2D3FB | HFB 6B2S3FX | |
|
||||
| **Air conditioner** | AD105S2SM3FA <br/> AS20HPL1HRA <br/> AS25PBAHRA <br/> AS25S2SF1FA-WH <br/> AS25TADHRA-2 <br/> AS35TADHRA-2 <br/> | | |
|
||||
| **Fridge** | HFW7720ENMB | | CCE4T620EWU |
|
||||
| **Hob** | HA2MTSJ68MC | | CIS633SCTTWIFI |
|
||||
| **Hood** | HADG6DS46BWIFI | | |
|
||||
|
||||
## Contribute
|
||||
Want to help us to support more appliances? Or add more sensors? Or help with translating? Or beautify some icons or captions?
|
||||
|
|
|
@ -248,6 +248,7 @@ NAMES = {
|
|||
"freezer": "REF.ZONES.FREEZER",
|
||||
"oven": "GLOBALS.APPLIANCES_NAME.OV",
|
||||
},
|
||||
"fan": {"air_extraction": "HO.DASHBOARD.AIR_EXTRACTION_TITLE"},
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -14,6 +14,7 @@ from custom_components.hon.climate import CLIMATES
|
|||
from custom_components.hon.number import NUMBERS
|
||||
from custom_components.hon.select import SELECTS
|
||||
from custom_components.hon.sensor import SENSORS
|
||||
from custom_components.hon.fan import FANS
|
||||
from custom_components.hon.switch import (
|
||||
SWITCHES,
|
||||
HonControlSwitchEntityDescription,
|
||||
|
@ -48,6 +49,7 @@ entities = {
|
|||
"sensor": SENSORS,
|
||||
"switch": SWITCHES,
|
||||
"climate": CLIMATES,
|
||||
"fan": FANS,
|
||||
}
|
||||
|
||||
result = {}
|
||||
|
|
Loading…
Reference in a new issue