I’m having trouble getting my AppDaemon app to talk to the MQTT service. Here’s the details of my config;
- Mosquitto running on HASS.IO
AppDaemon config
secrets: /config/secrets.yaml
log:
logfile: STDOUT
errorfile: STDERR
appdaemon:
threads: 10
app_dir: /config/appdaemon/apps
plugins:
HASS:
type: hass
ha_url: http://hassio/homeassistant
token: <removed>
MQTT:
type: mqtt
namespace: mqtt
client_host: 192.168.86.125
My app is as follows (I’ve also used MQTT_MESSAGE);
import appdaemon.plugins.mqtt.mqttapi as mqtt
import json
class SendSMS(mqtt.Mqtt):
def initialize(self):
self.log("SendSMS Ready")
self.listen_event(self.mqtt_message, "MQTT_EVENT", namespace = "mqtt", topic = 'homeassistant/sms/send_message')
def mqtt_message(self, event_name, data, kwargs):
json_data = json.loads(data['payload'])
self.log('Sending "' + json_data['message'] + '" to ' + json_data['number'])
And the log shows the following;
2019-11-15 21:25:01.794885 INFO AppDaemon: Loading Plugin MQTT using class MqttPlugin from module mqttplugin
2019-11-15 21:25:01.827799 INFO AppDaemon: MQTT: MQTT Plugin Initializing
2019-11-15 21:25:01.828369 INFO AppDaemon: MQTT: Using 'mqtt client status' as Will Topic
2019-11-15 21:25:01.828913 INFO AppDaemon: MQTT: Using 'mqtt client status' as Birth Topic
2019-11-15 21:25:01.829494 INFO AppDaemon: MQTT: Using 'appdaemon_mqtt_client' as Client ID
2019-11-15 21:25:01.895857 INFO AppDaemon: Got initial state from namespace mqtt
2019-11-15 21:25:01.883919 INFO AppDaemon: MQTT: Connected to Broker at URL 192.168.86.125:1883
2019-11-15 21:25:01.897103 INFO AppDaemon: MQTT: MQTT Plugin initialization complete
I’ve got an MQTT client checking the broker and the message is getting picked up by the broker, but the app is not responding. Have I missed anything obvious?