Odianosen25 / Monitor-App

Appdaemon App for Andrew's Monitor Presence Detection System
74 stars 9 forks source link

Presence_event not firing due to wildcard #83

Open alandtse opened 2 years ago

alandtse commented 2 years ago

I'm not sure when it started, but after some recent updates of HA/AppDaemon, I noticed my monitor sensors weren't being created. Currently my HA/AppDaemon/Home_presence_app is at 2021.10.5/0.7.0/2.4.1. My configuration for home_presence_app is basically just defaults and didn't change from when it stopped working.

After debugging, I determined that the listen event was not processing anything from monitor/#. I ended up having to commenting out the wildcard arg in the listen_event registration and adding a manual filter in presence_message.

        # Setup primary MQTT Listener for all presence messages.
        self.mqtt.listen_event(
            self.presence_message,
            self.args.get("mqtt_event", "MQTT_MESSAGE"),
            #wildcard=f"{self.presence_topic}/#",
        )
    def presence_message(self, event_name, data, kwargs):
        """Process a message sent on the MQTT Topic."""
        topic = data.get("topic")
        payload = data.get("payload")
        self.adbase.log(f"{topic} payload: {payload}", level="DEBUG")

# addition here
        if not topic.startswith(self.presence_topic):
            return
        topic_path = topic.split("/")
        action = topic_path[-1].lower()

Reading through the AppDaemon MQTT API, I have no idea why the wildcard kwarg is having a problem. I'd normally submit a PR but it seems like a step backward to disable the wildcard and filter in the callback. I did check the AppDaemon Issues and didn't see any mention of this there. Once I got my workaround, I didn't bother to go down the stack to figure out anything further due to attention-span constraints but I thought I'd at least report the issue if someone else runs into this and wants a workaround.

Odianosen25 commented 2 years ago

Hello @alandtse,

Apologies too a while to response. There was a recent update in AD, and it only allows to make use of wildcards, only if AD subscribed to the MQTT topic using wildcards. So there is a recent fix for this, and its simply the app being response for the subscribing and not from plugin setup.

Kind use the latest and let me know how it goes