Skip to content

MQTT plugin never resets first_time → apps in mqtt namespace not restarted after broker reconnect (regression in 4.5.x) #2665

Description

@herrmannj

What happened?

When the MQTT broker connection drops, AppDaemon stops apps in the mqtt namespace (PLUGIN_FAILED) but never restarts them after reconnect — they stay stopped until a manual reload. HASS recovers, MQTT does not.

Root cause: PLUGIN_RESTART is only triggered when self.first_time is False (plugin_management.py).
PluginBase.first_time defaults to True. hass/hassplugin.py sets self.first_time = False in post_auth; mqtt/mqttplugin.py never sets it (only an unrelated local first_time_service) → stays True → restart never fires.

Regression: 4.4.2 had a local first_time toggle in the MQTT get_updates, lost in the 4.5 refactor. Affects 4.5.0–4.5.11+ dev.

Docs contradiction: APPGUIDE says reconnect restarts all apps + calls initialize().

Fix: set self.first_time = False after first successful MQTT connect, mirroring hassplugin.py.

Repro: app in namespace: mqtt; restart broker; app is stopped and never restarted.

Version

4.5.x

Installation type

Home Assistant add-on

Relevant log output

Relevant code in the app or config file that caused the issue

Anything else?

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    issueSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions