mirror of
https://github.com/Andre0512/hon.git
synced 2026-04-30 14:53:18 +00:00
Compare commits
12 commits
v0.14.0-be
...
main
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
70eb6c0111 | ||
|
|
9bab35f8c4 | ||
|
|
39fc30c95e | ||
|
|
6906e751b1 | ||
|
|
6d2a6ce2e9 | ||
|
|
0e166f3c66 | ||
|
|
54dd406ec2 | ||
|
|
a746584833 | ||
|
|
36aed2e6ea | ||
|
|
510c10bd9f | ||
|
|
09189ff0f8 | ||
|
|
0e26b4a0f7 |
|
|
@ -36,7 +36,7 @@ async def async_setup_entry(hass: HomeAssistantType, entry: ConfigEntry) -> bool
|
||||||
password=entry.data[CONF_PASSWORD],
|
password=entry.data[CONF_PASSWORD],
|
||||||
mobile_id=MOBILE_ID,
|
mobile_id=MOBILE_ID,
|
||||||
session=session,
|
session=session,
|
||||||
# test_data_path=Path(config_dir),
|
test_data_path=Path(config_dir),
|
||||||
refresh_token=entry.data.get(CONF_REFRESH_TOKEN, ""),
|
refresh_token=entry.data.get(CONF_REFRESH_TOKEN, ""),
|
||||||
).create()
|
).create()
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -82,7 +82,7 @@ class HonButtonEntity(HonEntity, ButtonEntity):
|
||||||
return (
|
return (
|
||||||
super().available
|
super().available
|
||||||
and int(self._device.get("remoteCtrValid", "1")) == 1
|
and int(self._device.get("remoteCtrValid", "1")) == 1
|
||||||
and self._device.get("attributes.lastConnEvent.category") != "DISCONNECTED"
|
and self._device.connection
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -126,6 +126,7 @@ async def async_setup_entry(
|
||||||
|
|
||||||
class HonACClimateEntity(HonEntity, ClimateEntity):
|
class HonACClimateEntity(HonEntity, ClimateEntity):
|
||||||
entity_description: HonACClimateEntityDescription
|
entity_description: HonACClimateEntityDescription
|
||||||
|
_enable_turn_on_off_backwards_compatibility = False
|
||||||
|
|
||||||
def __init__(
|
def __init__(
|
||||||
self,
|
self,
|
||||||
|
|
@ -211,6 +212,14 @@ class HonACClimateEntity(HonEntity, ClimateEntity):
|
||||||
await self._device.commands["settings"].send()
|
await self._device.commands["settings"].send()
|
||||||
self.async_write_ha_state()
|
self.async_write_ha_state()
|
||||||
|
|
||||||
|
async def async_turn_on(self, **kwargs: Any) -> None:
|
||||||
|
await self._device.commands["startProgram"].send()
|
||||||
|
self._device.sync_command("startProgram", "settings")
|
||||||
|
|
||||||
|
async def async_turn_off(self, **kwargs: Any) -> None:
|
||||||
|
await self._device.commands["stopProgram"].send()
|
||||||
|
self._device.sync_command("stopProgram", "settings")
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def preset_mode(self) -> str | None:
|
def preset_mode(self) -> str | None:
|
||||||
"""Return the current Preset for this channel."""
|
"""Return the current Preset for this channel."""
|
||||||
|
|
@ -223,7 +232,7 @@ class HonACClimateEntity(HonEntity, ClimateEntity):
|
||||||
self._device.sync_command("startProgram", "settings")
|
self._device.sync_command("startProgram", "settings")
|
||||||
self._set_temperature_bound()
|
self._set_temperature_bound()
|
||||||
self._handle_coordinator_update(update=False)
|
self._handle_coordinator_update(update=False)
|
||||||
self.async_write_ha_state()
|
self.coordinator.async_set_updated_data({})
|
||||||
self._attr_preset_mode = preset_mode
|
self._attr_preset_mode = preset_mode
|
||||||
await self._device.commands["startProgram"].send()
|
await self._device.commands["startProgram"].send()
|
||||||
self.async_write_ha_state()
|
self.async_write_ha_state()
|
||||||
|
|
@ -286,6 +295,7 @@ class HonACClimateEntity(HonEntity, ClimateEntity):
|
||||||
|
|
||||||
class HonClimateEntity(HonEntity, ClimateEntity):
|
class HonClimateEntity(HonEntity, ClimateEntity):
|
||||||
entity_description: HonClimateEntityDescription
|
entity_description: HonClimateEntityDescription
|
||||||
|
_enable_turn_on_off_backwards_compatibility = False
|
||||||
|
|
||||||
def __init__(
|
def __init__(
|
||||||
self,
|
self,
|
||||||
|
|
@ -363,6 +373,14 @@ class HonClimateEntity(HonEntity, ClimateEntity):
|
||||||
self._attr_hvac_mode = hvac_mode
|
self._attr_hvac_mode = hvac_mode
|
||||||
self.async_write_ha_state()
|
self.async_write_ha_state()
|
||||||
|
|
||||||
|
async def async_turn_on(self) -> None:
|
||||||
|
"""Set the HVAC State to on."""
|
||||||
|
await self._device.commands["startProgram"].send()
|
||||||
|
|
||||||
|
async def async_turn_off(self) -> None:
|
||||||
|
"""Set the HVAC State to off."""
|
||||||
|
await self._device.commands["stopProgram"].send()
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def preset_mode(self) -> str | None:
|
def preset_mode(self) -> str | None:
|
||||||
"""Return the current Preset for this channel."""
|
"""Return the current Preset for this channel."""
|
||||||
|
|
@ -390,7 +408,7 @@ class HonClimateEntity(HonEntity, ClimateEntity):
|
||||||
self._device.sync_command(command, "settings")
|
self._device.sync_command(command, "settings")
|
||||||
self._set_temperature_bound()
|
self._set_temperature_bound()
|
||||||
self._attr_preset_mode = preset_mode
|
self._attr_preset_mode = preset_mode
|
||||||
self.async_write_ha_state()
|
self.coordinator.async_set_updated_data({})
|
||||||
await self._device.commands[command].send()
|
await self._device.commands[command].send()
|
||||||
self.async_write_ha_state()
|
self.async_write_ha_state()
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -42,10 +42,12 @@ class HonEntity(CoordinatorEntity[DataUpdateCoordinator[dict[str, Any]]]):
|
||||||
def device_info(self) -> DeviceInfo:
|
def device_info(self) -> DeviceInfo:
|
||||||
return DeviceInfo(
|
return DeviceInfo(
|
||||||
identifiers={(DOMAIN, self._device.unique_id)},
|
identifiers={(DOMAIN, self._device.unique_id)},
|
||||||
manufacturer=self._device.get("brand", ""),
|
manufacturer=self._device.get("brand", "").capitalize(),
|
||||||
name=self._device.nick_name,
|
name=self._device.nick_name,
|
||||||
model=self._device.model_name,
|
model=self._device.model_name,
|
||||||
sw_version=self._device.get("fwVersion", ""),
|
sw_version=self._device.get("fwVersion", ""),
|
||||||
|
hw_version=f"{self._device.appliance_type}{self._device.model_id}",
|
||||||
|
serial_number=self._device.get("serialNumber", ""),
|
||||||
)
|
)
|
||||||
|
|
||||||
@callback
|
@callback
|
||||||
|
|
|
||||||
|
|
@ -58,7 +58,7 @@ class HonLockEntity(HonEntity, LockEntity):
|
||||||
setting.value = setting.max if isinstance(setting, HonParameterRange) else 1
|
setting.value = setting.max if isinstance(setting, HonParameterRange) else 1
|
||||||
self.async_write_ha_state()
|
self.async_write_ha_state()
|
||||||
await self._device.commands["settings"].send()
|
await self._device.commands["settings"].send()
|
||||||
self.async_write_ha_state()
|
self.coordinator.async_set_updated_data({})
|
||||||
|
|
||||||
async def async_unlock(self, **kwargs: Any) -> None:
|
async def async_unlock(self, **kwargs: Any) -> None:
|
||||||
"""Unlock method."""
|
"""Unlock method."""
|
||||||
|
|
@ -68,7 +68,7 @@ class HonLockEntity(HonEntity, LockEntity):
|
||||||
setting.value = setting.min if isinstance(setting, HonParameterRange) else 0
|
setting.value = setting.min if isinstance(setting, HonParameterRange) else 0
|
||||||
self.async_write_ha_state()
|
self.async_write_ha_state()
|
||||||
await self._device.commands["settings"].send()
|
await self._device.commands["settings"].send()
|
||||||
self.async_write_ha_state()
|
self.coordinator.async_set_updated_data({})
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def available(self) -> bool:
|
def available(self) -> bool:
|
||||||
|
|
@ -76,7 +76,7 @@ class HonLockEntity(HonEntity, LockEntity):
|
||||||
return (
|
return (
|
||||||
super().available
|
super().available
|
||||||
and int(self._device.get("remoteCtrValid", 1)) == 1
|
and int(self._device.get("remoteCtrValid", 1)) == 1
|
||||||
and self._device.get("attributes.lastConnEvent.category") != "DISCONNECTED"
|
and self._device.connection
|
||||||
)
|
)
|
||||||
|
|
||||||
@callback
|
@callback
|
||||||
|
|
|
||||||
|
|
@ -9,7 +9,7 @@
|
||||||
"iot_class": "cloud_push",
|
"iot_class": "cloud_push",
|
||||||
"issue_tracker": "https://github.com/Andre0512/hon/issues",
|
"issue_tracker": "https://github.com/Andre0512/hon/issues",
|
||||||
"requirements": [
|
"requirements": [
|
||||||
"pyhOn==0.17.2"
|
"pyhOn==0.17.5"
|
||||||
],
|
],
|
||||||
"version": "0.14.0-beta.4"
|
"version": "0.14.0"
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -257,7 +257,7 @@ class HonNumberEntity(HonEntity, NumberEntity):
|
||||||
await self._device.commands[command].send()
|
await self._device.commands[command].send()
|
||||||
if command != "settings":
|
if command != "settings":
|
||||||
self._device.sync_command(command, "settings")
|
self._device.sync_command(command, "settings")
|
||||||
self.async_write_ha_state()
|
self.coordinator.async_set_updated_data({})
|
||||||
|
|
||||||
@callback
|
@callback
|
||||||
def _handle_coordinator_update(self, update: bool = True) -> None:
|
def _handle_coordinator_update(self, update: bool = True) -> None:
|
||||||
|
|
@ -276,7 +276,7 @@ class HonNumberEntity(HonEntity, NumberEntity):
|
||||||
return (
|
return (
|
||||||
super().available
|
super().available
|
||||||
and int(self._device.get("remoteCtrValid", 1)) == 1
|
and int(self._device.get("remoteCtrValid", 1)) == 1
|
||||||
and self._device.get("attributes.lastConnEvent.category") != "DISCONNECTED"
|
and self._device.connection
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
|
|
@ -300,7 +300,7 @@ class HonConfigNumberEntity(HonEntity, NumberEntity):
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def native_value(self) -> float | None:
|
def native_value(self) -> float | None:
|
||||||
if value := self._device.settings[self.entity_description.key].value:
|
if (value := self._device.settings[self.entity_description.key].value) != "":
|
||||||
return float(value)
|
return float(value)
|
||||||
return None
|
return None
|
||||||
|
|
||||||
|
|
@ -308,7 +308,7 @@ class HonConfigNumberEntity(HonEntity, NumberEntity):
|
||||||
setting = self._device.settings[self.entity_description.key]
|
setting = self._device.settings[self.entity_description.key]
|
||||||
if isinstance(setting, HonParameterRange):
|
if isinstance(setting, HonParameterRange):
|
||||||
setting.value = value
|
setting.value = value
|
||||||
self.async_write_ha_state()
|
self.coordinator.async_set_updated_data({})
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def available(self) -> bool:
|
def available(self) -> bool:
|
||||||
|
|
|
||||||
|
|
@ -263,7 +263,7 @@ class HonConfigSelectEntity(HonEntity, SelectEntity):
|
||||||
async def async_select_option(self, option: str) -> None:
|
async def async_select_option(self, option: str) -> None:
|
||||||
setting = self._device.settings[self.entity_description.key]
|
setting = self._device.settings[self.entity_description.key]
|
||||||
setting.value = self._option_to_number(option, setting.values)
|
setting.value = self._option_to_number(option, setting.values)
|
||||||
self.async_write_ha_state()
|
self.coordinator.async_set_updated_data({})
|
||||||
|
|
||||||
@callback
|
@callback
|
||||||
def _handle_coordinator_update(self, update: bool = True) -> None:
|
def _handle_coordinator_update(self, update: bool = True) -> None:
|
||||||
|
|
@ -317,7 +317,7 @@ class HonSelectEntity(HonEntity, SelectEntity):
|
||||||
await self._device.commands[command].send()
|
await self._device.commands[command].send()
|
||||||
if command != "settings":
|
if command != "settings":
|
||||||
self._device.sync_command(command, "settings")
|
self._device.sync_command(command, "settings")
|
||||||
self.async_write_ha_state()
|
self.coordinator.async_set_updated_data({})
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def available(self) -> bool:
|
def available(self) -> bool:
|
||||||
|
|
@ -325,7 +325,7 @@ class HonSelectEntity(HonEntity, SelectEntity):
|
||||||
return (
|
return (
|
||||||
super().available
|
super().available
|
||||||
and int(self._device.get("remoteCtrValid", 1)) == 1
|
and int(self._device.get("remoteCtrValid", 1)) == 1
|
||||||
and self._device.get("attributes.lastConnEvent.category") != "DISCONNECTED"
|
and self._device.connection
|
||||||
)
|
)
|
||||||
|
|
||||||
@callback
|
@callback
|
||||||
|
|
|
||||||
|
|
@ -18,7 +18,6 @@ from homeassistant.const import (
|
||||||
UnitOfEnergy,
|
UnitOfEnergy,
|
||||||
UnitOfVolume,
|
UnitOfVolume,
|
||||||
UnitOfMass,
|
UnitOfMass,
|
||||||
UnitOfPower,
|
|
||||||
UnitOfTime,
|
UnitOfTime,
|
||||||
UnitOfTemperature,
|
UnitOfTemperature,
|
||||||
)
|
)
|
||||||
|
|
@ -84,7 +83,7 @@ SENSORS: dict[str, tuple[SensorEntityDescription, ...]] = {
|
||||||
name="Current Electricity Used",
|
name="Current Electricity Used",
|
||||||
state_class=SensorStateClass.MEASUREMENT,
|
state_class=SensorStateClass.MEASUREMENT,
|
||||||
device_class=SensorDeviceClass.POWER,
|
device_class=SensorDeviceClass.POWER,
|
||||||
native_unit_of_measurement=UnitOfPower.KILO_WATT,
|
native_unit_of_measurement=UnitOfEnergy.KILO_WATT_HOUR,
|
||||||
icon="mdi:lightning-bolt",
|
icon="mdi:lightning-bolt",
|
||||||
translation_key="energy_current",
|
translation_key="energy_current",
|
||||||
),
|
),
|
||||||
|
|
|
||||||
|
|
@ -447,7 +447,7 @@ class HonSwitchEntity(HonEntity, SwitchEntity):
|
||||||
setting.value = setting.max if isinstance(setting, HonParameterRange) else 1
|
setting.value = setting.max if isinstance(setting, HonParameterRange) else 1
|
||||||
self.async_write_ha_state()
|
self.async_write_ha_state()
|
||||||
await self._device.commands["settings"].send()
|
await self._device.commands["settings"].send()
|
||||||
self.async_write_ha_state()
|
self.coordinator.async_set_updated_data({})
|
||||||
|
|
||||||
async def async_turn_off(self, **kwargs: Any) -> None:
|
async def async_turn_off(self, **kwargs: Any) -> None:
|
||||||
setting = self._device.settings[f"settings.{self.entity_description.key}"]
|
setting = self._device.settings[f"settings.{self.entity_description.key}"]
|
||||||
|
|
@ -456,7 +456,7 @@ class HonSwitchEntity(HonEntity, SwitchEntity):
|
||||||
setting.value = setting.min if isinstance(setting, HonParameterRange) else 0
|
setting.value = setting.min if isinstance(setting, HonParameterRange) else 0
|
||||||
self.async_write_ha_state()
|
self.async_write_ha_state()
|
||||||
await self._device.commands["settings"].send()
|
await self._device.commands["settings"].send()
|
||||||
self.async_write_ha_state()
|
self.coordinator.async_set_updated_data({})
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def available(self) -> bool:
|
def available(self) -> bool:
|
||||||
|
|
@ -489,14 +489,14 @@ class HonControlSwitchEntity(HonEntity, SwitchEntity):
|
||||||
|
|
||||||
async def async_turn_on(self, **kwargs: Any) -> None:
|
async def async_turn_on(self, **kwargs: Any) -> None:
|
||||||
self._device.sync_command(self.entity_description.turn_on_key, "settings")
|
self._device.sync_command(self.entity_description.turn_on_key, "settings")
|
||||||
self.async_write_ha_state()
|
self.coordinator.async_set_updated_data({})
|
||||||
await self._device.commands[self.entity_description.turn_on_key].send()
|
await self._device.commands[self.entity_description.turn_on_key].send()
|
||||||
self._device.attributes[self.entity_description.key] = True
|
self._device.attributes[self.entity_description.key] = True
|
||||||
self.async_write_ha_state()
|
self.async_write_ha_state()
|
||||||
|
|
||||||
async def async_turn_off(self, **kwargs: Any) -> None:
|
async def async_turn_off(self, **kwargs: Any) -> None:
|
||||||
self._device.sync_command(self.entity_description.turn_off_key, "settings")
|
self._device.sync_command(self.entity_description.turn_off_key, "settings")
|
||||||
self.async_write_ha_state()
|
self.coordinator.async_set_updated_data({})
|
||||||
await self._device.commands[self.entity_description.turn_off_key].send()
|
await self._device.commands[self.entity_description.turn_off_key].send()
|
||||||
self._device.attributes[self.entity_description.key] = False
|
self._device.attributes[self.entity_description.key] = False
|
||||||
self.async_write_ha_state()
|
self.async_write_ha_state()
|
||||||
|
|
@ -507,7 +507,7 @@ class HonControlSwitchEntity(HonEntity, SwitchEntity):
|
||||||
return (
|
return (
|
||||||
super().available
|
super().available
|
||||||
and int(self._device.get("remoteCtrValid", 1)) == 1
|
and int(self._device.get("remoteCtrValid", 1)) == 1
|
||||||
and self._device.get("attributes.lastConnEvent.category") != "DISCONNECTED"
|
and self._device.connection
|
||||||
)
|
)
|
||||||
|
|
||||||
@property
|
@property
|
||||||
|
|
@ -541,7 +541,7 @@ class HonConfigSwitchEntity(HonEntity, SwitchEntity):
|
||||||
if type(setting) == HonParameter:
|
if type(setting) == HonParameter:
|
||||||
return
|
return
|
||||||
setting.value = setting.max if isinstance(setting, HonParameterRange) else "1"
|
setting.value = setting.max if isinstance(setting, HonParameterRange) else "1"
|
||||||
self.async_write_ha_state()
|
self.coordinator.async_set_updated_data({})
|
||||||
self.async_write_ha_state()
|
self.async_write_ha_state()
|
||||||
|
|
||||||
async def async_turn_off(self, **kwargs: Any) -> None:
|
async def async_turn_off(self, **kwargs: Any) -> None:
|
||||||
|
|
@ -549,7 +549,7 @@ class HonConfigSwitchEntity(HonEntity, SwitchEntity):
|
||||||
if type(setting) == HonParameter:
|
if type(setting) == HonParameter:
|
||||||
return
|
return
|
||||||
setting.value = setting.min if isinstance(setting, HonParameterRange) else "0"
|
setting.value = setting.min if isinstance(setting, HonParameterRange) else "0"
|
||||||
self.async_write_ha_state()
|
self.coordinator.async_set_updated_data({})
|
||||||
self.async_write_ha_state()
|
self.async_write_ha_state()
|
||||||
|
|
||||||
@callback
|
@callback
|
||||||
|
|
|
||||||
|
|
@ -1 +1 @@
|
||||||
pyhOn==0.17.2
|
pyhOn==0.17.5
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue