Skip to content

Commit

Permalink
Many air conditioner fixes for #52
Browse files Browse the repository at this point in the history
  • Loading branch information
Andre0512 committed May 16, 2023
1 parent d39deba commit a4ec329
Show file tree
Hide file tree
Showing 30 changed files with 199 additions and 30 deletions.
23 changes: 15 additions & 8 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -155,22 +155,29 @@ For every device exists a hidden button which can be used to log all infos of yo
| Air Conditioner | `air-conditioner` | `climate` | `settings` |
| Echo | `account-voice` | `switch` | `settings.echoStatus` |
| Eco Mode | | `switch` | `settings.ecoMode` |
| Eco Pilot | `run` | `select` | `settings.humanSensingStatus` |
| Health Mode | `medication-outline` | `switch` | `settings.healthMode` |
| Mute | `volume-off` | `switch` | `settings.muteStatus` |
| Rapid Mode | `run-fast` | `switch` | `settings.rapidMode` |
| Screen Display | `monitor-small` | `switch` | `settings.screenDisplayStatus` |
| Self Cleaning | `air-filter` | `switch` | `settings.selfCleaningStatus` |
| Self Cleaning 56 | `air-filter` | `switch` | `settings.selfCleaning56Status` |
| Silent Sleep | `bed` | `switch` | `settings.silentSleepStatus` |
#### Configs
| Name | Icon | Entity | Key |
| --- | --- | --- | --- |
| Program | | `select` | `startProgram.program` |
| Target Temperature | `thermometer` | `number` | `settings.tempSel` |
#### Sensors
| Name | Icon | Entity | Key |
| --- | --- | --- | --- |
| Eco Pilot | `run` | `select` | `settings.humanSensingStatus` |
| Target Temperature | `thermometer` | `number` | `settings.tempSel` |
| Air Temperature Outdoor | `thermometer` | `sensor` | `tempAirOutdoor` |
| Ch2O Cleaning | | `binary_sensor` | `ch2oCleaningStatus` |
| Coiler Temperature Indoor | `thermometer` | `sensor` | `tempCoilerIndoor` |
| Coiler Temperature Outside | `thermometer` | `sensor` | `tempCoilerOutdoor` |
| Defrost Temperature Outdoor | `thermometer` | `sensor` | `tempDefrostOutdoor` |
| Filter Replacement | | `binary_sensor` | `filterChangeStatusLocal` |
| In Air Temperature Outdoor | `thermometer` | `sensor` | `tempInAirOutdoor` |
| Indoor Temperature | `thermometer` | `sensor` | `tempIndoor` |
| Outdoor Temperature | `thermometer` | `sensor` | `tempOutdoor` |
| Program | | `select` | `startProgram.program` |
| Selected Temperature | `thermometer` | `sensor` | `tempSel` |
### Dish washer
#### Controls
Expand Down Expand Up @@ -262,6 +269,8 @@ For every device exists a hidden button which can be used to log all infos of yo
| Name | Icon | Entity | Key |
| --- | --- | --- | --- |
| Auto-Set Mode | `thermometer-auto` | `switch` | `settings.intelligenceMode` |
| Freezer Temperature | `thermometer` | `number` | `settings.tempSelZ2` |
| Fridge Temperature | `thermometer` | `number` | `settings.tempSelZ1` |
| Super Cool | `snowflake` | `switch` | `settings.quickModeZ2` |
| Super Freeze | `snowflake-variant` | `switch` | `settings.quickModeZ1` |
#### Configs
Expand All @@ -274,8 +283,6 @@ For every device exists a hidden button which can be used to log all infos of yo
| Auto-Set Mode | `thermometer-auto` | `binary_sensor` | `intelligenceMode` |
| Door Status Freezer | `fridge-top` | `binary_sensor` | `doorStatusZ1` |
| Door Status Fridge | `fridge-bottom` | `binary_sensor` | `door2StatusZ1` |
| Freezer Temperature | `thermometer` | `number` | `settings.tempSelZ2` |
| Fridge Temperature | `thermometer` | `number` | `settings.tempSelZ1` |
| Holiday Mode | `palm-tree` | `binary_sensor` | `holidayMode` |
| Room Humidity | `water-percent` | `sensor` | `humidityEnv` |
| Room Temperature | `home-thermometer-outline` | `sensor` | `tempEnv` |
Expand Down
18 changes: 16 additions & 2 deletions custom_components/hon/binary_sensor.py
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
import logging
from dataclasses import dataclass

from pyhon import Hon

from homeassistant.components.binary_sensor import (
BinarySensorEntityDescription,
BinarySensorDeviceClass,
BinarySensorEntity,
)
from homeassistant.config_entries import ConfigEntry
from homeassistant.core import callback
from pyhon import Hon

from .const import DOMAIN
from .hon import HonCoordinator, HonEntity, unique_entities

Expand Down Expand Up @@ -179,6 +179,20 @@ class HonBinarySensorEntityDescription(
translation_key="door_open",
),
),
"AC": (
HonBinarySensorEntityDescription(
key="filterChangeStatusLocal",
name="Filter Replacement",
device_class=BinarySensorDeviceClass.PROBLEM,
on_value="1",
translation_key="filter_replacement",
),
HonBinarySensorEntityDescription(
key="ch2oCleaningStatus",
name="Ch2O Cleaning",
on_value="1",
),
),
"REF": (
HonBinarySensorEntityDescription(
key="quickModeZ2",
Expand Down
21 changes: 12 additions & 9 deletions custom_components/hon/climate.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
import logging

from pyhon import Hon
from pyhon.appliance import HonAppliance

from homeassistant.components.climate import (
ClimateEntity,
ClimateEntityDescription,
Expand All @@ -20,9 +23,6 @@
TEMP_CELSIUS,
)
from homeassistant.core import callback
from pyhon import Hon
from pyhon.appliance import HonAppliance

from .const import HON_HVAC_MODE, HON_FAN, HON_HVAC_PROGRAM, DOMAIN
from .hon import HonEntity, HonCoordinator

Expand Down Expand Up @@ -107,13 +107,15 @@ async def async_set_hvac_mode(self, hvac_mode):
]
await self._device.commands["startProgram"].send()
self._attr_hvac_mode = hvac_mode
self.async_write_ha_state()

async def async_set_fan_mode(self, fan_mode):
mode_number = list(HON_FAN.values()).index(fan_mode)
self._device.settings["settings.windSpeed"].value = list(HON_FAN.keys())[
mode_number
]
await self._device.commands["settings"].send()
self.async_write_ha_state()

async def async_set_swing_mode(self, swing_mode):
horizontal = self._device.settings["settings.windDirectionHorizontal"]
Expand All @@ -128,29 +130,29 @@ async def async_set_swing_mode(self, swing_mode):
horizontal.value = "0"
self._attr_swing_mode = swing_mode
await self._device.commands["settings"].send()
self.async_write_ha_state()

async def async_set_temperature(self, **kwargs):
if (temperature := kwargs.get(ATTR_TEMPERATURE)) is None:
return False
self._device.settings["settings.tempSel"].value = int(temperature)
self._device.settings["settings.tempSel"].value = str(int(temperature))
await self._device.commands["settings"].send()
self.async_write_ha_state()

@callback
def _handle_coordinator_update(self, update=True) -> None:
self._attr_target_temperature = int(float(self._device.get("tempSel")))
self._attr_current_temperature = float(self._device.get("tempIndoor"))
self._attr_max_temp = self._device.settings["settings.tempSel"].max
self._attr_min_temp = self._device.settings["settings.tempSel"].min

if self._device.get("onOffStatus") == "0":
self._attr_hvac_mode = HVACMode.OFF
else:
self._attr_hvac_mode = HON_HVAC_MODE[self._device.get("machMode") or "0"]

self._attr_fan_mode = HON_FAN[self._device.settings["settings.windSpeed"].value]
self._attr_fan_mode = HON_FAN[self._device.get("windSpeed")]

horizontal = self._device.settings["settings.windDirectionHorizontal"]
vertical = self._device.settings["settings.windDirectionVertical"]
horizontal = self._device.get("windDirectionHorizontal")
vertical = self._device.get("windDirectionVertical")
if horizontal == "7" and vertical == "8":
self._attr_swing_mode = SWING_BOTH
elif horizontal == "7":
Expand All @@ -159,3 +161,4 @@ def _handle_coordinator_update(self, update=True) -> None:
self._attr_swing_mode = SWING_VERTICAL
else:
self._attr_swing_mode = SWING_OFF
self.async_write_ha_state()
2 changes: 1 addition & 1 deletion custom_components/hon/config_flow.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
import logging

import voluptuous as vol

from homeassistant import config_entries
from homeassistant.const import CONF_EMAIL, CONF_PASSWORD

from .const import DOMAIN

_LOGGER = logging.getLogger(__name__)
Expand Down
2 changes: 1 addition & 1 deletion custom_components/hon/const.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
HON_HVAC_MODE = {
"0": HVACMode.AUTO,
"1": HVACMode.COOL,
"2": HVACMode.COOL,
"2": HVACMode.DRY,
"3": HVACMode.DRY,
"4": HVACMode.HEAT,
"5": HVACMode.FAN_ONLY,
Expand Down
4 changes: 2 additions & 2 deletions custom_components/hon/hon.py
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
import logging
from datetime import timedelta

from pyhon.appliance import HonAppliance

from homeassistant.helpers.entity import DeviceInfo
from homeassistant.helpers.update_coordinator import CoordinatorEntity
from homeassistant.helpers.update_coordinator import DataUpdateCoordinator
from pyhon.appliance import HonAppliance

from .const import DOMAIN

_LOGGER = logging.getLogger(__name__)
Expand Down
1 change: 0 additions & 1 deletion custom_components/hon/select.py
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,6 @@
SelectEntityDescription(
key="startProgram.program",
name="Program",
entity_category=EntityCategory.CONFIG,
translation_key="programs_ac",
),
SelectEntityDescription(
Expand Down
70 changes: 68 additions & 2 deletions custom_components/hon/sensor.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
import logging

from pyhon import Hon

from homeassistant.components.sensor import (
SensorEntity,
SensorDeviceClass,
Expand All @@ -20,8 +22,6 @@
from homeassistant.core import callback
from homeassistant.helpers.entity import EntityCategory
from homeassistant.helpers.typing import StateType
from pyhon import Hon

from . import const
from .const import DOMAIN
from .hon import HonCoordinator, HonEntity, unique_entities
Expand Down Expand Up @@ -399,6 +399,72 @@
options=list(const.DISHWASHER_PR_PHASE),
),
),
"AC": (
SensorEntityDescription(
key="tempAirOutdoor",
name="Air Temperature Outdoor",
icon="mdi:thermometer",
state_class=SensorStateClass.MEASUREMENT,
device_class=SensorDeviceClass.TEMPERATURE,
native_unit_of_measurement=UnitOfTemperature.CELSIUS,
),
SensorEntityDescription(
key="tempCoilerIndoor",
name="Coiler Temperature Indoor",
icon="mdi:thermometer",
state_class=SensorStateClass.MEASUREMENT,
device_class=SensorDeviceClass.TEMPERATURE,
native_unit_of_measurement=UnitOfTemperature.CELSIUS,
),
SensorEntityDescription(
key="tempCoilerOutdoor",
name="Coiler Temperature Outside",
icon="mdi:thermometer",
state_class=SensorStateClass.MEASUREMENT,
device_class=SensorDeviceClass.TEMPERATURE,
native_unit_of_measurement=UnitOfTemperature.CELSIUS,
),
SensorEntityDescription(
key="tempDefrostOutdoor",
name="Defrost Temperature Outdoor",
icon="mdi:thermometer",
state_class=SensorStateClass.MEASUREMENT,
device_class=SensorDeviceClass.TEMPERATURE,
native_unit_of_measurement=UnitOfTemperature.CELSIUS,
),
SensorEntityDescription(
key="tempInAirOutdoor",
name="In Air Temperature Outdoor",
icon="mdi:thermometer",
state_class=SensorStateClass.MEASUREMENT,
device_class=SensorDeviceClass.TEMPERATURE,
native_unit_of_measurement=UnitOfTemperature.CELSIUS,
),
SensorEntityDescription(
key="tempIndoor",
name="Indoor Temperature",
icon="mdi:thermometer",
state_class=SensorStateClass.MEASUREMENT,
device_class=SensorDeviceClass.TEMPERATURE,
native_unit_of_measurement=UnitOfTemperature.CELSIUS,
),
SensorEntityDescription(
key="tempOutdoor",
name="Outdoor Temperature",
icon="mdi:thermometer",
state_class=SensorStateClass.MEASUREMENT,
device_class=SensorDeviceClass.TEMPERATURE,
native_unit_of_measurement=UnitOfTemperature.CELSIUS,
),
SensorEntityDescription(
key="tempSel",
name="Selected Temperature",
icon="mdi:thermometer",
state_class=SensorStateClass.MEASUREMENT,
device_class=SensorDeviceClass.TEMPERATURE,
native_unit_of_measurement=UnitOfTemperature.CELSIUS,
),
),
"REF": (
SensorEntityDescription(
key="humidityEnv",
Expand Down
Loading

0 comments on commit a4ec329

Please sign in to comment.