Compare commits

...

3 Commits

Author SHA1 Message Date
c8189414b8 Use pyhon v0.6.1 2023-04-10 17:02:16 +02:00
799ac67d94 Use info.md for hacs 2023-04-10 08:17:27 +02:00
7e9202ef38 New pyhOn version 2023-04-10 07:09:54 +02:00
12 changed files with 70 additions and 34 deletions

View File

@ -16,6 +16,8 @@ Home Assistant integration for Haier hOn: support for Haier/Candy/Hoover home ap
**Method 3:** Manually copy `hon` folder from [latest release](https://github.com/Andre0512/hon/releases/latest) to `config/custom_components` folder.
_Restart Home Assistant_
## Configuration
**Method 1**: [![Open your Home Assistant instance and start setting up a new integration.](https://my.home-assistant.io/badges/config_flow_start.svg)](https://my.home-assistant.io/redirect/config_flow_start/?domain=hon)
@ -65,8 +67,9 @@ Any kind of contribution is welcome!
5. Create a [pull request](https://github.com/Andre0512/hon/pulls)
#### Tips and Tricks
- If you want to have some states humanreadable, have a look at the `translation_key` parameter of the `EntityDescription`
- If you want to have some states humanreadable, have a look at the `translation_key` parameter of the `EntityDescription`.
- If you need to implement some more logic, create a pull request to the underlying library. There we collect special requirements in the `appliances` directory.
- Use [pyhOn](https://github.com/Andre0512/pyhOn)s translate command to read out the official translations
## Tested Devices
- Haier WD90-B14TEAM5

View File

@ -1,7 +1,7 @@
import logging
import voluptuous as vol
from pyhon import HonConnection
from pyhon import Hon
from homeassistant.config_entries import ConfigEntry
from homeassistant.const import CONF_EMAIL, CONF_PASSWORD
@ -28,8 +28,7 @@ CONFIG_SCHEMA = vol.Schema(
async def async_setup_entry(hass: HomeAssistantType, entry: ConfigEntry):
session = aiohttp_client.async_get_clientsession(hass)
hon = HonConnection(entry.data["email"], entry.data["password"], session)
await hon.setup()
hon = await Hon(entry.data["email"], entry.data["password"], session=session).create()
hass.data.setdefault(DOMAIN, {})
hass.data[DOMAIN][entry.unique_id] = hon
hass.data[DOMAIN]["coordinators"] = {}

View File

@ -1,7 +1,7 @@
import logging
from dataclasses import dataclass
from pyhon import HonConnection
from pyhon import Hon
from homeassistant.components.binary_sensor import BinarySensorEntityDescription, BinarySensorDeviceClass, \
BinarySensorEntity
@ -123,10 +123,10 @@ BINARY_SENSORS: dict[str, tuple[HonBinarySensorEntityDescription, ...]] = {
async def async_setup_entry(hass, entry: ConfigEntry, async_add_entities) -> None:
hon: HonConnection = hass.data[DOMAIN][entry.unique_id]
hon: Hon = hass.data[DOMAIN][entry.unique_id]
coordinators = hass.data[DOMAIN]["coordinators"]
appliances = []
for device in hon.devices:
for device in hon.appliances:
if device.mac_address in coordinators:
coordinator = hass.data[DOMAIN]["coordinators"][device.mac_address]
else:

View File

@ -1,7 +1,7 @@
from homeassistant.components.button import ButtonEntityDescription, ButtonEntity
from homeassistant.config_entries import ConfigEntry
from pyhon import HonConnection
from pyhon.device import HonDevice
from pyhon import Hon
from pyhon.appliance import HonAppliance
from .const import DOMAIN
from .hon import HonCoordinator, HonEntity
@ -23,10 +23,10 @@ BUTTONS: dict[str, tuple[ButtonEntityDescription, ...]] = {
async def async_setup_entry(hass, entry: ConfigEntry, async_add_entities) -> None:
hon: HonConnection = hass.data[DOMAIN][entry.unique_id]
hon: Hon = hass.data[DOMAIN][entry.unique_id]
coordinators = hass.data[DOMAIN]["coordinators"]
appliances = []
for device in hon.devices:
for device in hon.appliances:
if device.mac_address in coordinators:
coordinator = hass.data[DOMAIN]["coordinators"][device.mac_address]
else:
@ -46,7 +46,7 @@ async def async_setup_entry(hass, entry: ConfigEntry, async_add_entities) -> Non
class HonButtonEntity(HonEntity, ButtonEntity):
def __init__(self, hass, coordinator, entry, device: HonDevice, description) -> None:
def __init__(self, hass, coordinator, entry, device: HonAppliance, description) -> None:
super().__init__(hass, entry, coordinator, device)
self._coordinator = coordinator

View File

@ -1,7 +1,7 @@
import logging
from datetime import timedelta
from pyhon.device import HonDevice
from pyhon.appliance import HonAppliance
from homeassistant.helpers.entity import DeviceInfo
from homeassistant.helpers.update_coordinator import CoordinatorEntity
@ -15,7 +15,7 @@ _LOGGER = logging.getLogger(__name__)
class HonEntity(CoordinatorEntity):
_attr_has_entity_name = True
def __init__(self, hass, entry, coordinator, device: HonDevice) -> None:
def __init__(self, hass, entry, coordinator, device: HonAppliance) -> None:
super().__init__(coordinator)
self._hon = hass.data[DOMAIN][entry.unique_id]
@ -36,7 +36,7 @@ class HonEntity(CoordinatorEntity):
class HonCoordinator(DataUpdateCoordinator):
def __init__(self, hass, device: HonDevice):
def __init__(self, hass, device: HonAppliance):
"""Initialize my coordinator."""
super().__init__(hass, _LOGGER, name=device.mac_address, update_interval=timedelta(seconds=30))
self._device = device

View File

@ -6,7 +6,7 @@
"documentation": "https://github.com/Andre0512/hon/",
"iot_class": "cloud_polling",
"issue_tracker": "https://github.com/Andre0512/hon/issues",
"requirements": ["pyhOn==0.4.1"],
"version": "0.4.0"
"requirements": ["pyhOn==0.6.1"],
"version": "0.5.0-beta.2"
}

View File

@ -1,6 +1,6 @@
from __future__ import annotations
from pyhon import HonConnection
from pyhon import Hon
from pyhon.parameter import HonParameterRange
from homeassistant.components.number import (
@ -111,10 +111,10 @@ NUMBERS: dict[str, tuple[NumberEntityDescription, ...]] = {
async def async_setup_entry(hass, entry: ConfigEntry, async_add_entities) -> None:
hon: HonConnection = hass.data[DOMAIN][entry.unique_id]
hon: Hon = hass.data[DOMAIN][entry.unique_id]
coordinators = hass.data[DOMAIN]["coordinators"]
appliances = []
for device in hon.devices:
for device in hon.appliances:
if device.mac_address in coordinators:
coordinator = hass.data[DOMAIN]["coordinators"][device.mac_address]
else:

View File

@ -2,8 +2,8 @@ from __future__ import annotations
import logging
from pyhon import HonConnection
from pyhon.device import HonDevice
from pyhon import Hon
from pyhon.appliance import HonAppliance
from pyhon.parameter import HonParameterFixed
from homeassistant.components.select import SelectEntity, SelectEntityDescription
@ -79,10 +79,10 @@ SELECTS = {
async def async_setup_entry(hass, entry: ConfigEntry, async_add_entities) -> None:
hon: HonConnection = hass.data[DOMAIN][entry.unique_id]
hon: Hon = hass.data[DOMAIN][entry.unique_id]
coordinators = hass.data[DOMAIN]["coordinators"]
appliances = []
for device in hon.devices:
for device in hon.appliances:
if device.mac_address in coordinators:
coordinator = hass.data[DOMAIN]["coordinators"][device.mac_address]
else:
@ -101,7 +101,7 @@ async def async_setup_entry(hass, entry: ConfigEntry, async_add_entities) -> Non
class HonSelectEntity(HonEntity, SelectEntity):
def __init__(self, hass, coordinator, entry, device: HonDevice, description) -> None:
def __init__(self, hass, coordinator, entry, device: HonAppliance, description) -> None:
super().__init__(hass, entry, coordinator, device)
self._coordinator = coordinator

View File

@ -1,6 +1,6 @@
import logging
from pyhon import HonConnection
from pyhon import Hon
from homeassistant.components.sensor import (
SensorEntity,
@ -231,10 +231,10 @@ SENSORS: dict[str, tuple[SensorEntityDescription, ...]] = {
async def async_setup_entry(hass, entry: ConfigEntry, async_add_entities) -> None:
hon: HonConnection = hass.data[DOMAIN][entry.unique_id]
hon: Hon = hass.data[DOMAIN][entry.unique_id]
coordinators = hass.data[DOMAIN]["coordinators"]
appliances = []
for device in hon.devices:
for device in hon.appliances:
if device.mac_address in coordinators:
coordinator = hass.data[DOMAIN]["coordinators"][device.mac_address]
else:

View File

@ -6,8 +6,8 @@ from typing import Any
from homeassistant.components.switch import SwitchEntityDescription, SwitchEntity
from homeassistant.config_entries import ConfigEntry
from homeassistant.const import EntityCategory
from pyhon import HonConnection
from pyhon.device import HonDevice
from pyhon import Hon
from pyhon.appliance import HonAppliance
from .const import DOMAIN
from .hon import HonCoordinator, HonEntity
@ -93,10 +93,10 @@ SWITCHES: dict[str, tuple[HonSwitchEntityDescription, ...]] = {
async def async_setup_entry(hass, entry: ConfigEntry, async_add_entities) -> None:
hon: HonConnection = hass.data[DOMAIN][entry.unique_id]
hon: Hon = hass.data[DOMAIN][entry.unique_id]
coordinators = hass.data[DOMAIN]["coordinators"]
appliances = []
for device in hon.devices:
for device in hon.appliances:
if device.mac_address in coordinators:
coordinator = hass.data[DOMAIN]["coordinators"][device.mac_address]
else:
@ -119,7 +119,7 @@ async def async_setup_entry(hass, entry: ConfigEntry, async_add_entities) -> Non
class HonSwitchEntity(HonEntity, SwitchEntity):
entity_description: HonSwitchEntityDescription
def __init__(self, hass, coordinator, entry, device: HonDevice, description: HonSwitchEntityDescription) -> None:
def __init__(self, hass, coordinator, entry, device: HonAppliance, description: HonSwitchEntityDescription) -> None:
super().__init__(hass, entry, coordinator, device)
self._coordinator = coordinator
self._device = device

View File

@ -1,5 +1,4 @@
{
"name": "Haier hOn",
"render_readme": true,
"homeassistant": "2023.2.0"
}

35
info.md Normal file
View File

@ -0,0 +1,35 @@
# Haier hOn
[![GitHub manifest version (path)](https://img.shields.io/github/manifest-json/v/andre0512/hon?color=g&filename=custom_components%2Fhon%2Fmanifest.json)](https://github.com/Andre0512/hon/releases/latest)
[![Home Assistant installs](https://img.shields.io/badge/dynamic/json?color=41BDF5&label=usage&suffix=%20installs&cacheSeconds=15600&url=https://analytics.home-assistant.io/custom_integrations.json&query=$.hon.total)](https://analytics.home-assistant.io/)
Support for home appliances of Haier's mobile app hOn.
## Supported Appliances
- Tumble Dryer
- Washer Dryer
- Washing Machine
- Oven
## Tested Appliances
- Haier WD90-B14TEAM5
- Haier HD80-A3959
- Haier HWO60SM2F3XH
- Hoover H-WASH 500
## Configuration
**Method 1**: [![Open your Home Assistant instance and start setting up a new integration.](https://my.home-assistant.io/badges/config_flow_start.svg)](https://my.home-assistant.io/redirect/config_flow_start/?domain=hon)
**Method 2**: Settings > Devices & Services > Add Integration > **Haier hOn**
_If the integration is not in the list, you need to clear the browser cache._
## Contribute
Want to help us to support more appliances?
Or add more sensors?
Or help with translating?
Or beautify some icons or captions?
Check out the [project on GitHub](https://github.com/Andre0512/hon), every contribution is welcome!