Appdaemon not receiving MQTT events

Hi,

I want to make a simple class that catches MQTT change. Here is what I do. But the event is never triggered.
I publish MQTT data manually with MQTT explorer (on windows)

What am I doing wrong ?

class myClass(hass.Hass, mqtt.Mqtt):

    def initialize(self):
        self.listen_event(self.mqtt_message_received_event, "MQTT_MESSAGE" )
     
    def mqtt_message_received_event(self,eventname,data,kwargs):
        self.log("---------------------")
        self.log(data[0])

Please post your appdemon.yaml file.

Depending on your config, you might need to change the self.listen_event to

self.listen_event(self.mqtt_message_received_event, "MQTT_MESSAGE", namespace="mqtt")
---
secrets: /config/secrets.yaml
appdaemon:
  latitude: ---
  longitude: ---
  elevation: 2
  time_zone: Europe/Amsterdam
  plugins:
    HASS:
      type: hass
http:
  url: http://127.0.0.1:5050
admin:
api:
hadashboard:
logs:
  error_log:
    filename: /config/appdaemon/logs/error.log
  main_log:
    filename: /config/appdaemon/logs/appdaemon.log
  access_log:
    filename: /config/appdaemon/logs/access.log
  diag_log:
    filename: /config/appdaemon/logs/diag.log

you are missing the MQTT config. Change the plugins section to: (Adjust for your MQTT ip and port)

  plugins:
    HASS:
      type: hass
    MQTT:
      type: mqtt
      namespace: mqtt
      client_host: 192.168.1.45
      client_port: 1883

Thanks. That was it :slight_smile: