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
73.51k stars 30.71k forks source link

Zigbee - [bellows.uart] CRC error in frame b'004421a1addb537e' (b'db53' != b'4e9f') #37733

Closed mkanet closed 4 years ago

mkanet commented 4 years ago

The problem

Hi There, I am using a HUSBZB-1 USB stick. I am getting error log messages in Home Assistant's regularly like the ones below. The these errors are triggered when my Home Assistant automations turn on lights (when motion is detected with my Zigbee "CentraLite" motion sensors).

2020-07-09 17:12:54 ERROR (bellows.thread_0) [bellows.uart] CRC error in frame b'004421a1addb537e' (b'db53' != b'4e9f')
2020-07-09 17:18:55 ERROR (bellows.thread_0) [bellows.uart] CRC error in frame b'0023c8a1aded0c7e' (b'ed0c' != b'78c0')
2020-07-09 17:31:06 ERROR (bellows.thread_0) [bellows.uart] CRC error in frame b'00729ba1ade91d7e' (b'e91d' != b'7cd1')
2020-07-09 18:29:46 ERROR (bellows.thread_0) [bellows.uart] CRC error in frame b'006330a1adc9637e' (b'c963' != b'5caf')
2020-07-09 18:33:26 ERROR (bellows.thread_0) [bellows.uart] CRC error in frame b'0075d6a1ade7cc7e' (b'e7cc' != b'7200')
2020-07-09 22:47:47 ERROR (bellows.thread_0) [bellows.uart] CRC error in frame b'006774a1adc2ff7e' (b'c2ff' != b'5733')
2020-07-10 00:26:14 ERROR (bellows.thread_0) [bellows.uart] CRC error in frame b'0011b2a1ad33447e' (b'3344' != b'a688')
2020-07-10 01:22:51 ERROR (bellows.thread_0) [bellows.uart] CRC error in frame b'005429a1ad69557e' (b'6955' != b'fc99')
2020-07-10 01:26:52 ERROR (bellows.thread_0) [bellows.uart] CRC error in frame b'0010c5a1ad18687e' (b'1868' != b'8da4')
2020-07-10 01:38:04 ERROR (bellows.thread_0) [bellows.uart] CRC error in frame b'000293a1ad02c97e' (b'02c9' != b'9705')
2020-07-10 02:40:19 ERROR (bellows.thread_0) [bellows.uart] CRC error in frame b'003233b1ed542e14b459954b65ab55929d63fb644312316083cecc6389ec7ea39d7e' (b'a39d' != b'49f0')
2020-07-10 03:02:07 ERROR (bellows.thread_0) [bellows.uart] CRC error in frame b'002546a1adeace7e' (b'eace' != b'7f02')
2020-07-10 03:10:08 ERROR (bellows.thread_0) [bellows.uart] CRC error in frame b'005479a1ad379b7e' (b'379b' != b'a257')
2020-07-10 03:31:01 ERROR (bellows.thread_0) [bellows.uart] CRC error in frame b'00418aa1ad2a7b7e' (b'2a7b' != b'bfb7')
2020-07-10 04:09:56 ERROR (bellows.thread_0) [bellows.uart] CRC error in frame b'0001a2a1ad6b807e' (b'6b80' != b'fe4c')
2020-07-10 05:01:53 ERROR (bellows.thread_0) [bellows.uart] CRC error in frame b'006370a1add4ce7e' (b'd4ce' != b'4102')
2020-07-10 05:56:41 ERROR (bellows.thread_0) [bellows.uart] CRC error in frame b'0007e4a1ade3147e' (b'e314' != b'76d8')
2020-07-10 06:43:08 ERROR (bellows.thread_0) [bellows.uart] CRC error in frame b'000398a1ad848c7e' (b'848c' != b'1140')
2020-07-10 06:43:38 ERROR (bellows.thread_0) [bellows.uart] CRC error in frame b'00679ca1adcb6f7e' (b'cb6f' != b'5ea3')
2020-07-10 06:48:00 ERROR (bellows.thread_0) [bellows.uart] CRC error in frame b'007546a1ad9ff57e' (b'9ff5' != b'0a39')
2020-07-10 08:02:02 ERROR (bellows.thread_0) [bellows.uart] CRC error in frame b'00521ba1ade5097e' (b'e509' != b'70c5')
2020-07-10 13:45:50 ERROR (bellows.thread_0) [bellows.uart] CRC error in frame b'0020bda1ad45287e' (b'4528' != b'd0e4')

These errors all have the below in common:
2020-07-10 13:52:11 ERROR (bellows.thread_0) [bellows.uart] CRC error in frame b'00....a1ad....7e' (b'....' != b'....')

Zigbee devices:

Environment

Problem-relevant configuration.yaml

database_path: /config/zigbee.db

Traceback/Error logs

2020-07-09 17:12:54 ERROR (bellows.thread_0) [bellows.uart] CRC error in frame b'004421a1addb537e' (b'db53' != b'4e9f')
2020-07-09 17:18:55 ERROR (bellows.thread_0) [bellows.uart] CRC error in frame b'0023c8a1aded0c7e' (b'ed0c' != b'78c0')
2020-07-09 17:31:06 ERROR (bellows.thread_0) [bellows.uart] CRC error in frame b'00729ba1ade91d7e' (b'e91d' != b'7cd1')
2020-07-09 17:36:23 WARNING (MainThread) [homeassistant.helpers.entity] Update of sensor.gpu is taking over 10 seconds
2020-07-09 17:36:23 ERROR (SyncWorker_3) [homeassistant.components.rest.sensor] Error fetching data: http://192.168.1.2:61208/api/3/gpu failed with HTTPConnectionPool(host='192.168.1.2', port=61208): Read timed out. (read timeout=10)
2020-07-09 17:36:23 WARNING (SyncWorker_3) [homeassistant.components.rest.sensor] Empty reply found when expecting JSON data
2020-07-09 17:36:23 ERROR (MainThread) [homeassistant.components.template.sensor] Could not render template horizon_gpu_memory: UndefinedError: 'mappingproxy object' has no attribute 'mem'
2020-07-09 17:36:24 WARNING (MainThread) [homeassistant.components.alexa.capabilities] Invalid temp value  for sensor.horizon_gpu_temperature
2020-07-09 18:29:46 ERROR (bellows.thread_0) [bellows.uart] CRC error in frame b'006330a1adc9637e' (b'c963' != b'5caf')
2020-07-09 18:33:26 ERROR (bellows.thread_0) [bellows.uart] CRC error in frame b'0075d6a1ade7cc7e' (b'e7cc' != b'7200')
2020-07-09 20:10:42 WARNING (MainThread) [homeassistant.helpers.entity] Update of sensor.gpu is taking over 10 seconds
2020-07-09 20:10:42 ERROR (SyncWorker_1) [homeassistant.components.rest.sensor] Error fetching data: http://192.168.1.2:61208/api/3/gpu failed with HTTPConnectionPool(host='192.168.1.2', port=61208): Read timed out. (read timeout=10)
2020-07-09 20:10:42 WARNING (SyncWorker_1) [homeassistant.components.rest.sensor] Empty reply found when expecting JSON data
2020-07-09 20:10:42 ERROR (MainThread) [homeassistant.components.template.sensor] Could not render template horizon_gpu_memory: UndefinedError: 'mappingproxy object' has no attribute 'mem'
2020-07-09 20:10:42 WARNING (MainThread) [homeassistant.components.alexa.capabilities] Invalid temp value  for sensor.horizon_gpu_temperature
2020-07-09 22:47:47 ERROR (bellows.thread_0) [bellows.uart] CRC error in frame b'006774a1adc2ff7e' (b'c2ff' != b'5733')
2020-07-10 00:26:14 ERROR (bellows.thread_0) [bellows.uart] CRC error in frame b'0011b2a1ad33447e' (b'3344' != b'a688')
2020-07-10 01:22:51 ERROR (bellows.thread_0) [bellows.uart] CRC error in frame b'005429a1ad69557e' (b'6955' != b'fc99')
2020-07-10 01:26:52 ERROR (bellows.thread_0) [bellows.uart] CRC error in frame b'0010c5a1ad18687e' (b'1868' != b'8da4')
2020-07-10 01:38:04 ERROR (bellows.thread_0) [bellows.uart] CRC error in frame b'000293a1ad02c97e' (b'02c9' != b'9705')
2020-07-10 02:40:19 ERROR (bellows.thread_0) [bellows.uart] CRC error in frame b'003233b1ed542e14b459954b65ab55929d63fb644312316083cecc6389ec7ea39d7e' (b'a39d' != b'49f0')
2020-07-10 03:02:07 ERROR (bellows.thread_0) [bellows.uart] CRC error in frame b'002546a1adeace7e' (b'eace' != b'7f02')
2020-07-10 03:10:08 ERROR (bellows.thread_0) [bellows.uart] CRC error in frame b'005479a1ad379b7e' (b'379b' != b'a257')
2020-07-10 03:31:01 ERROR (bellows.thread_0) [bellows.uart] CRC error in frame b'00418aa1ad2a7b7e' (b'2a7b' != b'bfb7')
2020-07-10 04:09:56 ERROR (bellows.thread_0) [bellows.uart] CRC error in frame b'0001a2a1ad6b807e' (b'6b80' != b'fe4c')
2020-07-10 04:15:57 ERROR (MainThread) [aiohttp.server] Error handling request
Traceback (most recent call last):
  File "/usr/local/lib/python3.7/site-packages/aiohttp/web_protocol.py", line 275, in data_received
    messages, upgraded, tail = self._request_parser.feed_data(data)
  File "aiohttp\_http_parser.pyx", line 523, in aiohttp._http_parser.HttpParser.feed_data
aiohttp.http_exceptions.BadStatusLine: invalid HTTP method
2020-07-10 05:01:53 ERROR (bellows.thread_0) [bellows.uart] CRC error in frame b'006370a1add4ce7e' (b'd4ce' != b'4102')
2020-07-10 05:56:41 ERROR (bellows.thread_0) [bellows.uart] CRC error in frame b'0007e4a1ade3147e' (b'e314' != b'76d8')
2020-07-10 06:43:08 ERROR (bellows.thread_0) [bellows.uart] CRC error in frame b'000398a1ad848c7e' (b'848c' != b'1140')
2020-07-10 06:43:38 ERROR (bellows.thread_0) [bellows.uart] CRC error in frame b'00679ca1adcb6f7e' (b'cb6f' != b'5ea3')
2020-07-10 06:48:00 ERROR (bellows.thread_0) [bellows.uart] CRC error in frame b'007546a1ad9ff57e' (b'9ff5' != b'0a39')
2020-07-10 08:02:02 ERROR (bellows.thread_0) [bellows.uart] CRC error in frame b'00521ba1ade5097e' (b'e509' != b'70c5')
2020-07-10 09:05:40 WARNING (MainThread) [homeassistant.helpers.entity] Update of sensor.gpu is taking over 10 seconds
2020-07-10 09:05:40 ERROR (SyncWorker_4) [homeassistant.components.rest.sensor] Error fetching data: http://192.168.1.2:61208/api/3/gpu failed with HTTPConnectionPool(host='192.168.1.2', port=61208): Read timed out. (read timeout=10)
2020-07-10 09:05:40 WARNING (SyncWorker_4) [homeassistant.components.rest.sensor] Empty reply found when expecting JSON data
2020-07-10 09:05:40 ERROR (MainThread) [homeassistant.components.template.sensor] Could not render template horizon_gpu_memory: UndefinedError: 'mappingproxy object' has no attribute 'mem'
2020-07-10 09:05:40 WARNING (MainThread) [homeassistant.components.alexa.capabilities] Invalid temp value  for sensor.horizon_gpu_temperature
2020-07-10 13:45:50 ERROR (bellows.thread_0) [bellows.uart] CRC error in frame b'0020bda1ad45287e' (b'4528' != b'd0e4')
2020-07-10 13:52:11 ERROR (bellows.thread_0) [bellows.uart] CRC error in frame b'00626ba1ad11e87e' (b'11e8' != b'8424')
2020-07-10 14:12:34 ERROR (MainThread) [homeassistant.components.alexa.state_report] Error when sending ChangeReport to Alexa: INVALID_ACCESS_TOKEN_EXCEPTION: Access token is not valid.

Additional information

Adminiuga commented 4 years ago

There was a similar report in the past, but not as many you have. Does it work at all? Just trying to see if all frames are with bad crc or only some of them. Other than that, but sure what could be done. The frame has wrong crc then it either was corrupted during transmission (unlikely, it's USB serial) or it was sent incorrectly by the stick. What radio are you using and can you enable debug logging and provide logs of ZHA starting? Would like to see the stack version. Usually around EZSP reset

mkanet commented 4 years ago

My Zigbee devices seem to be working correctly. Even during generating these errors.

Radio Type: ezsp: Silicon Labs EmberZNet protocol [HUSBZB-1 USB] Windows 10 64bit drivers (latest version from website)

EZSP Stack Type: 2, Stack Version: 21520

Please forgive me, but I wasn't sure which part of my log is the ZHA startup. I hope it's okay I just attached the whole log during system startup. No CRC errors were generated in the debug log. The CRC errors seem to happen a few hours after startup. If you think it would help, I could provide debug logs when the CRC errors happen as well:

home-assistant.log

If there's any other information I can provide to help narrow down the issue, please let me know.

Adminiuga commented 4 years ago

Stack version I was looking for. and seems you are running standard version of husbzb. Are you running a hassos image in virtual box? Probably has something to do with virtualization, although must be something specific to your setup, cause I don't hear too many complains. I do run dev environment in a virtual box, but don't really see that many errors.

mkanet commented 4 years ago

Yes. I'm using the hassos image in Virtualbox. This issue starting to make sense. I've had another issue where Virtualbox locks up after 2-3 days of use. I should have known that both issues were related. I was told to submit my Virtualbox log files to the Virtualbox Forum thread below next time it locks up.

https://forums.virtualbox.org/viewtopic.php?f=6&t=98938

Thank you very much for helping me. At least I know there isn't much that can be done in the HASSOS side of things.

probot-home-assistant[bot] commented 4 years ago

zha documentation zha source (message by IssueLinks)

probot-home-assistant[bot] commented 4 years ago

Hey there @dmulcahey, mind taking a look at this issue as its been labeled with an integration (zha) you are listed as a codeowner for? Thanks! (message by CodeOwnersMention)

mkanet commented 4 years ago

For the record, I'm seeing the below error messages in the Virtualbox logs. I know that my ZHA radio is on serial0:


00:00:29.714657 Serial#0: Failed to change parameters to 115200,NONE,5,1 -> VERR_IO_GEN_FAILURE
00:00:29.716643 Serial#0: Failed to change parameters to 115200,SPACE,8,2 -> VERR_IO_GEN_FAILURE
00:00:29.718710 Serial#0: Failed to change parameters to 115200,NONE,5,1 -> VERR_IO_GEN_FAILURE
00:00:29.720694 Serial#0: Failed to change parameters to 115200,NONE,5,1 -> VERR_IO_GEN_FAILURE
00:00:29.722925 Serial#0: Failed to change parameters to 115200,NONE,5,1 -> VERR_IO_GEN_FAILURE
00:00:29.725657 Serial#0: Failed to change parameters to 115200,NONE,5,1 -> VERR_IO_GEN_FAILURE```
Adminiuga commented 4 years ago

Hrm, I wonder if hassos trying to spawn a serial console on serial 0. If you are using HUSBZB-1, then zha would use 57600 baudrate by default, so setting speed to 115200 must be done by something else

mkanet commented 4 years ago

I really appreciate your help. I have EventGhost installed on the Host computer that controls another USB->Serial device (USB UIRT). It's possible EventGhost maybe be interfering with VirtualBox using the HUSBZB-1.

Maybe if I define a USB filter for my HUSBZB-1 in VirtualBox, that would prevent other apps from trying to control my HUSBZB-1.

Adminiuga commented 4 years ago

🤷 Try disabling it temporarily and see if it makes a difference.

mkanet commented 4 years ago

I finally figured out what's going on. If I add all my USB devices to the VirtualBox USB filter list (except for the HUSBZB-1), I don't have any more issues. However, that causes the devices I added to the filter list to be completely disabled on VirtualBox and the HOST too.

Does anyone know how I can disable/hide the offending USB devices from VirtualBox ONLY? I'm not even sure what use VirtualBox's USB filter has if it's going to completely disconnect the devices from everything. If I wanted to do that, I'll just plug these devices completely/physically from the entire PC.

Adminiuga commented 4 years ago

you lost me there. If you don't add a device to VirtualBox USB filter, the devices won't be claimed/passed through to Virtualbox. If you don't add HUSBZB to the filter, how does it work on virtualbox?

mkanet commented 4 years ago

When I add my USB-UIRT device to VirtualBox's USB filter list, the issue completely goes away. However, doing that also completely disables/hides that device from the HOST PC. In other words, that device won't even show in Windows Device Manager while it's in VirtualBox's USB filter list. Of course, I can't leave it this way, since I completely depend on my USB-UIRT device on my HOST PC for another Windows application.

I was hoping VirtualBox's USB filter would hide/disable these devices from the Guest. Unfortunately, it hides/disables these devices from the Host instead.

I'm not sure how to force VirtualBox to only use the HUSBZB USB device without it conflicting with my other USB device(s). These USB devices don't have any conflicts at all in a pure Windows environment.

Do you have any ideas on how I might avoid this issue without buying another PC/device? Surely, there has to be some kind of solution.

Adminiuga commented 4 years ago

What is USB -UIRT device? Just only add husbzb-1 to usb filter, so it's hidden from the host

mkanet commented 4 years ago

USB-UIRT is a USB device that allows a PC to send and receive IR signals to and from IR devices.

Currently, VirtualBox is configured to forward Windows OS Serial port COM3 and COM4 --> Ubuntu VM usb_path: /dev/ttyS0 and /dev/ttyS1 (with no USB filters configured) like this: Portmapping

If I add HUSBZB-1 to USB Filter (while having the above port mappings), Home Assistant says all my ZWave/ZHA entities are Unavailable. Windows OS Serial port COM3/COM4 also disappears from Windows Device Manager.

Could you please tell me how to configure Home Assistant so my ZHA and Z-wave devices are usable again (after adding HUSBZB-1 to VirtualBox USB filter)? Below, is all the ports Home Assistant can currently see (after I added HUSBZB-1 to USB filter): Screenshot

Thank you so much for all your help!

Adminiuga commented 4 years ago

You don't need to forward the serial ports. Remove serial ports from VM guest and just add the filter for HUSBZB device. This would hide husbzb and its serial ports from the host OS and apps, so nothing could mess with it.

Adminiuga commented 4 years ago

After you add filter to VM, you may have to reboot the guest.

mkanet commented 4 years ago

I removed the forwarded serial ports (keeping the filter for HUSBZB device).. .then rebooted the guest. I also rebooted the entire host. This is all I did.

It looks like something is missing or wrong. All my Z-wave/Zigbee entities are still "Unavailable". I am also getting several errors in my Home Assistant Log: home-assistant.log

Screenshot

It looks like simply adding HUSBZB USB to the VirtualBox USB filters is not enough. Home Assistant can't see the radios: Screenshot

Adminiuga commented 4 years ago

Hrm, well, I don't really know how are you doing it. In my environment, after filter is added and I plug husbzb-1, it automatically gets captured by Virtual box image

and I get is in my guest OS image

I've just right-clicked on USB device in VBox and created a filter for it image

image

mkanet commented 4 years ago

Thank you so much for going out of your way to assist me. This is exactly how I did it too. However, the ports are not passed to the VM after adding the husbzb-1 to the USB filter list. The only difference is that my host OS is Windows.

Do you have any suggestions on where the issue might be so I can narrow it down? My husbzb-1 is not connected directly to my PC, it is connected to a USB powered hub. I will try to connect it directly to my PC to see if it makes any difference.

Adminiuga commented 4 years ago

I don't know then. I'm also running on windows 10 and the screen shots were from two different guests one with debian buster and 2nd is a HASSOS

There was an issue in the past, were you had to edit USB delete windows filter in registry editor https://forums.virtualbox.org/viewtopic.php?f=2&t=37326 to make Virtual Box USB filter work

When in VM Guest you click on Devices -> USB -> Silabs, does it have a checkbox indicating it was captured by the guest?

mkanet commented 4 years ago

Okay, I made significant progress (I think), after I connected my husbzb-1 directly to my PC, disabled the serial port mappings, and added the device to USB filter... the radios are now detected by Home Assistant: USB Edit: It looks like these devices are showing up as "audio" (see above screenshot). I'm not sure if it's supposed to say that or not.

However, the respective entities for all my Z-wave/ZHA devices are still showing has, "Unavailable". I still have the below lines in my configuration.yaml. I'm not sure if I'm supposed to change anything in the configuration.yaml or in the GUI.

  usb_path: /dev/ttyS1
  device_config: !include zwave_device_config.yaml
  network_key: "0xf1, 0x6d, 0xb7, 0xa7, 0x17, 0x6a, 0x4c, 0x2f, 0x20, 0xba, 0x30, 0xea, 0xdd, 0x98, 0x8c, 0xee"

zha:
  database_path: /config/zigbee.db

Below, is the respective Home Assistant Log: home-assistant.log

dmulcahey commented 4 years ago

Deleted previous comment because I didn’t look at the log. You are still having port issues with ZHA in HA. My guess is the port mapping changed and you need to update it in the config entry

mkanet commented 4 years ago

Could you please tell me the lines (with respective ports) to add to my config? Sorry, I'm not very familiar with Linux ports. Below, is what I have shown in the GUI: Linux-ports

Adminiuga commented 4 years ago

disabled the serial port mappings,

Yeah, if the host OS claims the serial ports for mapping to VM, the underlying USB device won't be available.

The port path has changed, so you have two options:

  1. The full proof one: remove ZHA integration, restart HA, configure ZHA integration and pick serial-by-id port containing -if01. But you would loose all ZHA entities customizations
  2. Edit /config/.storage/core.config_entries and carefully replace the port path for ZHA config entry. Very error prone, easy to break other integrations. Do it on your own risk and only if you are comfortable restoring from the backup
mkanet commented 4 years ago

Thank you. I will do the foolproof way. I feel bad for asking, but do you mind telling me what port path to specify in my configuration.yaml for my z-wave radio to work? Would I also have to delete the z-wave integration too (and add it back) after I change the port in my configuration.yaml?

EDIT; Do I need to change _usbpath: /dev/ttyS1 to the below line?

usb_path: /dev/serial/by-id/usb-Silicon_Labs_HubZ_Smart_Home_Controller_81300462-if00-port0

zwave:
  usb_path: /dev/ttyS1
  device_config: !include zwave_device_config.yaml
  network_key: "0xf1, 0x6d, 0xb7, 0xa7, 0x17, 0x6a, 0x4c, 0x2f, 0x20, 0xba, 0x30, 0xea, 0xdd, 0x98, 0x8c, 0xee"

I REALLY appreciate all your help!

Adminiuga commented 4 years ago

Hrm, that part of configuration doesn't have to do with ZHA integration, but ZWave one. HUSBZB-1 has two radios, so two integrations ares referencing the same physical device, just two different USB-Serial ports.

AH, yeah, if you want the ZWave port by serial id, that looks like correct one. However you would need to check the docs. I was not following ZWave develepement, but it could be that changes to configuration.yaml are not registered with integration which is using a config entry imported from configuration.yaml. The worst could happen, zwave won't start, so you would need to roll back the changes. But I thought the new recommendation is to use the new ZWave-to-MQTT integration, as old one is being deprecated and all dev resources are focusing on ZWave-to-MQTT

mkanet commented 4 years ago

I was able to get Z-wave working! I just used the by serial id I posted earlier. Now, all I have to do is delete the ZHA integration and add it back.... going to try now...

Adminiuga commented 4 years ago

Nah, check your serial by id path, yours is going to be different. if you followed the tuorialals, those are getting out-of-date quite quickly, so pick those with a grain of salt. For questsions, better join HA discord server. There're channels for zigbee and zwave.

I'm going to close this issue now, as it really not a bellows/zha problem.

mkanet commented 4 years ago

I am able to see ALL my devices (ZHA and Zigbee) after a reboot (using USB filter in VirtualBox). I'm hoping that the CRC errors are gone for good! Thanks again for all your help.

mkanet commented 4 years ago

UPDATE; I just wanted to report that this issue never returned after successfully adding my HUSBZB-1 device to VirtualBox's USB filter. Thank you for all your help!