Hi All, it’s been a while since the last release, due to some real life issues - but the good news is we have a new release now!
There are lots of goodies here, including support for HASS’ new authentication methods via Long Lived Tokens, and the official release of the AppDaemon MQTT plugin.
I also added support for version 5 of Font Awesome icons - that will be a breaking change for many dashboards and skins but I also included a compatibility mode to give you time to make the necessary changes.
Here is the full list of changes:
3.0.2 10/31/2018
Features
added set_textvalue() api call.
added app_init_delay to delay App Initialization
Added ability to register apps to receive log entries
Added instructions for running a dev build
Added support for Long Lived Access Tokens
Updated MDI Icons to 3.0.39
Updated Font Awesome Icons to 5.4.2
Added MQTT Plugin - contributed by Tod Schmidt <https://github.com/tschmidty69>__
Many MQTT Plugin enhancements - contributed by Odianosen Ejale <https://github.com/Odianosen25>__
Added entitypicture widget - contributed by hwmland <https://github.com/hwmland>__
Docker start script will now check recursively for additional requirements and install them - contributed by Kevin Eifinger <https://github.com/eifinger>__
Added ability to set units explicitly in widgets - contributed by Rene Tode <https://github.com/ReneTode>__
Added --upgrade to pip3 call for recursive requirements.txt scanning - contributed by Robert Schindler <https://github.com/efficiosoft>__
Added the ability to pass stringified JSON parameters to service calls - contributed by Clyra <https://github.com/clyra>__
Fixes
Fixed incorrect service call in set_value()
Enforce domain name in rss feed target to avoid issues with other functions
Previously deleted modules will now be correctly reloaded to reflect changes
Fixed a bug in get_scheduler_entries()
Prevent periodic refresh of HASS state from overwriting App created entities - contributed by Odianosen Ejale <https://github.com/Odianosen25>__
Fix to honor cert_path - contributed by Myles Eftos <https://github.com/madpilot>__
Run AD in docker as PID 1 - contributed by Rolf Schäuble <https://github.com/rschaeuble>__
Fix encoding error in log messages - contributed by Markus Meissner <https://github.com/daringer>__
Fix a bug in get_plugin_meta() - contributed by Odianosen Ejale <https://github.com/Odianosen25>__
Various Doc corrections and additions - contributed by Odianosen Ejale <https://github.com/Odianosen25>__
Various fixes in the Docker docs - contributed by Simon van der Veldt <https://github.com/simonvanderveldt>__
Namespace fixes - contributed by Odianosen Ejale <https://github.com/Odianosen25>__
More namespace fixes - contributed by Odianosen Ejale <https://github.com/Odianosen25>__
Fixes of the namespaces fixes - contributed by Brian Redbeard <https://github.com/brianredbeard>__
Fix typo in sample systemd config - contributed by Evgeni Kunev <https://github.com/kunev>__
Fix to cert path config - contributed by nevalain <https://github.com/nevalain>__
Breaking Changes
RSS target names must now consist of a domain as well as the target name, e.g. rss.cnn_news
SSE Support has been removed
Use of ha_key for authentication is deprecated and will be removed at some point. For now it will still work
Many Font Awesome Icon names have changed - any custom icons you have on dashboards will need to be changed to suit - see docs for more detail.
While working through the upgrade it is strongly advised that you clear your browser cache and force recompiles of all of your dashboards to flush out references to old icons. This can be done by manually removing the compiled subdirectory in conf_dir, specifying recompile=1 in the arguments to the dashboard, or setting the hadashboard option dash_compile_on_start to 1.
Thanks Rene - the URL argument to force a compile should be recompile=1 as stated, I should have made that clearer. dash_force_compil is an alternative to dash_compile_on_start and is part of the HADasboard config secion of appdaemon.yaml
The new hassio addon should be available soon, @frenck is aware of the new release.
I have been playing around with the MQTT plugin, and I can’t seem to use the MQTT api methods
2018-10-31 21:37:32.677179 WARNING AppDaemon: Traceback (most recent call last):
File "/home/homeassistant/appdaemon_venv/lib/python3.6/site-packages/appdaemon
/appdaemon.py", line 1581, in init_object
init()
File "/home/homeassistant/.homeassistant/apps/mqtt_light/mqtt_light.py", line
12, in initialize
self.mqtt_subscribe("abc")
AttributeError: 'MqttLights' object has no attribute 'mqtt_subscribe'
I can subscribe using the config, and receive messages through listen_event, so it is basically working, but it seems like I am missing some inheritance somewhere.
I’ve updated the Hass.io add-on to include this latest 3.0.2 release. There is a difference with the original announcement above by @aimc:
The add-on migrates the use of ha_key to token automatically in case you use http://hassio/homeassistant as the ha_url (which you should on Hassio)
The clearing/flushing of the compiled directory is handled by the add-on automatically, so no special configuration or actions from your end are needed.
I hadn’t, which was the problem. My excuse was there is no mention of having to do that in the docs.
It is obvious, once I think of it, since the hass apps are derived from something in the hass plugin, but some mention in the docs would probably help.
there are some parts of the docs rewritten, but when you use AD for a long time its hard to find those changes.
off course people like you dont look at the parts from the docs explaining how to write an app.
i have it already on my list to rearrange some parts from the docs, so if you have any idea how the docs could be better then please let us know.
But in general, can I suggest that the information for each plugin is collected together in one place, rather than scattered throughout the pages - I mean the base class, events listened to, the api reference and whatever else is needed, plus of course, some examples.
Then let me add to that with more thanks! I had some issues getting started, but with your help I was able to accomplish all of my automation needs with Python and AD! It has been running great for months now!
Hi, I am trying to figure out how to listen to mqtt topics using the new MQTT-feature and how to pass the payload and topic to my app. I cannot find any examples in the documentation that help me any further. Is something like this possible?
pseudo-code:
class myapp(hass.Hass):
def initialize(self):
# first subscribe to a topic x/y/z
self.mqtt_subscribe(self, x/y/z, **kwargs)
# next, listen to it
handle = listen_event(callback, event = None, **kwargs)
def callback(payload)
# do something with the received payload
self.log(payload)
First of all, it will not be possible to do self.mqtt_subscribe(self, x/y/z, **kwargs) within the HASS namespace. So it is better to do this in the plugin configuration. Also as highlighted by @gpbenton, you need to make use of the namespace parameter.
So your configuration should be something like this
You can leave most of the parameters empty if you are using localhost and have no username and password on your broker.
in your code, you do the following
class myapp(hass.Hass):
def initialize(self):
self.handle = self.listen_event(self.mqtt_callback, 'MQTT_MESSAGE', namespace = 'mqtt')
def mqtt_callback(self, event_name, data, kwargs):
# do something with the received payload
self.log(data['payload'])
Hope this helps. More examples will be released soon, so it becomes easier to build using it
import appdaemon.plugins.hass.hassapi as hass
class mqtttest(hass.Hass):
def initialize(self):
self.handle = self.listen_event(self.mqtt_callback, 'MQTT_MESSAGE', namespace = 'mqtt')
def mqtt_callback(self, event_name, data, kwargs):
# do something with the received payload
self.log(data['payload'])
Doing mosquitto_pub -t "x/y/z" -m "lala"
gives 2018-11-14 19:02:25.004754 INFO mqtttest: lala in the logs
AttributeError: 'mqtttest' object has no attribute 'mqtt_publish'
Edit:
I made some progress here, after changing the app to
import appdaemon.plugins.mqtt.mqttapi as mqtt
#import appdaemon.plugins.hass.hassapi as hass
class mqtttest(mqtt.Mqtt):
def initialize(self):
self.handle = self.listen_event(self.mqtt_callback, 'MQTT_MESSAGE', namespace = 'mqtt')
def mqtt_callback(self, event_name, data, kwargs):
# do something with the received payload
self.log(data['payload'])
self.log("Sending back to mqtt")
self.mqtt_publish("monitor/gg-mon", "100", qos = 0, retain = True, namepace = "mqtt")
I am getting
2019-02-03 08:33:51.403842 CRITICAL AppDaemon: Wrong Namespace 'default' selected for MQTT Service. Please use proper namespace before trying again
2019-02-03 08:33:51.405779 WARNING mqtttest: Could not execute Service Call, as wrong Namespace 'default' used