mirror of
https://github.com/home-assistant/core.git
synced 2025-07-12 15:57:06 +00:00
Bump pyHomee to 1.2.3 (#136213)
Co-authored-by: Joostlek <joostlek@outlook.com>
This commit is contained in:
parent
208805a930
commit
ea1cec2525
@ -121,14 +121,15 @@ class HomeeCover(HomeeNodeEntity, CoverEntity):
|
|||||||
def current_cover_position(self) -> int | None:
|
def current_cover_position(self) -> int | None:
|
||||||
"""Return the cover's position."""
|
"""Return the cover's position."""
|
||||||
# Translate the homee position values to HA's 0-100 scale
|
# Translate the homee position values to HA's 0-100 scale
|
||||||
if self.has_attribute(AttributeType.POSITION):
|
if (
|
||||||
attribute = self._node.get_attribute_by_type(AttributeType.POSITION)
|
attribute := self._node.get_attribute_by_type(AttributeType.POSITION)
|
||||||
|
) is not None:
|
||||||
homee_min = attribute.minimum
|
homee_min = attribute.minimum
|
||||||
homee_max = attribute.maximum
|
homee_max = attribute.maximum
|
||||||
homee_position = attribute.current_value
|
homee_position = attribute.current_value
|
||||||
position = ((homee_position - homee_min) / (homee_max - homee_min)) * 100
|
position = ((homee_position - homee_min) / (homee_max - homee_min)) * 100
|
||||||
|
|
||||||
return 100 - position
|
return int(100 - position)
|
||||||
|
|
||||||
return None
|
return None
|
||||||
|
|
||||||
@ -136,16 +137,17 @@ class HomeeCover(HomeeNodeEntity, CoverEntity):
|
|||||||
def current_cover_tilt_position(self) -> int | None:
|
def current_cover_tilt_position(self) -> int | None:
|
||||||
"""Return the cover's tilt position."""
|
"""Return the cover's tilt position."""
|
||||||
# Translate the homee position values to HA's 0-100 scale
|
# Translate the homee position values to HA's 0-100 scale
|
||||||
if self.has_attribute(AttributeType.SHUTTER_SLAT_POSITION):
|
if (
|
||||||
attribute = self._node.get_attribute_by_type(
|
attribute := self._node.get_attribute_by_type(
|
||||||
AttributeType.SHUTTER_SLAT_POSITION
|
AttributeType.SHUTTER_SLAT_POSITION
|
||||||
)
|
)
|
||||||
|
) is not None:
|
||||||
homee_min = attribute.minimum
|
homee_min = attribute.minimum
|
||||||
homee_max = attribute.maximum
|
homee_max = attribute.maximum
|
||||||
homee_position = attribute.current_value
|
homee_position = attribute.current_value
|
||||||
position = ((homee_position - homee_min) / (homee_max - homee_min)) * 100
|
position = ((homee_position - homee_min) / (homee_max - homee_min)) * 100
|
||||||
|
|
||||||
return 100 - position
|
return int(100 - position)
|
||||||
|
|
||||||
return None
|
return None
|
||||||
|
|
||||||
@ -176,8 +178,9 @@ class HomeeCover(HomeeNodeEntity, CoverEntity):
|
|||||||
@property
|
@property
|
||||||
def is_closed(self) -> bool | None:
|
def is_closed(self) -> bool | None:
|
||||||
"""Return if the cover is closed."""
|
"""Return if the cover is closed."""
|
||||||
if self.has_attribute(AttributeType.POSITION):
|
if (
|
||||||
attribute = self._node.get_attribute_by_type(AttributeType.POSITION)
|
attribute := self._node.get_attribute_by_type(AttributeType.POSITION)
|
||||||
|
) is not None:
|
||||||
return attribute.get_value() == attribute.maximum
|
return attribute.get_value() == attribute.maximum
|
||||||
|
|
||||||
if self._open_close_attribute is not None:
|
if self._open_close_attribute is not None:
|
||||||
@ -187,10 +190,11 @@ class HomeeCover(HomeeNodeEntity, CoverEntity):
|
|||||||
return self._open_close_attribute.get_value() == 0
|
return self._open_close_attribute.get_value() == 0
|
||||||
|
|
||||||
# If none of the above is present, it might be a slat only cover.
|
# If none of the above is present, it might be a slat only cover.
|
||||||
if self.has_attribute(AttributeType.SHUTTER_SLAT_POSITION):
|
if (
|
||||||
attribute = self._node.get_attribute_by_type(
|
attribute := self._node.get_attribute_by_type(
|
||||||
AttributeType.SHUTTER_SLAT_POSITION
|
AttributeType.SHUTTER_SLAT_POSITION
|
||||||
)
|
)
|
||||||
|
) is not None:
|
||||||
return attribute.get_value() == attribute.minimum
|
return attribute.get_value() == attribute.minimum
|
||||||
|
|
||||||
return None
|
return None
|
||||||
@ -217,7 +221,9 @@ class HomeeCover(HomeeNodeEntity, CoverEntity):
|
|||||||
position = 100 - cast(int, kwargs[ATTR_POSITION])
|
position = 100 - cast(int, kwargs[ATTR_POSITION])
|
||||||
|
|
||||||
# Convert position to range of our entity.
|
# Convert position to range of our entity.
|
||||||
attribute = self._node.get_attribute_by_type(AttributeType.POSITION)
|
if (
|
||||||
|
attribute := self._node.get_attribute_by_type(AttributeType.POSITION)
|
||||||
|
) is not None:
|
||||||
homee_min = attribute.minimum
|
homee_min = attribute.minimum
|
||||||
homee_max = attribute.maximum
|
homee_max = attribute.maximum
|
||||||
homee_position = (position / 100) * (homee_max - homee_min) + homee_min
|
homee_position = (position / 100) * (homee_max - homee_min) + homee_min
|
||||||
@ -231,9 +237,11 @@ class HomeeCover(HomeeNodeEntity, CoverEntity):
|
|||||||
|
|
||||||
async def async_open_cover_tilt(self, **kwargs: Any) -> None:
|
async def async_open_cover_tilt(self, **kwargs: Any) -> None:
|
||||||
"""Open the cover tilt."""
|
"""Open the cover tilt."""
|
||||||
slat_attribute = self._node.get_attribute_by_type(
|
if (
|
||||||
|
slat_attribute := self._node.get_attribute_by_type(
|
||||||
AttributeType.SLAT_ROTATION_IMPULSE
|
AttributeType.SLAT_ROTATION_IMPULSE
|
||||||
)
|
)
|
||||||
|
) is not None:
|
||||||
if not slat_attribute.is_reversed:
|
if not slat_attribute.is_reversed:
|
||||||
await self.async_set_value(slat_attribute, 2)
|
await self.async_set_value(slat_attribute, 2)
|
||||||
else:
|
else:
|
||||||
@ -241,9 +249,11 @@ class HomeeCover(HomeeNodeEntity, CoverEntity):
|
|||||||
|
|
||||||
async def async_close_cover_tilt(self, **kwargs: Any) -> None:
|
async def async_close_cover_tilt(self, **kwargs: Any) -> None:
|
||||||
"""Close the cover tilt."""
|
"""Close the cover tilt."""
|
||||||
slat_attribute = self._node.get_attribute_by_type(
|
if (
|
||||||
|
slat_attribute := self._node.get_attribute_by_type(
|
||||||
AttributeType.SLAT_ROTATION_IMPULSE
|
AttributeType.SLAT_ROTATION_IMPULSE
|
||||||
)
|
)
|
||||||
|
) is not None:
|
||||||
if not slat_attribute.is_reversed:
|
if not slat_attribute.is_reversed:
|
||||||
await self.async_set_value(slat_attribute, 1)
|
await self.async_set_value(slat_attribute, 1)
|
||||||
else:
|
else:
|
||||||
@ -255,9 +265,11 @@ class HomeeCover(HomeeNodeEntity, CoverEntity):
|
|||||||
position = 100 - cast(int, kwargs[ATTR_TILT_POSITION])
|
position = 100 - cast(int, kwargs[ATTR_TILT_POSITION])
|
||||||
|
|
||||||
# Convert position to range of our entity.
|
# Convert position to range of our entity.
|
||||||
attribute = self._node.get_attribute_by_type(
|
if (
|
||||||
|
attribute := self._node.get_attribute_by_type(
|
||||||
AttributeType.SHUTTER_SLAT_POSITION
|
AttributeType.SHUTTER_SLAT_POSITION
|
||||||
)
|
)
|
||||||
|
) is not None:
|
||||||
homee_min = attribute.minimum
|
homee_min = attribute.minimum
|
||||||
homee_max = attribute.maximum
|
homee_max = attribute.maximum
|
||||||
homee_position = (position / 100) * (homee_max - homee_min) + homee_min
|
homee_position = (position / 100) * (homee_max - homee_min) + homee_min
|
||||||
|
@ -73,13 +73,20 @@ class HomeeNodeEntity(Entity):
|
|||||||
self._attr_unique_id = f"{entry.unique_id}-{node.id}"
|
self._attr_unique_id = f"{entry.unique_id}-{node.id}"
|
||||||
self._entry = entry
|
self._entry = entry
|
||||||
|
|
||||||
|
## Homee hub itself has node-id -1
|
||||||
|
if node.id == -1:
|
||||||
self._attr_device_info = DeviceInfo(
|
self._attr_device_info = DeviceInfo(
|
||||||
identifiers={(DOMAIN, str(node.id))},
|
identifiers={(DOMAIN, entry.runtime_data.settings.uid)},
|
||||||
|
)
|
||||||
|
else:
|
||||||
|
self._attr_device_info = DeviceInfo(
|
||||||
|
identifiers={(DOMAIN, f"{entry.unique_id}-{node.id}")},
|
||||||
name=node.name,
|
name=node.name,
|
||||||
model=get_name_for_enum(NodeProfile, node.profile),
|
model=get_name_for_enum(NodeProfile, node.profile),
|
||||||
sw_version=self._get_software_version(),
|
sw_version=self._get_software_version(),
|
||||||
via_device=(DOMAIN, entry.runtime_data.settings.uid),
|
via_device=(DOMAIN, entry.runtime_data.settings.uid),
|
||||||
)
|
)
|
||||||
|
|
||||||
self._host_connected = entry.runtime_data.connected
|
self._host_connected = entry.runtime_data.connected
|
||||||
|
|
||||||
async def async_added_to_hass(self) -> None:
|
async def async_added_to_hass(self) -> None:
|
||||||
@ -91,23 +98,6 @@ class HomeeNodeEntity(Entity):
|
|||||||
)
|
)
|
||||||
)
|
)
|
||||||
|
|
||||||
@property
|
|
||||||
def device_info(self) -> DeviceInfo:
|
|
||||||
"""Return the device info."""
|
|
||||||
# Homee hub has id -1, but is identified only by the UID.
|
|
||||||
if self._node.id == -1:
|
|
||||||
return DeviceInfo(
|
|
||||||
identifiers={(DOMAIN, self._entry.runtime_data.settings.uid)},
|
|
||||||
)
|
|
||||||
|
|
||||||
return DeviceInfo(
|
|
||||||
identifiers={(DOMAIN, f"{self._entry.unique_id}-{self._node.id}")},
|
|
||||||
name=self._node.name,
|
|
||||||
model=get_name_for_enum(NodeProfile, self._node.profile),
|
|
||||||
sw_version=self._get_software_version(),
|
|
||||||
via_device=(DOMAIN, self._entry.runtime_data.settings.uid),
|
|
||||||
)
|
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def available(self) -> bool:
|
def available(self) -> bool:
|
||||||
"""Return the availability of the underlying node."""
|
"""Return the availability of the underlying node."""
|
||||||
@ -122,18 +112,26 @@ class HomeeNodeEntity(Entity):
|
|||||||
|
|
||||||
def _get_software_version(self) -> str | None:
|
def _get_software_version(self) -> str | None:
|
||||||
"""Return the software version of the node."""
|
"""Return the software version of the node."""
|
||||||
if self.has_attribute(AttributeType.FIRMWARE_REVISION):
|
if (
|
||||||
return self._node.get_attribute_by_type(
|
attribute := self._node.get_attribute_by_type(
|
||||||
AttributeType.FIRMWARE_REVISION
|
AttributeType.FIRMWARE_REVISION
|
||||||
).get_value()
|
)
|
||||||
if self.has_attribute(AttributeType.SOFTWARE_REVISION):
|
) is not None:
|
||||||
return self._node.get_attribute_by_type(
|
return str(attribute.get_value())
|
||||||
|
if (
|
||||||
|
attribute := self._node.get_attribute_by_type(
|
||||||
AttributeType.SOFTWARE_REVISION
|
AttributeType.SOFTWARE_REVISION
|
||||||
).get_value()
|
)
|
||||||
|
) is not None:
|
||||||
|
return str(attribute.get_value())
|
||||||
|
|
||||||
return None
|
return None
|
||||||
|
|
||||||
def has_attribute(self, attribute_type: AttributeType) -> bool:
|
def has_attribute(self, attribute_type: AttributeType) -> bool:
|
||||||
"""Check if an attribute of the given type exists."""
|
"""Check if an attribute of the given type exists."""
|
||||||
|
if self._node.attribute_map is None:
|
||||||
|
return False
|
||||||
|
|
||||||
return attribute_type in self._node.attribute_map
|
return attribute_type in self._node.attribute_map
|
||||||
|
|
||||||
async def async_set_value(self, attribute: HomeeAttribute, value: float) -> None:
|
async def async_set_value(self, attribute: HomeeAttribute, value: float) -> None:
|
||||||
|
@ -8,5 +8,5 @@
|
|||||||
"iot_class": "local_push",
|
"iot_class": "local_push",
|
||||||
"loggers": ["homee"],
|
"loggers": ["homee"],
|
||||||
"quality_scale": "bronze",
|
"quality_scale": "bronze",
|
||||||
"requirements": ["pyHomee==1.2.0"]
|
"requirements": ["pyHomee==1.2.3"]
|
||||||
}
|
}
|
||||||
|
@ -263,7 +263,7 @@ class HomeeSensor(HomeeEntity, SensorEntity):
|
|||||||
self.entity_description = description
|
self.entity_description = description
|
||||||
self._attr_translation_key = description.key
|
self._attr_translation_key = description.key
|
||||||
if attribute.instance > 0:
|
if attribute.instance > 0:
|
||||||
self._attr_translation_key = f"{description.translation_key}_instance"
|
self._attr_translation_key = f"{self._attr_translation_key}_instance"
|
||||||
self._attr_translation_placeholders = {"instance": str(attribute.instance)}
|
self._attr_translation_placeholders = {"instance": str(attribute.instance)}
|
||||||
|
|
||||||
@property
|
@property
|
||||||
|
2
requirements_all.txt
generated
2
requirements_all.txt
generated
@ -1763,7 +1763,7 @@ pyEmby==1.10
|
|||||||
pyHik==0.3.2
|
pyHik==0.3.2
|
||||||
|
|
||||||
# homeassistant.components.homee
|
# homeassistant.components.homee
|
||||||
pyHomee==1.2.0
|
pyHomee==1.2.3
|
||||||
|
|
||||||
# homeassistant.components.rfxtrx
|
# homeassistant.components.rfxtrx
|
||||||
pyRFXtrx==0.31.1
|
pyRFXtrx==0.31.1
|
||||||
|
2
requirements_test_all.txt
generated
2
requirements_test_all.txt
generated
@ -1452,7 +1452,7 @@ pyDuotecno==2024.10.1
|
|||||||
pyElectra==1.2.4
|
pyElectra==1.2.4
|
||||||
|
|
||||||
# homeassistant.components.homee
|
# homeassistant.components.homee
|
||||||
pyHomee==1.2.0
|
pyHomee==1.2.3
|
||||||
|
|
||||||
# homeassistant.components.rfxtrx
|
# homeassistant.components.rfxtrx
|
||||||
pyRFXtrx==0.31.1
|
pyRFXtrx==0.31.1
|
||||||
|
Loading…
x
Reference in New Issue
Block a user