Compare commits

...

4 Commits

Author SHA1 Message Date
4901be4050 Update badges, bump version 2023-04-10 18:50:51 +02:00
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 75 additions and 37 deletions

View File

@ -1,7 +1,8 @@
# Haier hOn # Haier hOn
[![hacs_badge](https://img.shields.io/badge/HACS-Default-41BDF5.svg)](https://github.com/hacs/integration) [![hacs_badge](https://img.shields.io/badge/HACS-Default-41BDF5.svg)](https://hacs.xyz)
[![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) [![GitHub release (latest by date)](https://img.shields.io/github/v/release/Andre0512/hon?color=green)](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/) ![GitHub](https://img.shields.io/github/license/Andre0512/hon?color=red)
[![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. Home Assistant integration for Haier hOn: support for Haier/Candy/Hoover home appliances like washing machines.
## Supported Appliances ## Supported Appliances
- Tumble Dryer - Tumble Dryer
@ -16,6 +17,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. **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 ## 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 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 +68,9 @@ Any kind of contribution is welcome!
5. Create a [pull request](https://github.com/Andre0512/hon/pulls) 5. Create a [pull request](https://github.com/Andre0512/hon/pulls)
#### Tips and Tricks #### 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. - 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 ## Tested Devices
- Haier WD90-B14TEAM5 - Haier WD90-B14TEAM5

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@ -1,6 +1,6 @@
from __future__ import annotations from __future__ import annotations
from pyhon import HonConnection from pyhon import Hon
from pyhon.parameter import HonParameterRange from pyhon.parameter import HonParameterRange
from homeassistant.components.number import ( 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: 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"] coordinators = hass.data[DOMAIN]["coordinators"]
appliances = [] appliances = []
for device in hon.devices: for device in hon.appliances:
if device.mac_address in coordinators: if device.mac_address in coordinators:
coordinator = hass.data[DOMAIN]["coordinators"][device.mac_address] coordinator = hass.data[DOMAIN]["coordinators"][device.mac_address]
else: else:

View File

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

View File

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

View File

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

View File

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

36
info.md Normal file
View File

@ -0,0 +1,36 @@
# Haier hOn
[![GitHub release (latest by date)](https://img.shields.io/github/v/release/Andre0512/hon?color=green)](https://github.com/Andre0512/hon/releases/latest)
![GitHub](https://img.shields.io/github/license/Andre0512/hon?color=red)
[![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/)
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!