Piscator
(Piscator)
April 4, 2025, 2:48pm
1
I am trying to upgrade from zigbee2mqtt 1.x to a 2.x version. I need to set legacy_availability_payload: false in comfiguration.yaml (Zigbee2MQTT 2.0.0 breaking changes · Koenkk/zigbee2mqtt · Discussion #24198 · GitHub )
When I do that, I get errors on all the availability channels in OpenHAB. For example:
Command '{"state":"online"}' from channel 'mqtt:topic:aqaraContactSensor1:availability' not supported by type 'OnOffValue': No enum constant org.openhab.core.library.types.OnOffType.{"state":"online"}
I have the following Thing configuration for that channel:
Type switch : availability "Availability" [ stateTopic = "zigbee2mqtt/aqaraContactSensor1/availability", on="online", off="offline" ]
I suppose zigbee2mqtt is now sending “state”:“online” instead of “online”, but how can I fix that in my Thing definition?
Piscator
(Piscator)
April 4, 2025, 3:39pm
2
I did try the following, because zigbee2mqtt sends now {“state”:“online”} instead of just online . Unfortunately, I still get the same error.
Type switch : availability "Availability" [ stateTopic = "zigbee2mqtt/aqaraClimateSensor1/availability", on="\"state\":\"online\"", off="\"state\":\"offline\"" ]
apella12
(Bob Eckhoff)
April 4, 2025, 6:05pm
3
The only thing that looks odd is that on !=ON
& off !=OFF
I thought the switch item was particular
zigbee2mqtt can use json payload as well as discrete topics. (MQTT Output Type)
So either change this setting to attribute
or attribute_and_json
or setup value transformation with JSONPath.
Type switch : availability "Availability" [ stateTopic = "zigbee2mqtt/aqaraContactSensor1/availability", on="online", off="offline", transformationPattern="JSONPATH:$.state" ]
1 Like
Piscator
(Piscator)
April 4, 2025, 9:31pm
5
Thanks, using the JSONPATH transformation fixed it.
I already did update the following in configuration.yaml . However, zigbee2mqtt keeps sending {“state”:“online”} instead of of just online .
From
experimental:
output: attribute
to
advanced:
output: attribute
Larsen
(Locke)
April 5, 2025, 6:36am
6
availability always sends the complete json as payload no matter if output is set to attribute or attribute_and_json. It doesn’t feel right but it’s stated in the docs too:
2 Likes
Piscator
(Piscator)
April 5, 2025, 10:19am
7
Thanks for pointing that out. I just assumed that the output config parameter would also apply to availability.