zigpy-espzb icon indicating copy to clipboard operation
zigpy-espzb copied to clipboard

AttributeError: 'Ledvance' object has no attribute 'get'

Open MostEmpire opened this issue 4 months ago • 4 comments

Hello, I am new to Zigbee stuff, so sorry if I am poisoning the issues section. I know that the zigbee network can have multiple end-devices from various vendors and a coordinator. End devices pair to the coordinator over the mesh network and the coordinator can poll the state of the end device and it can modify it too.

I have compiled esp_zigbee_ncp project in hopes that I would be able to control via a serial line to the esp32c6 and I would see pairing status of my outlet and that I would be able to toggle it on or off.

I see that the esp_zigbee_ncp listens on UART and has some specific protocol that zigpy-espzb might just implement. I have however absolutely no idea how to use this repository and how to start up even a simple thing. I have installed zigpy and zigpy-espzb. I tried this code:

import asyncio, zigpy.config as zc
from zigpy_espzb.zigbee.application import ControllerApplication

CFG = {
    zc.CONF_DEVICE: {
        zc.CONF_DEVICE_PATH: "COM14",
        zc.CONF_DEVICE_BAUDRATE: 115200,   # int
    },
    "database_path": "zigbee.db",
    "ota": {"enabled": False},             # avoid provider schema
}

async def main():
    app = await ControllerApplication.new(CFG)
    try:
        await app.form_network()
    except Exception:
        pass
    print(await app.network_info())
    await app.permit(120)

asyncio.run(main())

and this is the error I am getting:

Traceback (most recent call last):
  File "C:\Users\Patrik\AppData\Roaming\JetBrains\PyCharm2024.2\scratches\zigbee_dzigat.py", line 22, in <module>
    asyncio.run(main())
  File "C:\Program Files\Applications\python_3_12_7\Lib\asyncio\runners.py", line 194, in run
    return runner.run(main)
           ^^^^^^^^^^^^^^^^
  File "C:\Program Files\Applications\python_3_12_7\Lib\asyncio\runners.py", line 118, in run
    return self._loop.run_until_complete(task)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "C:\Program Files\Applications\python_3_12_7\Lib\asyncio\base_events.py", line 687, in run_until_complete
    return future.result()
           ^^^^^^^^^^^^^^^
  File "C:\Users\Patrik\AppData\Roaming\JetBrains\PyCharm2024.2\scratches\zigbee_dzigat.py", line 14, in main
    app = await ControllerApplication.new(CFG)
          ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "C:\Program Files\Applications\python_3_12_7\Lib\site-packages\zigpy\application.py", line 237, in new
    app = cls(config)
          ^^^^^^^^^^^
  File "C:\Program Files\Applications\python_3_12_7\Lib\site-packages\zigpy_espzb\zigbee\application.py", line 63, in __init__
    super().__init__(config=zigpy.config.ZIGPY_SCHEMA(config))
  File "C:\Program Files\Applications\python_3_12_7\Lib\site-packages\zigpy\application.py", line 70, in __init__
    self._config = self.SCHEMA(config)
                   ^^^^^^^^^^^^^^^^^^^
  File "C:\Program Files\Applications\python_3_12_7\Lib\site-packages\voluptuous\schema_builder.py", line 205, in __call__
    return self._compiled([], data)
           ^^^^^^^^^^^^^^^^^^^^^^^^
  File "C:\Program Files\Applications\python_3_12_7\Lib\site-packages\voluptuous\schema_builder.py", line 549, in validate_dict
    return base_validate(path, data.items(), out)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "C:\Program Files\Applications\python_3_12_7\Lib\site-packages\voluptuous\schema_builder.py", line 330, in validate_mapping
    cval = cvalue(key_path, value)
           ^^^^^^^^^^^^^^^^^^^^^^^
  File "C:\Program Files\Applications\python_3_12_7\Lib\site-packages\voluptuous\schema_builder.py", line 779, in validate_callable
    return schema(data)
           ^^^^^^^^^^^^
  File "C:\Program Files\Applications\python_3_12_7\Lib\site-packages\voluptuous\schema_builder.py", line 205, in __call__
    return self._compiled([], data)
           ^^^^^^^^^^^^^^^^^^^^^^^^
  File "C:\Program Files\Applications\python_3_12_7\Lib\site-packages\voluptuous\schema_builder.py", line 549, in validate_dict
    return base_validate(path, data.items(), out)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "C:\Program Files\Applications\python_3_12_7\Lib\site-packages\voluptuous\schema_builder.py", line 330, in validate_mapping
    cval = cvalue(key_path, value)
           ^^^^^^^^^^^^^^^^^^^^^^^
  File "C:\Program Files\Applications\python_3_12_7\Lib\site-packages\voluptuous\schema_builder.py", line 590, in validate_sequence
    cval = validate(index_path, value)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "C:\Program Files\Applications\python_3_12_7\Lib\site-packages\voluptuous\schema_builder.py", line 779, in validate_callable
    return schema(data)
           ^^^^^^^^^^^^
  File "C:\Program Files\Applications\python_3_12_7\Lib\site-packages\zigpy\config\validators.py", line 124, in cv_ota_provider
    provider_type = obj.get(zigpy.config.CONF_OTA_PROVIDER_TYPE)
                    ^^^^^^^
AttributeError: 'Ledvance' object has no attribute 'get'

I have no idea on how to get rid of that Ledvance error. I don't even know which library is misconfigured. Can someone guide me on how to get the pairing done and polling/toggling of the outlet done?

MostEmpire avatar Aug 10 '25 23:08 MostEmpire

I would instead use one of the other radios (e.g. the bellows library) with ZHA as a library. That should give you the simplest out-of-the-box experience. The ESP32 radio firmware and library aren't tested at the moment, they're still a WIP.

puddly avatar Aug 10 '25 23:08 puddly

Very fast reply :) I have tried one thing. In zigpy_espzb/zigbee/application.py I replaced super().__init__(config=zigpy.config.ZIGPY_SCHEMA(config)) by super().__init__(config=config) and I got the library to work. Well.. I was able to at least connect to a COM port and get a timeout. I think I have built esp_zigbee_ncp in such a way (the default way), that I cannot seem to interact with the radio on the ESP32C6. I disabled reporting on uart using "menuconfig->Component config->ESP System Settings->Channel for console output = None", thinking there is a conflict on the uart channel, but if enabled, I should see something like 'I (208) ESP_ZNSP_FRAME 10 00 00 00 c2 01 00 00 f4 fc' in the idf.py monitor, but the behavior of the ESP32 is similar to a brick. On one UART (UART15, left USB-C port on the devkit) it reports

Build:Sep 19 2022
rst:0x1 (POWERON),boot:0xc (SPI_FAST_FLASH_BOOT)
SPIWP:0xee
mode:DIO, clock div:2
load:0x40875730,len:0x1268
load:0x4086b910,len:0xbe8
load:0x4086e610,len:0x2f04
entry 0x4086b910

No response to any input. On the other UART (UART14, righ USB-C port on the devkit) there is no text report after reboot and no response to input. Is this how it should be? What sdkconfig flags should I set up so that I would be able to interact with the Zigbee NCP? Or do I need to send only valid frames, otherwise it would not respond? This sdkconfig did not work:

CONFIG_BOOTLOADER_LOG_LEVEL_WARN=y
CONFIG_BOOTLOADER_LOG_LEVEL=2

# Increase main task stack size
CONFIG_ESP_MAIN_TASK_STACK_SIZE=7168

# Enable filesystem
CONFIG_PARTITION_TABLE_CUSTOM=y
CONFIG_PARTITION_TABLE_CUSTOM_FILENAME="partitions.csv"
CONFIG_PARTITION_TABLE_FILENAME="partitions.csv"

# Enable FreeRTOS stats formatting functions, needed for 'tasks' command
CONFIG_FREERTOS_USE_TRACE_FACILITY=y
CONFIG_FREERTOS_USE_STATS_FORMATTING_FUNCTIONS=y

#
# Zboss
#
CONFIG_ZB_ENABLED=y
CONFIG_ZB_ZCZR=y```
and addition of these:
```CONFIG_NCP_BUS_MODE=0
CONFIG_NCP_BUS_UART_BAUD_RATE=115200
CONFIG_NCP_BUS_UART_BYTE_SIZE=3
CONFIG_NCP_BUS_UART_STOP_BITS=1
CONFIG_NCP_BUS_UART_FLOW_CONTROL=0
CONFIG_NCP_BUS_UART_NUM=0
CONFIG_NCP_BUS_UART_RX_PIN=16
CONFIG_NCP_BUS_UART_TX_PIN=17
CONFIG_NCP_BUS_UART_RTS_PIN=-1
CONFIG_NCP_BUS_UART_CTS_PIN=-1```
did not help either.

> I would instead use one of the other radios (e.g. the bellows library) with ZHA as a library. That should give you the simplest out-of-the-box experience. The ESP32 radio firmware and library aren't tested at the moment, they're still a WIP.
You mean I should ditch ESP32C6 radio and use a different chip with its supported library?

MostEmpire avatar Aug 11 '25 10:08 MostEmpire

You mean I should ditch ESP32C6 radio and use a different chip with its supported library?

Yes. https://github.com/zigpy/bellows talks to Silicon Labs chips and is what we primarily test with.

For actually communicating with a plug you'd need to find a spec-compliant plug and then set up a binding between the coordinator and the device's OnOff cluster, set up attribute reporting for the desired attributes, and then set up handlers for the attribute reports. ZHA the library abstracts away the OnOff cluster into Home Assistant-like Entity objects that expose the useful functionality of the device, completing the binding and attribute reporting config for you.

puddly avatar Aug 11 '25 14:08 puddly

@MostEmpire check out the zha library project (which):

  • https://github.com/zigpy/zha

It is that library that is used by Home Assistant's ZHA integration (which has implemented it as a dependency):

  • https://github.com/home-assistant/core/tree/dev/homeassistant/components/zha

PS: If you still want to experiment with that zha library in combination with zigpy-espzb radio then see this experimental PR::

  • https://github.com/zigpy/zha/pull/461

Hedda avatar Aug 13 '25 09:08 Hedda