mill1000 / midea-ac-py

Home Assistant custom integration to control Midea (and associated brands) air conditioners via LAN.
MIT License
151 stars 16 forks source link

Device became unavailable #137

Closed FaceStealerrog closed 4 months ago

FaceStealerrog commented 5 months ago

Hi,

I'm using this integration to connect my inventor units and most of the time it works greats. But i noticed in the log files that the 3 devices often became unavailable... sometimes for minutes. Is this a known issue and so yes can I resolve this?

mill1000 commented 5 months ago

Are you blocking the devices from internet access? Other users have reported issues with their devices when they have.

Are the device becoming unavailable at regular intervals? Some devices need the Maximum Connection Lifetime configured to prevent going unavailable at regular intervals, usually 2-3 minutes.

FaceStealerrog commented 5 months ago

Hi,

Thanks for your quick response! I'm not blocking any internet access. How long should i configure, 90 seconds?

mill1000 commented 5 months ago

It would be best to start with some debug logs of your devices when they go unavailable.

bharvey88 commented 4 months ago

fwiw i was having the same issue. I just set it to 30seconds and it stopped reconnecting every ~2minutes.

in the logs i just see a bunch of failed connections and transport errors. I believe there's actually a bug here but i'm not sure.

in the debug logs i see lots of 2024-05-21 13:30:26.992 ERROR (MainThread) [msmart.base_device] Network error 192.168.1.78:6444: Transport is closing or closed. and Unsupported packet: f28758727334de2b858f36748a5aa95af0907f11f4cb5439f1cb2fe21f0d7e0cf8fd91b21bb93b5ae8fcb9156b3456d69742fe36069ca61bff6ca3c95d6eb8f2 2024-05-21 14:27:15.015 ERROR (MainThread) [msmart.base_device] Network error 192.168.1.78:6444: Error packet received.

mill1000 commented 4 months ago

Can you post your full logs? That Unsupported packet message is particularly interesting.

bharvey88 commented 4 months ago

Can you post your full logs? That Unsupported packet message is particularly interesting.

I didnt post the full file cuz it has sensitive data that wasnt stripped from frigate and i wasnt sure about possibly leaking a token or some other info with this integration as well. I can try to sanitize and then upload in a few

mill1000 commented 4 months ago

There's nothing really sensitive in this integration logs, so if you can filter to them to this integration and msmart only you'll be good.

bharvey88 commented 4 months ago

home-assistant_midea_ac_2024-05-22T01-53-35.167Z.log

i believe during this test i changed Maximum Connection Lifetime to 300 seconds and reloaded the integration.

mill1000 commented 4 months ago

Looks like none of the really interesting errors (the unsupported packet) occurred while your debug logging was enabled.

I also see that you have the midea_ac_lan integration installed. Two copies of it somehow. Can you ensure that integration is not configured to talk to the device in question.

bharvey88 commented 4 months ago

It’s not using that custom component I moved to yours. I’ll remove it and capture more logs. Wil turning it on/off help? What should I set the timeout to in configure? Leave it blank so errors occur? FWIW I do not believe I observed this behavior of going unavailable with the other custom component. On Wed, May 22, 2024 at 11:36 AM Tucker Kern @.***> wrote:

Looks like none of the really interesting errors (the unsupported packet) occurred while your debug logging was enabled.

I also see that you have the midea_ac_lan integration installed. Two copies of it somehow. Can you ensure that integration is not configured to talk to the device in question.

— Reply to this email directly, view it on GitHub https://github.com/mill1000/midea-ac-py/issues/137#issuecomment-2125254608, or unsubscribe https://github.com/notifications/unsubscribe-auth/AB53NZSTVKF4CHK4KWORLR3ZDTCP7AVCNFSM6AAAAABHYKX722VHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZDCMRVGI2TINRQHA . You are receiving this because you commented.Message ID: @.***>

mill1000 commented 4 months ago

Wil turning it on/off help? What should I set the timeout to in configure? Leave it blank so errors occur?

I guess leave it blank for now. No need to turn the device on/off, just let the integration run for 10-15 minutes (or until you have issues with the unsupported packet messages).

FWIW I do not believe I observed this behavior of going unavailable with the other custom component.

Can't speak for midea_ac_lan but the original midea_ac_py pretty much just suppressed all network errors.

patrykwoj91 commented 4 months ago

Hello, I am using Your integration since few days with my MDV Aroma (Midea AC group) and I also face the issue with unavailability for both my units:

2024-05-22 23:40:37.156 ERROR (MainThread) [msmart.base_device] Network error 172.16.16.102:6444: Transport is closing or closed.
2024-05-22 23:40:49.189 ERROR (MainThread) [msmart.base_device] Network error 172.16.16.103:6444: Transport is closing or closed.
2024-05-22 23:42:52.213 ERROR (MainThread) [msmart.base_device] Network error 172.16.16.102:6444: Transport is closing or closed.
2024-05-22 23:43:05.039 ERROR (MainThread) [msmart.base_device] Network error 172.16.16.103:6444: Transport is closing or closed.
2024-05-22 23:45:07.216 ERROR (MainThread) [msmart.base_device] Network error 172.16.16.102:6444: Transport is closing or closed.
2024-05-22 23:45:20.039 ERROR (MainThread) [msmart.base_device] Network error 172.16.16.103:6444: Transport is closing or closed.
2024-05-22 23:47:22.214 ERROR (MainThread) [msmart.base_device] Network error 172.16.16.102:6444: Transport is closing or closed.
2024-05-22 23:47:35.040 ERROR (MainThread) [msmart.base_device] Network error 172.16.16.103:6444: Transport is closing or closed.
2024-05-22 23:49:37.165 ERROR (MainThread) [msmart.base_device] Network error 172.16.16.102:6444: Transport is closing or closed.

Should I give it a try with MaximumConnectionLifetime set to something like 2 minutes?

FaceStealerrog commented 4 months ago

Hi,

Sorry for my late response!

I did what @mill1000 said to do. And raised the Maximum Connection Lifetime to: 90sec

The connection is now stable, Thanks!

I only have some modes that are not working. For example, I cannot set the rotation of the fan. Neither can I change the position. No idea what causes this.

mill1000 commented 4 months ago

Should I give it a try with MaximumConnectionLifetime set to something like 2 minutes?

@patrykwoj91 Try 90 seconds. That seems like a good number for multiple people.

The connection is now stable, Thanks!

Well that's good to hear.

I only have some modes that are not working. For example, I cannot set the rotation of the fan. Neither can I change the position. No idea what causes this.

@FaceStealerrog Are these things supported by the OEM app for your device? If so, please enable debug logging, restart HA or reload the integration, and create a new issue.

FaceStealerrog commented 4 months ago

Hi @mill1000,

Yes this is supported by the OEM app. I will investigate some more and create a new issue if necessary. Thanks!

bharvey88 commented 4 months ago

Should I give it a try with MaximumConnectionLifetime set to something like 2 minutes?

@patrykwoj91 Try 90 seconds. That seems like a good number for multiple people.

The connection is now stable, Thanks!

Well that's good to hear.

I only have some modes that are not working. For example, I cannot set the rotation of the fan. Neither can I change the position. No idea what causes this.

@FaceStealerrog Are these things supported by the OEM app for your device? If so, please enable debug logging, restart HA or reload the integration, and create a new issue.

For fun i deleted my device and added it again from the integration. I noticed that when adding it this time, it got two new entities number.upstairs_ac_fan_speed and switch.upstairs_ac_purifier which both stay unavailable just like the other user.

Wil turning it on/off help? What should I set the timeout to in configure? Leave it blank so errors occur?

I guess leave it blank for now. No need to turn the device on/off, just let the integration run for 10-15 minutes (or until you have issues with the unsupported packet messages).

FWIW I do not believe I observed this behavior of going unavailable with the other custom component.

Can't speak for midea_ac_lan but the original midea_ac_py pretty much just suppressed all network errors.

home-assistant_midea_ac_2024-05-23T20-47-55.071Z.log 15 minutes of debug logs attached!

mill1000 commented 4 months ago

I noticed that when adding it this time, it got two new entities number.upstairs_ac_fan_speed and switch.upstairs_ac_purifier which both stay unavailable just like the other user.

Is your device off? Certain entities are unavailable when the device is off.

bharvey88 commented 4 months ago

no the device was power cycled and turned on then added it was never turned off during the log captures

mill1000 commented 4 months ago

Something is really strange with your logs. What version of HA are you running?

The unsupported packet error never occurs while debug logging is enabled.

There's a number of errors I've never seen before.

2024-05-23 15:32:58.520 ERROR (MainThread) [homeassistant.components.climate] Error adding entity None for domain climate with platform midea_ac
homeassistant.exceptions.HomeAssistantError: Can't link device to unknown config entry ddae8c00ec54d74cd00054f659c3a537

and

2024-05-23 15:33:25.766 WARNING (Recorder) [homeassistant.components.recorder.entity_registry] Cannot migrate history for entity_id `climate.midea_ac_40681930232708` to `climate.upstairs_ac` because the new entity_id is already in use
2024-05-23 15:33:25.783 WARNING (Recorder) [homeassistant.components.recorder.entity_registry] Cannot migrate history for entity_id `switch.midea_ac_40681930232708_display` to `switch.upstairs_ac_display` because the new entity_id is already in use
2024-05-23 15:33:25.794 WARNING (Recorder) [homeassistant.components.recorder.entity_registry] Cannot migrate history for entity_id `binary_sensor.midea_ac_40681930232708_filter_alert` to `binary_sensor.upstairs_ac_filter_alert` because the new entity_id is already in use
2024-05-23 15:33:25.799 ERROR (Recorder) [homeassistant.components.recorder.table_managers.statistics_meta] Cannot rename statistic_id `sensor.midea_ac_40681930232708_indoor_temperature` to `sensor.upstairs_ac_indoor_temperature` because the new statistic_id is already in use
2024-05-23 15:33:25.799 WARNING (Recorder) [homeassistant.components.recorder.entity_registry] Cannot migrate history for entity_id `sensor.midea_ac_40681930232708_indoor_temperature` to `sensor.upstairs_ac_indoor_temperature` because the new entity_id is already in use
2024-05-23 15:33:25.807 WARNING (Recorder) [homeassistant.components.recorder.entity_registry] Cannot migrate history for entity_id `sensor.midea_ac_40681930232708_outdoor_temperature` to `sensor.upstairs_ac_outdoor_temperature` because the new entity_id is already in use

Also the integration failed to query device capabilities, most likely due to network issues.

bharvey88 commented 4 months ago

i have a very stable home assistant setup running on an 8th gen intel i7 on latest stable haos 12.3 and core 2024.5.4.

ignore the recorder errors those are only there cuz i deleted the integration and added it again to start fresh and give you fresh logs. the warninga and errors are just saying it didnt merge some historical data when i renamed the device to the old device name.

mill1000 commented 4 months ago

Just making sure we aren't dealing with an out of date core.

I'd recommend adding the following to your configuration.yaml, removing all devices and adding one back.

logs:
    custom_components.midea_ac: info
    msmart: debug

Hopefully that should catch enough information to see what's going on.

bharvey88 commented 4 months ago

removing all devices of what? i only own one midea ac device

mill1000 commented 4 months ago

** Remove all devices associated with this integration.

So just your one device then.

bharvey88 commented 4 months ago

Just making sure we aren't dealing with an out of date core.

I'd recommend adding the following to your configuration.yaml, removing all devices and adding one back.

logs:
    custom_components.midea_ac: info
    msmart: debug

Hopefully that should catch enough information to see what's going on.

btw it's

logger:
  default: warning
  logs:
    custom_components.midea_ac: info
    msmart: debug

so i added the logs config to configuration.yaml, removed the device, restarted hass, added the device, and now it added back without the fan or air purifier entities i mentioned above showing up disabled but "existing".

logs have tokens and api keys. can you give me an email to send logs to please

mill1000 commented 4 months ago

tuckkern@gmail.com

mill1000 commented 4 months ago

@bharvey88 Looked at the logs you sent and nothing was out of the ordinary.

You do have regular disconnects about at the 2 minute mark (as you knew). So I would go back to the 90 second max connection lifetime.

raddah commented 3 months ago

Same issue on my side, any idea how to resolve this issue ?

Or do I have to open another issue ?

mill1000 commented 3 months ago

Same issue on my side, any idea how to resolve this issue ?

Or do I have to open another issue ?

Have you tried setting the maximum connection lifetime?

raddah commented 3 months ago

Same issue on my side, any idea how to resolve this issue ?

Or do I have to open another issue ?

Have you tried setting the maximum connection lifetime?

Hi I have configured 90 second is there any preferred time to configured more? please suggest

mill1000 commented 3 months ago

The correct value is device dependent, but 90 seconds is a common value.

raddah commented 3 months ago

I have done that configuration to 90 seconds still on the logs I can see Became unavailable screenshot below

Screenshot 2024-07-05 at 2 52 59 PM

raddah commented 3 months ago

While I was checking the AC today I noticed Wi-Fi signal from AC split display become off when same time as Home assistant dashboard card what could be the issue if we can investigate it more.

image

mill1000 commented 3 months ago

While I was checking the AC today I noticed Wi-Fi signal from AC split display become off when same time as Home assistant dashboard card what could be the issue if we can investigate it more.

Are you blocking the device from accessing the internet? That can cause the WiFi to periodically reboot.

raddah commented 3 months ago

While I was checking the AC today I noticed Wi-Fi signal from AC split display become off when same time as Home assistant dashboard card what could be the issue if we can investigate it more.

Are you blocking the device from accessing the internet? That can cause the WiFi to periodically reboot.

No I didn't block it but still showing Became unavailable on the logs and still dashboard disappeared for 30 - 50 seconds.

Is there any root cause for this appeared from recent issues when we do integration with Home Assistant?

Device WiFi from Nethome

image

mill1000 commented 3 months ago

Is there any root cause for this appeared from recent issues when we do integration with Home Assistant?

Sorry I don't understand your question.

You need to provide full debug logs of the disconnect occurring for me to try to help.

raddah commented 3 months ago

Is there any root cause for this appeared from recent issues when we do integration with Home Assistant?

Sorry I don't understand your question.

You need to provide full debug logs of the disconnect occurring for me to try to help.

How can I provide to you the logs while option

-d

not in

msmart-g

I'll be happy to support.

mill1000 commented 3 months ago

You can enable debug logging in Home Assistant on the integration page. Or you can enable it in your config YAML with

logger:
  default: warning
  logs:
    custom_components.midea_ac: info
    msmart: debug
raddah commented 3 months ago

home-assistant_2024-07-20T20-30-44.395Z.log

Please see logs attached

raddah commented 2 months ago

Another logs after debug enabled from GUI also. home-assistant_2024-07-21T01-33-07.403Z.log

mill1000 commented 2 months ago

@raddah Ah..you're devices must be similar to the ones in #188. They don't respond to capability requests, which causes the first burst of errors. After that, everything appears to be working OK