Koenkk / zigbee2mqtt

Zigbee 🐝 to MQTT bridge 🌉, get rid of your proprietary Zigbee bridges 🔨
https://www.zigbee2mqtt.io
GNU General Public License v3.0
12.08k stars 1.68k forks source link

scene_add fails in 1.34.0 with Error: undefined is not a object, got undefined (undefined #20001

Closed jafrouk closed 3 months ago

jafrouk commented 11 months ago

What happened?

In 1.34.0, Attempting to add a new scene as per https://www.zigbee2mqtt.io/guide/usage/scenes.html#using-transitions-in-scenes fails, no scene is added.

In 1.33.2, the scene is created as expected, though transition_time not honoured as per https://github.com/Koenkk/zigbee2mqtt/issues/20002

What did you expect to happen?

A blank scene would be created, This worked in 1.33.2

How to reproduce it (minimal and precise)

Create a group called "new_group" with some lights in. Send an MQTT message to zigbee2mqtt/new_group/set/scene_add' with Payload:

{
        "ID": 206,
        "transition_time": 15
    }

Note - I tried with an without quotes around the numbers, and also sending to "set" with "scene_add" in the payload.

Zigbee2MQTT version

1.34.0

Adapter firmware version

6.10.3.0 build 297

Adapter

Home assistant yellow (not sure which adapter you mean or where to find it)

Debug log

1.34.0:

debug 2023-12-03 11:05:02: Received MQTT message on 'zigbee2mqtt/new_group/set/scene_add' with data '{
        "ID": 206,
        "transition_time": 15
    }'
debug 2023-12-03 11:05:02: Publishing 'set' 'scene_add' to 'new_group'
error 2023-12-03 11:05:03: Publish 'set' 'scene_add' to 'new_group' failed: 'Error: undefined is not a object, got undefined (undefined)'
debug 2023-12-03 11:05:03: Error: undefined is not a object, got undefined (undefined)
    at Object.assertObject (/app/node_modules/zigbee-herdsman-converters/src/lib/utils.ts:511:15)
    at Object.convertSet (/app/node_modules/zigbee-herdsman-converters/src/converters/toZigbee.ts:4300:19)
    at Publish.onMQTTMessage (/app/lib/extension/publish.ts:248:36)
debug 2023-12-03 11:05:03: Clearing Home Assistant scene discovery topics for 'Coordinator'
debug 2023-12-03 11:05:03: Clearing Home Assistant scene discovery topics for 'LC mid R'

1.33.2:

debug 2023-12-03 11:37:42: Received MQTT message on 'zigbee2mqtt/new_group/set/scene_add' with data '{
        "ID": 206,
        "transition_time": 15
}'
debug 2023-12-03 11:37:42: Publishing 'set' 'scene_add' to 'new_group'
info  2023-12-03 11:37:43: Successfully added scene
Koenkk commented 11 months ago

Could you provide the herdsman debug log of this?

See https://www.zigbee2mqtt.io/guide/usage/debug.html on how to enable the herdsman debug logging. Note that this is only logged to STDOUT and not to log files.

jafrouk commented 11 months ago

Hi @Koenkk happy to do so, but I'm having trouble figuring out how to follow those instructions!

I am using Home Assistant Yellow, zigbee2mqtt is installed via addons. I haven't directly configured it using docker, and don't see anywhere to edit the launch options; I can't find Supervisor in the menu in the UI .... the addon Documentation tab says to add "zigbee_herdsman_debug: true" but doesn't say where (I switched the Op;tions dialog to yaml mode and added it, but not sure if that was right)....

I can SSH but don't seem to have the docker command available.

Sorry, I guess I am missing something obvious - can you point me in the right direction?

jafrouk commented 11 months ago

OK, got it (side note the docs could do with minor updates to make it clearer how to do this and whee to fidn the log in the UI when installed as add-on).

I had to turn the main zigbee2mqtt logging down to "warn" as it was too chatty and the herdsman logging was getting lost before I could capture it.

From the main log, command executed at 09:05:42: 2023-12-04 09:05:42Publish 'set' 'scene_add' to 'new_group' failed: 'Error: undefined is not a object, got undefined (undefined)'

And here's the debug output from addon log:

2023-12-04T09:05:41.794Z zigbee-herdsman:adapter:ezsp:ezsp Time to watchdog ... 0
2023-12-04T09:05:41.795Z zigbee-herdsman:adapter:ezsp:ezsp ==> nop: null
2023-12-04T09:05:41.795Z zigbee-herdsman:adapter:ezsp:ezsp ==> {"_cls_":"nop","_id_":5,"_isRequest_":true}
2023-12-04T09:05:41.795Z zigbee-herdsman:adapter:ezsp:uart --> DATA (2,1,0): 6a00010500
2023-12-04T09:05:41.795Z zigbee-herdsman:adapter:ezsp:uart --> [212821a9512aae707e]
2023-12-04T09:05:41.796Z zigbee-herdsman:adapter:ezsp:uart -?- waiting (3)
2023-12-04T09:05:41.800Z zigbee-herdsman:adapter:ezsp:uart <-- [7d3328a1a9512ad7847e]
2023-12-04T09:05:41.810Z zigbee-herdsman:adapter:ezsp:uart <-- DATA (1,3,0): 1328a1a9512ad7847e
2023-12-04T09:05:41.810Z zigbee-herdsman:adapter:ezsp:uart --> ACK  (2)
2023-12-04T09:05:41.811Z zigbee-herdsman:adapter:ezsp:uart --> [82503a7e]
2023-12-04T09:05:41.811Z zigbee-herdsman:adapter:ezsp:ezsp <== Frame: 6a80010500
2023-12-04T09:05:41.812Z zigbee-herdsman:adapter:ezsp:ezsp <== 0x5: {"_cls_":"nop","_id_":5,"_isRequest_":false}
2023-12-04T09:05:41.812Z zigbee-herdsman:adapter:ezsp:uart -+- waiting (3) success
2023-12-04T09:05:42.574Z zigbee-herdsman:controller:group Command 150 genScenes.remove({"groupid":150,"sceneid":208})
2023-12-04T09:05:42.577Z zigbee-herdsman:adapter:ezsp:ezsp ==> sendMulticast: {"apsFrame":{"clusterId":5,"profileId":260,"sequence":21,"sourceEndpoint":1,"destinationEndpoint":1,"groupId":150,"options":256},"hops":0,"nonmemberRadius":3,"messageTag":22,"message":{"type":"Buffer","data":[17,9,2,150,0,208]}}
2023-12-04T09:05:42.578Z zigbee-herdsman:adapter:ezsp:ezsp ==> {"_cls_":"sendMulticast","_id_":56,"_isRequest_":true,"apsFrame":{"clusterId":5,"profileId":260,"sequence":21,"sourceEndpoint":1,"destinationEndpoint":1,"groupId":150,"options":256},"hops":0,"nonmemberRadius":3,"messageTag":22,"message":{"type":"Buffer","data":[17,9,2,150,0,208]}}
2023-12-04T09:05:42.578Z zigbee-herdsman:adapter:ezsp:uart --> DATA (3,2,0): 6b000138000401050001010001960015000316061109029600d0
2023-12-04T09:05:42.579Z zigbee-herdsman:adapter:ezsp:uart --> [322921a96c2a7d31b35c944b24aa540449894e24bdebdf6e896bc6b3d5c77e]
2023-12-04T09:05:42.579Z zigbee-herdsman:adapter:ezsp:uart -?- waiting (4)
2023-12-04T09:05:42.587Z zigbee-herdsman:adapter:ezsp:uart <-- [2429a1a96c2a1573c3047e]
2023-12-04T09:05:42.588Z zigbee-herdsman:adapter:ezsp:uart <-- DATA (2,4,0): 2429a1a96c2a1573c3047e
2023-12-04T09:05:42.588Z zigbee-herdsman:adapter:ezsp:uart --> ACK  (3)
2023-12-04T09:05:42.588Z zigbee-herdsman:adapter:ezsp:uart --> [83401b7e]
2023-12-04T09:05:42.596Z zigbee-herdsman:adapter:ezsp:ezsp <== Frame: 6b8001380000c1
2023-12-04T09:05:42.596Z zigbee-herdsman:adapter:ezsp:ezsp <== 0x38: {"_cls_":"sendMulticast","_id_":56,"_isRequest_":false,"status":0,"sequence":193}
2023-12-04T09:05:42.597Z zigbee-herdsman:adapter:ezsp:uart -+- waiting (4) success
2023-12-04T09:05:42.598Z zigbee-herdsman:adapter:ezsp:uart <-- [3429b1a97d312a16b658914a24555593df9c8fd8abedce9874fbd76a8b6a7d5eef4fbd7e]
2023-12-04T09:05:42.598Z zigbee-herdsman:adapter:ezsp:uart <-- DATA (3,4,0): 3429b1a9112a16b658914a24555593df9c8fd8abedce9874fbd76a8b6a7eef4fbd7e
2023-12-04T09:05:42.598Z zigbee-herdsman:adapter:ezsp:uart --> ACK  (4)
2023-12-04T09:05:42.600Z zigbee-herdsman:adapter:ezsp:uart --> [8430fc7e]
2023-12-04T09:05:42.601Z zigbee-herdsman:adapter:ezsp:ezsp <== Frame: 6b90014500030401050001ff00019600c1ff000000ffff061109029600d0
2023-12-04T09:05:42.602Z zigbee-herdsman:adapter:ezsp:ezsp <== 0x45: {"_cls_":"incomingMessageHandler","_id_":69,"_isRequest_":false,"type":3,"apsFrame":{"profileId":260,"clusterId":5,"sourceEndpoint":1,"destinationEndpoint":255,"options":256,"groupId":150,"sequence":193},"lastHopLqi":255,"lastHopRssi":0,"sender":0,"bindingIndex":255,"addressIndex":255,"message":{"type":"Buffer","data":[17,9,2,150,0,208]}}
2023-12-04T09:05:42.602Z zigbee-herdsman:adapter:ezsp:debg processMessage: {"messageType":3,"apsFrame":{"profileId":260,"clusterId":5,"sourceEndpoint":1,"destinationEndpoint":255,"options":256,"groupId":150,"sequence":193},"lqi":255,"rssi":0,"sender":0,"bindingIndex":255,"addressIndex":255,"message":{"type":"Buffer","data":[17,9,2,150,0,208]}}
2023-12-04T09:05:42.606Z zigbee-herdsman:controller:log Received 'zcl' data '{"frame":{"Header":{"frameControl":{"frameType":1,"manufacturerSpecific":false,"direction":0,"disableDefaultResponse":true,"reservedBits":0},"transactionSequenceNumber":9,"manufacturerCode":null,"commandIdentifier":2},"Payload":{"groupid":150,"sceneid":208},"Command":{"ID":2,"response":2,"parameters":[{"name":"groupid","type":33},{"name":"sceneid","type":32}],"name":"remove"}},"address":0,"endpoint":1,"linkquality":255,"groupID":150,"wasBroadcast":false,"destinationEndpoint":255}'
2023-12-04T09:05:42.607Z zigbee-herdsman:controller:log Skipping command 'remove' because it is missing from the lookup
Zigbee2MQTT:error 2023-12-04 09:05:42: Publish 'set' 'scene_add' to 'new_group' failed: 'Error: undefined is not a object, got undefined (undefined)'
2023-12-04T09:05:44.790Z zigbee-herdsman:adapter:ezsp:uart <-- [4429b1a96b2a164fa6904b20aa546d499dd8276afbce67163c7e4c29b1a96b2a164fa6904b20aa546d499dd8276afbce670e077e]
2023-12-04T09:05:44.791Z zigbee-herdsman:adapter:ezsp:uart <-- DATA (4,4,0): 4429b1a96b2a164fa6904b20aa546d499dd8276afbce67163c7e
2023-12-04T09:05:44.792Z zigbee-herdsman:adapter:ezsp:uart --> ACK  (5)
2023-12-04T09:05:44.793Z zigbee-herdsman:adapter:ezsp:uart --> [8520dd7e]
2023-12-04T09:05:44.794Z zigbee-herdsman:adapter:ezsp:ezsp <== Frame: 6b90013f0003fdff0401050001ff00019600c1160000
2023-12-04T09:05:44.800Z zigbee-herdsman:adapter:ezsp:ezsp <== 0x3f: {"_cls_":"messageSentHandler","_id_":63,"_isRequest_":false,"type":3,"indexOrDestination":65533,"apsFrame":{"profileId":260,"clusterId":5,"sourceEndpoint":1,"destinationEndpoint":255,"options":256,"groupId":150,"sequence":193},"messageTag":22,"status":0,"message":{"type":"Buffer","data":[]}}
2023-12-04T09:05:44.801Z zigbee-herdsman:adapter:ezsp:cast 150 is already subscribed
2023-12-04T09:05:44.802Z zigbee-herdsman:adapter:ezsp:uart <-- DATA (4,4,1): 4c29b1a96b2a164fa6904b20aa546d499dd8276afbce670e077e
2023-12-04T09:05:44.803Z zigbee-herdsman:adapter:ezsp:uart --> ACK  (5)
2023-12-04T09:05:44.804Z zigbee-herdsman:adapter:ezsp:uart --> [8520dd7e]
2023-12-04T09:05:44.805Z zigbee-herdsman:adapter:ezsp:uart Skipping the packet as repeated (5)
Koenkk commented 11 months ago

Found the issue!

Changes will be available in the dev branch in a few hours from now.

bfayers commented 11 months ago

Just swapped onto the dev branch which says its using 16.0.2 in the about section but I'm still seeing this behaviour when attempting to add a scene over mqtt, but adding scenes in the webui works.

It is actually storing scenes sent over mqtt despite the error message shown in the webui because it's they work fine if a scene_recall is done after the fact; just get the error message in webui and it never gets added to the scene dropdown/exposed to hass.

If I scene_add over mqtt, then scene_recall, then "add" in the webui I get the settings (including transition time) sent with mqtt, but it shows in the webui dropdown and hass.

Some debug logs:


zigbee2mqtt  | Zigbee2MQTT:debug 2023-12-04 21:42:34: Received MQTT message on 'zigbee2mqtt/Ben's Light/set' with data '{
zigbee2mqtt  |   "scene_add": {
zigbee2mqtt  |     "ID": 3,
zigbee2mqtt  |     "group_id": 2,
zigbee2mqtt  |     "name": "Ben's Room Superdim",
zigbee2mqtt  |     "state": "ON",
zigbee2mqtt  |     "brightness": 1,
zigbee2mqtt  |     "color_temp": 250,
zigbee2mqtt  |     "transition": 1
zigbee2mqtt  |   }
zigbee2mqtt  | }'
zigbee2mqtt  | Zigbee2MQTT:debug 2023-12-04 21:42:34: Publishing 'set' 'scene_add' to 'Ben's Light'
zigbee2mqtt  | Zigbee2MQTT:error 2023-12-04 21:42:34: Publish 'set' 'scene_add' to 'Ben's Light' failed: 'Error: undefined is not a object, got undefined (undefined)'
zigbee2mqtt  | Zigbee2MQTT:debug 2023-12-04 21:42:35: Error: undefined is not a object, got undefined (undefined)
zigbee2mqtt  |     at Object.assertObject (/app/node_modules/zigbee-herdsman-converters/src/lib/utils.ts:517:15)
zigbee2mqtt  |     at Object.convertSet (/app/node_modules/zigbee-herdsman-converters/src/converters/toZigbee.ts:4324:23)
zigbee2mqtt  |     at Publish.onMQTTMessage (/app/lib/extension/publish.ts:249:36)```
Koenkk commented 11 months ago

Found another issue, fixed it!

Changes will be available in the dev branch in a few hours from now.

bfayers commented 11 months ago

Found another issue, fixed it!

All good here now

robertwigley commented 11 months ago

@Koenkk Is this the same issue I am seeing when trying to set Aqara H1 switches to Decoupled, which also seems to have been introduced in 1.34.0? I just want to check before opening a new issue, as it sounds very similar. Error below when trying to set Decoupled mode.

image

Koenkk commented 11 months ago

@robertwigley should be fixed now.

Changes will be available in the dev branch in a few hours from now.

robertwigley commented 11 months ago

@Koenkk Thanks for the quick fix. I was contemplating having to do a restore to the previous version. Is there a guide on how to temporarily move to the Edge version of the add-on without losing any settings?

jerrm commented 11 months ago

Is there a guide on how to temporarily move to the Edge version of the add-on without losing any settings?

  1. Stop the Release add-on
  2. Disable Start on boot for the Release add-on
  3. Install the Edge add-on
  4. Duplicate the HA add-on Configuration tab from Release add-on into the Edge add-on. I generally choose the edit in yaml option, and just cut/paste everything in one block.
  5. Enable Edge Start on boot
  6. Enable Edge Show in sidebar
  7. Start the edge addon
jjc092 commented 10 months ago

Not sure if this is related, but I'm getting this error on the latest dev version.

{
  "scene_add": {
    "ID": 0,
    "transition": 1
  }
}
error 2023-12-10 17:57:40: Publish 'set' 'scene_add' to 'Master Bedroom Bedside Lamp' failed: 'Error: Command 0x1c34f1fffe540a26/1 genScenes.add({"groupid":0,"sceneid":0,"scenename":"","commandTransitionTime":1,"extensionfieldsets":[]}, {"sendWhen":"immediate","timeout":10000,"disableResponse":false,"disableRecovery":false,"disableDefaultResponse":true,"direction":0,"srcEndpoint":null,"reservedBits":0,"manufacturerCode":null,"transactionSequenceNumber":null,"writeUndiv":false}) failed (Parameter 'transtime' is missing)'
gdgib commented 10 months ago

Not sure if this is related, but I'm getting this error on the latest dev version.

{
  "scene_add": {
    "ID": 0,
    "transition": 1
  }
}
error 2023-12-10 17:57:40: Publish 'set' 'scene_add' to 'Master Bedroom Bedside Lamp' failed: 'Error: Command 0x1c34f1fffe540a26/1 genScenes.add({"groupid":0,"sceneid":0,"scenename":"","commandTransitionTime":1,"extensionfieldsets":[]}, {"sendWhen":"immediate","timeout":10000,"disableResponse":false,"disableRecovery":false,"disableDefaultResponse":true,"direction":0,"srcEndpoint":null,"reservedBits":0,"manufacturerCode":null,"transactionSequenceNumber":null,"writeUndiv":false}) failed (Parameter 'transtime' is missing)'

I saw the original error on 1.34.0, so I tried edge, and saw this instead. Either way, definitely not working right now.

gdgib commented 10 months ago

For anyone else who needs an immediate fix and is running Z2M as an HA add-on...

  1. Stop your copy of the Z2M add-on, and disable "start on boot"
  2. Go to the terminal and run cd addons && wget https://github.com/zigbee2mqtt/hassio-zigbee2mqtt/releases/tag/v1.33.2-1 && unzip v1.33.2-1.zip
  3. Go to the add on-store and click the triple dots in the top right, then update repositories, then wait
  4. Reload the add on store, and you should see a local section with the Z2M add on (and edge, etc, etc). Install this one, it's the one you just downloaded above
  5. Go to the configuration tab of the one you disabled, show the config as YAML and copy it to the one you just installed
  6. Set the "start on boot" and other options of the downgraded version you just installed.

This should let you enjoy the older version until this bug is fixed. When you're ready, you'll want to stop and uninstall the local version, and maybe delete the download. Then re-enable the version from the normal store, of course.

Thanks @Koenkk for the truly excellent software, godspeed with the bugs.

Koenkk commented 10 months ago

Issue with transtime on latest dev is solved now.

Changes will be available in the dev branch in a few hours from now.

github-actions[bot] commented 4 months ago

This issue is stale because it has been open 180 days with no activity. Remove stale label or comment or this will be closed in 30 days