From 9d8b17b2cfe1fad534048502be3b5c631e48eca7 Mon Sep 17 00:00:00 2001 From: Andre Basche Date: Sun, 5 Mar 2023 21:16:09 +0100 Subject: [PATCH] Add sensors, renamed repo --- .github/workflows/hacs_check.yml | 17 +++++++++++++++++ .github/workflows/validate.yml | 14 ++++++++++++++ README.md | 7 ++++--- custom_components/hOn/manifest.json | 10 ---------- custom_components/{hOn => haier}/__init__.py | 0 .../{hOn => haier}/binary_sensor.py | 2 +- custom_components/{hOn => haier}/button.py | 0 custom_components/{hOn => haier}/config_flow.py | 1 - custom_components/{hOn => haier}/const.py | 2 +- custom_components/{hOn => haier}/hon.py | 0 custom_components/haier/manifest.json | 11 +++++++++++ custom_components/{hOn => haier}/number.py | 0 custom_components/{hOn => haier}/select.py | 4 +--- custom_components/{hOn => haier}/sensor.py | 17 +++++++++++++++-- custom_components/{hOn => haier}/switch.py | 6 ++---- .../{hOn => haier}/translations/en.json | 3 ++- hacs.json | 4 ++-- 17 files changed, 70 insertions(+), 28 deletions(-) create mode 100644 .github/workflows/hacs_check.yml create mode 100644 .github/workflows/validate.yml delete mode 100755 custom_components/hOn/manifest.json rename custom_components/{hOn => haier}/__init__.py (100%) rename custom_components/{hOn => haier}/binary_sensor.py (99%) rename custom_components/{hOn => haier}/button.py (100%) rename custom_components/{hOn => haier}/config_flow.py (99%) mode change 100755 => 100644 rename custom_components/{hOn => haier}/const.py (86%) mode change 100755 => 100644 rename custom_components/{hOn => haier}/hon.py (100%) mode change 100755 => 100644 create mode 100644 custom_components/haier/manifest.json rename custom_components/{hOn => haier}/number.py (100%) rename custom_components/{hOn => haier}/select.py (98%) rename custom_components/{hOn => haier}/sensor.py (88%) rename custom_components/{hOn => haier}/switch.py (98%) rename custom_components/{hOn => haier}/translations/en.json (92%) diff --git a/.github/workflows/hacs_check.yml b/.github/workflows/hacs_check.yml new file mode 100644 index 0000000..8369e39 --- /dev/null +++ b/.github/workflows/hacs_check.yml @@ -0,0 +1,17 @@ +name: HACS Action + +on: + push: + pull_request: + schedule: + - cron: "0 0 * * *" + +jobs: + hacs: + name: HACS Action + runs-on: "ubuntu-latest" + steps: + - name: HACS Action + uses: "hacs/action@main" + with: + category: "integration" \ No newline at end of file diff --git a/.github/workflows/validate.yml b/.github/workflows/validate.yml new file mode 100644 index 0000000..afbde1a --- /dev/null +++ b/.github/workflows/validate.yml @@ -0,0 +1,14 @@ +name: Validate with hassfest + +on: + push: + pull_request: + schedule: + - cron: '0 0 * * *' + +jobs: + validate: + runs-on: "ubuntu-latest" + steps: + - uses: "actions/checkout@v3" + - uses: "home-assistant/actions/hassfest@master" \ No newline at end of file diff --git a/README.md b/README.md index d5c9b80..3d24922 100644 --- a/README.md +++ b/README.md @@ -1,10 +1,11 @@ -# hOn +# Haier hOn Home Assistant component supporting hOn cloud. ## Installation -1. Installing via HACS +#### Installing via HACS +1. You need to have installed [HACS](https://hacs.xyz/) 2. Go to HACS->Integrations -3. Add this repo into your HACS custom repositories +3. Add this repo (`https://github.com/Andre0512/haier.git`) into your HACS custom repositories 4. Search for Haier hOn and Download it 5. Restart your HomeAssistant 6. Go to Settings->Devices & Services diff --git a/custom_components/hOn/manifest.json b/custom_components/hOn/manifest.json deleted file mode 100755 index 8701ffa..0000000 --- a/custom_components/hOn/manifest.json +++ /dev/null @@ -1,10 +0,0 @@ -{ - "domain": "hon", - "name": "hOn", - "config_flow": true, - "version": "0.1.0", - "codeowners": ["@Andre0512"], - "iot_class": "cloud_polling", - "requirements": ["pyhOn==0.2.4"], - "documentation": "https://github.com/Andre0512/hOn/" -} diff --git a/custom_components/hOn/__init__.py b/custom_components/haier/__init__.py similarity index 100% rename from custom_components/hOn/__init__.py rename to custom_components/haier/__init__.py diff --git a/custom_components/hOn/binary_sensor.py b/custom_components/haier/binary_sensor.py similarity index 99% rename from custom_components/hOn/binary_sensor.py rename to custom_components/haier/binary_sensor.py index 55f907c..fad7a8e 100644 --- a/custom_components/hOn/binary_sensor.py +++ b/custom_components/haier/binary_sensor.py @@ -35,7 +35,7 @@ BINARY_SENSORS: dict[str, tuple[HonBinarySensorEntityDescription, ...]] = { key="doorLockStatus", name="Door Locked", device_class=BinarySensorDeviceClass.DOOR, - on_value="1", + on_value="0", ), ) } diff --git a/custom_components/hOn/button.py b/custom_components/haier/button.py similarity index 100% rename from custom_components/hOn/button.py rename to custom_components/haier/button.py diff --git a/custom_components/hOn/config_flow.py b/custom_components/haier/config_flow.py old mode 100755 new mode 100644 similarity index 99% rename from custom_components/hOn/config_flow.py rename to custom_components/haier/config_flow.py index ea30fbc..e4ec404 --- a/custom_components/hOn/config_flow.py +++ b/custom_components/haier/config_flow.py @@ -11,7 +11,6 @@ _LOGGER = logging.getLogger(__name__) class HonFlowHandler(config_entries.ConfigFlow, domain=DOMAIN): - VERSION = 1 CONNECTION_CLASS = config_entries.CONN_CLASS_LOCAL_POLL diff --git a/custom_components/hOn/const.py b/custom_components/haier/const.py old mode 100755 new mode 100644 similarity index 86% rename from custom_components/hOn/const.py rename to custom_components/haier/const.py index 5dae56e..6e99520 --- a/custom_components/hOn/const.py +++ b/custom_components/haier/const.py @@ -1,4 +1,4 @@ -DOMAIN = "hon" +DOMAIN = "haier" PLATFORMS = [ "sensor", diff --git a/custom_components/hOn/hon.py b/custom_components/haier/hon.py old mode 100755 new mode 100644 similarity index 100% rename from custom_components/hOn/hon.py rename to custom_components/haier/hon.py diff --git a/custom_components/haier/manifest.json b/custom_components/haier/manifest.json new file mode 100644 index 0000000..a0d3bd8 --- /dev/null +++ b/custom_components/haier/manifest.json @@ -0,0 +1,11 @@ +{ + "domain": "haier", + "name": "Haier hOn", + "codeowners": ["@Andre0512"], + "config_flow": true, + "documentation": "https://github.com/Andre0512/haier/", + "iot_class": "cloud_polling", + "issue_tracker": "https://github.com/Andre0512/haier/issues", + "requirements": ["pyhOn==0.2.4"], + "version": "0.1.1" +} diff --git a/custom_components/hOn/number.py b/custom_components/haier/number.py similarity index 100% rename from custom_components/hOn/number.py rename to custom_components/haier/number.py diff --git a/custom_components/hOn/select.py b/custom_components/haier/select.py similarity index 98% rename from custom_components/hOn/select.py rename to custom_components/haier/select.py index 7c0406a..acd4162 100644 --- a/custom_components/hOn/select.py +++ b/custom_components/haier/select.py @@ -1,4 +1,3 @@ -"""Support for Tuya select.""" from __future__ import annotations from pyhon import HonConnection @@ -11,10 +10,9 @@ from homeassistant.const import UnitOfTemperature, REVOLUTIONS_PER_MINUTE from homeassistant.core import callback from homeassistant.helpers.entity import EntityCategory +from .const import DOMAIN from .hon import HonEntity, HonCoordinator -DOMAIN = "hon" - SELECTS = { "WM": ( SelectEntityDescription( diff --git a/custom_components/hOn/sensor.py b/custom_components/haier/sensor.py similarity index 88% rename from custom_components/hOn/sensor.py rename to custom_components/haier/sensor.py index 2dbd0c4..d957283 100644 --- a/custom_components/hOn/sensor.py +++ b/custom_components/haier/sensor.py @@ -9,7 +9,7 @@ from homeassistant.components.sensor import ( SensorEntityDescription, ) from homeassistant.config_entries import ConfigEntry -from homeassistant.const import UnitOfEnergy, UnitOfVolume, UnitOfMass, UnitOfPower +from homeassistant.const import UnitOfEnergy, UnitOfVolume, UnitOfMass, UnitOfPower, UnitOfTime from homeassistant.core import callback from homeassistant.helpers.entity import EntityCategory from homeassistant.helpers.typing import StateType @@ -75,7 +75,20 @@ SENSORS: dict[str, tuple[SensorEntityDescription, ...]] = { 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, + ), + SensorEntityDescription( + key="spinSpeed", + name="Spin Speed", + icon="mdi:timer", + state_class=SensorStateClass.MEASUREMENT, + native_unit_of_measurement=UnitOfTime.MINUTES, + ), ) } diff --git a/custom_components/hOn/switch.py b/custom_components/haier/switch.py similarity index 98% rename from custom_components/hOn/switch.py rename to custom_components/haier/switch.py index 28e7887..00f4cb0 100644 --- a/custom_components/hOn/switch.py +++ b/custom_components/haier/switch.py @@ -1,13 +1,11 @@ -from collections.abc import Callable, Coroutine from dataclasses import dataclass from typing import Any -from pyhon import HonConnection -from pyhon.device import HonDevice - 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 .const import DOMAIN from .hon import HonCoordinator, HonEntity diff --git a/custom_components/hOn/translations/en.json b/custom_components/haier/translations/en.json similarity index 92% rename from custom_components/hOn/translations/en.json rename to custom_components/haier/translations/en.json index c4d9edd..e8e66b3 100644 --- a/custom_components/hOn/translations/en.json +++ b/custom_components/haier/translations/en.json @@ -2,7 +2,6 @@ "config": { "step": { "user": { - "title": "hOn", "description": "Please enters your hOn credentials", "data": { "email": "Email Address", @@ -15,8 +14,10 @@ "sensor": { "mode": { "state": { + "0": "Disconnected", "1": "Ready", "2": "Running", + "3": "Paused", "5": "Scheduled", "6": "Error", "7": "Finished" diff --git a/hacs.json b/hacs.json index a24c0d4..02a4917 100644 --- a/hacs.json +++ b/hacs.json @@ -1,5 +1,5 @@ { - "name": "hOn", - "render_readme": false, + "name": "Haier hOn", + "render_readme": true, "homeassistant": "2023.2.0" } \ No newline at end of file