abmantis / whirlpool-sixth-sense

Whirlpool unofficial API for 6th Sense appliances
MIT License
13 stars 12 forks source link

Notify HA of updates on fetch_data() #45

Closed mkmer closed 11 months ago

mkmer commented 12 months ago

Need to tell listeners when new data is fetched - found when restarting the socket and calling fetch_data() HA was not notified of updated entities until an event message was received.

abmantis commented 12 months ago

I am not sure I understand the need for this change. fetch_data() is only called on startup when HA calls connect(), so there is no need to call the attr changed callback there.

mkmer commented 12 months ago

It is also called when the socket reconnects:

https://github.com/abmantis/whirlpool-sixth-sense/blob/f217ca550a275e1a04fd567a8efd092ad2968bce/whirlpool/appliance.py#L192

which is mapped to this: https://github.com/abmantis/whirlpool-sixth-sense/blob/f217ca550a275e1a04fd567a8efd092ad2968bce/whirlpool/eventsocket.py#L138

When the event socket reconnects, we don't "know" the states for sure, so we do a fetch to make sure everything is up to date. Unfortunately, we don't tell HA that there is new data to update when this happens.

This will also allow us to drive 1 timed update function and still trigger all other entities (The bandaid for a crappy event socket)

abmantis commented 11 months ago

It is also called when the socket reconnects: https://github.com/abmantis/whirlpool-sixth-sense/blob/f217ca550a275e1a04fd567a8efd092ad2968bce/whirlpool/appliance.py#L192C8-L192C8 which is mapped to this:

https://github.com/abmantis/whirlpool-sixth-sense/blob/f217ca550a275e1a04fd567a8efd092ad2968bce/whirlpool/eventsocket.py#L138

When the event socket reconnects, we don't "know" the states for sure, so we do a fetch to make sure everything is up to date. Unfortunately, we don't tell HA that there is new data to update when this happens.

This will also allow us to drive 1 timed update function and still trigger all other entities (The bandaid for a crappy event socket)

Ah I see! Makes sense!

abmantis commented 11 months ago

Thanks!

mkmer commented 11 months ago

Can we get a release in pypi for this? Looking to activate the polling feature in HA and this is necessary for HA to update all entities. Thanks!

abmantis commented 11 months ago

@mkmer sure! I just released it as v0.18.4.