Aohzan / ipx800

IPX800 V4 integration for Home-Assistant
Apache License 2.0
20 stars 12 forks source link

Gerenic API URL to force HA updating channels states #29

Closed Neuvidor closed 1 year ago

Neuvidor commented 2 years ago

Target is to be able through a single PUSH request (IPX side) to force Home Assistant (your custom component) to update all states of its channels & arguments from IPX800.

It will allow us to keep the default "scan_interval" value and have a better user experience :

Aohzan commented 2 years ago

Hello My bad, I actually did it for ipx800v5 2 months ago, but not for the v4... It's done now, can you test the 3.2.0 version please

LHommeQuAVuLOurs commented 2 years ago

Hello @Aohzan I just updated to 3.2.0 and tried the "api/ipx800v4_refresh" push : image

However it's not updating the entities (at least not faster than the scan interval).

My previous push was working well for one specific binary sensor, I only changed the "url on" and "url off" values to test the update.

Please let me know where I can find logs or anything else that might be of some help because it is definitely a very cool feature ;)

Aohzan commented 2 years ago

Can you enable debug log and see if the update is done or not just after the push?

LHommeQuAVuLOurs commented 2 years ago

I'm sorry can you be more specific ? What logs ? Home Assistant ? IPX custom integration ? IPX card ? Where do I change the log level ?

At the moment in Home Assistant configuration / System / Logs I can see some logs but not related to the IPX integration. I can choose some of my integrations in a list in the upper right corner but no IPX integration there neither. I'm not sure I'm looking in the right place.

image

Aohzan commented 2 years ago
logger:
  logs:
    custom_components.ipx800v4: debug
raspberryvincent commented 1 year ago

Hi, I have the same issue. Did you find where it came from? Did you manage to get the global refresh to work ?

Thanks

Aohzan commented 1 year ago

Je n'ai plus d'ipx800v4 du coup je ne peux pas tester de mon côté, du coup j'aurais besoin des logs en debug au moment où vous enclenchez le push pour voir ce qu'il se passe

raspberryvincent commented 1 year ago

Merci pour ta réponse.

J'ai uniquement ça dans le log : 2022-08-31 14:06:30.086 DEBUG (MainThread) [custom_components.ipx800v4] Finished fetching ipx800v4 data in 0.084 seconds (success: True)

Je ne vois rien passer d'autre.

J'ai un jeedom en //. Les push sont générés par le même scenario dans l'IPX.

J'ai configuré mes push comme ci-dessous : image

Aohzan commented 1 year ago

la ligne de log apparait au moment où tu lances le push ? si oui c'est que ça fonctionne bien

raspberryvincent commented 1 year ago

Elle apparait toutes les 15 secondes. Temps d'actualisation configuré.

Aohzan commented 1 year ago

est-ce que tu peux ajouter cette ligne:

_LOGGER.debug("Update asked from push")

dans le fichier __init__.py à la ligne 481 entre """Respond to requests from the device.""" et if check_api_auth(request, self.host, self.password):, relancer HA et retester

raspberryvincent commented 1 year ago

image

Log : 2022-08-31 14:48:45.086 DEBUG (MainThread) [custom_components.ipx800v4] Finished fetching ipx800v4 data in 0.084 seconds (success: True) 2022-08-31 14:49:00.086 DEBUG (MainThread) [custom_components.ipx800v4] Finished fetching ipx800v4 data in 0.085 seconds (success: True) 2022-08-31 14:49:15.086 DEBUG (MainThread) [custom_components.ipx800v4] Finished fetching ipx800v4 data in 0.085 seconds (success: True)

Rien de plus quand le push est censé passer.

raspberryvincent commented 1 year ago

Entre temps j'ai éteint mon jeedom et retiré les push lié à jeedom pour faire du propre et être sûr de ne pas être pollué par ça...

raspberryvincent commented 1 year ago

J'ai configuré ça dans mon config : image

Aohzan commented 1 year ago

si tu enlèves le "/" de fin dans les URL du push ?

raspberryvincent commented 1 year ago

C'est ce que j'étais entrain de tester.

J'ai ça dans le log (à chaque push):

2022-08-31 15:06:52.252 ERROR (MainThread) [aiohttp.server] Error handling request Traceback (most recent call last): File "/usr/local/lib/python3.10/site-packages/aiohttp/web_protocol.py", line 435, in _handle_request resp = await request_handler(request) File "/usr/local/lib/python3.10/site-packages/aiohttp/web_app.py", line 504, in _handle resp = await handler(request) File "/usr/local/lib/python3.10/site-packages/aiohttp/web_middlewares.py", line 117, in impl return await handler(request) File "/usr/src/homeassistant/homeassistant/components/http/security_filter.py", line 60, in security_filter_middleware return await handler(request) File "/usr/src/homeassistant/homeassistant/components/http/forwarded.py", line 100, in forwarded_middleware return await handler(request) File "/usr/src/homeassistant/homeassistant/components/http/request_context.py", line 28, in request_context_middleware return await handler(request) File "/usr/src/homeassistant/homeassistant/components/http/ban.py", line 82, in ban_middleware return await handler(request) File "/usr/src/homeassistant/homeassistant/components/http/auth.py", line 236, in auth_middleware return await handler(request) File "/usr/src/homeassistant/homeassistant/components/http/view.py", line 133, in handle result = handler(request, **request.match_info) TypeError: IpxRequestRefreshView.get() missing 1 required positional argument: 'data'

Aohzan commented 1 year ago

met /api/ipx800v4_refresh/on pour tester

Aohzan commented 1 year ago

et je pense ligne 467 remplacer par

url = "/api/ipx800v4_refresh/{data}"
raspberryvincent commented 1 year ago

Avec modification de la ligne 467.

Log à chaque push: 2022-08-31 15:14:50.846 DEBUG (MainThread) [custom_components.ipx800v4] Update asked from push 2022-08-31 15:14:51.937 DEBUG (MainThread) [custom_components.ipx800v4] Update asked from push

Je vois passer les push dans les logs mais les valeurs ne s'actualisent pas.

J'ai configuré comme ça, l'IPX : image

On est pas loin du but je pense...

Aohzan commented 1 year ago

yes c'est mieux, essaie ce code pour mieux debug:

class IpxRequestRefreshView(HomeAssistantView):
    """Provide a page for the device to call for send multiple data at once."""

    requires_auth = False
    url = "/api/ipx800v4_refresh/{data}"
    name = "api:ipx800v4_refresh"

    def __init__(
        self, host: str, password: str, coordinator: DataUpdateCoordinator
    ) -> None:
        """Init the IPX view."""
        self.host = host
        self.password = password
        self.coordinator = coordinator
        super().__init__()

    async def get(self, request, data):
        """Respond to requests from the device."""
        _LOGGER.debug("Update asked from push")
        if check_api_auth(request, self.host, self.password):
            _LOGGER.debug("Auth ok, ask update to the IPX")
            self.coordinator.async_request_refresh()
            return web.Response(status=HTTPStatus.OK, text="OK")
        _LOGGER.debug("Auth invalid")
raspberryvincent commented 1 year ago

J'ai ça dans le log : 2022-08-31 15:25:17.663 DEBUG (MainThread) [custom_components.ipx800v4] Update asked from push 2022-08-31 15:25:17.663 DEBUG (MainThread) [custom_components.ipx800v4] Auth ok, ask update to the IPX

J'ai collé le code à la fin du fichier init.py

Aohzan commented 1 year ago

c'était à mettre à la place de l'autre class IpxRequestRefreshView mais ça a l'air d'être passé quand même. Est-ce que tu peux ajouter await devant le self.coordinator.async_request_refresh(), comme ceci

class IpxRequestRefreshView(HomeAssistantView):
    """Provide a page for the device to force refresh data from coordinator."""

    requires_auth = False
    url = "/api/ipx800v4_refresh/{data}"
    name = "api:ipx800v4_refresh"

    def __init__(
        self, host: str, password: str, coordinator: DataUpdateCoordinator
    ) -> None:
        """Init the IPX view."""
        self.host = host
        self.password = password
        self.coordinator = coordinator
        super().__init__()

    async def get(self, request, data):
        """Respond to requests from the device."""
        _LOGGER.debug("Update asked from push")
        if check_api_auth(request, self.host, self.password):
            _LOGGER.debug("Auth ok, ask update to the IPX")
            await self.coordinator.async_request_refresh()
            return web.Response(status=HTTPStatus.OK, text="OK")
        _LOGGER.debug("Auth invalid")
raspberryvincent commented 1 year ago

Yes !! ça marche :) Log : 2022-08-31 15:34:06.805 DEBUG (MainThread) [custom_components.ipx800v4] Update asked from push 2022-08-31 15:34:06.805 DEBUG (MainThread) [custom_components.ipx800v4] Auth ok, ask update to the IPX 2022-08-31 15:34:06.910 DEBUG (MainThread) [custom_components.ipx800v4] Finished fetching ipx800v4 data in 0.084 seconds (success: True)

Merci beaucoup pour ton aide et ta réactivité.

Tu vas faire une update avec les corrections ?

Aohzan commented 1 year ago

voilà https://github.com/Aohzan/ipx800/releases/tag/3.4.0 !

Neuvidor commented 1 year ago

Merci pour cette mise à jour, cela est fonctionnel sur mon IPX800_v4 et mon X-8R cependant j'ai l'impression que cela ne fonctionne pas sur mes X-Dimmer. Est-ce un soucis de config de ma part ?

Aohzan commented 1 year ago

Comment tu déclenches ton PUSH ?

Neuvidor commented 1 year ago

Actuellement je déclenche comme ceci, j'ai également essayer avec un "ON EVENT- Entrées Physiques" mais cela ne semble rien changer. Je pense cependant que tu as raison et que le soucis provient de mon declencheur car si je change l'état d'un relai le refresh a lieux et le X-Dimmer se met à jour sous HA.

Screenshot_20220831-194317_Chrome.jpg

Screenshot_20220831-194323_Chrome.jpg

Aohzan commented 1 year ago

je sais que les X-Dimmer ne fonctionnent pas comme les relais classiques au niveau des déclencheurs :( je te conseille de demander un avis sur le forum gce

Neuvidor commented 1 year ago

Juste pour te confirmer que le problème provenait bien de mon déclencheur dans les scènes. Je partage donc ici ma solution si cela peut éviter des questions plus tard. En tous cas merci de ta réactivité et de ton temps pour ce développement !

Ma config Ipx800_v4 :

Seulement 1 push global : Screenshot_20220831-214318_Chrome.jpg

Screenshot_20220831-214835_Chrome.jpg

Seulement 3 scènes pointant vers le push global pour updater l'ensemble de mes modules sous HA :

Screenshot_20220831-214332_Chrome.jpg

Screenshot_20220831-214354_Chrome.jpg

Screenshot_20220831-214414_Chrome.jpg

Screenshot_20220831-214427_Chrome.jpg

LHommeQuAVuLOurs commented 1 year ago

Merci à tous les deux pour votre temps, Je suis désolé de ne pas avoir répondu plus tôt mais comme j'aurai probablement été incapable de t'aider comme l'a fait raspberryvincent je pense que j'ai bien fait :D

Merci encore pour l'update !

Le jeu. 1 sept. 2022 à 07:17, Neuvidor @.***> a écrit :

Juste pour te confirmer que le problème provenait bien de mon déclencheur dans les scènes. Je partage donc ici ma solution si cela peut éviter des questions plus tard. En tous cas merci de ta réactivité et de ton temps pour ce développement !

Ma config Ipx800_v4 :

  • 1x IPX800_v4
  • 1x X-8R
  • 2x X-Dimmer

Seulement 1 push global : [image: Screenshot_20220831-214318_Chrome.jpg] https://user-images.githubusercontent.com/64861851/187772715-2ece9d47-8f30-48b2-a8c5-41f817e9c034.jpg

[image: Screenshot_20220831-214835_Chrome.jpg] https://user-images.githubusercontent.com/64861851/187773448-62246906-2d1c-4d35-9932-04f125114658.jpg

Seulement 3 scènes pointant vers le push global pour updater l'ensemble de mes modules sous HA :

[image: Screenshot_20220831-214332_Chrome.jpg] https://user-images.githubusercontent.com/64861851/187773334-e8de58ad-7182-4656-baae-4d82166fe870.jpg

[image: Screenshot_20220831-214427_Chrome.jpg] https://user-images.githubusercontent.com/64861851/187773643-b1cad871-b281-4d40-b6aa-e7032583ee7e.jpg

[image: Screenshot_20220831-214414_Chrome.jpg] https://user-images.githubusercontent.com/64861851/187773771-f4c9e86b-89c9-48ad-a3a5-eaefbb003686.jpg

[image: Screenshot_20220831-214427_Chrome.jpg] https://user-images.githubusercontent.com/64861851/187773798-39280704-71a3-46bc-b0c5-f5afcbbacc25.jpg

— Reply to this email directly, view it on GitHub https://github.com/Aohzan/ipx800/issues/29#issuecomment-1233379142, or unsubscribe https://github.com/notifications/unsubscribe-auth/ATQ4CZ6NBWP7RUCJ77IS6BLV364V7ANCNFSM5QWVZV6A . You are receiving this because you commented.Message ID: @.***>