Skip to content
This repository has been archived by the owner on Jul 19, 2024. It is now read-only.

Lock-Icon change takes too long #5

Open
ChristophCaina opened this issue Jan 1, 2024 · 1 comment
Open

Lock-Icon change takes too long #5

ChristophCaina opened this issue Jan 1, 2024 · 1 comment
Assignees
Labels
enhancement New feature or request

Comments

@ChristophCaina
Copy link
Owner

ChristophCaina commented Jan 1, 2024

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

@ChristophCaina ChristophCaina added the enhancement New feature or request label Jan 1, 2024
@ChristophCaina ChristophCaina self-assigned this Jan 1, 2024
@ChristophCaina
Copy link
Owner Author

  • could also be an issue of surepy ... ?

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

1 participant