From Deconz to Z2M

Hi,

I am in the process of moving all my Zigbee lights form Deconz to Z2M, and would like to know the mqtt alternative to:

self.turn_on(light)

I have been trying with:


light = "zigbee2mqtt/Flur EG"
self.mqtt_publish(light, "ON")

where zigbee2mqtt/Flur EG is the light name that I see in the Z2M logs.

According to the AddDaemon Reference, this should work:

self.mqtt_publish("homeassistant/bedroom/light", "ON")

I can see the message being published in the AppDaemon MQTT Events, but the light stays OFF:

"{"event_type":"MQTT_MESSAGE","data":{"topic":"zigbee2mqtt/Flur EG","wildcard":"#","payload":"ON"},"namespace":"mqtt","time_received":"2022-11-27T13:10:15.276Z"}"

This is my appdaemeon.yaml file:

secrets: /config/secrets.yaml
appdaemon:
  latitude: 52.379189
  longitude: 4.899431
  elevation: 2
  time_zone: Europe/Amsterdam
  plugins:
    HASS:
      type: hass
    MQTT:
      type: mqtt
      namespace: mqtt
      client_host: '192.168.178.76'
      client_port: 1883
      client_user: user
      client_password: password

Can someone help me with this?
Thanks!

Your topic probably isn’t correct, maybe try adding /set to the end of your topic so that its zigbee2mqtt/Flur EG/set. You should be using MQTT Explorer connected to your MQTT broker to help troubleshoot issues like this.

Hi there,

/set made te trick! And MQTT explorer helped me to find a naming error. Thanks for that.

Now I can turn on and off the lights with my KNX wall switches.

That was step 1, just to be sure that AppDaemon is communicating with Z2M, the real aim is to be able to dimm the lights. Some time ago Burningstone helped me with this. I took some code that he wrote and adapted it to my needs, since then my zigbee lights have been working with deconz. But now I would like to know if there are Z2M alternatives to the following:

                     self.call_service(
                        "deconz/configure",
                        field = "/action", 
                        entity = light, 
                        data={"bri_inc": 254, "transitiontime": 25}
                        )
                    self.call_service(
                        "deconz/configure",
                        field = "/action",
                        entity=light,
                        data={"bri_inc": -254, "transitiontime": 25}
                        )
                    self.call_service(
                        "deconz/configure",
                        field = "/action",
                        entity=light,
                        data={"bri_inc": 0}
                        )

Have been trying with variations of:

self.mqtt_publish(light, "ON", brightness = 254, transition = 25)

# or

self.mqtt_publish(light, "ON", "brightness" : 254, "transition" : 25)

This is not working. But has to be possible somehow, right?

Is there any repository with examples on about how to do this?

Try passing the payload as a JSON encoded string. You will need to know what payloads your device is expecting but based on your second example, it would be like this:

payload = json.dumps({"bri_inc": -254, "transitiontime": 25})
self.mqtt_publish(topic=light, payload=payload)