home-assistant / core

:house_with_garden: Open source home automation that puts local control and privacy first.
https://www.home-assistant.io
Apache License 2.0
71.06k stars 29.73k forks source link

Broadlink Component - Handling Of Communication Errors #37361

Closed Silvenga closed 3 years ago

Silvenga commented 4 years ago

The problem

It appears that the Broadlink component will not process commands after the remote device is marked as unavailable.

Environment

Problem-relevant configuration.yaml

remote:
- platform: broadlink
  host: 192.168.2.144
  mac: blah
  type: rm4_mini
  name: Servers Broadlink
sensor:
- platform: broadlink
  host: 192.168.2.144
  mac: blah
  type: rm4_mini
  name: Servers Broadlink
  scan_interval: 60
  monitored_conditions:
    - temperature
    - humidity

Traceback/Error logs

cat home-assistant.log | grep broad
2020-07-01 21:19:34 INFO (SyncWorker_36) [homeassistant.loader] Loaded broadlink from homeassistant.components.broadlink
2020-07-01 21:19:34 INFO (MainThread) [homeassistant.components.remote] Setting up remote.broadlink
2020-07-01 21:19:37 INFO (MainThread) [homeassistant.components.sensor] Setting up sensor.broadlink
2020-07-01 22:01:21 WARNING (MainThread) [homeassistant.components.broadlink.device] Disconnected from device at 192.168.2.144: Control key is expired
2020-07-01 22:02:17 WARNING (MainThread) [homeassistant.components.broadlink.device] Connected to device at 192.168.2.144
2020-07-01 23:31:47 WARNING (MainThread) [homeassistant.components.broadlink.device] Disconnected from device at 192.168.2.144: Control key is expired
2020-07-01 23:32:39 WARNING (MainThread) [homeassistant.components.broadlink.device] Connected to device at 192.168.2.144
2020-07-02 01:02:10 WARNING (MainThread) [homeassistant.components.broadlink.device] Disconnected from device at 192.168.2.144: Control key is expired
2020-07-02 01:02:10 ERROR (MainThread) [homeassistant.components.broadlink.remote] Failed to send 'fan only/server ac': The device is offline
2020-07-02 02:32:25 WARNING (MainThread) [homeassistant.components.broadlink.device] Disconnected from device at 192.168.2.144: Control key is expired
2020-07-02 02:33:20 WARNING (MainThread) [homeassistant.components.broadlink.device] Connected to device at 192.168.2.144
2020-07-02 05:23:55 WARNING (MainThread) [homeassistant.components.broadlink.device] Disconnected from device at 192.168.2.144: Control key is expired
2020-07-02 05:24:51 WARNING (MainThread) [homeassistant.components.broadlink.device] Connected to device at 192.168.2.144
2020-07-02 09:10:22 WARNING (MainThread) [homeassistant.components.broadlink.device] Disconnected from device at 192.168.2.144: Control key is expired
2020-07-02 09:11:15 WARNING (MainThread) [homeassistant.components.broadlink.device] Connected to device at 192.168.2.144

Additional information

wipeout666 commented 3 years ago

Felipe, you were successful using a RM mini 3, offline, without reboots?

I've read in this thread about downgrades; how do I find out which version I have? I'd like to try matching your version. If we share the same firmware, I don't which it wouldn't work, except that maybe I've done something wrong with the python execution. If we do share the same firmware version, I'll know where to look.

Let me know,

Thanks for your help

felipediel commented 3 years ago

I tested with RM mini 3 0x2737 running v57. I don't recommend you to mess with the firmware. If it doesn't work, you will "brick" your device forever.

wipeout666 commented 3 years ago

Felipe, I'll try the update once it become available. It may just be that I did something wrong. Let me know when it's part of the main code, I'll update and try again.

Castelvielh commented 3 years ago

Hello @felipediel, now your code for a heartbeat is ready and has passed all the tests to be merged in the main branch of Home Assistant, do you know how long it usually takes to be part of the official releases?

felipediel commented 3 years ago

It may take a while, the code still needs to go through review and devops. You can try the workarounds for now.

Did you try to disable UPnP on your main router?

Internet -> Router A -> Router B -> Broadlink device

Disable UPnP on router A and the device stops rebooting. Another option is the Dockerfile mentioned above, it looks good.

Castelvielh commented 3 years ago

An update for the support of the last versions of Apple tvOS took something like 5-6 months to end up in an official Home Assistant release, this is why I asked... It will probably be the same for your new feature, let's just be patient about it.

Regarding the workaround you're talking about, I indeed have this configuration with 2 routers. The router A already had the UPnP disabled, while the router B has it enabled (for Home Assistant to gather the network throughput data) and the router B denies all internet access to the Broadlink RM Mini 3 (which I would like not to change). And the problem is still there, the heartbeat seems to me the best workaround, without modifyind the Broadlink firmware and removing the rebooting process.

As it is not a too painful problem, I'll just wait for your code to be added to the main branch, I'd prefer avoiding tweaking my Home Assistant install too much, in case of a possible future reinstall. But thank you very much for your quick answer!

MarkHofmann11 commented 3 years ago

Sorry to add more to the thread, but to add to what was already discussed, it appears the newest rm3 minis on the market right now will constantly reset internally to try and connect to the cloud when they are being blocked by a firewall. Thus you see these messages - only my new rm3 mini does this. The other (2) older models don't behave like this.

2021-05-12 16:09:30 ERROR (MainThread) [homeassistant.components.broadlink.updater] Error fetching Marks Office - IR Remote #2 (RM mini 3 at 192.168.0.126) data: [WinError 10054] An existing connection was forcibly closed by the remote host 2021-05-12 16:27:33 ERROR (MainThread) [homeassistant.components.broadlink.updater] Error fetching Marks Office - IR Remote #2 (RM mini 3 at 192.168.0.126) data: [WinError 10054] An existing connection was forcibly closed by the remote host 2021-05-12 16:45:36 ERROR (MainThread) [homeassistant.components.broadlink.updater] Error fetching Marks Office - IR Remote #2 (RM mini 3 at 192.168.0.126) data: [WinError 10054] An existing connection was forcibly closed by the remote host

I'll see if allowing it to the cloud stops the errors, but then I'm concerned it won't work with HA (which was my original issue). It seems the new rm3 minis suffer from this particular issue.

wipeout666 commented 6 days ago

@felipediel gave it a try again today with HA core 2024.8.3. Believe it or not, blocking internet access to my RM3 still yield a reboot every couple of minutes. No internet blocking, no reboots at all.

Am I missing something? Do I need to enable the heartbeat function in the integration? Was it incorporated in the production builds of Home Assistant at all?

Let me know how can I help you debug this

felipediel commented 6 days ago

The original issue has been resolved, but there may still be other firmware versions that require attention. Someone needs to capture the keepalive packets for your firmware and submit a pull request to the library. Unfortunately, I’m unable to work on this at the moment. Please open a new issue so others can see it