ESPresense / ad-espresense-ips

DEAD: See https://github.com/ESPresense/ESPresense-companion
65 stars 9 forks source link

Unable to decode MQTT message #11

Open beatified opened 2 years ago

beatified commented 2 years ago

I saw this issue in the How to Use thread in a post by @duceduc, but couldn't find an answer that worked for him. I to have my MQTT Broker set to use authentication. And attempted to add those creds to my config... I am assuming I should end up seeing new entities in HA for my configured BLE devices if everything is working. Is that correct?

AppDaemon is new to me so please bear with my ignorance.

I attempted to notate parts that I though might be problematic...

Here is my config and associated Logs... AppDaemon: Config:

init_commands:
  - apk add --update python3 python3-dev py3-numpy py3-scipy
python_packages: []
system_packages: []
type: hass
ha_url: '!secret ha_local_url'
token: '!secret appdaemon_token'

Log:

[s6-init] making user provided files available at /var/run/s6/etc...exited 0.
[s6-init] ensuring user provided files have correct perms...exited 0.
[fix-attrs.d] applying ownership & permissions fixes...
[fix-attrs.d] done.
[cont-init.d] executing container initialization scripts...
[cont-init.d] 00-banner.sh: executing... 
-----------------------------------------------------------
 Add-on: AppDaemon 4
 Python Apps and Dashboard using AppDaemon 4.x for Home Assistant
-----------------------------------------------------------
 Add-on version: 0.8.1
 You are running the latest version of this add-on.
 System: Home Assistant OS 7.4  (aarch64 / odroid-n2)
 Home Assistant Core: 2022.2.6
 Home Assistant Supervisor: 2022.01.1
-----------------------------------------------------------
 Please, share the above information when looking for help
 or support in, e.g., GitHub, forums or the Discord chat.
-----------------------------------------------------------
[cont-init.d] 00-banner.sh: exited 0.
[cont-init.d] 01-log-level.sh: executing... 
[cont-init.d] 01-log-level.sh: exited 0.
[cont-init.d] appdaemon.sh: executing... 
fetch https://dl-cdn.alpinelinux.org/alpine/v3.15/main/aarch64/APKINDEX.tar.gz
fetch https://dl-cdn.alpinelinux.org/alpine/v3.15/community/aarch64/APKINDEX.tar.gz
(1/7) Installing libgfortran (10.3.1_git20211027-r0)
(2/7) Installing openblas (0.3.18-r1)
(3/7) Installing py3-numpy (1.21.4-r0)
(4/7) Installing pkgconf (1.8.0-r0)
(5/7) Installing python3-dev (3.9.7-r4)
(6/7) Installing py3-numpy-f2py (1.21.4-r0)
(7/7) Installing py3-scipy (1.7.2-r0)
Executing busybox-1.34.1-r3.trigger
OK: 236 MiB in 74 packages
[cont-init.d] appdaemon.sh: exited 0.
[cont-init.d] done.
[services.d] starting services
[services.d] done.
[10:15:55] INFO: Starting AppDaemon...
2022-02-23 10:15:56.899945 INFO AppDaemon: AppDaemon Version 4.2.1 starting
2022-02-23 10:15:56.900272 INFO AppDaemon: Python version is 3.9.7
2022-02-23 10:15:56.900527 INFO AppDaemon: Configuration read from: /config/appdaemon/appdaemon.yaml
2022-02-23 10:15:56.900747 INFO AppDaemon: Added log: AppDaemon
2022-02-23 10:15:56.900972 INFO AppDaemon: Added log: Error
2022-02-23 10:15:56.901174 INFO AppDaemon: Added log: Access
2022-02-23 10:15:56.901369 INFO AppDaemon: Added log: Diag
2022-02-23 10:15:56.928966 INFO AppDaemon: Loading Plugin HASS using class HassPlugin from module hassplugin
2022-02-23 10:15:57.259672 INFO HASS: HASS Plugin Initializing
2022-02-23 10:15:57.259981 INFO HASS: HASS Plugin initialization complete
2022-02-23 10:15:57.260431 INFO AppDaemon: Loading Plugin MQTT using class MqttPlugin from module mqttplugin
2022-02-23 10:15:57.270073 INFO MQTT: MQTT Plugin Initializing
2022-02-23 10:15:57.271187 INFO MQTT: Using appdaemon_mqtt_client as Client ID
2022-02-23 10:15:57.272147 INFO AppDaemon: Initializing HTTP
2022-02-23 10:15:57.272704 INFO AppDaemon: Using 'ws' for event stream
2022-02-23 10:15:57.278229 INFO AppDaemon: Starting API
2022-02-23 10:15:57.283083 INFO AppDaemon: Starting Admin Interface
2022-02-23 10:15:57.283703 INFO AppDaemon: Starting Dashboards
2022-02-23 10:15:57.299168 INFO HASS: Connected to Home Assistant 2022.2.6
2022-02-23 10:15:57.309481 INFO MQTT: Connected to Broker at URL 192.168.20.8:1883
###
###Area of concern
###
2022-02-23 10:15:57.336588 WARNING AppDaemon: App 'module' missing 'class' or 'module' entry - ignoring
2022-02-23 10:15:57.337452 WARNING AppDaemon: App 'class' missing 'class' or 'module' entry - ignoring
2022-02-23 10:15:57.338206 WARNING AppDaemon: App 'pluggins' missing 'class' or 'module' entry - ignoring
2022-02-23 10:15:57.339032 WARNING AppDaemon: App 'rooms' missing 'class' or 'module' entry - ignoring
2022-02-23 10:15:57.339546 WARNING AppDaemon: App 'devices' missing 'class' or 'module' entry - ignoring
2022-02-23 10:15:57.339920 WARNING AppDaemon: App 'roomplans' missing 'class' or 'module' entry - ignoring
###
End Area of concern###
###
2022-02-23 10:15:57.341036 INFO AppDaemon: Found 0 total apps
2022-02-23 10:15:57.341723 INFO AppDaemon: Starting Apps with 0 workers and 0 pins
2022-02-23 10:15:57.342384 INFO AppDaemon: Running on port 5050
2022-02-23 10:15:57.347969 INFO AppDaemon: Got initial state from namespace mqtt
2022-02-23 10:15:57.348693 INFO MQTT: MQTT Plugin initialization complete
2022-02-23 10:15:57.379426 INFO HASS: Evaluating startup conditions
2022-02-23 10:15:57.380201 WARNING HASS: Disconnected from Home Assistant, retrying in 5 seconds
###
###Area of concern
###
2022-02-23 10:15:57.562077 INFO MQTT: Unable to decode MQTT message
###
End Area of concern###
###
2022-02-23 10:15:58.846213 INFO AppDaemon: New client Admin Client connected
2022-02-23 10:16:02.387854 INFO HASS: Connected to Home Assistant 2022.2.6
2022-02-23 10:16:02.430545 INFO HASS: Evaluating startup conditions
2022-02-23 10:16:02.435964 INFO HASS: Startup condition met: hass state=RUNNING
2022-02-23 10:16:02.436412 INFO HASS: All startup conditions met
2022-02-23 10:16:02.489022 INFO AppDaemon: Got initial state from namespace default
###
###Area of concern
###
2022-02-23 10:16:02.889058 INFO MQTT: Previous message repeated 17 times
###
End Area of concern###
###
2022-02-23 10:16:02.889466 INFO MQTT: Unable to decode MQTT message
2022-02-23 10:16:04.378388 INFO AppDaemon: Scheduler running in realtime
2022-02-23 10:16:04.385863 INFO AppDaemon: Adding /config/appdaemon/apps to module import path
2022-02-23 10:16:04.388837 WARNING AppDaemon: No app description found for: /config/appdaemon/apps/hello.py - ignoring
2022-02-23 10:16:04.390198 INFO AppDaemon: App initialization complete
###
###Area of concern
###
2022-02-23 10:16:07.891376 INFO MQTT: Previous message repeated 10 times
2022-02-23 10:16:07.891786 INFO MQTT: Unable to decode MQTT message
2022-02-23 10:16:12.907239 INFO MQTT: Previous message repeated 10 times
2022-02-23 10:16:12.907641 INFO MQTT: Unable to decode MQTT message
###
End Area of concern###
###

appdaemon.yaml Config:

---
secrets: /config/secrets.yaml
appdaemon:
  latitude: !secret home_lat
  longitude: !secret home_long
  elevation: !secret home_elevation
  time_zone: ! secret time_zone
  plugins:
    HASS:
      type: hass
      ha_url: !secret ha_local_url
      token: !secret appdaemon_token
      app_init_delay: 30
      appdaemon_startup_conditions:
        delay:30
    MQTT:
      type: mqtt
      client_host: !secret mqtt_broker_ip
      client_user: !secret mqtt_broker_username
      client_password: !secret mqtt_password
      namespace: mqtt
      birth_topic: appdaemon
      will_topic: appdaemon
http:
  url: http://127.0.0.1:5050
admin:
api:
hadashboard:

apps.yaml Config:

  ESPresenseIps:
  module: espresense-ips
  class: ESPresenseIps
  pluggins:
    - HASS
    - MQTT
  rooms:
    bedroom: [1.5, 0.5, 0.6]
    bathroom: [4.5, 5.7, 1.5]
    living_room: [8.8, 0.7, 0.5]
    kitchen: [5.3, 5.4, 1.5]
  devices:
  - id: !secret oneplus9pro_ble_id
    name: Stuart OnePlus 9 Pro BLE IPS
    timeout: 30
    away_timeout: 120
  - id: !secret ticwatch3pro_ble_id
    name: TicWatch Pro 3 BLE IPS
    timeout: 30
    away_timeout: 120
  roomplans:
  - name: living_room
    y1: 8.9
    x1: 0.5
    y2: 4.7
    x2: 4.3
  - name: bathroom
    y1: 3.2
    x1: 5.5
    y2: 5.7
    x2: 3.7
  - name: bedroom
    y1: 0
    x1: 0
    y2: 4.1
    x2: 3.2
  - name: kitchen
    y1: 4.9
    x1: 4.5
    y2: 7.0
    x2: 8.0
stan69b commented 2 years ago

I have been having trouble as well and downloaded an mqtt explorer. turns out devices NEED to be detected by at least 3 eps32 , I had to bump the radius of each esp32 (via ESPresense web interface) to 16m to make sure each one covers a large part of the house and it ended up sending data on espresense/ips/#. Home assistant never picked up on it so I created a sensor and dumped the json string on its state. I use the value with HA-floorplan so i can juste JSON.parse() my way out of it.

Maybe everything is ok and home assistant just does not auto discover. make sure 3 esp32 sees your device. and check your mqtt messages with an explorer app to see if you have them popup :)

hope you wil find something that works for you

EDIT: I also played with appDeamon configuration to get rid of the unable to decode mqtt message (well i think it was that that did the trick, but not 100% sure) :

init_commands:
  - apk add --update python3 python3-dev py3-numpy py3-scipy
python_packages:
  - numpy
  - scipy
system_packages:
  - py3-numpy
  - py3-scipy

Your AppDaemon also starts with 0 apps, I had that when i tried importing this plugin via package downloaded with the "code download" button on github. I ended up going to the release page and got a working version there.