IoTLabs-pl / hon

Home Assistant integration for Haier hOn: support for Haier/Candy/Hoover home appliances like washing machines and air conditioners in 28 languages.
MIT License
6 stars 1 forks source link

Washing machine entities are not updated during cycle #2

Open kubasaw opened 1 month ago

kubasaw commented 1 month ago

Reported in: https://github.com/Andre0512/hon/issues/230#issuecomment-2283501485, https://github.com/Andre0512/hon/issues/230#issuecomment-2284545584

@deezid, @KameDomotics

As a first step, we need to verify whether the subscription to events on the MQTT server is successful. To check this, go to Settings -> System -> Logs. After clicking Load Full Logs, you should see log entries from the logger named pyhon.connection.mqtt at the INFO and DEBUG levels, which might provide more detailed information.

KameDomotics commented 1 month ago

I don't seem to see anything related to pyhon (or I'm not able to see it)

kubasaw commented 1 month ago

Can you add:

logger:
  logs:
    pyhon: debug

to your configuration.yaml and try again?

deezid commented 1 month ago

Can you add:

logger:
  logs:
    pyhon: debug

to your configuration.yaml and try again?

Thank you, added. Will do the next cycle tomorrow.

kubasaw commented 1 month ago

At the HA startup you should have logs indicating subscription on the events coming from Haier Cloud. When you change some parameters from appliance control panel, notification events should appear even if you do not start program.

deezid commented 1 month ago

ok, even better. So maybe even a HON restart would suffice? Have family here till tomorrow and don't want to reboot HA. 😅

On Tue, Aug 13, 2024 at 9:27 PM Kuba Sawulski @.***> wrote:

At the HA startup you should have logs indicating subscription on the events coming from Haier Cloud. When you change some parameters from appliance control panel, notification events should appear even if you do not start program.

— Reply to this email directly, view it on GitHub https://github.com/IoTLabs-pl/hon/issues/2#issuecomment-2286865551, or unsubscribe https://github.com/notifications/unsubscribe-auth/AXRWXSBYW37D6J42MF3B3LDZRJFYJAVCNFSM6AAAAABMN7KHY6VHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZDEOBWHA3DKNJVGE . You are receiving this because you were mentioned.Message ID: @.***>

KameDomotics commented 1 month ago

Can you add:

logger:
  logs:
    pyhon: debug

to your configuration.yaml and try again?

When I restart Home Assistant, this appears in the log:

2024-08-13 21:59:20.712 WARNING (MainThread) [homeassistant.util.loop] Detected blocking call to import_module inside the event loop by custom integration 'hon' at custom_components/hon/__init__.py, line 34: hon = await Hon( (offender: /usr/local/lib/python3.12/site-packages/pyhon/appliance.py, line 52: self._extra: Optional[ApplianceBase] = importlib.import_module(), please create a bug report at https://github.com/Andre0512/hon/issues
kubasaw commented 1 month ago

@KameDomotics Generally, integration subscribed for updates. Some messages should appear when you make some changes on your devices. For example, when I turn on my washing machine I can see:

2024-08-13 18:02:44.776 DEBUG (Thread-6 (_thread_main)) [pyhon.connection.mqtt] Received PUBLISH (d0, q0, r0, m0), '$aws/events/presence/connected/xx-xx-xx-xx-xx-xx', properties=[], ... (276 bytes)
2024-08-13 18:02:47.720 DEBUG (Thread-6 (_thread_main)) [pyhon.connection.mqtt] Received PUBLISH (d0, q0, r0, m0), 'haier/things/xx-xx-xx-xx-xx-xx/event/appliancestatus/update', properties=[], ... (306 bytes)
2024-08-13 18:02:48.751 DEBUG (Thread-6 (_thread_main)) [pyhon.connection.mqtt] Received PUBLISH (d0, q0, r0, m0), 'haier/things/xx-xx-xx-xx-xx-xx/event/appliancestatus/update', properties=[], ... (428 bytes)
KameDomotics commented 1 month ago

Now it seems to work, the washing machine entities are updating. So, now the washing machine and Home Assistant talk locally, without going through Haier servers? Does it work without an internet connection?

image

However, not all entities are updated, for example those highlighted in green have updated and when I started the washing machine, the others are stuck when I restarted Home Assistant. Could you explain how it works? Thanks

KameDomotics commented 1 month ago

There is one problem I have always encountered with hOn integration. The entity that indicates the remaining time never reaches zero, but always leaves a few minutes (usually 1 or 3 minutes). On the official hOn app everything is ok.

kubasaw commented 4 weeks ago

Could you explain how it works?

@deezid With a high degree of probability, it's not possible to communicate with Haier devices over the local network. The mainboard is connected to a module containing an ESP32, which handles communication. Its firmware attempts to establish an encrypted connection with AWS IoT Core. The only thing we can do is to query AWS from the other side.

The previous version of the integration used the HTTP protocol: it periodically fetched the complete state of the device. Since there can be many parameters, the API response could be quite large. Multiplying this by the number of requests explains why Haier became angry :disappointed:

The new version of the API connects to AWS using the MQTT protocol. This means that we have persistent connection (periodically sending a ping to the server) and receive instant updates on changes to our device's state. This approach has several advantages:

More about protocol can be read here.

There is one problem I have always encountered with hOn integration. The entity that indicates the remaining time never reaches zero, but always leaves a few minutes (usually 1 or 3 minutes). On the official hOn app everything is ok.

@KameDomotics Since the previous version of the integration periodically queried the current state of the device, when your washing machine reports that there are X minutes left, you would find out anywhere between 0 and N minutes later, depending on how frequently (every N minutes) we query. The more often we query, the more Haier is sad. By using MQTT, we should be receiving new data instantly.

If that's not the case, it seems less effective to store the data in this form in HA. It would be much better to store the timestamp of the expected program completion. This is documented in the HA developer documentation: the state of an entity shouldn’t change solely due to the passage of time. HA's frontend can nicely display "in 5 minutes" based on the current time and the program’s completion timestamp.

I’ll try to improve this, but it may take a while. For now, I’m working a lot on refactoring pyhOn, which I hope will make the code easier to maintain and allow for more efficient codebase in HA. Currently, when one parameter update comes in, all entities in the integration are recalculated, even though 'most likely' only one of them has actually changed.

KameDomotics commented 4 weeks ago

Thanks for the explanation. Unfortunately it doesn't work anymore, it doesn't update any entity, it starts working again only when I reload the Haier integration, but when I next start the washing machine it doesn't work again

AndreaSegoni commented 4 weeks ago

Same here, when i reload the integration, all data sync, no update during the cycle.

kubasaw commented 4 weeks ago

@KameDomotics, @AndreaSegoni There’s an issue with refreshing access tokens. Haier’s auth flow is quite complicated (and mostly reverse-engineered), and the code handling it is rather messy. For example, if any request fails, the entire integration enters a failed state and doesn’t attempt to reconnect.

I’m currently working on getting everything into a usable state, but I’m afraid it might take about another week to resolve.

deezid commented 4 weeks ago

Exactly the issue I noticed as well. It works for a bit and at some point will stop refreshing any sensor.

AndreaSegoni commented 4 weeks ago

Seriously, i really can't understand why Haier is trying to block integrations for their machines in every possible way. hOn is a fantastic application in itself, but as time goes by, more and more people are interfacing with home automation on Home Assistant. Having an integration on HA can only be an added value for them...

kubasaw commented 4 weeks ago

@AndreaSegoni I don’t think this is intentional or malicious on Haier's part; it seems that, like most companies, they prefer to maintain and control their own app. Maintaining an interface for external systems also comes with costs.

The previous version of the integration queried the API every 10 seconds, and in my case, it returned 11kB of data each time. Over a month, this adds up significantly:

This amount of traffic could cost Haier around $0.24 per device each month, based on AWS data transfer pricing. However, we don’t know exactly how the data is processed within AWS IoT Core, and the costs of that processing could be at least an order of magnitude higher.

And this calculation doesn’t even account for factors like refreshing tokens (which might require 7-8 additional requests), sending commands to the device, or the costs of computing power, and so on. With MQTT (subscription on state changes) we can reduce this workload to almost zero.

Doktor-X commented 4 weeks ago

There’s an issue with refreshing access tokens. Haier’s auth flow is quite complicated (and mostly reverse-engineered), and the code handling it is rather messy. For example, if any request fails, the entire integration enters a failed state and doesn’t attempt to reconnect.

I’m currently working on getting everything into a usable state, but I’m afraid it might take about another week to resolve.

So this is why my AC is not updating in real time, i hope you will be able to fix this in some time

deezid commented 4 weeks ago

Checked latest version 0.14 beta 10.



2024-08-19 14:46:29.982 INFO (Dummy-12) [pyhon.connection.mqtt] Lifecycle Attempting Connect - LifecycleAttemptingConnectData()
2024-08-19 14:46:30.975 INFO (Dummy-12) [pyhon.connection.mqtt] Lifecycle Connection Success: LifecycleConnectSuccessData(connack_packet=ConnackPacket(session_present=False, reason_code=<ConnectReasonCode.SUCCESS: 0>, session_expiry_interval_sec=None, receive_maximum=100, maximum_qos=<QoS.AT_LEAST_ONCE: 1>, retain_available=True, maximum_packet_size=149504, assigned_client_identifier=None, topic_alias_maximum=8, reason_string=None, user_properties=None, wildcard_subscriptions_available=True, subscription_identifiers_available=False, shared_subscription_available=True, server_keep_alive_sec=1200, response_information=None, server_reference=None), negotiated_settings=NegotiatedSettings(maximum_qos=<QoS.AT_LEAST_ONCE: 1>, session_expiry_interval_sec=0, receive_maximum_from_server=100, maximum_packet_size_to_server=149504, topic_alias_maximum_to_server=8, topic_alias_maximum_to_client=0, server_keep_alive_sec=1200, retain_available=True, wildcard_subscriptions_available=True, subscription_identifiers_available=False, shared_subscriptions_available=True, rejoined_session=False, client_id='homassistant_1814cce904b66283'))
2024-08-19 14:46:31.105 INFO (MainThread) [pyhon.connection.mqtt] Subscribed to topic $aws/events/presence/disconnected/a8-42-e3-98-52-c8
2024-08-19 14:46:31.227 INFO (MainThread) [pyhon.connection.mqtt] Subscribed to topic $aws/events/presence/connected/a8-42-e3-98-52-c8
2024-08-19 14:46:31.348 INFO (MainThread) [pyhon.connection.mqtt] Subscribed to topic haier/things/a8-42-e3-98-52-c8/event/appliancestatus/update
2024-08-19 14:46:31.468 INFO (MainThread) [pyhon.connection.mqtt] Subscribed to topic haier/things/a8-42-e3-98-52-c8/event/discovery/update

After starting a cycle:

2024-08-19 14:53:07.713 INFO (Dummy-12) [pyhon.connection.mqtt] Connected Washing Machine
2024-08-19 14:53:10.214 INFO (Dummy-12) [pyhon.connection.mqtt] Discovered Washing Machine
2024-08-19 16:33:48.856 INFO (Dummy-12) [pyhon.connection.mqtt] Disconnected Washing Machine: CLIENT_INITIATED_DISCONNECT```

None of the provided sensors is updating sadly. 
kubasaw commented 4 weeks ago

@deezid It looks like you’ve installed the version from Andre0512's repository, as these logs aren’t generated by my fork. By the way, there was a new release last week, so Andre might eventually return to maintaining the integration.

That being said, I’ve just about finished refactoring the pyhOn library. I’ve rewritten most of the code responsible for maintaining the connection. The next step is to add backoff mechanisms to restore the connection in case of issues. For now, MQTT should work fairly smoothly. https://github.com/IoTLabs-pl/pyhOn/commit/e60c7bf045ba7412d50f14b79c0a683a8658bc94

I’ll try to rewrite the part of the integration responsible for communication with pyhOn by tomorrow, so it will be ready for testing. I’ll let you know when it’s ready.

Due to the significant changes, and since I’m not following a strict git-flow process, everything is going into the dev branch for now. When installing in HACS, you’ll need to select this branch to load the latest version. You’ll still need to run docker exec homeassistant pip uninstall pyhon -y to ensure the pyhOn version gets updated properly.

deezid commented 4 weeks ago

Yea, noticed that I had two versions of the integration installed via HACS. Fixed that situation, got rid of pyhon via command line and installed yours again.

Would love to test the new (alpha) version whenever ready. :)

asierralozano commented 3 weeks ago

Hello! Not related with a Washing Machine, but my Air conditioner is basically facing what I guess it is the same issue. After some hours of inactivity, there are no updates on the entities. If I toggle the Air conditioner using the psychical button, within HA, the AC is still off.

I've enabled the debug logging of the integration, and it seems that the connection with the MQTT broker get lost.

I've verified that I'm using your version of pyhOn.

Here you have the log:

2024-08-21 08:51:11.952 WARNING (MainThread) [pyhon.connection.mqtt] Connection to MQTT broker lost. Reconnecting in 5 seconds
2024-08-21 08:51:28.698 WARNING (MainThread) [pyhon.connection.mqtt] Connection to MQTT broker lost. Reconnecting in 5 seconds
2024-08-21 08:51:45.250 WARNING (MainThread) [pyhon.connection.mqtt] Connection to MQTT broker lost. Reconnecting in 5 seconds
2024-08-21 08:51:51.847 DEBUG (SyncWorker_6) [pyhon.connection.mqtt.paho] Sending CONNECT (u1, p0, wr0, wq0, wf0, c1, k60) client_id=b'homassistant_50644c6b2c7e89e7' properties=None
2024-08-21 08:51:51.847 DEBUG (MainThread) [pyhon.connection.mqtt.paho] Sending SUBSCRIBE (d0, m392) [(b'$aws/events/presence/disconnected/90-38-0c-14-eb-84', {QoS=0, noLocal=False, retainAsPublished=False, retainHandling=0})]
2024-08-21 08:52:01.849 WARNING (MainThread) [pyhon.connection.mqtt] Connection to MQTT broker lost. Reconnecting in 5 seconds
2024-08-21 08:52:02.800 DEBUG (SyncWorker_54) [pyhon.connection.mqtt.paho] Sending CONNECT (u1, p0, wr0, wq0, wf0, c1, k60) client_id=b'homassistant_1e081293b9ec3d67' properties=None
2024-08-21 08:52:03.194 DEBUG (MainThread) [pyhon.connection.mqtt.paho] Received CONNACK (0, Success) properties=[ServerKeepAlive : 60, ReceiveMaximum : 100, TopicAliasMaximum : 8, MaximumQoS : 1, RetainAvailable : 1, MaximumPacketSize : 149504, WildcardSubscriptionAvailable : 1, SubscriptionIdentifierAvailable : 0, SharedSubscriptionAvailable : 1]
2024-08-21 08:52:03.194 DEBUG (MainThread) [pyhon.connection.mqtt.paho] Sending SUBSCRIBE (d0, m1) [(b'$aws/events/presence/disconnected/90-38-0c-14-eb-84', {QoS=0, noLocal=False, retainAsPublished=False, retainHandling=0})]
2024-08-21 08:52:03.287 DEBUG (MainThread) [pyhon.connection.mqtt.paho] Received SUBACK
2024-08-21 08:52:03.287 DEBUG (MainThread) [pyhon.connection.mqtt.paho] Sending SUBSCRIBE (d0, m2) [(b'$aws/events/presence/connected/90-38-0c-14-eb-84', {QoS=0, noLocal=False, retainAsPublished=False, retainHandling=0})]
2024-08-21 08:52:03.390 DEBUG (MainThread) [pyhon.connection.mqtt.paho] Received SUBACK
2024-08-21 08:52:03.390 DEBUG (MainThread) [pyhon.connection.mqtt.paho] Sending SUBSCRIBE (d0, m3) [(b'haier/things/90-38-0c-14-eb-84/event/appliancestatus/update', {QoS=0, noLocal=False, retainAsPublished=False, retainHandling=0})]
2024-08-21 08:52:03.475 DEBUG (MainThread) [pyhon.connection.mqtt.paho] Received SUBACK
➜  ~ docker exec homeassistant pip show pyhon                                                     
Name: pyhOn
Version: 0.17.7
Summary: Control hOn devices with python
Home-page: 
Author: Andre Basche
Author-email: 
License: MIT
Location: /usr/local/lib/python3.12/site-packages
Requires: aiohttp, aiomqtt, typing-extensions, yarl

Let me know if there is anything else I can test.

Thanks!

deezid commented 3 weeks ago

Uninstalled Pyhon and reinstalled latest beta. Getting lots of log (almost like spamming?) Attached as a file. Don't know if there's anything remotely helpful.

home-assistant_2024-08-21T10-00-53.070Z.log

Name: pyhOn
Version: 0.17.7
Summary: Control hOn devices with python
Home-page: 
Author: Andre Basche
Author-email: 
License: MIT
Location: /usr/local/lib/python3.12/site-packages
Requires: aiohttp, aiomqtt, typing-extensions, yarl
Required-by: 
kubasaw commented 3 weeks ago

I’ve pushed changes that potentially improve the connection stability with the broker to the dev branches of both pyhOn and hOn. I’ve also filtered out some of the spam logs. I’ve been testing this with my washing machine for about a day and a half, and everything seems to be working fine.

In the meantime, I also updated HACS on my machine, and it seems that there’s no longer an option to install the integration from the default branch. Because of this, you’ll need to install the package manually (at least temporarily until I stabilize the integration enough to establish a reasonable release schedule, or unless something changes in HACS). To do this, download the zip and place it in the custom_components directory.

If the change only affects pyhOn, you can simply run docker exec ... and restart the machine.

It will be very helpful if you can test it with your own appliances. In case of any issues other than directly connected with unstable MQTT connections, please open new issue threads.

deezid commented 3 weeks ago

I’ve pushed changes that potentially improve the connection stability with the broker to the dev branches of both pyhOn and hOn. I’ve also filtered out some of the spam logs. I’ve been testing this with my washing machine for about a day and a half, and everything seems to be working fine.

In the meantime, I also updated HACS on my machine, and it seems that there’s no longer an option to install the integration from the default branch. Because of this, you’ll need to install the package manually (at least temporarily until I stabilize the integration enough to establish a reasonable release schedule, or unless something changes in HACS). To do this, download the zip and place it in the custom_components directory.

If the change only affects pyhOn, you can simply run docker exec ... and restart the machine.

It will be very helpful if you can test it with your own appliances. In case of any issues other than directly connected with unstable MQTT connections, please open new issue threads.

Sounds good. Noticed as well that HACS doesn't support choosing the dev branch anymore.

Any tips on how to download the dev branch files? Command line?

asierralozano commented 3 weeks ago

I’ve pushed changes that potentially improve the connection stability with the broker to the dev branches of both pyhOn and hOn. I’ve also filtered out some of the spam logs. I’ve been testing this with my washing machine for about a day and a half, and everything seems to be working fine.

In the meantime, I also updated HACS on my machine, and it seems that there’s no longer an option to install the integration from the default branch. Because of this, you’ll need to install the package manually (at least temporarily until I stabilize the integration enough to establish a reasonable release schedule, or unless something changes in HACS). To do this, download the zip and place it in the custom_components directory.

If the change only affects pyhOn, you can simply run docker exec ... and restart the machine.

It will be very helpful if you can test it with your own appliances. In case of any issues other than directly connected with unstable MQTT connections, please open new issue threads.

I've reinstalled by moving the "dev" zip file to my HomeAssistant custom_components folder, and I've force the reinstall of pyhOn by running run docker exec.... Unfortunately, I have some login issues now. I've tried reconfiguring the entry, but no luck.

I'm attaching the log

home-assistant_hon_2024-08-22T18-56-13.229Z.log

EDIT: I'm trying to reinstall everything from scratch. I'll update the reply, and if it is still failing due to the login issues, I'll create a new task if needed

EDIT2: Still having the issues, and I was able to reproduce within the code of pyhOn. I've created a new issue there.

Thanks!

deezid commented 3 weeks ago

Quite promising over here. The sensors are super quick now to react, like 1 second after something happens on the machine. sensor.washing_machine_remote_control doesn't work yet though, stays on disconnected the whole time.

home-assistant_2024-08-22T19-34-35.241Z.log

KameDomotics commented 3 weeks ago

I’ve pushed changes that potentially improve the connection stability with the broker to the dev branches of both pyhOn and hOn. I’ve also filtered out some of the spam logs. I’ve been testing this with my washing machine for about a day and a half, and everything seems to be working fine.

In the meantime, I also updated HACS on my machine, and it seems that there’s no longer an option to install the integration from the default branch. Because of this, you’ll need to install the package manually (at least temporarily until I stabilize the integration enough to establish a reasonable release schedule, or unless something changes in HACS). To do this, download the zip and place it in the custom_components directory.

If the change only affects pyhOn, you can simply run docker exec ... and restart the machine.

It will be very helpful if you can test it with your own appliances. In case of any issues other than directly connected with unstable MQTT connections, please open new issue threads.

I still have the old version of Hacs (1.34), can I install your new version?

image

deezid commented 3 weeks ago

I’ve pushed changes that potentially improve the connection stability with the broker to the dev branches of both pyhOn and hOn. I’ve also filtered out some of the spam logs. I’ve been testing this with my washing machine for about a day and a half, and everything seems to be working fine. In the meantime, I also updated HACS on my machine, and it seems that there’s no longer an option to install the integration from the default branch. Because of this, you’ll need to install the package manually (at least temporarily until I stabilize the integration enough to establish a reasonable release schedule, or unless something changes in HACS). To do this, download the zip and place it in the custom_components directory. If the change only affects pyhOn, you can simply run docker exec ... and restart the machine. It will be very helpful if you can test it with your own appliances. In case of any issues other than directly connected with unstable MQTT connections, please open new issue threads.

I still have the old version of Hacs (1.34), can I install your new version?

image

Try installing dev.

KameDomotics commented 3 weeks ago

I’ve pushed changes that potentially improve the connection stability with the broker to the dev branches of both pyhOn and hOn. I’ve also filtered out some of the spam logs. I’ve been testing this with my washing machine for about a day and a half, and everything seems to be working fine.

In the meantime, I also updated HACS on my machine, and it seems that there’s no longer an option to install the integration from the default branch. Because of this, you’ll need to install the package manually (at least temporarily until I stabilize the integration enough to establish a reasonable release schedule, or unless something changes in HACS). To do this, download the zip and place it in the custom_components directory.

If the change only affects pyhOn, you can simply run docker exec ... and restart the machine.

It will be very helpful if you can test it with your own appliances. In case of any issues other than directly connected with unstable MQTT connections, please open new issue threads.

I still have the old version of Hacs (1.34), can I install your new version?

image

Try installing dev.

Installing the dev installs the beta 10. Unfortunately this also has the same problem

kubasaw commented 3 weeks ago

@KameDomotics I've released new beta.11. I think there it will no longer be necessary to use the docker exec command magic for update pyhOn under hOn. I'm not able to check this: I'm away from home and I don't have access to my HA nor devcontainer.

@asierralozano Are you sure, that you also can log in with native Haier App?

Doktor-X commented 3 weeks ago

For me beta 11 is not working with or without docker exec command

Error setting up entry xxxxxxxxxxxxx@gmail.com for hon Traceback (most recent call last): File "/usr/src/homeassistant/homeassistant/config_entries.py", line 604, in async_setup result = await component.async_setup_entry(hass, self) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/config/custom_components/hon/init.py", line 34, in async_setup_entry hon = await Hon( ^^^^^^^^^^ File "/usr/local/lib/python3.12/site-packages/pyhon/hon.py", line 75, in setup await self._create_appliance(appliance, self._api) File "/usr/local/lib/python3.12/site-packages/pyhon/hon.py", line 58, in _create_appliance await appliance.load_statistics() File "/usr/local/lib/python3.12/site-packages/pyhon/appliance.py", line 211, in load_statistics self._statistics |= await self.api.load_maintenance(self) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/usr/local/lib/python3.12/site-packages/pyhon/connection/api.py", line 177, in load_maintenance async with self._session.get( File "/usr/local/lib/python3.12/contextlib.py", line 210, in aenter return await anext(self.gen) ^^^^^^^^^^^^^^^^^^^^^ File "/usr/local/lib/python3.12/site-packages/pyhon/connection/handler/hon.py", line 40, in _request async with super()._request(method, *args, **kwargs) as response: File "/usr/local/lib/python3.12/contextlib.py", line 210, in aenter return await anext(self.gen) ^^^^^^^^^^^^^^^^^^^^^ File "/usr/local/lib/python3.12/site-packages/pyhon/connection/handler/base.py", line 78, in _request response.raise_for_status() File "/usr/local/lib/python3.12/site-packages/aiohttp/client_reqrep.py", line 1093, in raise_for_status raise ClientResponseError( aiohttp.client_exceptions.ClientResponseError: 400, message='Bad Request', url='https://api-iot.he.services/commands/v1/maintenance-cycle?macAddress=XX-XX-XX-XX-XX-XX'

AndreaSegoni commented 3 weeks ago

Same as @Doktor-X

asierralozano commented 3 weeks ago

@KameDomotics I've released new beta.11. I think there it will no longer be necessary to use the docker exec command magic for update pyhOn under hOn. I'm not able to check this: I'm away from home and I don't have access to my HA nor devcontainer.

@asierralozano Are you sure, that you also can log in with native Haier App?

I can try to update the hOn component using Hacs, and check if it updates the pyhOn lib, that's ok.

Yes! I've checked, and I have access using the native app.

I was debugging the pyhOn lib a bit, and did some tests. I think that at some point, the AC device is not fully working, because I've tried with another account with no devices, and I had no issues at all.

Thanks buddy!!

deezid commented 3 weeks ago

Updated to beta 11 via Hacs but pyHon didn't update automatically. So had to uninstall it using the terminal and reinstalled beta 11 via HACS.

Now pyHon is at version 0.18.0b0.

Washing machine connects fine and sensors are updating super quickly (push is working) but sensor.washing_machine_remote_control still doesn't work.

2024-08-24 10:46:59.779 DEBUG (SyncWorker_15) [pyhon.connection.mqtt.paho] Sending CONNECT (u1, p0, wr0, wq0, wf0, c1, k60) client_id=b'homassistant_BEDDe70064bbaEcf' properties=None
2024-08-24 10:47:01.171 DEBUG (MainThread) [pyhon.connection.mqtt.paho] Received CONNACK (0, Success) properties=[ServerKeepAlive : 60, ReceiveMaximum : 100, TopicAliasMaximum : 8, MaximumQoS : 1, RetainAvailable : 1, MaximumPacketSize : 149504, WildcardSubscriptionAvailable : 1, SubscriptionIdentifierAvailable : 0, SharedSubscriptionAvailable : 1]
2024-08-24 10:47:01.190 DEBUG (MainThread) [pyhon.connection.mqtt.paho] Sending SUBSCRIBE (d0, m1) [(b'$aws/events/presence/disconnected/a8-42-e3-98-52-c8', {QoS=0, noLocal=False, retainAsPublished=False, retainHandling=0}), (b'$aws/events/presence/connected/a8-42-e3-98-52-c8', {QoS=0, noLocal=False, retainAsPublished=False, retainHandling=0}), (b'haier/things/a8-42-e3-98-52-c8/event/appliancestatus/update', {QoS=0, noLocal=False, retainAsPublished=False, retainHandling=0})]
2024-08-24 10:47:01.330 DEBUG (MainThread) [pyhon.connection.mqtt.paho] Received SUBACK
2024-08-24 10:49:38.873 DEBUG (MainThread) [pyhon.connection.mqtt.paho] Received PUBLISH (d0, q0, r0, m0), '$aws/events/presence/connected/a8-42-e3-98-52-c8', properties=[], ... (278 bytes)
2024-08-24 10:49:41.589 DEBUG (MainThread) [pyhon.connection.mqtt.paho] Received PUBLISH (d0, q0, r0, m0), 'haier/things/a8-42-e3-98-52-c8/event/appliancestatus/update', properties=[], ... (304 bytes)
2024-08-24 10:49:41.592 DEBUG (MainThread) [pyhon.connection.mqtt] On topic 'haier/things/a8-42-e3-98-52-c8/event/appliancestatus/update' received:
2024-08-24 10:49:42.919 DEBUG (MainThread) [pyhon.connection.mqtt.paho] Received PUBLISH (d0, q0, r0, m0), 'haier/things/a8-42-e3-98-52-c8/event/appliancestatus/update', properties=[], ... (728 bytes)
2024-08-24 10:49:42.921 DEBUG (MainThread) [pyhon.connection.mqtt] On topic 'haier/things/a8-42-e3-98-52-c8/event/appliancestatus/update' received:
2024-08-24 10:50:10.282 DEBUG (MainThread) [pyhon.connection.mqtt.paho] Received PUBLISH (d0, q0, r0, m0), 'haier/things/a8-42-e3-98-52-c8/event/appliancestatus/update', properties=[], ... (763 bytes)
2024-08-24 10:50:10.285 DEBUG (MainThread) [pyhon.connection.mqtt] On topic 'haier/things/a8-42-e3-98-52-c8/event/appliancestatus/update' received:
2024-08-24 10:50:24.863 DEBUG (MainThread) [pyhon.connection.mqtt.paho] Received PUBLISH (d0, q0, r0, m0), 'haier/things/a8-42-e3-98-52-c8/event/appliancestatus/update', properties=[], ... (656 bytes)
2024-08-24 10:50:24.865 DEBUG (MainThread) [pyhon.connection.mqtt] On topic 'haier/things/a8-42-e3-98-52-c8/event/appliancestatus/update' received:
2024-08-24 10:50:28.448 DEBUG (MainThread) [pyhon.connection.mqtt.paho] Received PUBLISH (d0, q0, r0, m0), 'haier/things/a8-42-e3-98-52-c8/event/appliancestatus/update', properties=[], ... (308 bytes)
2024-08-24 10:50:28.450 DEBUG (MainThread) [pyhon.connection.mqtt] On topic 'haier/things/a8-42-e3-98-52-c8/event/appliancestatus/update' received:
2024-08-24 10:50:39.374 DEBUG (MainThread) [pyhon.connection.mqtt.paho] Received PUBLISH (d0, q0, r0, m0), 'haier/things/a8-42-e3-98-52-c8/event/appliancestatus/update', properties=[], ... (565 bytes)
2024-08-24 10:50:39.375 DEBUG (MainThread) [pyhon.connection.mqtt] On topic 'haier/things/a8-42-e3-98-52-c8/event/appliancestatus/update' received:
2024-08-24 10:50:47.354 DEBUG (MainThread) [pyhon.connection.mqtt.paho] Received PUBLISH (d0, q0, r0, m0), 'haier/things/a8-42-e3-98-52-c8/event/appliancestatus/update', properties=[], ... (590 bytes)
2024-08-24 10:50:47.356 DEBUG (MainThread) [pyhon.connection.mqtt] On topic 'haier/things/a8-42-e3-98-52-c8/event/appliancestatus/update' received:
2024-08-24 10:50:54.485 DEBUG (MainThread) [pyhon.connection.mqtt.paho] Received PUBLISH (d0, q0, r0, m0), 'haier/things/a8-42-e3-98-52-c8/event/appliancestatus/update', properties=[], ... (324 bytes)
2024-08-24 10:50:54.486 DEBUG (MainThread) [pyhon.connection.mqtt] On topic 'haier/things/a8-42-e3-98-52-c8/event/appliancestatus/update' received:
2024-08-24 10:52:24.116 DEBUG (MainThread) [pyhon.connection.mqtt.paho] Received PUBLISH (d0, q0, r0, m0), '$aws/events/presence/disconnected/a8-42-e3-98-52-c8', properties=[], ... (330 bytes)
AndreaSegoni commented 3 weeks ago

Seems like pyhOn is not installed on my HA (no result with pip show pyhOn) Any suggestion? My istance is running on a Raspberry Pi 3B

KameDomotics commented 3 weeks ago

after installing the dev, it no longer gives me the option to choose the version. I already tried to remove everything but it no longer lets me choose the version

image

image

deezid commented 3 weeks ago

Installed beta 12. This time pyHon updated itself to 0.18.0b1 automatically via HACS update.

sensor.washing_machine_remote_control still doesn't work though. Will do a wash later and see if the other sensors update.

2024-08-24 18:10:48.143 DEBUG (SyncWorker_7) [pyhon.connection.mqtt.paho] Sending CONNECT (u1, p0, wr0, wq0, wf0, c1, k60) client_id=b'homassistant_Dd7EcEd3aD7a6e8C' properties=None
2024-08-24 18:10:48.572 DEBUG (MainThread) [pyhon.connection.mqtt.paho] Received CONNACK (0, Success) properties=[ServerKeepAlive : 60, ReceiveMaximum : 100, TopicAliasMaximum : 8, MaximumQoS : 1, RetainAvailable : 1, MaximumPacketSize : 149504, WildcardSubscriptionAvailable : 1, SubscriptionIdentifierAvailable : 0, SharedSubscriptionAvailable : 1]
2024-08-24 18:10:48.574 DEBUG (MainThread) [pyhon.connection.mqtt.paho] Sending SUBSCRIBE (d0, m1) [(b'$aws/events/presence/disconnected/a8-42-e3-98-52-c8', {QoS=0, noLocal=False, retainAsPublished=False, retainHandling=0}), (b'$aws/events/presence/connected/a8-42-e3-98-52-c8', {QoS=0, noLocal=False, retainAsPublished=False, retainHandling=0}), (b'haier/things/a8-42-e3-98-52-c8/event/appliancestatus/update', {QoS=0, noLocal=False, retainAsPublished=False, retainHandling=0})]
2024-08-24 18:10:48.695 DEBUG (MainThread) [pyhon.connection.mqtt.paho] Received SUBACK
2024-08-24 18:34:35.652 DEBUG (MainThread) [pyhon.connection.mqtt.paho] Received PUBLISH (d0, q0, r0, m0), '$aws/events/presence/connected/a8-42-e3-98-52-c8', properties=[], ... (278 bytes)
2024-08-24 18:34:38.573 DEBUG (MainThread) [pyhon.connection.mqtt.paho] Received PUBLISH (d0, q0, r0, m0), 'haier/things/a8-42-e3-98-52-c8/event/appliancestatus/update', properties=[], ... (304 bytes)
2024-08-24 18:34:38.575 DEBUG (MainThread) [pyhon.connection.mqtt] On topic 'haier/things/a8-42-e3-98-52-c8/event/appliancestatus/update' received:
2024-08-24 18:34:39.457 DEBUG (MainThread) [pyhon.connection.mqtt.paho] Received PUBLISH (d0, q0, r0, m0), 'haier/things/a8-42-e3-98-52-c8/event/appliancestatus/update', properties=[], ... (728 bytes)
2024-08-24 18:34:39.467 DEBUG (MainThread) [pyhon.connection.mqtt] On topic 'haier/things/a8-42-e3-98-52-c8/event/appliancestatus/update' received:
2024-08-24 18:35:03.332 DEBUG (MainThread) [pyhon.connection.mqtt.paho] Received PUBLISH (d0, q0, r0, m0), 'haier/things/a8-42-e3-98-52-c8/event/appliancestatus/update', properties=[], ... (702 bytes)
2024-08-24 18:35:03.334 DEBUG (MainThread) [pyhon.connection.mqtt] On topic 'haier/things/a8-42-e3-98-52-c8/event/appliancestatus/update' received:
2024-08-24 18:35:04.357 DEBUG (MainThread) [pyhon.connection.mqtt.paho] Received PUBLISH (d0, q0, r0, m0), 'haier/things/a8-42-e3-98-52-c8/event/appliancestatus/update', properties=[], ... (247 bytes)
2024-08-24 18:35:04.358 DEBUG (MainThread) [pyhon.connection.mqtt] On topic 'haier/things/a8-42-e3-98-52-c8/event/appliancestatus/update' received:
2024-08-24 18:35:14.249 DEBUG (MainThread) [pyhon.connection.mqtt.paho] Received PUBLISH (d0, q0, r0, m0), 'haier/things/a8-42-e3-98-52-c8/event/appliancestatus/update', properties=[], ... (656 bytes)
2024-08-24 18:35:14.251 DEBUG (MainThread) [pyhon.connection.mqtt] On topic 'haier/things/a8-42-e3-98-52-c8/event/appliancestatus/update' received:
2024-08-24 18:35:17.842 DEBUG (MainThread) [pyhon.connection.mqtt.paho] Received PUBLISH (d0, q0, r0, m0), 'haier/things/a8-42-e3-98-52-c8/event/appliancestatus/update', properties=[], ... (308 bytes)
2024-08-24 18:35:17.847 DEBUG (MainThread) [pyhon.connection.mqtt] On topic 'haier/things/a8-42-e3-98-52-c8/event/appliancestatus/update' received:
2024-08-24 18:35:31.497 DEBUG (MainThread) [pyhon.connection.mqtt.paho] Received PUBLISH (d0, q0, r0, m0), 'haier/things/a8-42-e3-98-52-c8/event/appliancestatus/update', properties=[], ... (763 bytes)
2024-08-24 18:35:31.499 DEBUG (MainThread) [pyhon.connection.mqtt] On topic 'haier/things/a8-42-e3-98-52-c8/event/appliancestatus/update' received:
2024-08-24 18:35:34.422 DEBUG (MainThread) [pyhon.connection.mqtt.paho] Received PUBLISH (d0, q0, r0, m0), 'haier/things/a8-42-e3-98-52-c8/event/appliancestatus/update', properties=[], ... (504 bytes)
2024-08-24 18:35:34.423 DEBUG (MainThread) [pyhon.connection.mqtt] On topic 'haier/things/a8-42-e3-98-52-c8/event/appliancestatus/update' received:
2024-08-24 18:36:42.971 DEBUG (MainThread) [pyhon.connection.mqtt.paho] Received PUBLISH (d0, q0, r0, m0), '$aws/events/presence/disconnected/a8-42-e3-98-52-c8', properties=[], ... (333 bytes)
Doktor-X commented 3 weeks ago

Updated to beta 12 pyhon is 0.18.0b1 I have flexis plus AC

Home Assistant Core 2024-08-24 19:55:54.974 DEBUG (MainThread) [pyhon.connection.auth] Starting OAuth2 authorization 2024-08-24 19:55:56.570 DEBUG (MainThread) [pyhon.connection.auth] Logging in 2024-08-24 19:55:57.574 DEBUG (MainThread) [pyhon.connection.auth] Getting tokens 2024-08-24 19:55:59.662 DEBUG (MainThread) [pyhon.connection.auth] Trying to retrieve Cognito token 2024-08-24 19:56:01.087 WARNING (MainThread) [homeassistant.util.loop] Detected blocking call to import_module with args ('pyhon.appliances.ac',) inside the event loop by custom integration 'hon' at custom_components/hon/init.py, line 34: hon = await Hon( (offender: /usr/local/lib/python3.12/site-packages/pyhon/appliance.py, line 52: self._extra: Optional[ApplianceBase] = importlib.import_module(), please create a bug report at https://github.com/IoTLabs-pl/hon/issues 2024-08-24 19:56:03.712 ERROR (MainThread) [pyhon.connection.handler.base] hOn Authentication Error File "/usr/local/lib/python3.12/site-packages/pyhon/hon.py", line 75, in setup File "/usr/local/lib/python3.12/site-packages/pyhon/hon.py", line 58, in _create_appliance File "/usr/local/lib/python3.12/site-packages/pyhon/appliance.py", line 211, in load_statistics File "/usr/local/lib/python3.12/site-packages/pyhon/connection/api.py", line 177, in load_maintenance File "/usr/local/lib/python3.12/site-packages/pyhon/connection/handler/hon.py", line 40, in _request File "/usr/local/lib/python3.12/site-packages/pyhon/connection/handler/base.py", line 79, in _request

KameDomotics commented 3 weeks ago

I don't know what happened to the repo https://github.com/IoTLabs-pl/hon, it doesn't download anything anymore, and you can't choose any version

Doktor-X commented 3 weeks ago

I don't know what happened to the repo https://github.com/IoTLabs-pl/hon, it doesn't download anything anymore, and you can't choose any version

I have just reverted back to beta 10 and pyhon 0.17.7 without problem. I have latest HA and HACS

KameDomotics commented 3 weeks ago

I don't know what happened to the repo https://github.com/IoTLabs-pl/hon, it doesn't download anything anymore, and you can't choose any version

I have just reverted back to beta 10 and pyhon 0.17.7 without problem. I have latest HA and HACS

I think there are problems with repository, it no longer allows you to select the version to download (see screenshot). I tried on 2 different HomeAssistant installed on different machines, same problem.

KameDomotics commented 3 weeks ago

is there a command to install beta 11 from ssh terminal?

KameDomotics commented 2 weeks ago

I managed to install Beta 11 (the problem was Hacs). It works better, but after a while it no longer updates the status. (dryer running, from the home assistant integration dryer is off). Not even reloading the hOn integration does it start working again.

Now I'm trying with beta 13

deezid commented 2 weeks ago

Did you check which pyhon version is installed? Here it stays connected throughout many cycles without any issues.

On Tue, 27 Aug 2024, 23:26 KameDomotics, @.***> wrote:

I managed to install Beta 11 (the problem was Hacs). It works better, but after a while it no longer updates the status. (dryer running, from the home assistant integration dryer is off). Not even reloading the hOn integration does it start working again.

— Reply to this email directly, view it on GitHub https://github.com/IoTLabs-pl/hon/issues/2#issuecomment-2313446372, or unsubscribe https://github.com/notifications/unsubscribe-auth/AXRWXSGVK6XR5YT3FPVFWY3ZTTOGTAVCNFSM6AAAAABMN7KHY6VHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZDGMJTGQ2DMMZXGI . You are receiving this because you were mentioned.Message ID: @.***>

KameDomotics commented 2 weeks ago

Did you check which pyhon version is installed? Here it stays connected

throughout many cycles without any issues.

On Tue, 27 Aug 2024, 23:26 KameDomotics, @.***> wrote:

I managed to install Beta 11 (the problem was Hacs). It works better, but

after a while it no longer updates the status. (dryer running, from the

home assistant integration dryer is off). Not even reloading the hOn

integration does it start working again.

—

Reply to this email directly, view it on GitHub

https://github.com/IoTLabs-pl/hon/issues/2#issuecomment-2313446372, or

unsubscribe

https://github.com/notifications/unsubscribe-auth/AXRWXSGVK6XR5YT3FPVFWY3ZTTOGTAVCNFSM6AAAAABMN7KHY6VHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZDGMJTGQ2DMMZXGI

.

You are receiving this because you were mentioned.Message ID:

@.***>

pyhOn 0.18.0-beta.2

Beta-13 doesn't work for me either. From the hOn app it works fine instead.

KameDomotics commented 2 weeks ago
Logger: homeassistant.config_entries
Source: config_entries.py:772
First occurred: 22:47:57 (1 occurrences)
Last logged: 22:47:57

Error unloading entry xxxxx@gmail.com for hon
Traceback (most recent call last):
  File "/usr/src/homeassistant/homeassistant/config_entries.py", line 772, in async_unload
    result = await component.async_unload_entry(hass, self)
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/config/custom_components/hon/__init__.py", line 59, in async_unload_entry
    ]._api._session._auth.get_refresh_token()
                          ^^^^^^^^^^^^^^^^^
AttributeError: 'HonAuth' object has no attribute 'get_refresh_token'. Did you mean: 'get_access_token'?
Logger: pyhon.connection.mqtt
Source: /usr/local/lib/python3.12/site-packages/pyhon/connection/mqtt.py:119
First occurred: 22:45:28 (1 occurrences)
Last logged: 22:45:28

MQTT loop broken
Traceback (most recent call last):
  File "/usr/local/lib/python3.12/site-packages/backoff/_async.py", line 151, in retry
    ret = await target(*args, **kwargs)
          ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.12/site-packages/pyhon/connection/mqtt.py", line 175, in loop
    self._subscriptions[message.topic].handler(message)
  File "/usr/local/lib/python3.12/site-packages/pyhon/connection/mqtt.py", line 105, in _status_handler
    appliance.attributes["parameters"][parameter["parName"]].update(parameter)
    ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^
KeyError: 'opt1'