You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
First of all, thanks for creating AppDaemon, my goto for HA automations!
I was trying to iterate over the mqtt broker stored/retained messages in my app via the topic 'homeassistant/#' on appdaemon startup.
However retained messages are never delivered to it but only updates after the app has started.
When running appdaemon in DEBUG log level I can see on startup that it's receiving the retained messages from the broker, but it doesn't forwards them to my app.
Which is sad as I was trying to append the force_update: True value to all retained messages.
This is similar to #571 but in that issue the author seemed to have atleast received the retained messages on appdaemon startup
Version
4.2.2
Installation type
Python virtual environment
Relevant log output
No response
Relevant code in the app or config file that caused the issue
mport json
import re
import mqttapi as mqtt
'''This class makes all mqtt entities to trigger an state update on every new incoming payload.This is required for statistics in influxdb and grafana,as without, only actual data changes are forwarded to influx,but if the last send data is out-of the current graph timespan no data will be shown.Instead make every sensor update to be written to the influxdb'''
class MqttForceUpdate(mqtt.Mqtt):
def initialize(self):
self.set_log_level("DEBUG")
self.set_namespace("mqtt")
self.listen_event(self.mqtt_message_received_event, "MQTT_MESSAGE")
def mqtt_message_received_event(self, event_name, data, cb_args):
try:
topic = data["topic"]
payload = json.loads(data["payload"])
if not "force_update"in payload:
self.mqtt_force_update(topic=topic, payload=payload)
except (json.JSONDecodeError, KeyError) as err:
print(err)
def mqtt_force_update(self, **cb_args):
topic = cb_args["topic"]
payload = cb_args["payload"]
payload["force_update"] = True
self.log(f"Forcing update for '{topic}'")
self.mqtt_publish(topic=topic, payload=payload, retain = True)
Anything else?
No response
The text was updated successfully, but these errors were encountered:
PS: self.mqtt_publish(topic=topic, payload=payload, retain = True)
doesn't seem to work either, as nothing is published when triggered, but this is for another issue... maybe my configuration is just simply wrong?
EDIT: fixed it, I had to convert the payload back to a string for it to work
What happened?
First of all, thanks for creating AppDaemon, my goto for HA automations!
I was trying to iterate over the mqtt broker stored/retained messages in my app via the topic 'homeassistant/#' on appdaemon startup.
However retained messages are never delivered to it but only updates after the app has started.
When running appdaemon in DEBUG log level I can see on startup that it's receiving the retained messages from the broker, but it doesn't forwards them to my app.
Which is sad as I was trying to append the
force_update: True
value to all retained messages.Here is my appdaemon.yaml:
apps/apps.yaml
:This is similar to #571 but in that issue the author seemed to have atleast received the retained messages on appdaemon startup
Version
4.2.2
Installation type
Python virtual environment
Relevant log output
No response
Relevant code in the app or config file that caused the issue
Anything else?
No response
The text was updated successfully, but these errors were encountered: