Odianosen25 / Monitor-App

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

Failing after appdaemon update #76

Closed pittbull closed 3 years ago

pittbull commented 3 years ago

I am having issues getting the monitor-app to run after the 0.5.0 update recently. Is this a known issue?

Odianosen25 commented 3 years ago

@pittbull,

Please can you help with the new errors? I do run mine, and it works fine. Or maybe I made a change and haven't updated it yet since it hadn't been released

Regards

pittbull commented 3 years ago

I actually don't have any error messages (will retry with debug mode), but what I see in the appdaemon dashboard is that Monitor-app does not load at all.

pittbull commented 3 years ago

This is the output with log_level debug on the Monitor-app:

2021-03-22 12:41:55.302953 INFO AppDaemon: SIGTERM Received
2021-03-22 12:41:55.303319 INFO AppDaemon: AppDaemon is shutting down
2021-03-22 12:41:55.306564 INFO MQTT: Stopping MQTT Plugin and Unsubscribing from URL 192.168.1.20:1883
2021-03-22 12:41:55.308270 INFO HASS: Disconnecting from Home Assistant
2021-03-22 12:41:55.533306 INFO AppDaemon: Removing module /config/appdaemon/apps/Monitor-App/home_presence_app.py
2021-03-22 12:41:55.533764 INFO AppDaemon: Terminating home_presence_app
2021-03-22 12:41:55.534103 INFO AppDaemon: Calling terminate() for home_presence_app
2021-03-22 12:41:55.536197 INFO AppDaemon: Shutting down webserver
2021-03-22 12:41:55.974719 INFO AppDaemon: Saving all namespaces
2021-03-22 12:41:55.975150 INFO AppDaemon: AppDaemon is stopped.
2021-03-22 12:42:02.520140 INFO AppDaemon: AppDaemon Version 4.0.6 starting
2021-03-22 12:42:02.520442 INFO AppDaemon: Python version is 3.8.8
2021-03-22 12:42:02.520712 INFO AppDaemon: Configuration read from: /config/appdaemon/appdaemon.yaml
2021-03-22 12:42:02.520941 INFO AppDaemon: Added log: AppDaemon
2021-03-22 12:42:02.521202 INFO AppDaemon: Added log: Error
2021-03-22 12:42:02.521438 INFO AppDaemon: Added log: Access
2021-03-22 12:42:02.521707 INFO AppDaemon: Added log: Diag
2021-03-22 12:42:02.542005 INFO AppDaemon: Loading Plugin HASS using class HassPlugin from module hassplugin
2021-03-22 12:42:02.575400 INFO HASS: HASS Plugin Initializing
2021-03-22 12:42:02.575675 INFO HASS: HASS Plugin initialization complete
2021-03-22 12:42:02.575989 INFO AppDaemon: Loading Plugin MQTT using class MqttPlugin from module mqttplugin
2021-03-22 12:42:02.582602 INFO MQTT: MQTT Plugin Initializing
2021-03-22 12:42:02.582857 INFO MQTT: Using 'appdaemon/status' as Will Topic
2021-03-22 12:42:02.583090 INFO MQTT: Using 'appdaemon/status' as Birth Topic
2021-03-22 12:42:02.584067 INFO AppDaemon: Initializing HTTP
2021-03-22 12:42:02.584596 INFO AppDaemon: Using 'ws' for event stream
2021-03-22 12:42:02.587850 INFO AppDaemon: Starting API
2021-03-22 12:42:02.591310 INFO AppDaemon: Starting Admin Interface
2021-03-22 12:42:02.591732 INFO AppDaemon: Starting Dashboards
2021-03-22 12:42:02.605511 INFO HASS: Connected to Home Assistant 2021.3.4
2021-03-22 12:42:02.612635 INFO MQTT: Connected to Broker at URL 192.168.1.20:1883
2021-03-22 12:42:02.625793 INFO AppDaemon: Got initial state from namespace mqtt
2021-03-22 12:42:02.626234 INFO MQTT: MQTT Plugin initialization complete
2021-03-22 12:42:02.627732 INFO AppDaemon: App 'home_presence_app' added
2021-03-22 12:42:02.628464 INFO AppDaemon: Found 1 total apps
2021-03-22 12:42:02.628932 INFO AppDaemon: Starting Apps with 1 workers and 1 pins
2021-03-22 12:42:02.630066 INFO AppDaemon: Running on port 5050
2021-03-22 12:42:02.641394 INFO HASS: Evaluating startup conditions
2021-03-22 12:42:02.644528 INFO HASS: Startup condition met: hass state=RUNNING
2021-03-22 12:42:02.644844 INFO HASS: All startup conditions met
2021-03-22 12:42:02.674209 INFO AppDaemon: Got initial state from namespace default
2021-03-22 12:42:04.637244 INFO AppDaemon: Scheduler running in realtime
2021-03-22 12:42:04.640820 INFO AppDaemon: Adding /config/appdaemon/apps to module import path
2021-03-22 12:42:04.641274 INFO AppDaemon: Adding /config/appdaemon/apps/Monitor-App to module import path
2021-03-22 12:42:04.643531 INFO AppDaemon: Loading App Module: /config/appdaemon/apps/Monitor-App/home_presence_app.py
2021-03-22 12:42:04.648840 INFO AppDaemon: Initializing app home_presence_app using class HomePresenceApp from module home_presence_app
2021-03-22 12:42:04.656925 DEBUG home_presence_app: set state: monitor.monitor_state, {'state': 'idle', 'attributes': {'locations': [], 'version': '2.3.4', 'nodes': 0, 'online_nodes': [], 'offline_nodes': [], 'friendly_name': 'Monitor System State'}, 'replace': True}
2021-03-22 12:42:04.657522 WARNING home_presence_app: home_presence_app: Entity monitor.monitor_state not found in namespace mqtt
2021-03-22 12:42:04.658129 INFO AppDaemon: home_presence_app: Entity monitor.monitor_state created in namespace: mqtt
2021-03-22 12:42:04.660103 DEBUG home_presence_app: Calling listen_state for home_presence_app
2021-03-22 12:42:04.664918 INFO home_presence_app: Previous message repeated 1 times
2021-03-22 12:42:04.665219 WARNING home_presence_app: home_presence_app: Entity binary_sensor.cinema_smoke_detector_sensor not found in namespace default
2021-03-22 12:42:04.665775 DEBUG home_presence_app: Calling listen_state for home_presence_app
2021-03-22 12:42:04.668134 DEBUG home_presence_app: Registering run_every starting 2021-03-22 12:42:05.666994+01:00 in 30s intervals for home_presence_app
2021-03-22 12:42:04.669836 DEBUG home_presence_app: Calling listen_event for home_presence_app
2021-03-22 12:42:04.777708 DEBUG home_presence_app: Listening on MQTT Topic monitor
2021-03-22 12:42:04.778662 DEBUG home_presence_app: Calling listen_event for home_presence_app
2021-03-22 12:42:04.779969 DEBUG home_presence_app: Registering run_in in 0 seconds for home_presence_app
2021-03-22 12:42:04.781571 DEBUG home_presence_app: register_service: monitor/remove_known_device, {}
2021-03-22 12:42:04.781879 DEBUG home_presence_app: register_service: monitor/run_arrive_scan, {}
2021-03-22 12:42:04.782157 DEBUG home_presence_app: register_service: monitor/run_depart_scan, {}
2021-03-22 12:42:04.782434 DEBUG home_presence_app: register_service: monitor/run_rssi_scan, {}
2021-03-22 12:42:04.782749 DEBUG home_presence_app: register_service: monitor/run_node_command, {}
2021-03-22 12:42:04.783036 DEBUG home_presence_app: register_service: monitor/restart_device, {}
2021-03-22 12:42:04.783314 DEBUG home_presence_app: register_service: monitor/reload_device_state, {}
2021-03-22 12:42:04.783626 DEBUG home_presence_app: register_service: monitor/load_known_devices, {}
2021-03-22 12:42:04.783913 DEBUG home_presence_app: register_service: monitor/clear_location_entities, {}
2021-03-22 12:42:04.784211 DEBUG home_presence_app: register_service: monitor/clean_devices, {}
2021-03-22 12:42:04.786399 INFO AppDaemon: App initialization complete
2021-03-22 12:42:05.007448 DEBUG home_presence_app: call_service: mqtt/publish, {'topic': 'monitor/state', 'payload': '{"locations": [], "version": "2.3.4", "nodes": 0, "online_nodes": [], "offline_nodes": [], "last_changed": "2021-03-22T12:42:04+01:00", "state": "idle"}'}
2021-03-22 12:42:05.016969 DEBUG home_presence_app: Registering run_in in 45 seconds for home_presence_app
2021-03-22 12:42:05.018741 DEBUG home_presence_app: Registering run_in in 105 seconds for home_presence_app
2021-03-22 12:42:06.005768 DEBUG home_presence_app: call_service: mqtt/publish, {'topic': 'monitor/echo', 'payload': ''}

From what I can see monitoring the mqtt transactions the app does what it is supposed to do, but it does not seem to load properly in Appdaemon. I find no active apps in the dashboard.

Odianosen25 commented 3 years ago

From what I can see monitoring the mqtt transactions the app does what it is supposed to do, but it does not seem to load properly in Appdaemon. I find no active apps in the dashboard.

That is weird really, not sure why the app should stop. as mine has been running in this version of AD for a long time. And you sure no errors or anything? Mine on Admin panel is below

image

But on another note, in 4.0.6, there is a breaking change, whereby when subscribing and wanting to use the wildcard in the app, one must subscribe using the wild card.

So please can you ensure you have monitor/# as the topic you listening to when configuring your plugin?

I will need to add the subscription of the topic in the app itself, if this fixes your issue.

Regards

pittbull commented 3 years ago

Might be that I have an appdaemon issues as this table is empty when loading the AD dashboard after reinstalling and having no apps:

Version  
Booted  
Uptime  
Odianosen25 commented 3 years ago

Ah if that is the case, pls clear your cache and try again.

Sometimes it can be annoying when that happens. I have like 3 AD systems running on my network, and sometimes I get into that issue when I ave different versions running at once.

Regards

pittbull commented 3 years ago

I have cleared all cache, restarted HA, rebooted host - and reinstalled AD - same result. 🤷‍♂️

pittbull commented 3 years ago

Embarrassing - clearing the cache yet another time solved it. Now I get the proper dashboard and Monitor is loaded.

pittbull commented 3 years ago

From what I can see monitoring the mqtt transactions the app does what it is supposed to do, but it does not seem to load properly in Appdaemon. I find no active apps in the dashboard.

That is weird really, not sure why the app should stop. as mine has been running in this version of AD for a long time. And you sure no errors or anything? Mine on Admin panel is below

image

But on another note, in 4.0.6, there is a breaking change, whereby when subscribing and wanting to use the wildcard in the app, one must subscribe using the wild card.

So please can you ensure you have monitor/# as the topic you listening to when configuring your plugin?

I will need to add the subscription of the topic in the app itself, if this fixes your issue.

Regards

If I add 'monitor/#' to the monitor-app yaml I get the following, and nothing works:

2021-03-22 13:15:06.567892 WARNING home_presence_app: home_presence_app: Entity #.monitor_state not found in namespace mqtt
2021-03-22 13:15:06.568436 INFO AppDaemon: home_presence_app: Entity #.monitor_state created in namespace: mqtt
2021-03-22 13:15:06.575874 WARNING home_presence_app: home_presence_app: Entity binary_sensor.cinema_smoke_detector_sensor not found in namespace default
2021-03-22 13:15:06.695542 INFO AppDaemon: App initialization complete
2021-03-22 13:15:23.963866 INFO AppDaemon: Client disconnection from Admin Client
2021-03-22 13:15:24.123420 INFO AppDaemon: New client Admin Client connected
Odianosen25 commented 3 years ago

If I add 'monitor/#' to the monitor-app yaml I get the following, and nothing works

No I meant the plugin config not the app. But if its working now, there is nothing to do again.

Regards

Odianosen25 commented 3 years ago

Embarrassing - clearing the cache yet another time solved it. Now I get the proper dashboard and Monitor is loaded.

Oh yeah I know that feeling heheh

pittbull commented 3 years ago

If I add 'monitor/#' to the monitor-app yaml I get the following, and nothing works

No I meant the plugin config not the app. But if its working now, there is nothing to do again.

Regards

Well, actually it is not working. I can see the app interfacing with MQTT, but it does not create the devices nor interact with Home Assistant.

Odianosen25 commented 3 years ago

@pittbull,

Can I know what your mqtt plugin config looks like?

pittbull commented 3 years ago
appdaemon:
  latitude: 52.379189
  longitude: 4.899431
  elevation: 2
  time_zone: Europe/Amsterdam
  plugins:
    HASS:
      type: hass
      token:<token>
      ha_url: http://ip:8123
    MQTT:
      type: mqtt
      namespace: mqtt
      client_host: 'x.x.x.x'
      client_user: <username>
      client_password: <password>
      client_id: appdaemon

Been like this since I started with AD and Monitor.

Log from MQTT showing that Monitor-app communicates:

monitor/echo (null)
monitor/garage/echo ok
monitor/main floor/echo ok
nortuzar commented 3 years ago

Having a similar problem, after updating to AD 5.0 it seems that it wont connect with the raspberry running monitor, this is the log on the HA MQTT broker plugin

1616417112: New connection from 192.168.1.17 on port 1883.
1616417112: New client connected from 192.168.1.17 as w30190 (p2, c1, k60, u'mqtt').
1616417112: Client w30190 disconnected.
1616417113: New connection from 192.168.1.17 on port 1883.
1616417113: New client connected from 192.168.1.17 as w30192 (p2, c1, k60, u'mqtt').
1616417113: Client w30192 disconnected.
1616417113: New connection from 192.168.1.17 on port 1883.
1616417113: New client connected from 192.168.1.17 as w30200 (p2, c1, k60, u'mqtt').
1616417113: Client w30200 disconnected.
1616417113: New connection from 192.168.1.17 on port 1883.
1616417113: New client connected from 192.168.1.17 as w30207 (p2, c1, k60, u'mqtt').
1616417113: Client w30207 disconnected.
1616417113: New connection from 192.168.1.17 on port 1883.
1616417113: New client connected from 192.168.1.17 as w30211 (p2, c1, k60, u'mqtt').
1616417114: Client w30211 disconnected.
1616417114: New connection from 192.168.1.17 on port 1883.
1616417114: New client connected from 192.168.1.17 as w30217 (p2, c1, k60, u'mqtt').
1616417114: Client w30217 disconnected.
1616417114: New connection from 192.168.1.17 on port 1883.
1616417114: New client connected from 192.168.1.17 as w30234 (p2, c1, k60, u'mqtt').
1616417114: Client w30234 disconnected.
1616417115: New connection from 192.168.1.17 on port 1883.
1616417115: New client connected from 192.168.1.17 as w30286 (p2, c1, k60, u'mqtt').
1616417115: Client w30286 disconnected.
1616417115: New connection from 192.168.1.17 on port 1883.
1616417115: New client connected from 192.168.1.17 as w30305 (p2, c1, k60, u'mqtt').
1616417115: Client w30305 disconnected.
1616417132: New connection from 192.168.1.17 on port 1883.
1616417132: New client connected from 192.168.1.17 as w31242 (p2, c1, k60, u'mqtt').
1616417132: Client w31242 disconnected.
1616417132: New connection from 192.168.1.17 on port 1883.
1616417132: New client connected from 192.168.1.17 as w31244 (p2, c1, k60, u'mqtt').
1616417133: Client w31244 disconnected.
1616417133: New connection from 192.168.1.17 on port 1883.
1616417133: New client connected from 192.168.1.17 as w31246 (p2, c1, k60, u'mqtt').
1616417133: Client w31246 disconnected.

Monitor on the rasp is working, but the node wont connect to HA image

Also in the AD log I'm having this message 2021-03-22 10:00:19.510935 INFO MQTT: Unable to decode MQTT message

Odianosen25 commented 3 years ago

Ok please use this for your plugin config

      client_host: 'x.x.x.x'
      client_user: <username>
      client_password: <password>
      client_id: appdaemon
      client_topics:
          - monitor/#

Or add the following to the intialize function of the app at line 178, and let me know if that fixes your issue

self.mqtt.mqtt_subscribe(f"{self.presence_topic}/#") 
pittbull commented 3 years ago

You are a wizard @Odianosen25 :)

The app now starts, but I do get the following error:

2021-03-22 14:46:32.926815 WARNING AppDaemon: Invalid callback handle '9bb03cf9cb134138920822736cebcc7c' in cancel_timer() from app home_presence_app

Odianosen25 commented 3 years ago

You are a wizard @Odianosen25 :)

Well not exactly, but more like silly. I actually made the changes to AD, and should have foreseen this and updated the app to allow for this. I will release an update to the app to fix this, as I assume you used the new function?

The app now starts, but I do get the following error:

2021-03-22 14:46:32.926815 WARNING AppDaemon: Invalid callback handle '9bb03cf9cb134138920822736cebcc7c' in cancel_timer() from app home_presence_app

Yeah that is another silly thing I am also responsible for, as now in AD it complains when timers are not valid and I will also fix that in the next app update. I think I didn't just think I will be getting users update so early lols.

Regards

pittbull commented 3 years ago

hehe.. You have my sympathies. :)

With HA I've started to snapshot (running proxmox) and just upgrade, so I am a very early adopter. Just this time I didn't snapshot before upgrading.

When you say "... as I assumed you used the new function?" I am not sure what you mean?

Odianosen25 commented 3 years ago

Did you fix it by adding the line in the code, or updating the plugin with the client_topics?

Regards

pittbull commented 3 years ago

Did you fix it by adding the line in the code, or updating the plugin with the client_topics?

Regards

Aha. Added the client_topics.

Odianosen25 commented 3 years ago

Ok no worries, I will have the app subscribe to the topic and that should fix it.

Thanks for the update.

Don't close this issue pls, will close it myself so I remember to fix this, as I am so busy now and won't be able to look into it today.

Regards

pittbull commented 3 years ago

Thank you so much for stopping by, and for your help. :)

nortuzar commented 3 years ago

Ok please use this for your plugin config

      client_host: 'x.x.x.x'
      client_user: <username>
      client_password: <password>
      client_id: appdaemon
      client_topics:
          - monitor/#

Did that and now the node is connected! Thanks for the quick solution

skynet01 commented 3 years ago

Updating the config also fixed it for me. Thanks for the fix!