Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Tasmota ESP32 Matter Sonoff BasicR4 adding to Home Assistant #113279

Closed
MCheckN opened this issue Mar 13, 2024 · 11 comments · Fixed by home-assistant-libs/python-matter-server#684

Comments

@MCheckN
Copy link

MCheckN commented Mar 13, 2024

The problem

Sonoff Basic R4 flashed to Tasmota ESP32 13.4.0.2. Configured with template without Magic Button. When I try to connect device with Matter enabled to Home Assistant Matter integration, the integration itself hangs in HA. Even if there were successful Matter added devices in HA before that, after trying to add Tasmota device the integration hangs in an endless loop trying to restore integration. The only thing that helps is remove all integrations and reinstall Matter integration with addon from scratch

What version of Home Assistant Core has the issue?

2024.3.0

What was the last working version of Home Assistant Core?

No response

What type of installation are you running?

Home Assistant OS

Integration causing the issue

Matter

Link to integration documentation on our website

No response

Diagnostics information

TypeError: Value 1 of type <class 'int'> is invalid for NOCStruct.noc, expected value of type <class 'bytes'>
2024-03-13 23:30:32.747 DEBUG (MainThread) [homeassistant.components.matter] Add-on store info: {'advanced': False, 'arch': ['aarch64', 'amd64'], 'available': True, 'build': False, 'description': 'Matter WebSocket Server for Home Assistant Matter support.', 'documentation': True, 'homeassistant': '2023.12.0', 'icon': True, 'installed': True, 'logo': True, 'name': 'Matter Server', 'repository': 'core', 'slug': 'core_matter_server', 'stage': 'stable', 'update_available': False, 'url': 'https://github.com/home-assistant/addons/tree/master/matter_server', 'version_latest': '5.4.1', 'version': '5.4.1', 'apparmor': 'default', 'auth_api': False, 'detached': False, 'docker_api': False, 'full_access': False, 'hassio_api': True, 'hassio_role': 'default', 'homeassistant_api': False, 'host_network': True, 'host_pid': False, 'ingress': False, 'long_description': '# Home Assistant Add-on: Matter Server\n\n![Supports aarch64 Architecture][aarch64-shield]\n![Supports amd64 Architecture][amd64-shield]\n\n## About\n\nMatter Python WebSocket Server for Home Assistant Core. Matter (formerly\nknown as Connected Home over IP or CHIP) is an IPv6 based smart home\nstandard. This add-on provides a Matter Controller which allows you to\ncommission and control of Matter devices. The matching Home Assistant Core\nintegration communicates via WebSocket with this server.\n\n[aarch64-shield]: https://img.shields.io/badge/aarch64-yes-green.svg\n[amd64-shield]: https://img.shields.io/badge/amd64-yes-green.svg\n', 'rating': 4, 'signed': False}
2024-03-13 23:30:32.780 ERROR (MainThread) [homeassistant.components.matter] Unexpected exception: Value 1 of type <class 'int'> is invalid for NOCStruct.noc, expected value of type <class 'bytes'>
Traceback (most recent call last):
  File "/usr/src/homeassistant/homeassistant/components/matter/__init__.py", line 151, in _client_listen
    await matter_client.start_listening(init_ready)
  File "/usr/local/lib/python3.12/site-packages/matter_server/client/client.py", line 598, in start_listening
    MatterNode(dataclass_from_dict(MatterNodeData, x))
  File "/usr/local/lib/python3.12/site-packages/matter_server/client/models/node.py", line 245, in __init__
    self.update(node_data)
  File "/usr/local/lib/python3.12/site-packages/matter_server/client/models/node.py", line 332, in update
    self.endpoints[endpoint_id] = MatterEndpoint(
                                  ^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.12/site-packages/matter_server/client/models/node.py", line 71, in __init__
    self.update(attributes_data)
  File "/usr/local/lib/python3.12/site-packages/matter_server/client/models/node.py", line 221, in update
    self.set_attribute_value(attribute_path, attribute_value)
  File "/usr/local/lib/python3.12/site-packages/matter_server/client/models/node.py", line 212, in set_attribute_value
    attribute_value = parse_value(
                      ^^^^^^^^^^^^
  File "/usr/local/lib/python3.12/site-packages/matter_server/common/helpers/util.py", line 148, in parse_value
    return origin(
           ^^^^^^^
  File "/usr/local/lib/python3.12/site-packages/matter_server/common/helpers/util.py", line 149, in <genexpr>
    parse_value(name, subvalue, get_args(value_type)[0])
  File "/usr/local/lib/python3.12/site-packages/matter_server/common/helpers/util.py", line 144, in parse_value
    return dataclass_from_dict(value_type, value)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.12/site-packages/matter_server/common/helpers/util.py", line 263, in dataclass_from_dict
    field.name: parse_value(
                ^^^^^^^^^^^^
  File "/usr/local/lib/python3.12/site-packages/matter_server/common/helpers/util.py", line 237, in parse_value
    raise TypeError(
TypeError: Value 1 of type <class 'int'> is invalid for NOCStruct.noc, expected value of type <class 'bytes'>

Example YAML snippet

No response

Anything in the logs that might be useful for us?

No response

Additional information

No response

@home-assistant
Copy link

Hey there @home-assistant/matter, mind taking a look at this issue as it has been labeled with an integration (matter) you are listed as a code owner for? Thanks!

Code owner commands

Code owners of matter can trigger bot actions by commenting:

  • @home-assistant close Closes the issue.
  • @home-assistant rename Awesome new title Renames the issue.
  • @home-assistant reopen Reopen the issue.
  • @home-assistant unassign matter Removes the current integration label and assignees on the issue, add the integration domain after the command.
  • @home-assistant add-label needs-more-information Add a label (needs-more-information, problem in dependency, problem in custom component) to the issue.
  • @home-assistant remove-label needs-more-information Remove a label (needs-more-information, problem in dependency, problem in custom component) on the issue.

(message by CodeOwnersMention)


matter documentation
matter source
(message by IssueLinks)

@TheBinaryLoop
Copy link

I have the same error an am currently unable to use the matter integration

@bnadgersi
Copy link

I have exact same error on the integration side log adding Tasmota Flashed Switchbot plug. No errors in the Add-On server side log that shows the plug completed commissioning with no errors. Reboot of the Add-On Matter server shows it can find the device with no issues.

@southseaboy
Copy link

I think have the same here with a newly flashed Tasmota install on a Sonoff Dual R3 - with matter installed on the device I can link it to Google Home as matter device, but cannot link it to Home Assistant, and after the attempt the HA Matter Integration consistently shows flips between 'Initialising' and 'Failed setup, will retry'.

Tasmota version:
Program Version 13.4.0(tasmota32)
Build Date & Time 2024-02-14T16:17:40

Home Assistant Versions:
Core 2024.4.3
Supervisor 2024.04.0
Frontend 20240404.2
Matter Integration:

Error logged (using debug settings):

Logger: homeassistant.components.matter
Source: components/matter/__init__.py:151
integration: Matter (BETA) (documentation, issues)
First occurred: 11:11:33 (3 occurrences)
Last logged: 11:12:49

Unexpected exception: Value 2 of type <class 'int'> is invalid for NOCStruct.noc, expected value of type <class 'bytes'>
Traceback (most recent call last):
  File "/usr/src/homeassistant/homeassistant/components/matter/__init__.py", line 151, in _client_listen
    await matter_client.start_listening(init_ready)
  File "/usr/local/lib/python3.12/site-packages/matter_server/client/client.py", line 598, in start_listening
    MatterNode(dataclass_from_dict(MatterNodeData, x))
  File "/usr/local/lib/python3.12/site-packages/matter_server/client/models/node.py", line 245, in __init__
    self.update(node_data)
  File "/usr/local/lib/python3.12/site-packages/matter_server/client/models/node.py", line 332, in update
    self.endpoints[endpoint_id] = MatterEndpoint(
                                  ^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.12/site-packages/matter_server/client/models/node.py", line 71, in __init__
    self.update(attributes_data)
  File "/usr/local/lib/python3.12/site-packages/matter_server/client/models/node.py", line 221, in update
    self.set_attribute_value(attribute_path, attribute_value)
  File "/usr/local/lib/python3.12/site-packages/matter_server/client/models/node.py", line 212, in set_attribute_value
    attribute_value = parse_value(
                      ^^^^^^^^^^^^
  File "/usr/local/lib/python3.12/site-packages/matter_server/common/helpers/util.py", line 148, in parse_value
    return origin(
           ^^^^^^^
  File "/usr/local/lib/python3.12/site-packages/matter_server/common/helpers/util.py", line 149, in <genexpr>
    parse_value(name, subvalue, get_args(value_type)[0])
  File "/usr/local/lib/python3.12/site-packages/matter_server/common/helpers/util.py", line 144, in parse_value
    return dataclass_from_dict(value_type, value)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.12/site-packages/matter_server/common/helpers/util.py", line 263, in dataclass_from_dict
    field.name: parse_value(
                ^^^^^^^^^^^^
  File "/usr/local/lib/python3.12/site-packages/matter_server/common/helpers/util.py", line 237, in parse_value
    raise TypeError(
TypeError: Value 2 of type <class 'int'> is invalid for NOCStruct.noc, expected value of type <class 'bytes'>

@agners
Copy link
Member

agners commented May 1, 2024

Hm, the NOCStruct type clearly is defined as octstr, so I wonder why Tasmota response with an integer here 🤔

Can you try to clear the flash before flashing Tasmota? To me it seems a problem of Tasmota not adhering to the data type of NOCStruct. But I guess since others handle it gracefully (presumably ignore the value?) we probably should too. But this seems a bug in Tasmota.

@MCheckN
Copy link
Author

MCheckN commented May 1, 2024

Thank you! So I guess we'll see this bug fixed in 5.6.0 release. Installing )
Meanwhile, I've confirmed that there's seem so be a bug in Tasmota also. Because downgrading to 13.3 solves the problem.
But I had to set "Force static endpoints" as seems HA Matter doesn't support it in Bridge mode.
More details on Tasmota bugreport here - arendst/Tasmota#20949

@agners
Copy link
Member

agners commented May 1, 2024

Thank you! So I guess we'll see this bug fixed in 5.6.0 release. Installing )

I think this also needs the update on client side (addressed with #116514). So needs Core 2024.5.0.

@agners
Copy link
Member

agners commented May 1, 2024

But I had to set "Force static endpoints" as seems HA Matter doesn't support it in Bridge mode.
More details on Tasmota bugreport here - arendst/Tasmota#20949

Yeah I saw this discussion. In general, wee do support bridges, at least Hue and M1 are known to work. I am not sure why Tasmota emulating a bridge doesn't work. What happens exactly? Is there an error in the Matter Server or Client logs?

@MCheckN
Copy link
Author

MCheckN commented May 2, 2024

But I had to set "Force static endpoints" as seems HA Matter doesn't support it in Bridge mode.
More details on Tasmota bugreport here - arendst/Tasmota#20949

Yeah I saw this discussion. In general, wee do support bridges, at least Hue and M1 are known to work. I am not sure why Tasmota emulating a bridge doesn't work. What happens exactly? Is there an error in the Matter Server or Client logs?

Exactly, it creates the device in Matter but no objects inside. No switch or anything. Just an empty device

@marcelveldt
Copy link
Member

Exactly, it creates the device in Matter but no objects inside. No switch or anything. Just an empty device

If Tasmota adheres to the Matter standard you will see the devices pop up in HA just fine, as long as the device types are already supported in HA ofcourse.

@s-hadinger
Copy link

Thanks for the troubleshooting. It was a stupid mistake in the attribute number in NOCStruct. It is fixed now in arendst/Tasmota#21365

@github-actions github-actions bot locked and limited conversation to collaborators Jun 4, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

8 participants