Skip to content
This repository was archived by the owner on Dec 12, 2024. It is now read-only.
This repository was archived by the owner on Dec 12, 2024. It is now read-only.

Lock-Icon change takes too long #5

@ChristophCaina

Description

@ChristophCaina

the cat flap sensor does change its icon based on the lock state.

the icon will be called by surepy / entities / devices.py

    @property
    def icon(self) -> str | None:
        """Icon of the Pet/Cap Flap."""

        icon_url = "https://surehub.io/assets/images/petdoor-left-menu.png"

        if self.state == LockState.LOCKED_ALL:
            icon_url = "https://surehub.io/assets/images/both-ways-icon.svg"
        elif self.state == LockState.LOCKED_IN:
            icon_url = "https://surehub.io/assets/images/inside-icon.svg"
        elif self.state == LockState.LOCKED_OUT:
            icon_url = "https://surehub.io/assets/images/outside-icon.svg"

        return urlparse(icon_url).geturl()

The Icon will be set in sureha / sensors.py

class Flap(SurePetcareSensor):
    """Sure Petcare Flap."""

    def __init__(self, coordinator, _id: int, spc: SurePetcareAPI) -> None:
        super().__init__(coordinator, _id, spc)

        self._surepy_entity: SureFlap

        self._attr_entity_picture = self._surepy_entity.icon
        self._attr_unit_of_measurement = None

But the Icon change will not take place whenever the device status changes... it seems, that this will only be polled from time to time, or whenever something else might trigger a poll from the webserver.
image

Would it be better to save the image locally instead?
Or to pull the picture directly with each state change?

states:
unlocked https://surehub.io/assets/images/petdoor-left-menu.png
locked_in https://surehub.io/assets/images/inside-icon.svg
locked_out https://surehub.io/assets/images/outside-icon.svg
locked_all https://surehub.io/assets/images/both-ways-icon.svg

Metadata

Metadata

Labels

enhancementNew feature or request

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions