Skip to content

Commit

Permalink
Improve fridge support #41
Browse files Browse the repository at this point in the history
  • Loading branch information
Andre0512 committed May 21, 2023
1 parent 833c395 commit bf1a6e8
Show file tree
Hide file tree
Showing 29 changed files with 788 additions and 278 deletions.
6 changes: 6 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,7 @@ Support has been confirmed for these models, but many more will work. Please add
- Haier HWO60SM2F3XH
- Haier XIB 3B2SFS-80
- Haier XIB 6B2D3FB
- Candy BCTDH7A1TE
- Candy CIS633SCTTWIFI
- Candy CSOE C10DE-80
- Candy ROE H9A3TCEX-S
Expand Down Expand Up @@ -274,18 +275,23 @@ For every device exists a hidden button which can be used to log all infos of yo
| Auto-Set Mode | `thermometer-auto` | `switch` | `settings.intelligenceMode` |
| Freezer Temperature | `thermometer` | `number` | `settings.tempSelZ2` |
| Fridge Temperature | `thermometer` | `number` | `settings.tempSelZ1` |
| Holiday Mode | `palm-tree` | `switch` | `settings.holidayMode` |
| Program Start | `play` | `button` | `startProgram` |
| Program Stop | `stop` | `button` | `stopProgram` |
| Super Cool | `snowflake` | `switch` | `settings.quickModeZ2` |
| Super Freeze | `snowflake-variant` | `switch` | `settings.quickModeZ1` |
#### Configs
| Name | Icon | Entity | Key |
| --- | --- | --- | --- |
| Program | | `select` | `startProgram.program` |
| Zone | `radiobox-marked` | `select` | `startProgram.zone` |
#### Sensors
| Name | Icon | Entity | Key |
| --- | --- | --- | --- |
| Auto-Set Mode | `thermometer-auto` | `binary_sensor` | `intelligenceMode` |
| Door Status Freezer | `fridge-top` | `binary_sensor` | `doorStatusZ1` |
| Door Status Fridge | `fridge-bottom` | `binary_sensor` | `door2StatusZ1` |
| Error | `math-log` | `sensor` | `errors` |
| Holiday Mode | `palm-tree` | `binary_sensor` | `holidayMode` |
| Room Humidity | `water-percent` | `sensor` | `humidityEnv` |
| Room Temperature | `home-thermometer-outline` | `sensor` | `tempEnv` |
Expand Down
14 changes: 14 additions & 0 deletions custom_components/hon/button.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,20 @@
translation_key="induction_hob",
),
),
"REF": (
ButtonEntityDescription(
key="startProgram",
name="Program Start",
icon="mdi:play",
translation_key="start_program",
),
ButtonEntityDescription(
key="stopProgram",
name="Program Stop",
icon="mdi:stop",
translation_key="stop_program",
),
),
}


Expand Down
7 changes: 7 additions & 0 deletions custom_components/hon/const.py
Original file line number Diff line number Diff line change
Expand Up @@ -180,6 +180,13 @@
"2": "AC.PROGRAM_DETAIL.FOLLOW_TOUCH",
}

REF_ZONES = {
"fridge": "REF.ZONES.FRIDGE",
"freezer": "REF.ZONES.FREEZER",
"vtRoom1": "REF.ZONES.MY_ZONE_1",
"[fridge|freezer]": ["REF.ZONES.FRIDGE", " & ", "REF.ZONES.FREEZER"],
}

PROGRAMS_TD = [
"active_dry",
"allergy_care",
Expand Down
8 changes: 6 additions & 2 deletions custom_components/hon/manifest.json
Original file line number Diff line number Diff line change
@@ -1,11 +1,15 @@
{
"domain": "hon",
"name": "Haier hOn",
"codeowners": ["@Andre0512"],
"codeowners": [
"@Andre0512"
],
"config_flow": true,
"documentation": "https://github.com/Andre0512/hon/",
"iot_class": "cloud_polling",
"issue_tracker": "https://github.com/Andre0512/hon/issues",
"requirements": ["pyhOn==0.10.10"],
"requirements": [
"pyhOn==0.11.0"
],
"version": "0.8.0-beta.5"
}
2 changes: 1 addition & 1 deletion custom_components/hon/number.py
Original file line number Diff line number Diff line change
Expand Up @@ -216,7 +216,7 @@ def native_value(self) -> float | None:
async def async_set_native_value(self, value: float) -> None:
setting = self._device.settings[self.entity_description.key]
if not (
isinstance(setting, HonParameter) or isinstance(setting, HonParameterFixed)
type(setting) == HonParameter or isinstance(setting, HonParameterFixed)
):
setting.value = value
if "settings." in self.entity_description.key:
Expand Down
7 changes: 7 additions & 0 deletions custom_components/hon/select.py
Original file line number Diff line number Diff line change
Expand Up @@ -124,6 +124,13 @@
entity_category=EntityCategory.CONFIG,
translation_key="programs_ref",
),
SelectEntityDescription(
key="startProgram.zone",
name="Zone",
icon="mdi:radiobox-marked",
entity_category=EntityCategory.CONFIG,
translation_key="ref_zones",
),
),
}

Expand Down
3 changes: 3 additions & 0 deletions custom_components/hon/sensor.py
Original file line number Diff line number Diff line change
Expand Up @@ -502,6 +502,9 @@
native_unit_of_measurement=UnitOfTemperature.CELSIUS,
translation_key="freezer_temp",
),
SensorEntityDescription(
key="errors", name="Error", icon="mdi:math-log", translation_key="errors"
),
),
}
SENSORS["WD"] = unique_entities(SENSORS["WM"], SENSORS["TD"])
Expand Down
48 changes: 32 additions & 16 deletions custom_components/hon/switch.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@

from pyhon import Hon
from pyhon.appliance import HonAppliance
from pyhon.parameter.base import HonParameter
from pyhon.parameter.range import HonParameterRange

from homeassistant.components.switch import SwitchEntityDescription, SwitchEntity
Expand Down Expand Up @@ -319,22 +320,32 @@ class HonSwitchEntityDescription(
"REF": (
HonSwitchEntityDescription(
key="settings.intelligenceMode",
status_key="intelligenceMode",
name="Auto-Set Mode",
icon="mdi:thermometer-auto",
translation_key="auto_set",
),
HonSwitchEntityDescription(
key="settings.quickModeZ1",
status_key="quickModeZ1",
name="Super Freeze",
icon="mdi:snowflake-variant",
translation_key="super_freeze",
),
HonSwitchEntityDescription(
key="settings.quickModeZ2",
status_key="quickModeZ2",
name="Super Cool",
icon="mdi:snowflake",
translation_key="super_cool",
),
HonSwitchEntityDescription(
key="settings.holidayMode",
status_key="holidayMode",
name="Holiday Mode",
icon="mdi:palm-tree",
translation_key="holiday_mode",
),
),
}

Expand Down Expand Up @@ -411,13 +422,14 @@ async def async_turn_on(self, **kwargs: Any) -> None:
or "settings." in self.entity_description.key
):
setting = self._device.settings[self.entity_description.key]
setting.value = (
setting.max if isinstance(setting, HonParameterRange) else "1"
)
self.async_write_ha_state()
if "settings." in self.entity_description.key:
await self._device.commands["settings"].send()
await self.coordinator.async_refresh()
if not type(setting) == HonParameter:
setting.value = (
setting.max if isinstance(setting, HonParameterRange) else "1"
)
self.async_write_ha_state()
await self.coordinator.async_refresh()
if "settings." in self.entity_description.key:
await self._device.commands["settings"].send()
else:
await self._device.commands[self.entity_description.turn_on_key].send()

Expand All @@ -427,13 +439,14 @@ async def async_turn_off(self, **kwargs: Any) -> None:
or "settings." in self.entity_description.key
):
setting = self._device.settings[self.entity_description.key]
setting.value = (
setting.min if isinstance(setting, HonParameterRange) else "0"
)
self.async_write_ha_state()
if "settings." in self.entity_description.key:
await self._device.commands["settings"].send()
await self.coordinator.async_refresh()
if not type(setting) == HonParameter:
setting.value = (
setting.min if isinstance(setting, HonParameterRange) else "0"
)
self.async_write_ha_state()
if "settings." in self.entity_description.key:
await self._device.commands["settings"].send()
await self.coordinator.async_refresh()
else:
await self._device.commands[self.entity_description.turn_off_key].send()

Expand All @@ -452,8 +465,11 @@ def available(self) -> bool:

@callback
def _handle_coordinator_update(self):
if not self.entity_description.status_key:
if self.entity_description.status_key:
value = self._device.get(self.entity_description.status_key, "0")
elif self.entity_category == EntityCategory.CONFIG:
value = self._device.settings.get(self.entity_description.key, "0")
else:
return
value = self._device.get(self.entity_description.status_key, "0")
self._attr_state = value == "1"
self.async_write_ha_state()
56 changes: 40 additions & 16 deletions custom_components/hon/translations/cs.json
Original file line number Diff line number Diff line change
Expand Up @@ -225,7 +225,7 @@
"hqd_precious_cure": "Precious cure",
"hqd_quick_20": "Rychlý 20",
"hqd_quick_30": "Rychlý 30",
"hqd_quick_dry": "Rychlé sušení",
"hqd_quick_dry": "Rychlé sušení 30",
"hqd_quilt": "Deky",
"hqd_refresh": "Osvěžení",
"hqd_school_uniform": "Školní uniformy",
Expand Down Expand Up @@ -409,6 +409,11 @@
"silent": "Noc",
"silent_care": "Silent Care",
"smart_ai": "Smart AI",
"smart_ai_pro": "Smart AI Pro",
"smart_ai_pro_soil": "Smart AI Pro",
"smart_ai_rapid": "Smart AI Rapid",
"smart_ai_rapid_soil": "Smart AI Rapid",
"smart_ai_soil": "Smart AI",
"special": "speciální",
"special_pw_prz": "speciální",
"steam": "Parní 75 °C",
Expand Down Expand Up @@ -465,19 +470,20 @@
"programs_ov": {
"state": {
"bakery": "Těstoviny a pečivo",
"bakery_steam": "Chléb pečený v páře",
"bakery_steam": "Pára v troubě",
"bottom_heating": "Spodní ohřev",
"bottom_heating_fan": "Spodní ohřev + ventilátor",
"bread": "Chléb",
"bread_steam": "Pečivo pečené v páře",
"bread_steam": "Chléb pečený v páře",
"combi": "Combi",
"convection_fan": "Statický + ventilátor",
"convection_fan_turnspit": "Konvekce + ventilátor + rožeň",
"conventional": "Statický",
"conventional_turnspit": "Konvekční + rožeň",
"conventional_turnspit": "Konvekce + rožeň",
"defrost": "Rozmrazování",
"descaling": "Odstraňování vodního kamene",
"fish": "Ryby",
"fish_steam": "Ryby připravované v páře",
"fish_steam": "Ryby v páře",
"grill_cata": "Gril",
"grill_fan_cata": "Ventilátor grilu",
"grill_fan_pyro": "Gril + ventilátor",
Expand All @@ -487,21 +493,21 @@
"iot_h20_clean": "h2O clean",
"leavening": "Kynutí",
"low_temp_cooking": "Příprava při nízkých teplotách",
"low_temp_cooking_fish": "Příprava ryb při nízkých teplotách",
"low_temp_cooking_fish_steam": "Příprava ryb v páře při nízkých teplotách",
"low_temp_cooking_meat": "Příprava masa při nízkých teplotách",
"low_temp_cooking_meat_steam": "Příprava masa v páře při nízkých teplotách",
"low_temp_cooking_fish": "Příprava při nízkých teplotách – ryby",
"low_temp_cooking_fish_steam": "Příprava při nízkých teplotách – ryby v páře",
"low_temp_cooking_meat": "Příprava při nízkých teplotách – maso",
"low_temp_cooking_meat_steam": "Příprava při nízkých teplotách - dušené maso",
"low_temp_cooking_steam": "Příprava v páře při nízkých teplotách",
"meat": "Maso",
"meat_steam": "Maso připravované v páře",
"meat_steam": "Maso v páře",
"multi_level": "Víceúrovňové",
"paella": "Paella",
"pasta_and_bakery": "Těstoviny a pečivo",
"pizza": "Pizza",
"pyrolysis": "Pyrolýza",
"pyrolysis_plus": "Pyrolýza +",
"red_meat": "Tmavé maso",
"red_meat_steam": "Červené maso připravované v páře",
"red_meat_steam": "Červené maso vařené v páře",
"regenerate": "Regenerace",
"soft_plus": "Soft +",
"super_grill": "Super gril",
Expand All @@ -511,9 +517,9 @@
"vegetables": "Zelenina",
"vegetables_cata": "Zelenina",
"vegetables_pyro": "Zelenina",
"water_discharge": "Odtok vody",
"water_discharge": "Vypouštění vody",
"white_meat": "Bílé maso",
"white_meat_steam": "Bílé maso připravované v páře"
"white_meat_steam": "Bílé maso vařené v páře"
},
"name": "Program"
},
Expand Down Expand Up @@ -570,7 +576,7 @@
"hqd_precious_cure": "Precious cure",
"hqd_quick_20": "Rychlý 20",
"hqd_quick_30": "Rychlý 30",
"hqd_quick_dry": "Rychlé sušení",
"hqd_quick_dry": "Rychlé sušení 30",
"hqd_quilt": "Deky",
"hqd_refresh": "Osvěžení",
"hqd_school_uniform": "Školní uniformy",
Expand Down Expand Up @@ -1050,6 +1056,15 @@
},
"remaining_time": {
"name": "Zbývající čas"
},
"ref_zones": {
"state": {
"fridge": "Chladnička",
"freezer": "Mraznička",
"vtRoom1": "My Zone",
"[fridge|freezer]": "Chladnička & Mraznička"
},
"name": "Zóna"
}
},
"switch": {
Expand Down Expand Up @@ -1093,7 +1108,7 @@
"name": "Trouba"
},
"prewash": {
"name": "Předpírka\r\r\r\r\r\r\n"
"name": "Předpírka\r\r\r\r\r\r\r\n"
},
"pause": {
"name": "Pozastavit"
Expand Down Expand Up @@ -1157,6 +1172,9 @@
},
"super_freeze": {
"name": "Super Freeze"
},
"refrigerator": {
"name": "Chladnička"
}
},
"binary_sensor": {
Expand Down Expand Up @@ -1227,7 +1245,7 @@
"name": "Zapnout"
},
"prewash": {
"name": "Předpírka\r\r\r\r\r\r\n"
"name": "Předpírka\r\r\r\r\r\r\r\n"
},
"acqua_plus": {
"name": "Aquaplus"
Expand Down Expand Up @@ -1301,6 +1319,12 @@
"button": {
"induction_hob": {
"name": "Indukční varná deska"
},
"start_program": {
"name": "Program Zahájení"
},
"stop_program": {
"name": "Program Zastavit"
}
},
"climate": {
Expand Down
Loading

0 comments on commit bf1a6e8

Please sign in to comment.