Closed jiripaskov closed 1 year ago
AttributeError: 'NoneType' object has no attribute 'mqtt_publish'
There's something wrong with your MQTT in appdaemon.yaml, unfortunally the log snippent of appdaemon isn't right after restarting the add-on so it doesn't contain the relevat part. You can also check the log of your mqtt broker for addional information.
Mosquitto broker debug log: s6-rc: info: service s6rc-oneshot-runner: starting s6-rc: info: service s6rc-oneshot-runner successfully started s6-rc: info: service fix-attrs: starting s6-rc: info: service fix-attrs successfully started s6-rc: info: service legacy-cont-init: starting cont-init: info: running /etc/cont-init.d/mosquitto.sh [16:25:52] INFO: SSL is not enabled cont-init: info: /etc/cont-init.d/mosquitto.sh exited 0 cont-init: info: running /etc/cont-init.d/nginx.sh cont-init: info: /etc/cont-init.d/nginx.sh exited 0 s6-rc: info: service legacy-cont-init successfully started s6-rc: info: service legacy-services: starting services-up: info: copying legacy longrun mosquitto (no readiness notification) services-up: info: copying legacy longrun nginx (no readiness notification) s6-rc: info: service legacy-services successfully started [16:25:52] INFO: Starting NGINX for authentication handling... [16:25:53] INFO: Starting mosquitto MQTT broker... 2023-01-07 16:25:53: Warning: Mosquitto should not be run as root/administrator. [16:25:54] INFO: Successfully send discovery information to Home Assistant. [16:25:54] INFO: Successfully send service information to the Supervisor.
appdaemon log after restart: 2023-01-07 16:24:05.695189 WARNING HASS: Disconnected from Home Assistant, retrying in 5 seconds 2023-01-07 16:24:10.707517 WARNING HASS: Disconnected from Home Assistant, retrying in 5 seconds 2023-01-07 16:24:15.720300 WARNING HASS: Disconnected from Home Assistant, retrying in 5 seconds 2023-01-07 16:24:20.735505 INFO HASS: Connected to Home Assistant 2023.1.1 2023-01-07 16:24:20.801933 INFO HASS: Evaluating startup conditions 2023-01-07 16:24:20.815541 INFO HASS: Startup condition met: hass state=RUNNING 2023-01-07 16:24:20.815935 INFO HASS: All startup conditions met 2023-01-07 16:24:20.860521 INFO AppDaemon: Processing restart for HASS 2023-01-07 16:24:20.860980 INFO AppDaemon: Terminating nspanel-1 2023-01-07 16:24:20.862060 INFO AppDaemon: Initializing app nspanel-1 using class NsPanelLovelaceUIManager from module nspanel-lovelace-ui 2023-01-07 16:24:20.867620 INFO nspanel-1: Starting 2023-01-07 16:24:20.869259 WARNING AppDaemon: Unknown Plugin Configuration in get_plugin_api() 2023-01-07 16:24:20.873159 INFO nspanel-1: Input config: {'panelRecvTopic': 'tele/nspanel_1/RESULT', 'panelSendTopic': 'cmnd/nspanel_1/CustomSend', 'model': 'eu'} 2023-01-07 16:24:20.877212 INFO nspanel-1: Loaded config: {'panelRecvTopic': 'tele/nspanel_1/RESULT', 'panelSendTopic': 'cmnd/nspanel_1/CustomSend', 'updateMode': 'auto-notify', 'model': 'eu', 'sleepTimeout': 20, 'sleepBrightness': 20, 'screenBrightness': 100, 'defaultBackgroundColor': 'ha-dark', 'sleepTracking': None, 'sleepTrackingZones': ['not_home', 'off'], 'sleepOverride': None, 'locale': 'en_US', 'timeFormat': '%H:%M', 'dateFormatBabel': 'full', 'dateAdditionalTemplate': '', 'timeAdditionalTemplate': '', 'dateFormat': '%A, %d. %B %Y', 'homeButton': False, 'cards': [{'type': 'cardEntities', 'entities': [{'entity': 'iText.', 'name': 'MQTT Config successful', 'icon': 'mdi:check', 'color:': [0, 255, 0]}, {'entity': 'iText.', 'name': 'Continue adding', 'icon': 'mdi:arrow-right-bold'}, {'entity': 'iText.', 'name': 'cards to your', 'icon': 'mdi:card'}, {'entity': 'iText.', 'name': 'apps.yaml', 'icon': 'mdi:cog'}], 'title': 'Setup successful'}], 'screensaver': {'type': 'screensaver', 'entity': 'weather.example', 'weatherUnit': 'celsius', 'forecastSkip': 0, 'weatherOverrideForecast1': None, 'weatherOverrideForecast2': None, 'weatherOverrideForecast3': None, 'weatherOverrideForecast4': None, 'doubleTapToUnlock': False, 'alternativeLayout': False, 'defaultCard': None, 'key': 'screensaver'}, 'hiddenCards': []} 2023-01-07 16:24:20.880417 WARNING nspanel-1: ------------------------------------------------------------ 2023-01-07 16:24:20.880789 WARNING nspanel-1: Unexpected error running initialize() for nspanel-1 2023-01-07 16:24:20.881040 WARNING nspanel-1: ------------------------------------------------------------ 2023-01-07 16:24:20.881691 WARNING nspanel-1: Traceback (most recent call last): File "/usr/lib/python3.10/site-packages/appdaemon/app_management.py", line 165, in initialize_app await utils.run_in_executor(self, init) File "/usr/lib/python3.10/site-packages/appdaemon/utils.py", line 337, in run_in_executor response = future.result() File "/usr/lib/python3.10/concurrent/futures/thread.py", line 58, in run result = self.fn(*self.args, *self.kwargs) File "/config/appdaemon/apps/nspanel-lovelace-ui/nspanel-lovelace-ui.py", line 25, in initialize apis.mqtt_api.mqtt_publish(topic_send.replace("CustomSend", "GetDriverVersion"), "x") AttributeError: 'NoneType' object has no attribute 'mqtt_publish' 2023-01-07 16:24:20.881993 WARNING nspanel-1: ------------------------------------------------------------ 2023-01-07 16:26:41.041535 WARNING HASS: Disconnected from Home Assistant, retrying in 5 seconds 2023-01-07 16:26:46.054060 WARNING HASS: Disconnected from Home Assistant, retrying in 5 seconds 2023-01-07 16:26:51.066291 WARNING HASS: Disconnected from Home Assistant, retrying in 5 seconds 2023-01-07 16:26:56.078790 WARNING HASS: Disconnected from Home Assistant, retrying in 5 seconds 2023-01-07 16:27:01.091462 WARNING HASS: Disconnected from Home Assistant, retrying in 5 seconds 2023-01-07 16:27:06.104178 WARNING HASS: Disconnected from Home Assistant, retrying in 5 seconds 2023-01-07 16:27:11.121485 WARNING HASS: Disconnected from Home Assistant, retrying in 5 seconds 2023-01-07 16:27:20.863992 WARNING HASS: Disconnected from Home Assistant, retrying in 5 seconds 2023-01-07 16:27:21.111589 WARNING HASS: Error getting services - retrying Task exception was never retrieved future: <Task finished name='Task-120521' coro=<HassPlugin.run_hass_service_check() done, defined at /usr/lib/python3.10/site-packages/appdaemon/plugins/hass/hassplugin.py:783> exception=ClientResponseError(RequestInfo(url=URL('http://supervisor/core/api/services'), method='GET', headers=<CIMultiDictProxy('Host': 'supervisor', 'Authorization': 'Bearer 3c2e1d3f0dc5b3f4e024243544376444f79959206f205cd144e5433ca476e671659efa5fbc0cf9db025a25ce7b476feaed5251854968715e', 'Accept': '/', 'Accept-Encoding': 'gzip, deflate', 'User-Agent': 'Python/3.10 aiohttp/3.8.1')>, real_url=URL('http://supervisor/core/api/services')), (), status=502, message='Bad Gateway', headers=<CIMultiDictProxy('Content-Type': 'text/plain; charset=utf-8', 'Content-Length': '16', 'Date': 'Sat, 07 Jan 2023 15:27:21 GMT', 'Server': 'Python/3.10 aiohttp/3.8.3')>)> Traceback (most recent call last): File "/usr/lib/python3.10/site-packages/appdaemon/plugins/hass/hassplugin.py", line 792, in run_hass_service_check hass_services = await self.get_hass_services() File "/usr/lib/python3.10/site-packages/appdaemon/plugins/hass/hassplugin.py", line 754, in get_hass_services r.raise_for_status() File "/usr/lib/python3.10/site-packages/aiohttp/client_reqrep.py", line 1004, in raise_for_status raise ClientResponseError( aiohttp.client_exceptions.ClientResponseError: 502, message='Bad Gateway', url=URL('http://supervisor/core/api/services') 2023-01-07 16:27:25.876628 WARNING HASS: Disconnected from Home Assistant, retrying in 5 seconds 2023-01-07 16:27:31.213420 INFO HASS: Connected to Home Assistant 2023.1.1 2023-01-07 16:27:31.601996 INFO HASS: Evaluating startup conditions 2023-01-07 16:27:31.623715 INFO HASS: Startup condition met: hass state=RUNNING 2023-01-07 16:27:31.624288 INFO HASS: All startup conditions met 2023-01-07 16:27:31.686417 INFO AppDaemon: Processing restart for HASS 2023-01-07 16:27:31.686947 INFO AppDaemon: Terminating nspanel-1 2023-01-07 16:27:31.688016 INFO AppDaemon: Initializing app nspanel-1 using class NsPanelLovelaceUIManager from module nspanel-lovelace-ui 2023-01-07 16:27:31.692597 INFO nspanel-1: Starting 2023-01-07 16:27:31.693848 WARNING AppDaemon: Unknown Plugin Configuration in get_plugin_api() 2023-01-07 16:27:31.695933 INFO nspanel-1: Input config: {'panelRecvTopic': 'tele/nspanel_1/RESULT', 'panelSendTopic': 'cmnd/nspanel_1/CustomSend', 'model': 'eu'} 2023-01-07 16:27:31.697453 INFO nspanel-1: Loaded config: {'panelRecvTopic': 'tele/nspanel_1/RESULT', 'panelSendTopic': 'cmnd/nspanel_1/CustomSend', 'updateMode': 'auto-notify', 'model': 'eu', 'sleepTimeout': 20, 'sleepBrightness': 20, 'screenBrightness': 100, 'defaultBackgroundColor': 'ha-dark', 'sleepTracking': None, 'sleepTrackingZones': ['not_home', 'off'], 'sleepOverride': None, 'locale': 'en_US', 'timeFormat': '%H:%M', 'dateFormatBabel': 'full', 'dateAdditionalTemplate': '', 'timeAdditionalTemplate': '', 'dateFormat': '%A, %d. %B %Y', 'homeButton': False, 'cards': [{'type': 'cardEntities', 'entities': [{'entity': 'iText.', 'name': 'MQTT Config successful', 'icon': 'mdi:check', 'color:': [0, 255, 0]}, {'entity': 'iText.', 'name': 'Continue adding', 'icon': 'mdi:arrow-right-bold'}, {'entity': 'iText.', 'name': 'cards to your', 'icon': 'mdi:card'}, {'entity': 'iText.', 'name': 'apps.yaml', 'icon': 'mdi:cog'}], 'title': 'Setup successful'}], 'screensaver': {'type': 'screensaver', 'entity': 'weather.example', 'weatherUnit': 'celsius', 'forecastSkip': 0, 'weatherOverrideForecast1': None, 'weatherOverrideForecast2': None, 'weatherOverrideForecast3': None, 'weatherOverrideForecast4': None, 'doubleTapToUnlock': False, 'alternativeLayout': False, 'defaultCard': None, 'key': 'screensaver'}, 'hiddenCards': []} 2023-01-07 16:27:31.699179 WARNING nspanel-1: ------------------------------------------------------------ 2023-01-07 16:27:31.699557 WARNING nspanel-1: Unexpected error running initialize() for nspanel-1 2023-01-07 16:27:31.699835 WARNING nspanel-1: ------------------------------------------------------------ 2023-01-07 16:27:31.700425 WARNING nspanel-1: Traceback (most recent call last): File "/usr/lib/python3.10/site-packages/appdaemon/app_management.py", line 165, in initialize_app await utils.run_in_executor(self, init) File "/usr/lib/python3.10/site-packages/appdaemon/utils.py", line 337, in run_in_executor response = future.result() File "/usr/lib/python3.10/concurrent/futures/thread.py", line 58, in run result = self.fn(self.args, **self.kwargs) File "/config/appdaemon/apps/nspanel-lovelace-ui/nspanel-lovelace-ui.py", line 25, in initialize apis.mqtt_api.mqtt_publish(topic_send.replace("CustomSend", "GetDriverVersion"), "x") AttributeError: 'NoneType' object has no attribute 'mqtt_publish' 2023-01-07 16:27:31.700752 WARNING nspanel-1: ------------------------------------------------------------
This shows console in NS panel: 16:28:21.147 MQT: tele/nspanel_1/RESULT = {"CustomRecv":"event,startup,48,eu"} 16:28:27.052 MQT: tele/nspanel_1/RESULT = {"CustomRecv":"event,startup,48,eu"} 16:28:33.055 MQT: tele/nspanel_1/RESULT = {"CustomRecv":"event,startup,48,eu"} 16:28:38.960 MQT: tele/nspanel_1/RESULT = {"CustomRecv":"event,startup,48,eu"} 16:28:44.865 MQT: tele/nspanel_1/RESULT = {"CustomRecv":"event,startup,48,eu"} 16:28:50.866 MQT: tele/nspanel_1/RESULT = {"CustomRecv":"event,startup,48,eu"} 16:28:56.772 MQT: tele/nspanel_1/RESULT = {"CustomRecv":"event,startup,48,eu"} 16:29:02.676 MQT: tele/nspanel_1/RESULT = {"CustomRecv":"event,startup,48,eu"} 16:29:08.584 MQT: tele/nspanel_1/RESULT = {"CustomRecv":"event,startup,48,eu"} 16:29:14.584 MQT: tele/nspanel_1/RESULT = {"CustomRecv":"event,startup,48,eu"} 16:29:20.488 MQT: tele/nspanel_1/RESULT = {"CustomRecv":"event,startup,48,eu"} 16:29:26.393 MQT: tele/nspanel_1/RESULT = {"CustomRecv":"event,startup,48,eu"} 16:29:32.348 MQT: tele/nspanel_1/RESULT = {"CustomRecv":"event,startup,48,eu"} 16:29:38.351 MQT: tele/nspanel_1/RESULT = {"CustomRecv":"event,startup,48,eu"} 16:29:44.260 MQT: tele/nspanel_1/RESULT = {"CustomRecv":"event,startup,48,eu"} 16:29:50.160 MQT: tele/nspanel_1/RESULT = {"CustomRecv":"event,startup,48,eu"}
over and over again
Did you restart your mqtt broker?
[16:25:53] INFO: Starting mosquitto MQTT broker...
Restart AppDaemon and look into the MQTT Broker Log during the restart of AppDaemon, do not restart the MQTT Broker itself.
Oh unbelievable. Installed MQTT Explorer > restarted AppDaemon while watched what will be new in MQTT tele - and voila appdaemon shows status = online and NS panel works now...
Thank you (even if we don´t know what was wrong :)
Btw. GREAT JOB with all of this. Really nice work man!
Hello, have NS panel flashed with latest tasmota. MQTT config in tasmota is: https://tinyurl.com/2k7gx5cq
appdaemon.yaml:
secrets: /config/secrets.yaml appdaemon: latitude: 52.0 longitude: 4.0 elevation: 2 time_zone: Europe/Berlin plugins: HASS: type: hass MQTT: type: mqtt namespace: mqtt client_id: "appdaemon" client_host: 192.168.1.15 # This should work if you are using supervised HomeAssistant; if not use the IP Address instead. client_port: 1883 client_user: "daniel" client_password: "xxxxxxxx" client_topics: NONE http: url: http://127.0.0.1:5050 admin: api: hadashboard:
apps.yaml:
nspanel-1: module: nspanel-lovelace-ui class: NsPanelLovelaceUIManager config: panelRecvTopic: "tele/nspanel_1/RESULT" panelSendTopic: "cmnd/nspanel_1/CustomSend" model: eu
Appdaemon log: 2023-01-07 16:01:37.199020 INFO AppDaemon: Reading config 2023-01-07 16:01:37.204201 INFO AppDaemon: /config/appdaemon/apps/apps.yaml added or modified 2023-01-07 16:01:37.204633 INFO AppDaemon: App 'nspanel_1' deleted 2023-01-07 16:01:37.207691 INFO AppDaemon: App 'nspanel-1' added 2023-01-07 16:01:37.208112 INFO AppDaemon: Found 1 total apps 2023-01-07 16:01:37.221209 INFO AppDaemon: Initializing app nspanel-1 using class NsPanelLovelaceUIManager from module nspanel-lovelace-ui 2023-01-07 16:01:37.226524 INFO nspanel-1: Starting 2023-01-07 16:01:37.228096 WARNING AppDaemon: Unknown Plugin Configuration in get_plugin_api() 2023-01-07 16:01:37.231822 INFO nspanel-1: Input config: {'panelRecvTopic': 'tele/nspanel_1/RESULT', 'panelSendTopic': 'cmnd/nspanel_1/CustomSend', 'model': 'eu'} 2023-01-07 16:01:37.235355 INFO nspanel-1: Loaded config: {'panelRecvTopic': 'tele/nspanel_1/RESULT', 'panelSendTopic': 'cmnd/nspanel_1/CustomSend', 'updateMode': 'auto-notify', 'model': 'eu', 'sleepTimeout': 20, 'sleepBrightness': 20, 'screenBrightness': 100, 'defaultBackgroundColor': 'ha-dark', 'sleepTracking': None, 'sleepTrackingZones': ['not_home', 'off'], 'sleepOverride': None, 'locale': 'en_US', 'timeFormat': '%H:%M', 'dateFormatBabel': 'full', 'dateAdditionalTemplate': '', 'timeAdditionalTemplate': '', 'dateFormat': '%A, %d. %B %Y', 'homeButton': False, 'cards': [{'type': 'cardEntities', 'entities': [{'entity': 'iText.', 'name': 'MQTT Config successful', 'icon': 'mdi:check', 'color:': [0, 255, 0]}, {'entity': 'iText.', 'name': 'Continue adding', 'icon': 'mdi:arrow-right-bold'}, {'entity': 'iText.', 'name': 'cards to your', 'icon': 'mdi:card'}, {'entity': 'iText.', 'name': 'apps.yaml', 'icon': 'mdi:cog'}], 'title': 'Setup successful'}], 'screensaver': {'type': 'screensaver', 'entity': 'weather.example', 'weatherUnit': 'celsius', 'forecastSkip': 0, 'weatherOverrideForecast1': None, 'weatherOverrideForecast2': None, 'weatherOverrideForecast3': None, 'weatherOverrideForecast4': None, 'doubleTapToUnlock': False, 'alternativeLayout': False, 'defaultCard': None, 'key': 'screensaver'}, 'hiddenCards': []} 2023-01-07 16:01:37.238197 WARNING nspanel-1: ------------------------------------------------------------ 2023-01-07 16:01:37.238574 WARNING nspanel-1: Unexpected error running initialize() for nspanel-1 2023-01-07 16:01:37.238890 WARNING nspanel-1: ------------------------------------------------------------ 2023-01-07 16:01:37.239481 WARNING nspanel-1: Traceback (most recent call last): File "/usr/lib/python3.10/site-packages/appdaemon/app_management.py", line 165, in initialize_app await utils.run_in_executor(self, init) File "/usr/lib/python3.10/site-packages/appdaemon/utils.py", line 337, in run_in_executor response = future.result() File "/usr/lib/python3.10/concurrent/futures/thread.py", line 58, in run result = self.fn(*self.args, **self.kwargs) File "/config/appdaemon/apps/nspanel-lovelace-ui/nspanel-lovelace-ui.py", line 25, in initialize apis.mqtt_api.mqtt_publish(topic_send.replace("CustomSend", "GetDriverVersion"), "x") AttributeError: 'NoneType' object has no attribute 'mqtt_publish' 2023-01-07 16:01:37.239781 WARNING nspanel-1: ------------------------------------------------------------
BUT the NS Panel still shows only Waiting for content... what could be please wrong?