[SOLVED] Zigbee2mqtt and trådfri getting availabilityTopic

Hi,
I’m trying to get the availabilityTopic for a IKEA trådfri socket.

I have managed to get state and linkquality working, but I can’t get the availabilityTopic.
Here is my current “Thing” setup:

    Thing topic ZT007 "ZT007" @ "House" [availabilityTopic="zigbee2mqtt/ZT007/available/state", on="online", off="offline", payloadAvailable="online", payloadNotAvailable="offline"]
    {
        Channels:
            Type switch : state "state" [ stateTopic = "zigbee2mqtt/ZT007", commandTopic = "zigbee2mqtt/ZT007/set/state", on="ON", off="OFF", transformationPattern="JSONPATH:$.state" ]
            Type number : linkquality "linkquality" [ stateTopic = "zigbee2mqtt/ZT007" , transformationPattern="JSONPATH:$.linkquality"]
    }

Using MQTT Explorer (OS X) I can see the messages as:
Screenshot 2022-05-18 at 08.15.56

Any ideas?

Your availabilityTopic is

zigbee2mqtt/ZT007/available

by the looks of your screenshot.

Then your on payload seems to be

{"state":"online"}

Thanks, I didnt realise you could put json in the payloadAvailable, I had to escape the quotation marks.

This is now working:

    Thing topic ZT007 "ZT007" @ "House" [availabilityTopic="zigbee2mqtt/ZT007/availability", payloadAvailable="{\"state\":\"online\"}", payloadNotAvailable="{\"state\":\"offline\"}"]
    {
        Channels:
            Type switch : state "state" [ stateTopic = "zigbee2mqtt/ZT007", commandTopic = "zigbee2mqtt/ZT007/set/state", on="ON", off="OFF", transformationPattern="JSONPATH:$.state" ]
            Type number : linkquality "linkquality" [ stateTopic = "zigbee2mqtt/ZT007" , transformationPattern="JSONPATH:$.linkquality"]
    }
1 Like

No problem.

You don’t need to rename the topic - just click the check box on the post that contains the solution - this way the solution will appear together with the top post, and a check mark will appear in the title automatically.

2 Likes