QuantumEntangledAndy / neolink

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

mqtt control topic missing for poe floodlight #189

Closed jakommo closed 6 months ago

jakommo commented 7 months ago

Describe the bug I'm trying to get the Reolink Floodlight PoE (without camera) working and control it through Homeassistant, but can't get it to work. MQTT discovery works fine and entities are created in Homeassistant, but they become unavailable instantly. Looking at the related MQTT topics, I noticed that the config for the floodlight in the Homeassistnat topic refers to "command_topic": "neolink/floodlight1/control/floodlight", but under the neolink topic I only have status and no control topic. For what it's worth, the status topic works fine, as I can see it switching from off to on when I toggle the light via their app.

I also saw that there were some major changes to MQTT in v0.6.0 and after https://github.com/QuantumEntangledAndy/neolink/pull/14 and https://github.com/QuantumEntangledAndy/neolink/pull/95 were implemented, but even when testing with v0.5.13 the control topic is missing.

Also tried manually creating neolink/floodlight1/control/floodlight with a value of on, but that doesn't work either. Running out of ideas now. Let me know if you need any additional info.

To Reproduce Steps to reproduce the behavior. Example:

  1. Create this configuration file: v6:
    
    bind = "0.0.0.0"

discovery = "local"

[mqtt] broker_addr = "XXX" port = 1883 credentials = ["user", "my pass"]

[[cameras]] name = "floodlight1" username = "admin" password = "XXX" address = "XXX:9000" [cameras.mqtt] enable_light = true enable_floodlight = true [cameras.mqtt.discovery] topic = "homeassistant" features = ["floodlight","motion","led"]

v5:

discovery = "local"

[[cameras]] name = "floodlight1" username = "admin" password = "XXX" address = "XXX:9000" mqtt.broker_addr = "XXX" mqtt.port = 1883 mqtt.credentials = ["user", "my pass"] mqtt.discovery.topic = "homeassistant" mqtt.discovery.features = ["floodlight"]

2. Launch Neolink in docker via
v6:

sudo docker run --rm --volume=./neolink.toml:/etc/neolink.toml --name neolink quantumentangledandy/neolink:v0.6.2 /usr/local/bin/neolink mqtt --config /etc/neolink.toml [2023-11-15T21:40:33Z INFO neolink] Neolink e47a0d5734b0a06b53bd8d78be9ca2f6b8396480 release [2023-11-15T21:40:33Z INFO neolink::mqtt] floodlight1: MQTT Staring [2023-11-15T21:40:33Z INFO neolink::utils] floodlight1: Connecting to camera at Address: XXX:9000 [2023-11-15T21:40:33Z INFO neolink_core::bc_protocol] floodlight1: Trying TCP discovery [2023-11-15T21:40:33Z INFO neolink::mqtt::discovery] Enabled MQTT discovery for floodlight1 with friendly name Floodlight1 [2023-11-15T21:40:33Z INFO neolink_core::bc_protocol] floodlight1: TCP Discovery success at XXX:9000 [2023-11-15T21:40:33Z INFO neolink::utils] floodlight1: Logging in [2023-11-15T21:40:33Z INFO neolink::utils] floodlight1: Connected and logged in [2023-11-15T21:40:33Z INFO neolink::common::camthread] floodlight1: Camera time is already set: 2023-11-15 22:40:35.0 -01:00:00 [2023-11-15T21:40:33Z INFO neolink::common::neocam] floodlight1: Model Reolink Floodlight PoE [2023-11-15T21:40:33Z INFO neolink::common::neocam] floodlight1: Firmware Version v3.0.0.1311_22090741

v5:

sudo docker run --rm --volume=./neolinkv5.toml:/etc/neolink.toml --name neolink quantumentangledandy/neolink:v0.5.13 /usr/local/bin/neolink mqtt --config /etc/neolink.toml [2023-11-15T21:13:18Z INFO neolink] Neolink 254a310fe9e9a9516a1a72e634074781aa23f780 release [2023-11-15T21:13:18Z INFO neolink::mqtt] floodlight1: Setting up mqtt [2023-11-15T21:13:18Z INFO neolink::mqtt::mqttc] Starting MQTT Client for floodlight1 [2023-11-15T21:13:18Z INFO neolink::mqtt::event_cam] floodlight1: Connecting to camera at Address: XXX:9000 [2023-11-15T21:13:18Z INFO neolink_core::bc_protocol] floodlight1: Trying TCP discovery [2023-11-15T21:13:18Z INFO neolink_core::bc_protocol] floodlight1: TCP Discovery success at XXX:9000 [2023-11-15T21:13:18Z INFO neolink::mqtt::event_cam] floodlight1: Logging in [2023-11-15T21:13:18Z INFO neolink::mqtt::event_cam] floodlight1: Connected and logged in [2023-11-15T21:13:18Z INFO neolink::mqtt::event_cam] floodlight1: Listening to FloodLight Status [2023-11-15T21:13:18Z INFO neolink::mqtt::event_cam] floodlight1: Updating Preview [2023-11-15T21:13:18Z INFO neolink::mqtt::event_cam] floodlight1: Updating Battery Level [2023-11-15T21:13:18Z INFO neolink::mqtt::event_cam] floodlight1: Setting up camera actions [2023-11-15T21:13:18Z INFO neolink::mqtt::event_cam] floodlight1: Listening to Camera Motion [2023-11-15T21:13:18Z INFO neolink::mqtt::discovery] Enabled MQTT discovery for floodlight1 with friendly name Floodlight1


3. Check if the `neolink/floodlight1/control/...` topic was created 

**Expected behavior**
MQTT topic `neolink/floodlight1/control` should be created and allow control through Homeassistant

**Versions**
Neolink software: v0.5.13, v0.6.0, v0.6.2 and "latest" docker image as of today 
Reolink camera model and firmware: Model Reolink Floodlight PoE, Firmware Version v3.0.0.1311_22090741
jakommo commented 7 months ago

Hey @kevin-david since you added support for the poe floodlight in https://github.com/QuantumEntangledAndy/neolink/pull/14, are you still using it successfully with a recent version of neolink?

kevin-david commented 7 months ago

@jakommo I am using my own fork actually: https://github.com/kevin-david/neolink. It's based on master versus a specific release so maybe things have been fixed?

I've been meaning to un-fork and consolidate things but I'd need to go add different floodlight on/off time back to neolink which I haven't done yet.

jakommo commented 7 months ago

Thanks @kevin-david . I gave your fork a try, but still the same issue (no control topic). So it looks like it's either a problem with my config or my environment. I'll do some more digging, thanks again!

kevin-david commented 7 months ago

Dang, wish it was that easy! If it helps, here's my config that's working.


[mqtt]
broker_addr = "192.168.1.122"
port = 1883
credentials = ["homeassistant", "<password>"]

[[cameras]]
name = "backyard_floodlight"
username = "admin"
password = "<camera_password>"
address = "192.168.1.130"
mqtt.enable_battery = false
mqtt.enable_preview = false
mqtt.preview_update = 60000
mqtt.discovery.topic = "homeassistant"
mqtt.discovery.features = ["floodlight"]

[[cameras]]
name = "backyard_camera"
username = "admin"
password = "<camera_password>"
address = "192.168.1.194"
mqtt.enable_battery = false
mqtt.enable_preview = false
mqtt.preview_update = 60000
mqtt.discovery.topic = "homeassistant"
mqtt.discovery.features = ["floodlight"]
jakommo commented 7 months ago

Thanks for sharing your config! I adjusted it to my environment and even tried with a clean mosquitto instance dedicated for this testing, but still no luck.

It just won't create the control topic for some reason. The other topics are created just fine and do receive data etc.

image

I also checked this in the neolink debug logs. It doesn't even seem to try to create the control topic :shrug:

[2023-11-30T19:25:08Z DEBUG yaserde_derive] Struct BcXml @ 0: success
[2023-11-30T19:25:08Z DEBUG rumqttc::state] Publish. Topic = neolink/status, Pkid = 1, Payload Size = 9
[2023-11-30T19:25:08Z DEBUG rumqttc::state] Publish. Topic = neolink/config, Pkid = 2, Payload Size = 936
[2023-11-30T19:25:08Z DEBUG rumqttc::state] Publish. Topic = neolink/floodlight1/status, Pkid = 3, Payload Size = 12
[2023-11-30T19:25:08Z DEBUG rumqttc::state] Publish. Topic = neolink/floodlight1/status/motion, Pkid = 4, Payload Size = 7
[2023-11-30T19:25:08Z DEBUG rumqttc::state] Publish. Topic = neolink/floodlight1/status/notification, Pkid = 5, Payload Size = 7
[2023-11-30T19:25:08Z DEBUG rumqttc::state] Publish. Topic = homeassistant/light/neolink_floodlight1_floodlight/floodlight1/config, Pkid = 6, Payload Size = 575
[2023-11-30T19:25:08Z DEBUG rumqttc::state] Publish. Topic = homeassistant/switch/neolink_floodlight1_floodlight_tasks/floodlight1/config, Pkid = 7, Payload Size = 584
[2023-11-30T19:25:08Z DEBUG rumqttc::state] Publish. Topic = neolink/status, Pkid = 8, Payload Size = 9
[2023-11-30T19:25:08Z DEBUG rumqttc::state] Subscribe. Topics = [Filter = neolink/#, Qos = AtMostOnce], Pkid = 9

Are you running the standalone poe floodlight or the one that is included with the duo cam?

kevin-david commented 7 months ago

That's odd - I'm actually using both, one standalone floodlight and one Duo cam with the floodlight.

What if you just try manually creating the topic?

You might need to pull down the source and do some debugging. VS code is handy - if you reverse what I did here: https://github.com/QuantumEntangledAndy/neolink/pull/13/commits/dcafaa7e55d596218d8a21a359a506a6680b7636

that might be helpful

jakommo commented 6 months ago

Ok, I got it working now. It was a permission issue in my environment in the end :facepalm: Thanks much for your help!

For reference: After your comment, I tried manually creating the control topic again in an isolated environment and that made it work with your fork and the version of this repo. When moving it back to my main environment, I noticed that homeassistant marks the floodlight as unavailable the second after it is initially created and that got me on the right track. While the neolink mqtt user had permissions for the homeassistant an neolink topic, the HA mqtt user wasn't allowed to access the neolink topic. After fixing that, the floodlight device became available in HA and after switching it on for the first time, the control topic was created automatically.