Skip to content

Presence_event not firing due to wildcard #83

Description

@alandtse

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions