QuantumEntangledAndy / neolink

An RTSP bridge to Reolink IP cameras
GNU Affero General Public License v3.0
331 stars 45 forks source link

non updating mqtt entity #113

Closed jonahgcarpenter closed 1 year ago

jonahgcarpenter commented 1 year ago

Describe the bug The MQTT camera entity is not updating

To Reproduce

bind = "0.0.0.0"

[[cameras]]
name = "Garage"
username = "admin"
password = "*****"
address = "*****"
  [cameras.mqtt]
  server = "*****" # Address of the mqtt server
  port = 1883 # mqtt servers port
  credentials = ["*****", "*****"] # mqtt server login details
    [cameras.mqtt.discovery]
    topic = "homeassistant"
    features = ["floodlight", "motion", "camera"]

Expected behavior I was hoping the camera entity would update enough to send a notification including the photo when motion was detected

Versions NVR software: Home Assistant Neolink software: 0.0.6 Reolink camera model and firmware: LUMUS v2.0.0.705_21052800

QuantumEntangledAndy commented 1 year ago

The mqtt camera entitiy is meant to act as a preview only. It should update itself every second or so. The motion though should be firing whenever motion is detected. Are either of these not happening?

jonahgcarpenter commented 1 year ago

The entity shows up but there is no picture associated with it

QuantumEntangledAndy commented 1 year ago

Try conneting with something like mqtt explorer and see if the messages are being posted

jonahgcarpenter commented 1 year ago

could i automate this in HAS to have images saved on motion detection?

“You can write an image from the stream to disk using:

neolink image --config=config.toml --file-path=filepath CameraName Where filepath is the path to save the image to and CameraName is the name of the camera from the config to save the image from.

File is always jpeg and the extension given in filepath will be added or changed to reflect this.”

QuantumEntangledAndy commented 1 year ago

Yea you could. Just run a shell script on an event. But you've got to get neolink into a place that ha can run scripts from.

But if you have mqtt running the image is already stored inside the server every second in base64 format.

jonahgcarpenter commented 1 year ago

when using the mqtt-explorer i see the camera picture being sent but the HAS camera entity is still empty. The HAS MQTT entity is being updated but hasnt changed since i installed it?

Heres the mqtt message being sent too { "name": "Garage Camera", "unique_id": "neolink_Garage_camera", "icon": "mdi:camera-iris", "device": { "name": "Garage", "connections": [ [ "camera_addr", "****" ] ], "identifiers": [ "neolink_Garage" ], "manufacturer": "Reolink", "model": "Neolink", "sw_version": "0.5.13" }, "availability": { "topic": "neolink/Garage/status", "payload_available": "connected" }, "topic": "neolink/Garage/status/preview", "image_encoding": "b64"

QuantumEntangledAndy commented 1 year ago

So neolink is posting the image to neolink/Garage/status/preview and neolink/Garage/status has a value of connected right?

If so then neolink is doing it's job and the issue lies in your ha mqtt configuration. You might want to remove all entities and then uninstall and reinstall the mqtt integration. See if it can pick up the entities again.

jonahgcarpenter commented 1 year ago

"You might want to remove all entities and then uninstall and reinstall the mqtt integration." Doing all of this still doesn't populate the entity, If i look in developer states for the entity it says

entity_picture: >- /api/camera_proxy/camera.garage_camera?token=

is the mqtt entity looking in the wrong place for the picture if so how do i change it?

jonahgcarpenter commented 1 year ago

actually now that i check there is nothing being published to the topic "neolink/Garage/status/preview" only the floodlight and motion shows up

QuantumEntangledAndy commented 1 year ago

I see, then we need to figure out why that one isn't posted. Do you have a max message size on the mqtt server? The image can be quite large and won't send on some servers if the max message size is too low?

QuantumEntangledAndy commented 1 year ago

So I have been digging into this and it seems that not every camera supports the SNAP command that I am using for the jpeg. Works on my Argus2E but not my E1. Can you get the neolink image command to work manually (in latest build)?

QuantumEntangledAndy commented 1 year ago

Since this seems to just be that the camera dosen't support the SNAP command I am going to close this. If you want to add a feature to use the live stream instead of the Snap command for the picture please open a PR with the required changes. Otherwise I have no desire to make such a feature now. For viewing the stream in HA please instead add a generic rtsp camera instead with the neolink rtsp command