Hi all
I have a problem with AppDaemon and its MQTT plugin. I installed “Home Assistant Supervised” and installed AppDaemon from the App-Store within that. After that I changed appdaemon.yaml to this:
---
secrets: /config/secrets.yaml
appdaemon:
latitude: 52.379189
longitude: 4.899431
elevation: 2
time_zone: Europe/Amsterdam
plugins:
MQTT:
type: mqtt
namespace: mqtt
client_host: '172.21.42.8'
verbose: true
HASS:
type: hass
http:
url: http://127.0.0.1:5050
admin:
api:
hadashboard:
and I made a small test program:
import mqttapi as mqtt
class NokLight(mqtt.Mqtt):
def initialize(self):
# self.mqtt_subscribe("home/binary_sensor/nielsole/state")
self.listen_event(self.mqtt_message_received_event, "MQTT_MESSAGE", topic="home/#" )
if self.is_client_connected():
self.log('MQTT is connected')
self.log('NOK Light started')
def mqtt_message_received_event(self,eventname,data,kwargs):
self.log(data)
However this test-program results in this output in the AppDaemon log:
2020-04-02 18:14:55.101811 WARNING nok_light: ------------------------------------------------------------
2020-04-02 18:14:55.100732 WARNING nok_light: Traceback (most recent call last):
File "/usr/lib/python3.8/site-packages/appdaemon/app_management.py", line 145, in initialize_app
await utils.run_in_executor(self, init)
File "/usr/lib/python3.8/site-packages/appdaemon/utils.py", line 276, in run_in_executor
response = future.result()
File "/usr/lib/python3.8/concurrent/futures/thread.py", line 57, in run
result = self.fn(*self.args, **self.kwargs)
File "/config/appdaemon/apps/nok_light.py", line 10, in initialize
if self.is_client_connected():
File "/usr/lib/python3.8/site-packages/appdaemon/utils.py", line 191, in inner_sync_wrapper
f = run_coroutine_threadsafe(self, coro(self, *args, **kwargs))
File "/usr/lib/python3.8/site-packages/appdaemon/utils.py", line 285, in run_coroutine_threadsafe
result = future.result(self.AD.internal_function_timeout)
File "/usr/lib/python3.8/concurrent/futures/_base.py", line 439, in result
return self.__get_result()
File "/usr/lib/python3.8/concurrent/futures/_base.py", line 388, in __get_result
raise self._exception
File "/usr/lib/python3.8/site-packages/appdaemon/plugins/mqtt/mqttapi.py", line 318, in is_client_connected
return await plugin.mqtt_client_state()
AttributeError: 'HassPlugin' object has no attribute 'mqtt_client_state'
It is as if the MQTT plugin isn’t used at all. See the last line: “AttributeError: ‘HassPlugin’ object has no attribute ‘mqtt_client_state’”.
It also complains about mqtt_subscribe(), thats why it is commented out.
This is AppDaemon 4.0.3.
Does anyone have a clue? I’m a novice with respect to Home Assistant and AppDaemon