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

z2m: EventBus error 'HomeAssistant/publishEntityState': Cannot read properties of null (reading 'toString') #25133

Closed
XenorPLxx opened this issue Dec 8, 2024 · 6 comments
Labels
problem Something isn't working

Comments

@XenorPLxx
Copy link

What happened?

Hi,

I'm running in docker and my about shows as 1.42.0-dev commit: 7d63a87aad954225c77156d22576939b1ffe7d6c

I have experimental HA events turned on.

I've went trough breaking changes list and I'm pretty sure I addressed all issues, and everything seems to be behaving correctly within HA, but I am seeing errors in Z2M log like the one below. Not sure if that's something I should worry about, but I see that this code was in fact changed recently here 61cf509.

[2024-12-09 00:12:21] info:     z2m:mqtt: MQTT publish: topic 'zigbee2mqtt/Switch_Hallway-Lights', payload '{"action":null,"device_temperature":27,"flip_indicator_light":"ON","led_disabled_night":false,"linkquality":145,"mode_switch":"anti_flicker_mode","operation_mode":"control_relay","power_outage_count":2,"power_outage_memory":true,"state":"OFF"}'
[2024-12-09 00:12:21] error:    z2m: EventBus error 'HomeAssistant/publishEntityState': Cannot read properties of null (reading 'toString')
[2024-12-09 00:12:21] debug:    z2m: TypeError: Cannot read properties of null (reading 'toString')
    at HomeAssistant.onPublishEntityState (/app/lib/extension/homeassistant.ts:1284:50)
    at EventEmitter.wrappedCallback (/app/lib/eventBus.ts:204:23)
    at EventEmitter.emit (node:events:529:35)
    at EventBus.emitPublishEntityState (/app/lib/eventBus.ts:151:22)
    at Controller.publishEntityState (/app/lib/controller.ts:328:23)
    at publish (/app/lib/extension/receive.ts:155:17)
    at Receive.onDeviceMessage (/app/lib/extension/receive.ts:181:13)
    at EventEmitter.wrappedCallback (/app/lib/eventBus.ts:204:17)

What did you expect to happen?

No response

How to reproduce it (minimal and precise)

I'm not sure how to reproduce, it happens 'on its own' without any triggers from my side, in my setup with z2m docker connected to HA.

Zigbee2MQTT version

1.42.0-dev commit: 7d63a87

Adapter firmware version

20211217

Adapter

Sonoff Zigbee USB CC2652P (zStack3x0)

Setup

plain docker on unraid, connected to HA

Debug log

log.log

@XenorPLxx XenorPLxx added the problem Something isn't working label Dec 8, 2024
@ccutrer
Copy link
Contributor

ccutrer commented Dec 10, 2024

I'm also seeing this as of commit 6905c10. Disabling Event entities didn't seem to help. MQTT wasn't getting any actual state updates, so I've reverted to 1.42.0 for now.

@Koenkk
Copy link
Owner

Koenkk commented Dec 10, 2024

Could you try to stop z2m, remove the action from the data/state.json for that device, start z2m and see if the issue is fixed?

@Belox86
Copy link

Belox86 commented Dec 10, 2024

i have the same problem (or very similar).
i'm running 1.42.0-dev commit: acba533
with experimental_event_entities true

my debug log is a bit different:

[2024-12-05 21:18:28] info: 	z2m:mqtt: MQTT publish: topic 'zigbee2mqtt/Multi Switch Serra', payload '{"action":null,"battery":91,"linkquality":204,"voltage":2900}'
[2024-12-05 21:18:28] error: 	z2m: EventBus error 'HomeAssistant/publishEntityState': Cannot read properties of null (reading 'toString')
[2024-12-05 21:18:28] debug: 	z2m: TypeError: Cannot read properties of null (reading 'toString')
    at HomeAssistant.onPublishEntityState (/app/lib/extension/homeassistant.ts:1287:50)
    at EventEmitter.wrappedCallback (/app/lib/eventBus.ts:204:23)
    at EventEmitter.emit (node:events:531:35)
    at EventBus.emitPublishEntityState (/app/lib/eventBus.ts:151:22)
    at Controller.publishEntityState (/app/lib/controller.ts:326:23)
    at processTicksAndRejections (node:internal/process/task_queues:95:5)
    at runNextTicks (node:internal/process/task_queues:64:3)
    at processImmediate (node:internal/timers:449:9)
    at publish (/app/lib/extension/receive.ts:155:17)
    at Receive.onDeviceMessage (/app/lib/extension/receive.ts:181:13)

i look in the state.json (in addon_configs\45df7312_zigbee2mqtt_edge\zigbee2mqtt ) but i didn't find any action.
state.json

@XenorPLxx
Copy link
Author

XenorPLxx commented Dec 10, 2024

yup, no action in mine either

root@Home-unRaid:/mnt/user/appdata/zigbee2mqtt# cat state.json | grep action
root@Home-unRaid:/mnt/user/appdata/zigbee2mqtt#
{
    "0x00158d00029bbade": {
        "angle": -14.32,
        "battery": 90,
        "linkquality": 225,
        "side": 0,
        "voltage": 2985,
        "temperature": 23,
        "current": 0,
        "power": 26,
        "device_temperature": 24,
        "power_outage_count": 334
    },
    "0x00158d0002f386cc": {
        "battery": 97,
        "linkquality": 123,
        "voltage": 2995,
        "temperature": 31,
        "device_temperature": 28,
        "power_outage_count": 21
    },
    "0x00158d0002f38750": {
        "battery": 100,
        "linkquality": 178,
        "voltage": 3015,
        "temperature": 29,
        "device_temperature": 28,
        "power_outage_count": 181
    },
    "0x00158d00042853c3": {
        "consumption": 17.550312042236328,
        "energy": 17.55,
        "linkquality": 222,
        "power": 42.7,
        "state": "OFF",
        "state_l1": "OFF",
        "state_l2": "ON",
        "temperature": 35,
        "voltage": 225.45,
        "update_available": false,
        "update": {
            "state": "idle",
            "installed_version": 47,
            "latest_version": 47
        },
        "power_outage_count": 664,
        "current": 0.19,
        "device_temperature": 35,
        "interlock": false
    },
    "0x00158d00044939f7": {
        "battery_low": false,
        "gas": false,
        "gas_density": 0,
        "tamper": false,
        "sensitivity": "high",
        "linkquality": 102
    },
    "0x00158d00049fb9c6": {
        "battery": 77,
        "humidity": 53.42,
        "linkquality": 127,
        "temperature": 22.48,
        "voltage": 2965,
        "power_outage_count": 854
    },
    "0x00158d0004a058bb": {
        "battery": 100,
        "battery_low": false,
        "tamper": false,
        "voltage": 3015,
        "water_leak": false,
        "temperature": 26,
        "device_temperature": 26,
        "linkquality": 214,
        "power_outage_count": 14,
        "trigger_count": 0
    },
    "0x00158d0004ab6053": {
        "temperature": 21.61,
        "humidity": 61.14,
        "voltage": 2985,
        "battery": 90,
        "pressure": 1024.8,
        "linkquality": 123,
        "power_outage_count": 16519
    },
    "0x54ef4410003896e5": {
        "voltage": 3037,
        "battery": 100,
        "temperature": 25,
        "state": "OFF",
        "linkquality": 123,
        "power_outage_count": 75,
        "operation_mode": "event"
    },
    "0x00158d00047b3905": {
        "water_leak": false,
        "tamper": false,
        "battery_low": false,
        "voltage": 3025,
        "battery": 100,
        "temperature": 27,
        "device_temperature": 27,
        "linkquality": 222,
        "power_outage_count": 20,
        "trigger_count": 0
    },
    "0x00158d00051e8732": {
        "voltage": 3095,
        "battery": 100,
        "smoke_density": 0,
        "smoke": false,
        "tamper": false,
        "battery_low": false,
        "supervision_reports": false,
        "restore_reports": false,
        "trouble": false,
        "ac_status": false,
        "test": false,
        "temperature": 29,
        "device_temperature": 29,
        "linkquality": 222,
        "power_outage_count": 6,
        "battery_defect": false
    },
    "0x54ef44100033b356": {
        "temperature": 22,
        "state": "OFF",
        "battery": 84,
        "monitoring_mode": "undirected",
        "position": 0,
        "update": {
            "state": "idle",
            "installed_version": 3870,
            "latest_version": 3870
        },
        "update_available": false,
        "motor_state": "stopped",
        "running": false,
        "illuminance": 0,
        "illuminance_lux": 0,
        "charging_status": false,
        "device_temperature": 19,
        "linkquality": 142,
        "power_outage_count": 1
    },
    "0x54ef44100033b93d": {
        "temperature": 22,
        "state": "OFF",
        "battery": 100,
        "monitoring_mode": "undirected",
        "position": 0,
        "update": {
            "state": "idle",
            "installed_version": 3870,
            "latest_version": 3870
        },
        "update_available": false,
        "motor_state": "stopped",
        "running": false,
        "illuminance": 0,
        "illuminance_lux": 0,
        "charging_status": false,
        "device_temperature": 20,
        "linkquality": 120,
        "power_outage_count": 0
    },
    "0x54ef44100033b742": {
        "temperature": 21,
        "state": "OFF",
        "battery": 94,
        "monitoring_mode": "undirected",
        "update": {
            "state": "idle",
            "installed_version": 3870,
            "latest_version": 3870
        },
        "update_available": false,
        "position": 0,
        "motor_state": "stopped",
        "running": false,
        "illuminance": 0,
        "illuminance_lux": 0,
        "charging_status": false,
        "device_temperature": 16,
        "linkquality": 123,
        "power_outage_count": 1,
        "motor_speed": "high"
    },
    "0x54ef441000329e8f": {
        "temperature": 57,
        "illuminance": 0,
        "illuminance_lux": 0,
        "state": "OFF",
        "battery": 59,
        "position": 0,
        "motor_state": "stopped",
        "running": false,
        "charging_status": false,
        "update": {
            "state": "idle",
            "installed_version": 3870,
            "latest_version": 3870
        },
        "update_available": false,
        "device_temperature": 18,
        "linkquality": 145,
        "power_outage_count": 0,
        "motor_speed": "high"
    },
    "0x00158d0006b63bcb": {
        "occupancy": false,
        "illuminance": 21,
        "illuminance_lux": 10,
        "voltage": 3055,
        "battery": 100,
        "temperature": 27,
        "device_temperature": 27,
        "linkquality": 149,
        "power_outage_count": 10
    },
    "0x00158d0006b642f0": {
        "occupancy": false,
        "illuminance": 3,
        "illuminance_lux": 3,
        "voltage": 3045,
        "battery": 100,
        "temperature": 29,
        "device_temperature": 28,
        "linkquality": 167,
        "power_outage_count": 20
    },
    "0x54ef44100032920d": {
        "device_temperature": 19,
        "illuminance": 0,
        "illuminance_lux": 0,
        "state": "OFF",
        "battery": 65,
        "position": 0,
        "motor_state": "stopped",
        "running": false,
        "power_outage_count": 0,
        "linkquality": 142,
        "charging_status": false,
        "update": {
            "state": "idle",
            "installed_version": 3870,
            "latest_version": 3870
        },
        "update_available": false,
        "motor_speed": "high"
    },
    "0x54ef44100033aadf": {
        "device_temperature": 20,
        "power_outage_count": 40,
        "state": "OFF",
        "battery": 71,
        "position": 0,
        "motor_state": "stopped",
        "running": false,
        "linkquality": 163,
        "charging_status": false,
        "update": {
            "state": "idle",
            "installed_version": 3870,
            "latest_version": 3870
        },
        "update_available": false,
        "motor_speed": "high"
    },
    "0x00158d0007e62971": {
        "occupancy": false,
        "illuminance": 132,
        "illuminance_lux": 4,
        "voltage": 3045,
        "battery": 100,
        "device_temperature": 24,
        "power_outage_count": 9,
        "linkquality": 156
    },
    "0x00158d00044f0829": {
        "voltage": 3005,
        "battery": 100,
        "power_outage_count": 32741,
        "temperature": 23.91,
        "humidity": 59.47,
        "pressure": 1014.5,
        "linkquality": 112
    },
    "0x54ef4410002e1c43": {
        "device_temperature": 19,
        "power_outage_count": 1,
        "state": "OFF",
        "battery": 95,
        "position": 0,
        "motor_state": "stopped",
        "running": false,
        "linkquality": 142,
        "charging_status": false,
        "update": {
            "state": "idle",
            "installed_version": 3870,
            "latest_version": 3870
        },
        "update_available": false
    },
    "0x54ef441000817e98": {
        "device_temperature": 26,
        "power_outage_count": 2,
        "state": "OFF",
        "power_outage_memory": true,
        "flip_indicator_light": "ON",
        "led_disabled_night": false,
        "operation_mode": "control_relay",
        "mode_switch": "anti_flicker_mode",
        "linkquality": 138
    },
    "0x54ef441000258823": {
        "device_temperature": 24,
        "power_outage_count": 3,
        "state": "OFF",
        "state_left": "OFF",
        "state_right": "OFF",
        "mode_switch": "anti_flicker_mode",
        "flip_indicator_light": "ON",
        "power_outage_memory": true,
        "linkquality": 127,
        "operation_mode_left": "control_relay"
    },
    "0x54ef4410006a2d39": {
        "device_temperature": 26,
        "power_outage_count": 1,
        "state": "OFF",
        "state_left": "OFF",
        "power_outage_memory": true,
        "flip_indicator_light": "ON",
        "state_right": "ON",
        "led_disabled_night": false,
        "mode_switch": "anti_flicker_mode",
        "operation_mode_left": "decoupled",
        "operation_mode_right": "control_relay",
        "linkquality": 120
    },
    "0x54ef4410007f6512": {
        "sensor": "external",
        "battery": 51,
        "local_temperature": 22.4,
        "voltage": 3200,
        "occupied_heating_setpoint": 21.5,
        "system_mode": "heat",
        "setup": false,
        "preset": "manual",
        "child_lock": "UNLOCK",
        "window_detection": false,
        "valve_detection": true,
        "away_preset_temperature": "5.0",
        "linkquality": 167,
        "calibrated": true,
        "device_temperature": 22,
        "power_outage_count": 0,
        "internal_heating_setpoint": 21.5,
        "valve_alarm": false,
        "schedule": false,
        "schedule_settings": "mon,sun|0:00,21.0|12:00,17.0|18:00,21.0|23:59,21.0",
        "update": {
            "state": "idle",
            "installed_version": 2590,
            "latest_version": 2590
        },
        "update_available": false,
        "window_open": false
    },
    "0x54ef4410007f64ec": {
        "sensor": "external",
        "battery": 70,
        "voltage": 3200,
        "linkquality": 112,
        "local_temperature": 22.48,
        "calibrated": true,
        "occupied_heating_setpoint": 21.5,
        "system_mode": "heat",
        "setup": false,
        "preset": "manual",
        "child_lock": "LOCK",
        "valve_detection": true,
        "window_detection": false,
        "schedule": false,
        "schedule_settings": "mon,sun|0:00,21.0|12:00,17.0|18:00,21.0|23:59,21.0",
        "away_preset_temperature": "5.0",
        "device_temperature": 24,
        "power_outage_count": 0,
        "internal_heating_setpoint": 5,
        "valve_alarm": false,
        "update": {
            "state": "idle",
            "installed_version": 2590,
            "latest_version": 2590
        },
        "update_available": false,
        "window_open": false
    },
    "0x54ef4410007f65e6": {
        "sensor": "external",
        "battery": 5,
        "voltage": 3200,
        "occupied_heating_setpoint": 21,
        "linkquality": 167,
        "system_mode": "heat",
        "setup": false,
        "child_lock": "UNLOCK",
        "window_detection": false,
        "valve_detection": true,
        "away_preset_temperature": "5.0",
        "schedule": false,
        "schedule_settings": "mon,sun|0:00,21.0|12:00,17.0|18:00,21.0|23:59,21.0",
        "calibrated": true,
        "local_temperature": 21.61,
        "device_temperature": 22,
        "power_outage_count": 1,
        "internal_heating_setpoint": 21,
        "valve_alarm": false,
        "update": {
            "state": "idle",
            "installed_version": 2590,
            "latest_version": 2590
        },
        "update_available": false,
        "window_open": false,
        "preset": "manual"
    },
    "0x54ef4410007f5ceb": {
        "linkquality": 109,
        "battery": 57,
        "voltage": 3300,
        "calibrated": true,
        "local_temperature": 23.91,
        "occupied_heating_setpoint": 24,
        "system_mode": "heat",
        "setup": false,
        "preset": "manual",
        "child_lock": "UNLOCK",
        "sensor": "external",
        "window_detection": true,
        "valve_detection": true,
        "device_temperature": 25,
        "power_outage_count": 1,
        "internal_heating_setpoint": 24,
        "valve_alarm": false,
        "schedule_settings": "mon,sun|0:00,21.0|12:00,17.0|18:00,21.0|23:59,21.0",
        "away_preset_temperature": "5.0",
        "window_open": false,
        "schedule": false,
        "update": {
            "state": "idle",
            "installed_version": 2590,
            "latest_version": 2590
        },
        "update_available": false
    },
    "0x54ef44100098d371": {
        "contact": true,
        "linkquality": 171,
        "voltage": 3009,
        "device_temperature": 25,
        "power_outage_count": 40,
        "state": "OFF",
        "battery": 100
    },
    "0x54ef44100098d32f": {
        "contact": true,
        "voltage": 2993,
        "device_temperature": 25,
        "power_outage_count": 25,
        "state": "OFF",
        "linkquality": 123,
        "battery": 95
    },
    "0x54ef44100081724f": {
        "device_temperature": 19,
        "power_outage_count": 5,
        "state": "OFF",
        "power_outage_memory": true,
        "flip_indicator_light": "ON",
        "led_disabled_night": false,
        "operation_mode": "control_relay",
        "mode_switch": "anti_flicker_mode",
        "linkquality": 120
    },
    "0x54ef44100098d73c": {
        "contact": true,
        "linkquality": 112,
        "voltage": 3007,
        "device_temperature": 25,
        "power_outage_count": 302,
        "state": "OFF",
        "battery": 100
    },
    "0x54ef44100098d40c": {
        "contact": true,
        "voltage": 3014,
        "device_temperature": 25,
        "power_outage_count": 21,
        "state": "OFF",
        "linkquality": 171,
        "battery": 100
    },
    "0x54ef441000925119": {
        "contact": true,
        "voltage": 3022,
        "device_temperature": 25,
        "power_outage_count": 3557,
        "state": "OFF",
        "linkquality": 112,
        "battery": 100
    },
    "0x54ef441000a32674": {
        "device_temperature": 28,
        "power_outage_count": 4,
        "state": "ON",
        "voltage": 224,
        "current": 0.03,
        "power": 6.03,
        "consumer_connected": true,
        "linkquality": 160,
        "update": {
            "state": "idle",
            "installed_version": 43,
            "latest_version": 32
        },
        "update_available": false,
        "energy": 9.21,
        "consumption": 9.210927963256836
    },
    "0x54ef441000a323a9": {
        "device_temperature": 31,
        "power_outage_count": 4,
        "state": "ON",
        "voltage": 228,
        "current": 0.02,
        "power": 13.84,
        "consumer_connected": true,
        "energy": 17.64,
        "consumption": 17.63938331604004,
        "linkquality": 58,
        "update": {
            "state": "idle",
            "installed_version": 43,
            "latest_version": 32
        },
        "update_available": false
    },
    "0x001788010d92bc7a": {
        "color_mode": "color_temp",
        "state": "ON",
        "color_temp": 255,
        "brightness": 190,
        "power_on_behavior": "previous",
        "update": {
            "state": "idle",
            "installed_version": 16786690,
            "latest_version": 16786690
        },
        "update_available": false,
        "linkquality": 167
    },
    "0x001788010b1f85d2": {
        "color_mode": "color_temp",
        "state": "OFF",
        "color_temp": 256,
        "brightness": 254,
        "power_on_behavior": "previous",
        "update": {
            "state": "idle",
            "installed_version": 16786690,
            "latest_version": 16786690
        },
        "update_available": false,
        "linkquality": 123
    },
    "0x001788010ba410cd": {
        "color_mode": "color_temp",
        "state": "OFF",
        "color_temp": 256,
        "brightness": 254,
        "power_on_behavior": "previous",
        "update": {
            "state": "idle",
            "installed_version": 16786690,
            "latest_version": 16786690
        },
        "update_available": false,
        "linkquality": 167
    },
    "0x54ef441000b399c2": {
        "device_temperature": 23,
        "power_outage_count": 6,
        "state": "OFF",
        "voltage": 222,
        "current": 0,
        "power": 0,
        "consumer_connected": true,
        "energy": 4.04,
        "consumption": 4.044671058654785,
        "linkquality": 142,
        "update": {
            "state": "idle",
            "installed_version": 43,
            "latest_version": 32
        },
        "update_available": false
    },
    "0x54ef441000a857ea": {
        "voltage": 3076,
        "battery": 100,
        "device_temperature": 25,
        "power_outage_count": 18,
        "state": "OFF",
        "linkquality": 98
    },
    "0x54ef441000a0c30b": {
        "consumer_connected": true,
        "device_temperature": 24,
        "power_outage_count": 0,
        "state": "OFF",
        "voltage": 228,
        "current": 0,
        "power": 0,
        "energy": 3.48,
        "consumption": 3.480027675628662,
        "linkquality": 134
    },
    "0x54ef44100080f4f8": {
        "device_temperature": 23,
        "power_outage_count": 2,
        "state": "OFF",
        "voltage": 230,
        "current": 0,
        "power": 0,
        "consumer_connected": true,
        "linkquality": 138,
        "energy": 0.87,
        "consumption": 0.8717289566993713
    },
    "0x28dba7fffe0171e4": {
        "battery": 100,
        "voltage": 3000,
        "update": {
            "state": "idle",
            "installed_version": 8704,
            "latest_version": 8704
        },
        "update_available": false,
        "linkquality": 120
    }
}

@Koenkk
Copy link
Owner

Koenkk commented Dec 11, 2024

Fixed in #25169!

Changes will be available in the dev branch in a few hours from now. Note that the dev branch currently contains breaking changes, see #24198

@Koenkk Koenkk closed this as completed Dec 11, 2024
Koenkk added a commit that referenced this issue Dec 11, 2024
@XenorPLxx
Copy link
Author

Thanks, after updating to 1.42.0-dev commit: 1dde41f7eafe2ecfc55fa1d10a7963c211294043 errors no longer appear.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
problem Something isn't working
Projects
None yet
Development

No branches or pull requests

4 participants