roflcoopter / viseron

Self-hosted, local only NVR and AI Computer Vision software. With features such as object detection, motion detection, face recognition and more, it gives you the power to keep an eye on your home, office or any other place you want to monitor.
MIT License
1.66k stars 171 forks source link

Issues connecting MQTT with Home assistant #709

Closed BliXem1 closed 7 months ago

BliXem1 commented 7 months ago

Hi,

I've got some issues with connecting MQTT with Home assistant. Within Home assistant I have a local MQTT running via Supervisor. It's setup and working as far as I can see. Logs:

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
[13:53:08] INFO: Setting up user user
[13:53:08] 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)
[13:53:08] INFO: Starting NGINX for authentication handling...
s6-rc: info: service legacy-services successfully started
[13:53:08] INFO: Starting mosquitto MQTT broker...
2024-02-06 13:53:08: Warning: Mosquitto should not be run as root/administrator.
2024-02-06 13:53:08: mosquitto version 2.0.18 starting
2024-02-06 13:53:08: Config loaded from /etc/mosquitto/mosquitto.conf.
2024-02-06 13:53:08: Loading plugin: /usr/share/mosquitto/go-auth.so
2024-02-06 13:53:08:  ├── Username/password checking enabled.
2024-02-06 13:53:08:  ├── TLS-PSK checking enabled.
2024-02-06 13:53:08:  └── Extended authentication not enabled.
2024-02-06 13:53:08: Opening ipv4 listen socket on port 1883.
2024-02-06 13:53:08: Opening ipv6 listen socket on port 1883.
2024-02-06 13:53:08: Opening websockets listen socket on port 1884.
2024-02-06 13:53:08: mosquitto version 2.0.18 running
2024-02-06 13:53:08: New connection from 127.0.0.1:45216 on port 1883.
2024-02-06 13:53:08: Client <unknown> disconnected due to protocol error.
[13:53:09] INFO: Successfully send discovery information to Home Assistant.
[13:53:09] INFO: Successfully send service information to the Supervisor.
2024-02-06 13:53:09: New connection from 172.30.32.1:45970 on port 1883.
2024-02-06 13:53:09: New client connected from 172.30.32.1:45970 as 0v0jNxf1W6NcFxSxETehh6 (p2, c1, k60, u'user')
Configuration within Viseron itself:

# Thanks for trying out Viseron!
# This is a small walkthrough of the configuration to get you started.
# There are far more components and options available than what is listed here.
# See the documentation for the full list of configuration options.

mqtt:
  broker: 192.168.0.123
  port: 1883
  username: user
  password: pass
  client_id​: homeassistant

## Start by adding some cameras
ffmpeg:
  camera:
    camera_1:  # This value has to be unique across all cameras
      name: Oprit
      host: 192.168.0.210
      port: 554
      path: /h264Preview_01_main
      username: user
      password: pass

## Then add an object detector
codeprojectai:
  host: 192.168.0.125
  port: 32168
  object_detector:
    cameras:
      camera_1:
        fps: 1
        log_all_objects: true
        labels:
          - label: person
            confidence: 0.8
            trigger_recorder: true
          - label: car
            confidence: 0.8
            trigger_recorder: true
          - label: dog
            confidence: 0.8
            trigger_recorder: true
          - label: cat
            confidence: 0.8
            trigger_recorder: true

## You can also use motion detection
mog2:
  motion_detector:
    cameras:
      camera_1:  # Attach detector to the configured camera_2 above
        fps: 1

## To tie everything together we need to configure one more component.
nvr:
  camera_1:  # Run NVR for camera_1

# Now you can restart Viseron and you should be good to go!

Log file of docker within Synology:

<html><body>
<!--StartFragment-->
2024/02/06 13:49:44 | stderr | [2024-02-06 13:49:44] [INFO    ] [viseron.core] - Viseron initialized in 4.6 seconds
-- | -- | --
2024/02/06 13:49:44 | stderr | [2024-02-06 13:49:44] [INFO    ] [viseron.components] - Setup of domain nvr for component nvr with identifier camera_1 took 0.0 seconds
2024/02/06 13:49:44 | stderr | [2024-02-06 13:49:44] [INFO    ] [viseron.components.nvr.nvr.camera_1] - NVR for camera Oprit initialized
2024/02/06 13:49:44 | stderr | [2024-02-06 13:49:44] [INFO    ] [viseron.components] - Setup of domain object_detector for component codeprojectai with identifier camera_1 took 0.0 seconds
2024/02/06 13:49:44 | stderr | [2024-02-06 13:49:44] [INFO    ] [viseron.components] - Setup of domain motion_detector for component mog2 with identifier camera_1 took 0.0 seconds
2024/02/06 13:49:44 | stderr | [2024-02-06 13:49:44] [INFO    ] [viseron.components] - Setup of domain camera for component ffmpeg with identifier camera_1 took 3.3 seconds
2024/02/06 13:49:40 | stderr | [2024-02-06 13:49:40] [INFO    ] [viseron.components] - Setting up domain nvr for component nvr with identifier camera_1
2024/02/06 13:49:40 | stderr | [2024-02-06 13:49:40] [INFO    ] [viseron.components] - Setting up domain object_detector for component codeprojectai with identifier camera_1
2024/02/06 13:49:40 | stderr | [2024-02-06 13:49:40] [INFO    ] [viseron.components] - Setting up domain motion_detector for component mog2 with identifier camera_1
2024/02/06 13:49:40 | stderr | [2024-02-06 13:49:40] [INFO    ] [viseron.components] - Setting up domain camera for component ffmpeg with identifier camera_1
2024/02/06 13:49:40 | stderr | [2024-02-06 13:49:40] [INFO    ] [viseron.components] - Setup of component codeprojectai took 0.0 seconds
2024/02/06 13:49:39 | stderr | [2024-02-06 13:49:39] [ERROR   ] [viseron.components] - Failed setup of component mqtt
2024/02/06 13:49:39 | stderr | [2024-02-06 13:49:39] [ERROR   ] [viseron.components] - Setup of component mqtt failed
2024/02/06 13:49:39 | stderr | voluptuous.error.MultipleInvalid: extra keys not allowed @ data['mqtt']['client_id\u200b']
2024/02/06 13:49:39 | stderr | raise er.MultipleInvalid(errors)
2024/02/06 13:49:39 | stderr | File "/usr/local/lib/python3.8/dist-packages/voluptuous/schema_builder.py", line 432, in validate_mapping
2024/02/06 13:49:39 | stderr | return base_validate(path, iteritems(data), out)
2024/02/06 13:49:39 | stderr | File "/usr/local/lib/python3.8/dist-packages/voluptuous/schema_builder.py", line 594, in validate_dict
2024/02/06 13:49:39 | stderr | return self._compiled([], data)
2024/02/06 13:49:39 | stderr | File "/usr/local/lib/python3.8/dist-packages/voluptuous/schema_builder.py", line 272, in __call__
2024/02/06 13:49:39 | stderr | return component_module.CONFIG_SCHEMA(self._config)
2024/02/06 13:49:39 | stderr | File "/src/viseron/components/__init__.py", line 120, in validate_component_config
2024/02/06 13:49:39 | stderr | Traceback (most recent call last):
2024/02/06 13:49:39 | stderr | [2024-02-06 13:49:39] [ERROR   ] [viseron.components] - Error validating config for component mqtt: extra keys not allowed @ data['mqtt']['client_id\u200b']. Got 'homeassistant'

<!--EndFragment-->
</body>
</html>

Am I missing something? I don't see any sensors within HA. Running on latest version of Viseron.

UPDATE: Removed the client_id configuration, now it's working:

<html><body>
<!--StartFragment-->
2024/02/06 13:58:34 | stderr | [2024-02-06 13:58:34] [INFO    ] [viseron.core] - Viseron initialized in 3.6 seconds
-- | -- | --
2024/02/06 13:58:34 | stderr | [2024-02-06 13:58:34] [INFO    ] [viseron.components] - Setup of domain nvr for component nvr with identifier camera_1 took 0.0 seconds
2024/02/06 13:58:34 | stderr | [2024-02-06 13:58:34] [INFO    ] [viseron.components.nvr.nvr.camera_1] - NVR for camera Oprit initialized
2024/02/06 13:58:34 | stderr | [2024-02-06 13:58:34] [INFO    ] [viseron.components] - Setup of domain object_detector for component codeprojectai with identifier camera_1 took 0.0 seconds
2024/02/06 13:58:34 | stderr | [2024-02-06 13:58:34] [INFO    ] [viseron.components] - Setup of domain motion_detector for component mog2 with identifier camera_1 took 0.0 seconds
2024/02/06 13:58:34 | stderr | [2024-02-06 13:58:34] [INFO    ] [viseron.components] - Setup of domain camera for component ffmpeg with identifier camera_1 took 2.3 seconds
2024/02/06 13:58:31 | stderr | [2024-02-06 13:58:31] [INFO    ] [viseron.components] - Setting up domain nvr for component nvr with identifier camera_1
2024/02/06 13:58:31 | stderr | [2024-02-06 13:58:31] [INFO    ] [viseron.components] - Setting up domain object_detector for component codeprojectai with identifier camera_1
2024/02/06 13:58:31 | stderr | [2024-02-06 13:58:31] [INFO    ] [viseron.components] - Setting up domain motion_detector for component mog2 with identifier camera_1
2024/02/06 13:58:31 | stderr | [2024-02-06 13:58:31] [INFO    ] [viseron.components] - Setting up domain camera for component ffmpeg with identifier camera_1
2024/02/06 13:58:31 | stderr | [2024-02-06 13:58:31] [INFO    ] [viseron.components] - Setup of component codeprojectai took 0.0 seconds
2024/02/06 13:58:30 | stderr | [2024-02-06 13:58:30] [INFO    ] [viseron.components] - Setup of component mqtt took 0.0 seconds
2024/02/06 13:58:30 | stderr | [2024-02-06 13:58:30] [INFO    ] [viseron.components] - Setup of component mog2 took 0.0 seconds
2024/02/06 13:58:30 | stderr | [2024-02-06 13:58:30] [INFO    ] [viseron.components] - Setup of component ffmpeg took 0.0 seconds
2024/02/06 13:58:30 | stderr | [2024-02-06 13:58:30] [INFO    ] [viseron.components] - Setup of component nvr took 0.0 seconds
2024/02/06 13:58:30 | stderr | [2024-02-06 13:58:30] [INFO    ] [viseron.components] - Setting up component codeprojectai
2024/02/06 13:58:30 | stderr | [2024-02-06 13:58:30] [INFO    ] [viseron.components] - Setting up component nvr
2024/02/06 13:58:30 | stderr | [2024-02-06 13:58:30] [INFO    ] [viseron.components] - Setting up component mog2
2024/02/06 13:58:30 | stderr | [2024-02-06 13:58:30] [INFO    ] [viseron.components] - Setting up component ffmpeg
2024/02/06 13:58:30 | stderr | [2024-02-06 13:58:30] [INFO    ] [viseron.components] - Setting up component mqtt
2024/02/06 13:58:30 | stderr | [2024-02-06 13:58:30] [INFO    ] [viseron.components] - Setup of component webserver took 0.0 seconds
2024/02/06 13:58:30 | stderr | [2024-02-06 13:58:30] [INFO    ] [viseron.components] - Setting up component webserver
2024/02/06 13:58:30 | stderr | [2024-02-06 13:58:30] [INFO    ] [viseron.components] - Setup of component data_stream took 0.0 seconds
2024/02/06 13:58:30 | stderr | [2024-02-06 13:58:30] [INFO    ] [viseron.components] - Setting up component data_stream
2024/02/06 13:58:30 | stderr | [2024-02-06 13:58:30] [INFO    ] [viseron.core] - Initializing Viseron
2024/02/06 13:58:30 | stderr | [2024-02-06 13:58:30] [INFO    ] [viseron.core] - -------------------------------------------
2024/02/06 13:58:30 | stdout | [viseron-finish] Viseron exit code 100
2024/02/06 13:58:29 | stderr | [2024-02-06 13:58:29] [INFO    ] [viseron.core] - Shutdown complete

<!--EndFragment-->
</body>
</html>

But still no sensors within HA?

BliXem1 commented 7 months ago

Fixed :-).

added home_assistant: and it was fixed in the configuration.