Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Water Heater appliance #135

Open
wants to merge 7 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 10 additions & 0 deletions custom_components/hon/binary_sensor.py
Original file line number Diff line number Diff line change
Expand Up @@ -285,6 +285,16 @@ class HonBinarySensorEntityDescription(BinarySensorEntityDescription):
translation_key="on",
),
),
"WH": (
HonBinarySensorEntityDescription(
key="onOffStatus",
name="Power State",
icon="mdi:power-standby",
device_class=BinarySensorDeviceClass.POWER,
on_value=1,
translation_key="power-state",
),
),
"FRE": (
HonBinarySensorEntityDescription(
key="quickModeZ1",
Expand Down
6 changes: 6 additions & 0 deletions custom_components/hon/const.py
Original file line number Diff line number Diff line change
Expand Up @@ -294,3 +294,9 @@
7: "position_5",
8: "swing",
}

WH_MACH_MODE: dict[int, str] = {
1: "eco",
2: "max",
3: "bps",
}
22 changes: 19 additions & 3 deletions custom_components/hon/number.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
from homeassistant.components.number import (
NumberEntity,
NumberEntityDescription,
NumberDeviceClass,
)
from homeassistant.config_entries import ConfigEntry
from homeassistant.const import UnitOfTime, UnitOfTemperature
Expand All @@ -27,7 +28,7 @@ class HonConfigNumberEntityDescription(NumberEntityDescription):

@dataclass(frozen=True)
class HonNumberEntityDescription(NumberEntityDescription):
pass
send_key_only: bool = False


NUMBERS: dict[str, tuple[NumberEntityDescription, ...]] = {
Expand Down Expand Up @@ -201,6 +202,17 @@ class HonNumberEntityDescription(NumberEntityDescription):
translation_key="pollen_level",
),
),
"WH": (
HonNumberEntityDescription(
key="settings.tempSel",
name="Target Temperature",
icon="mdi:thermometer",
device_class=NumberDeviceClass.TEMPERATURE,
native_unit_of_measurement=UnitOfTemperature.CELSIUS,
translation_key="target_temperature",
send_key_only=True,
),
),
}

NUMBERS["WD"] = unique_entities(NUMBERS["WM"], NUMBERS["TD"])
Expand Down Expand Up @@ -253,8 +265,12 @@ async def async_set_native_value(self, value: float) -> None:
setting = self._device.settings[self.entity_description.key]
if isinstance(setting, HonParameterRange):
setting.value = value
command = self.entity_description.key.split(".")[0]
await self._device.commands[command].send()
key_parts = self.entity_description.key.split(".")
command = key_parts[0]
if self.entity_description.send_key_only:
await self._device.commands[command].send_specific([key_parts[1]])
else:
await self._device.commands[command].send()
if command != "settings":
self._device.sync_command(command, "settings")
self.coordinator.async_set_updated_data({})
Expand Down
27 changes: 25 additions & 2 deletions custom_components/hon/select.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
@dataclass(frozen=True)
class HonSelectEntityDescription(SelectEntityDescription):
option_list: dict[int, str] | None = None
send_key_only: bool = False


@dataclass(frozen=True)
Expand Down Expand Up @@ -185,6 +186,24 @@ class HonConfigSelectEntityDescription(SelectEntityDescription):
translation_key="mode",
),
),
"WH": (
HonSelectEntityDescription(
key="settings.tempSel",
name="Target Temperature",
icon="mdi:thermometer",
unit_of_measurement=UnitOfTemperature.CELSIUS,
translation_key="target_temperature",
send_key_only=True,
),
HonSelectEntityDescription(
key="settings.machMode",
name="Mode",
send_key_only=True,
icon="mdi:information",
option_list=const.WH_MACH_MODE,
translation_key="mach_modes_wh",
),
),
"FRE": (
HonConfigSelectEntityDescription(
key="startProgram.program",
Expand Down Expand Up @@ -313,8 +332,12 @@ def _option_to_number(self, option: str, values: list[str]) -> str:
async def async_select_option(self, option: str) -> None:
setting = self._device.settings[self.entity_description.key]
setting.value = self._option_to_number(option, setting.values)
command = self.entity_description.key.split(".")[0]
await self._device.commands[command].send()
key_parts = self.entity_description.key.split(".")
command = key_parts[0]
if self.entity_description.send_key_only:
await self._device.commands[command].send_specific([key_parts[1]])
else:
await self._device.commands[command].send()
if command != "settings":
self._device.sync_command(command, "settings")
self.coordinator.async_set_updated_data({})
Expand Down
57 changes: 57 additions & 0 deletions custom_components/hon/sensor.py
Original file line number Diff line number Diff line change
Expand Up @@ -780,6 +780,63 @@ class HonSensorEntityDescription(SensorEntityDescription):
translation_key="air_quality",
),
),
"WH": (
HonSensorEntityDescription(
key="temp",
name="Temperature",
state_class=SensorStateClass.MEASUREMENT,
device_class=SensorDeviceClass.TEMPERATURE,
native_unit_of_measurement=UnitOfTemperature.CELSIUS,
translation_key="temperature",
),
HonSensorEntityDescription(
key="tempZ1",
name="Temp Z1",
state_class=SensorStateClass.MEASUREMENT,
device_class=SensorDeviceClass.TEMPERATURE,
native_unit_of_measurement=UnitOfTemperature.CELSIUS,
),
HonSensorEntityDescription(
key="tempZ2",
name="Temp Z2",
state_class=SensorStateClass.MEASUREMENT,
device_class=SensorDeviceClass.TEMPERATURE,
native_unit_of_measurement=UnitOfTemperature.CELSIUS,
),
HonSensorEntityDescription(
key="tempSel",
name="Target Temperature",
icon="mdi:thermometer",
state_class=SensorStateClass.MEASUREMENT,
device_class=SensorDeviceClass.TEMPERATURE,
native_unit_of_measurement=UnitOfTemperature.CELSIUS,
translation_key="target_temperature",
),
HonSensorEntityDescription(
key="machMode",
name="Mode",
icon="mdi:information",
device_class=SensorDeviceClass.ENUM,
option_list=const.WH_MACH_MODE,
translation_key="mach_modes_wh",
),
HonSensorEntityDescription(
key="smartTestStatus",
name="Smart Test Status",
),
HonSensorEntityDescription(
key="anodeMaintenanceStatus",
name="Anode Maintenance Status",
),
HonSensorEntityDescription(
key="tankMaintenanceStatus",
name="Tank Maintenance Status",
),
HonSensorEntityDescription(
key="heatingStatus",
name="Heating Status",
),
),
"FRE": (
HonSensorEntityDescription(
key="tempEnv",
Expand Down
38 changes: 31 additions & 7 deletions custom_components/hon/switch.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,10 @@
class HonControlSwitchEntityDescription(SwitchEntityDescription):
turn_on_key: str = ""
turn_off_key: str = ""
only_mandatory_parameters: bool = False
on_value: bool | float = True
off_value: bool | float = False
to_sync: bool = False


@dataclass(frozen=True)
Expand Down Expand Up @@ -382,6 +386,20 @@ class HonConfigSwitchEntityDescription(SwitchEntityDescription):
translation_key="touch_tone",
),
),
"WH": (
HonControlSwitchEntityDescription(
key="onOffStatus",
name="Power",
icon="mdi:power-standby",
turn_on_key="startProgram",
turn_off_key="stopProgram",
translation_key="power",
only_mandatory_parameters=True,
on_value=1,
off_value=0,
to_sync=True,
),
),
"FRE": (
HonSwitchEntityDescription(
key="quickModeZ2",
Expand Down Expand Up @@ -485,20 +503,26 @@ class HonControlSwitchEntity(HonEntity, SwitchEntity):
@property
def is_on(self) -> bool | None:
"""Return True if entity is on."""
return self._device.get(self.entity_description.key, False)
on_value = self.entity_description.on_value
off_value = self.entity_description.off_value
return self._device.get(self.entity_description.key, off_value) == on_value

async def async_turn_on(self, **kwargs: Any) -> None:
self._device.sync_command(self.entity_description.turn_on_key, "settings")
desc = self.entity_description
self._device.sync_command(desc.turn_on_key, "settings", desc.to_sync)
self.coordinator.async_set_updated_data({})
await self._device.commands[self.entity_description.turn_on_key].send()
self._device.attributes[self.entity_description.key] = True
command = self._device.commands[desc.turn_on_key]
await command.send(desc.only_mandatory_parameters)
self._device.attributes[desc.key] = desc.on_value
self.async_write_ha_state()

async def async_turn_off(self, **kwargs: Any) -> None:
self._device.sync_command(self.entity_description.turn_off_key, "settings")
desc = self.entity_description
self._device.sync_command(desc.turn_off_key, "settings", desc.to_sync)
self.coordinator.async_set_updated_data({})
await self._device.commands[self.entity_description.turn_off_key].send()
self._device.attributes[self.entity_description.key] = False
command = self._device.commands[desc.turn_off_key]
await command.send(desc.only_mandatory_parameters)
self._device.attributes[desc.key] = desc.off_value
self.async_write_ha_state()

@property
Expand Down
86 changes: 86 additions & 0 deletions custom_components/hon/translations/bg.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,79 @@
}
}
}
}
}
},
"entity": {
"sensor": {
"mode": {
"state": {
"0": "Изключен",
"1": "Готов",
"2": "Работи",
"3": "На пауза",
"5": "Scheduled",
"6": "Грешка",
"7": "Завършен"
}
},
"errors": {
"state": {
"00": "Няма грешки",
"100000000000": "E2: Провери дали вратата е затворена",
"8000000000000": "E4: Провери подаването на вода"
}
},
"programs": {
"state": {
"0": "Стандартна",
"62": "Памук",
"63": "Синтетика",
"64": "Смесен тип",
"66": "Чаршафи",
"71": "Пердета",
"72": "Спорт",
"74": "i-time",
"75": "Олекотени завивки",
"76": "Вълна",
"78": "i-Refresh",
"83": "Хавлиена кърпа",
"85": "Бързо Сушене",
"92": "Деликатно пране",
"103": "Отдалечен"
}
},
"program_phases_td": {
"state": {
"0": "Изчаване",
"2": "Сушене",
"3": "Охлажане",
"11": "11"
}
},
"tumbledryertemplevel": {
"state": {
"1": "Хладен въздух",
"2": "Ниска температура L-1",
"3": "Средна температура L-2",
"4": "Висока температура L-3"
}
},
"dry_levels": {
"state": {
"3": "Готови за съхранение",
"12": "Готови за гладене H-1",
"13": "Готови за съхранение H-2",
"14": "Екстра сухо H-3"
}
},
"mach_modes_wh": {
"state": {
"eco": "Eco",
"max": "Max",
"bps": "BPS"
}
}
},
"entity": {
"sensor": {
Expand Down Expand Up @@ -2326,5 +2399,18 @@
"name": "Light"
}
}
},
"mach_modes_wh": {
"state": {
"eco": "Eco",
"max": "Max",
"bps": "BPS"
}
}
},
"binary_sensor": {
"power-state": {
"name": "Power State"
}
}
}
17 changes: 17 additions & 0 deletions custom_components/hon/translations/cs.json
Original file line number Diff line number Diff line change
Expand Up @@ -931,6 +931,13 @@
"high": "Vysoká"
},
"name": "Úroveň vlhkosti"
},
"mach_modes_wh": {
"state": {
"eco": "Eco",
"max": "Max",
"bps": "BPS"
}
}
},
"select": {
Expand Down Expand Up @@ -1816,6 +1823,13 @@
"position_5": "Pevný - Poloha 5",
"swing": "Pohyb lamel"
}
},
"mach_modes_wh": {
"state": {
"eco": "Eco",
"max": "Max",
"bps": "BPS"
}
}
},
"switch": {
Expand Down Expand Up @@ -2015,6 +2029,9 @@
},
"filter_replacement": {
"name": "Výměna filtru"
},
"power-state": {
"name": "Power State"
}
},
"button": {
Expand Down
Loading