Skip to content

Commit

Permalink
Add dishwasher #21
Browse files Browse the repository at this point in the history
  • Loading branch information
Andre0512 committed Apr 16, 2023
1 parent 2aa1d3d commit a41fb36
Show file tree
Hide file tree
Showing 8 changed files with 286 additions and 13 deletions.
3 changes: 2 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,12 @@
[![Home Assistant installs](https://img.shields.io/badge/dynamic/json?color=blue&label=usage&suffix=%20installs&cacheSeconds=15600&url=https://analytics.home-assistant.io/custom_integrations.json&query=$.hon.total)](https://analytics.home-assistant.io/)
Home Assistant integration for Haier hOn: support for Haier/Candy/Hoover home appliances like washing machines.
## Supported Appliances
- Washing Machine
- Tumble Dryer
- Washer Dryer
- Washing Machine
- Oven
- Hob
- Dish Washer

## 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)
Expand Down
28 changes: 28 additions & 0 deletions custom_components/hon/binary_sensor.py
Original file line number Diff line number Diff line change
Expand Up @@ -159,6 +159,34 @@ class HonBinarySensorEntityDescription(
on_value="0",
),
),
"DW": (
HonBinarySensorEntityDescription(
key="saltStatus",
name="Salt",
device_class=BinarySensorDeviceClass.PROBLEM,
on_value="1",
icon="mdi:shaker-outline",
),
HonBinarySensorEntityDescription(
key="rinseAidStatus",
name="Rinse Aid",
device_class=BinarySensorDeviceClass.PROBLEM,
on_value="1",
icon="mdi:spray-bottle",
),
HonBinarySensorEntityDescription(
key="attributes.lastConnEvent.category",
name="Connection",
device_class=BinarySensorDeviceClass.CONNECTIVITY,
on_value="CONNECTED",
),
HonBinarySensorEntityDescription(
key="doorStatus",
name="Door",
device_class=BinarySensorDeviceClass.DOOR,
on_value="1",
),
),
}


Expand Down
2 changes: 1 addition & 1 deletion custom_components/hon/manifest.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,5 +7,5 @@
"iot_class": "cloud_polling",
"issue_tracker": "https://github.com/Andre0512/hon/issues",
"requirements": ["pyhOn==0.8.0b5"],
"version": "0.6.0-beta.4"
"version": "0.6.0-beta.5"
}
15 changes: 15 additions & 0 deletions custom_components/hon/number.py
Original file line number Diff line number Diff line change
Expand Up @@ -120,6 +120,21 @@
icon="mdi:timelapse",
),
),
"DW": (
NumberEntityDescription(
key="startProgram.delayTime",
name="Delay time",
icon="mdi:timer-plus",
entity_category=EntityCategory.CONFIG,
native_unit_of_measurement=UnitOfTime.MINUTES,
),
NumberEntityDescription(
key="startProgram.waterHard",
name="Water hard",
icon="mdi:water",
entity_category=EntityCategory.CONFIG,
),
),
}


Expand Down
8 changes: 8 additions & 0 deletions custom_components/hon/select.py
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,14 @@
translation_key="programs",
),
),
"DW": (
SelectEntityDescription(
key="startProgram.program",
name="Program",
entity_category=EntityCategory.CONFIG,
translation_key="programs_dw",
),
),
}


Expand Down
64 changes: 64 additions & 0 deletions custom_components/hon/sensor.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
from homeassistant.core import callback
from homeassistant.helpers.entity import EntityCategory
from homeassistant.helpers.typing import StateType
from homeassistant.const import PERCENTAGE

from .const import DOMAIN
from .hon import HonCoordinator, HonEntity
Expand Down Expand Up @@ -237,6 +238,69 @@
),
SensorEntityDescription(key="errors", name="Error", icon="mdi:math-log"),
),
"DW": (
SensorEntityDescription(
key="startProgram.ecoIndex",
name="Eco Index",
icon="mdi:sprout",
state_class=SensorStateClass.MEASUREMENT,
entity_category=EntityCategory.CONFIG,
),
SensorEntityDescription(
key="startProgram.waterEfficiency",
name="Water Efficiency",
icon="mdi:water",
state_class=SensorStateClass.MEASUREMENT,
entity_category=EntityCategory.CONFIG,
),
SensorEntityDescription(
key="startProgram.waterSaving",
name="Water Saving",
icon="mdi:water-percent",
state_class=SensorStateClass.MEASUREMENT,
native_unit_of_measurement=PERCENTAGE,
entity_category=EntityCategory.CONFIG,
),
SensorEntityDescription(
key="startProgram.temp",
name="Temperature",
icon="mdi:thermometer",
state_class=SensorStateClass.MEASUREMENT,
native_unit_of_measurement=UnitOfTemperature.CELSIUS,
entity_category=EntityCategory.CONFIG,
),
SensorEntityDescription(
key="startProgram.energyLabel",
name="Energy Label",
icon="mdi:lightning-bolt-circle",
state_class=SensorStateClass.MEASUREMENT,
entity_category=EntityCategory.CONFIG,
),
SensorEntityDescription(
key="startProgram.remainingTime",
name="Time",
icon="mdi:timer",
state_class=SensorStateClass.MEASUREMENT,
native_unit_of_measurement=UnitOfTime.MINUTES,
entity_category=EntityCategory.CONFIG,
),
SensorEntityDescription(
key="machMode",
name="Machine Status",
icon="mdi:information",
translation_key="mode_dw",
),
SensorEntityDescription(
key="errors", name="Error", icon="mdi:math-log", translation_key="errors"
),
SensorEntityDescription(
key="remainingTimeMM",
name="Remaining Time",
icon="mdi:timer",
state_class=SensorStateClass.MEASUREMENT,
native_unit_of_measurement=UnitOfTime.MINUTES,
),
),
}


Expand Down
61 changes: 51 additions & 10 deletions custom_components/hon/switch.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import logging

from dataclasses import dataclass
from typing import Any

Expand Down Expand Up @@ -90,6 +89,51 @@ class HonSwitchEntityDescription(
turn_off_key="resumeProgram",
),
),
"DW": (
HonSwitchEntityDescription(
key="active",
name="Dish Washer",
icon="mdi:dishwasher",
turn_on_key="startProgram",
turn_off_key="stopProgram",
),
HonSwitchEntityDescription(
key="startProgram.extraDry",
name="Extra Dry",
icon="mdi:hair-dryer",
entity_category=EntityCategory.CONFIG,
),
HonSwitchEntityDescription(
key="startProgram.halfLoad",
name="Half Load",
icon="mdi:fraction-one-half",
entity_category=EntityCategory.CONFIG,
),
HonSwitchEntityDescription(
key="startProgram.openDoor",
name="Open Door",
icon="mdi:door-open",
entity_category=EntityCategory.CONFIG,
),
HonSwitchEntityDescription(
key="startProgram.threeInOne",
name="Three in One",
icon="mdi:numeric-3-box-outline",
entity_category=EntityCategory.CONFIG,
),
HonSwitchEntityDescription(
key="startProgram.ecoExpress",
name="Eco Express",
icon="mdi:sprout",
entity_category=EntityCategory.CONFIG,
),
HonSwitchEntityDescription(
key="startProgram.addDish",
name="Add Dish",
icon="mdi:silverware-fork-knife",
entity_category=EntityCategory.CONFIG,
),
),
}


Expand Down Expand Up @@ -139,13 +183,6 @@ def __init__(
self.entity_description = description
self._attr_unique_id = f"{super().unique_id}{description.key}"

def available(self) -> bool:
if self.entity_category == EntityCategory.CONFIG:
return (
self._device.settings[self.entity_description.key].typology != "fixed"
)
return True

@property
def is_on(self) -> bool | None:
"""Return True if entity is on."""
Expand All @@ -161,15 +198,19 @@ def is_on(self) -> bool | None:
async def async_turn_on(self, **kwargs: Any) -> None:
if self.entity_category == EntityCategory.CONFIG:
setting = self._device.settings[self.entity_description.key]
setting.value = setting.max
setting.value = (
setting.max if isinstance(setting, HonParameterRange) else "1"
)
self.async_write_ha_state()
else:
await self._device.commands[self.entity_description.turn_on_key].send()

async def async_turn_off(self, **kwargs: Any) -> None:
if self.entity_category == EntityCategory.CONFIG:
setting = self._device.settings[self.entity_description.key]
setting.value = setting.min
setting.value = (
setting.min if isinstance(setting, HonParameterRange) else "0"
)
self.async_write_ha_state()
else:
await self._device.commands[self.entity_description.turn_off_key].send()
Loading

0 comments on commit a41fb36

Please sign in to comment.