Skip to content

Commit

Permalink
Merge pull request #13 from alexandre-leites/main
Browse files Browse the repository at this point in the history
Added WD device type sensors.
  • Loading branch information
Andre0512 authored Apr 7, 2023
2 parents 135d6ca + 05e9d83 commit d3dc1b9
Show file tree
Hide file tree
Showing 7 changed files with 157 additions and 5 deletions.
41 changes: 39 additions & 2 deletions custom_components/hon/binary_sensor.py
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,44 @@ class HonBinarySensorEntityDescription(HonBinarySensorEntityDescriptionMixin, Bi
device_class=BinarySensorDeviceClass.DOOR,
on_value="1",
),
)
),
"WD": (
HonBinarySensorEntityDescription(
key="attributes.lastConnEvent.category",
name="Remote Control",
device_class=BinarySensorDeviceClass.CONNECTIVITY,
on_value="CONNECTED",
icon="mdi:remote"
),
HonBinarySensorEntityDescription(
key="startProgram.prewash",
name="Pre Wash",
),
HonBinarySensorEntityDescription(
key="extraRinse1",
name="Extra Rinse 1",
),
HonBinarySensorEntityDescription(
key="extraRinse2",
name="Extra Rinse 2",
),
HonBinarySensorEntityDescription(
key="extraRinse3",
name="Extra Rinse 3",
),
HonBinarySensorEntityDescription(
key="goodNight",
name="Good Night Mode",
),
HonBinarySensorEntityDescription(
key="acquaplus",
name="Acqua Plus",
),
HonBinarySensorEntityDescription(
key="anticrease",
name="Anti-Crease",
),
),
}


Expand All @@ -77,7 +114,7 @@ async def async_setup_entry(hass, entry: ConfigEntry, async_add_entities) -> Non
if descriptions := BINARY_SENSORS.get(device.appliance_type):
for description in descriptions:
if not device.get(description.key):
_LOGGER.info("Can't setup %s", description.key)
_LOGGER.warning("[%s] Can't setup %s", device.appliance_type, description.key)
continue
appliances.extend([
HonBinarySensorEntity(hass, coordinator, entry, device, description)]
Expand Down
9 changes: 9 additions & 0 deletions custom_components/hon/number.py
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,15 @@
entity_category=EntityCategory.CONFIG
),
),
"WD": (
NumberEntityDescription(
key="startProgram.delayTime",
name="Delay Time",
icon="mdi:timer-plus",
entity_category=EntityCategory.CONFIG,
native_unit_of_measurement=UnitOfTime.MINUTES
),
),
}


Expand Down
15 changes: 14 additions & 1 deletion custom_components/hon/select.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
from __future__ import annotations

import logging

from pyhon import HonConnection
from pyhon.device import HonDevice
from pyhon.parameter import HonParameterFixed
Expand All @@ -13,6 +15,8 @@
from .const import DOMAIN
from .hon import HonEntity, HonCoordinator

_LOGGER = logging.getLogger(__name__)

SELECTS = {
"WM": (
SelectEntityDescription(
Expand Down Expand Up @@ -50,7 +54,15 @@
icon="mdi:timer",
unit_of_measurement=UnitOfTime.MINUTES
),
)
),
"WD": (
SelectEntityDescription(
key="startProgram.program",
name="Program",
entity_category=EntityCategory.CONFIG,
translation_key="programs"
),
),
}


Expand All @@ -69,6 +81,7 @@ async def async_setup_entry(hass, entry: ConfigEntry, async_add_entities) -> Non
if descriptions := SELECTS.get(device.appliance_type):
for description in descriptions:
if not device.get(description.key):
_LOGGER.warning("[%s] Can't setup %s", device.appliance_type, description.key)
continue
appliances.extend([
HonSelectEntity(hass, coordinator, entry, device, description)]
Expand Down
74 changes: 72 additions & 2 deletions custom_components/hon/sensor.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,15 @@
SensorEntityDescription,
)
from homeassistant.config_entries import ConfigEntry
from homeassistant.const import UnitOfEnergy, UnitOfVolume, UnitOfMass, UnitOfPower, UnitOfTime
from homeassistant.const import (
REVOLUTIONS_PER_MINUTE,
UnitOfEnergy,
UnitOfVolume,
UnitOfMass,
UnitOfPower,
UnitOfTime,
UnitOfTemperature
)
from homeassistant.core import callback
from homeassistant.helpers.entity import EntityCategory
from homeassistant.helpers.typing import StateType
Expand Down Expand Up @@ -141,7 +149,68 @@
icon="mdi:thermometer",
translation_key="tumbledryertemplevel"
),
)
),
"WD": (
SensorEntityDescription(
key="machMode",
name="Machine Status",
icon="mdi:information",
translation_key="mode"
),
SensorEntityDescription(
key="spinSpeed",
name="Spin Speed",
icon="mdi:fast-forward-outline",
state_class=SensorStateClass.MEASUREMENT,
native_unit_of_measurement=REVOLUTIONS_PER_MINUTE,
),
SensorEntityDescription(
key="remainingTimeMM",
name="Remaining Time",
icon="mdi:timer",
state_class=SensorStateClass.MEASUREMENT,
native_unit_of_measurement=UnitOfTime.MINUTES,
),
SensorEntityDescription(
key="delayTime",
name="Start Time",
icon="mdi:clock-start",
state_class=SensorStateClass.MEASUREMENT,
native_unit_of_measurement=UnitOfTime.MINUTES,
),
SensorEntityDescription(
key="prCode",
name="Current Program",
icon="mdi:tumble-dryer",
),
SensorEntityDescription(
key="prPhase",
name="Program Phase",
icon="mdi:tumble-dryer",
),
SensorEntityDescription(
key="dryLevel",
name="Dry level",
icon="mdi:hair-dryer",
),
SensorEntityDescription(
key="dirtyLevel",
name="Dirt level",
icon="mdi:liquid-spot",
),
SensorEntityDescription(
key="steamLevel",
name="Steam level",
icon="mdi:smoke",
),
SensorEntityDescription(
key="temp",
name="Current Temperature",
icon="mdi:thermometer",
state_class=SensorStateClass.MEASUREMENT,
native_unit_of_measurement=UnitOfTemperature.CELSIUS,
),
),
}


Expand All @@ -160,6 +229,7 @@ async def async_setup_entry(hass, entry: ConfigEntry, async_add_entities) -> Non
if descriptions := SENSORS.get(device.appliance_type):
for description in descriptions:
if not device.get(description.key):
_LOGGER.warning("[%s] Can't setup %s", device.appliance_type, description.key)
continue
appliances.extend([
HonSensorEntity(hass, coordinator, entry, device, description)]
Expand Down
21 changes: 21 additions & 0 deletions custom_components/hon/switch.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
import logging

from dataclasses import dataclass
from typing import Any

Expand All @@ -10,6 +12,7 @@
from .const import DOMAIN
from .hon import HonCoordinator, HonEntity

_LOGGER = logging.getLogger(__name__)

@dataclass
class HonSwitchEntityDescriptionMixin:
Expand Down Expand Up @@ -69,6 +72,22 @@ class HonSwitchEntityDescription(HonSwitchEntityDescriptionMixin,
turn_off_key="resumeProgram",
),
),
"WD": (
HonSwitchEntityDescription(
key="active",
name="Washing Machine",
icon="mdi:washing-machine",
turn_on_key="startProgram",
turn_off_key="stopProgram",
),
HonSwitchEntityDescription(
key="pause",
name="Pause Washing Machine",
icon="mdi:pause",
turn_on_key="pauseProgram",
turn_off_key="resumeProgram",
),
),
}


Expand All @@ -90,6 +109,8 @@ async def async_setup_entry(hass, entry: ConfigEntry, async_add_entities) -> Non
appliances.extend([
HonSwitchEntity(hass, coordinator, entry, device, description)]
)
else:
_LOGGER.warning("[%s] Can't setup %s", device.appliance_type, description.key)

async_add_entities(appliances)

Expand Down
1 change: 1 addition & 0 deletions custom_components/hon/translations/bg.json
Original file line number Diff line number Diff line change
Expand Up @@ -377,6 +377,7 @@
"single_item_steam": "Single Item + Steam",
"smart_wash": "Smart Wash",
"soft_care": "Soft Care",
"soft_care_steam": "Soft Care + Steam",
"soft_care_steam_title": "Soft Care + Steam",
"special_39": "Special 39'",
"special_39_full_load": "Special 39'",
Expand Down
1 change: 1 addition & 0 deletions custom_components/hon/translations/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -377,6 +377,7 @@
"single_item_steam": "Single Item + Steam",
"smart_wash": "Smart Wash",
"soft_care": "Soft Care",
"soft_care_steam": "Soft Care + Steam",
"soft_care_steam_title": "Soft Care + Steam",
"special_39": "Special 39'",
"special_39_full_load": "Special 39'",
Expand Down

0 comments on commit d3dc1b9

Please sign in to comment.