this post was submitted on 07 Jul 2024
25 points (100.0% liked)

homeassistant

12072 readers
23 users here now

Home Assistant is open source home automation that puts local control and privacy first. Powered by a worldwide community of tinkerers and DIY enthusiasts. Perfect to run on a Raspberry Pi or a local server. Available for free at home-assistant.io

founded 1 year ago
MODERATORS
 

I have been using the BlueIris NVR integration (from HACS) for quite some time, and it works great for triggering BI from HA. I've trying to do the opposite now: Fire off automations in HA whenever BI detects motion on one of my cameras.

I've never used MQTT before, so I'm learning as I go, but I think I have most of my setup configured properly. I've installed Mosquitto and the MQTT integration in HA. I've configured BI to connect to HA, and running "Test" in the "Edit MQTT Server" menu in BI shows a good connection and no errors. I've set my cameras to post an MQTT event when the alert is triggered (and I've verified that the alerts are in fact being triggered).

Nothing happens in HA, though. The "Motion" sensor for my camera in HA stays at "Clear." In fact, the history shows no change at all, ever.

I have the events in BI set up as follows: On Alert: MQTT Topic - BlueIris/&CAM/Status and Payload - { "type": "&TYPE", "trigger": "ON" } On Reset: Exactly the same, but change ON to OFF.

I've tried change the MQTT autodiscovery header in HA from "homeassistant" to "BlueIris," and it made no difference. The Mosquitto logs show a login from HA, so I feel like I'm close, but I'm not sure where else to look.

Edit: I installed MQTT explorer, and I've verified that the messages are making it to Mosquitto, and they appear to be correctly formatted.

UPDATE: I set the MQTT integration to listen to the MQTT messages coming from BI, and sure enough, they were coming through just fine. For some reason, the BI integration just wasn't seeing them. Digging through the system logs, I saw some errors "creating a binary sensor" coming from the BI integration. The only thing I can think is that because I didn't have MQTT set up when I first installed the BI integration, something went wrong with the config (although I had already rebooted the system several times). I re-downloaded the BI integration and re-installed it, and now everything works perfectly.

top 6 comments
sorted by: hot top controversial new old
[–] dmtalon@infosec.pub 1 points 4 months ago* (last edited 4 months ago) (1 children)

I get alerts from BI Motion in HA (via mqtt)... I'll look at it a bit to jog my memory and see if I can give any tips. It'll likely be tomorrow or so as I'm traveling today

[–] corroded@lemmy.world 1 points 4 months ago (1 children)

I'd be interested to hear how you have it set up. My issue is definitely with HA. I can see the messages making it to the broker; HA just isn't recognizing them it seems.

[–] dmtalon@infosec.pub 1 points 4 months ago (1 children)

Didn't get home til late last night... Looking at my automation. If you've successfully connected (via mqtt) and validated in explorer. my automation to trigger a notification on motion is quite simple.

[–] dmtalon@infosec.pub 2 points 4 months ago

in BI, for each camera I have the following set under settings/alerts/on alerts

[–] chunkystyles@sopuli.xyz 1 points 4 months ago (1 children)

Auto detection for MQTT devices is a bit tricky. I struggled with that myself when I was trying to incorporate data from a web scraper I wrote. This config file here shows what I ended up with to create auto detecting sensors in HA https://github.com/chunkystyles/reservationsScraper/blob/main/mqttConfig.json

Each one of the devices gets registered at start up of the app.

If I were doing this all over again, I probably wouldn't use auto detect sensors. I'd manually configure them. Here's some examples of that kind of configuration I used for some HVAC remote devices I built:

mqtt:
  sensor:
    - name: "makerfabs_remote_1"
      state_topic: "makerfabs/hvacremote/1/status_out"
      force_update: true
      expire_after: 125
    - name: "makerfabs_remote_2"
      state_topic: "makerfabs/hvacremote/2/status_out"
      force_update: true
      expire_after: 125
    - name: "makerfabs_remote_3"
      state_topic: "makerfabs/hvacremote/3/status_out"
      force_update: true
      expire_after: 125
    - name: "makerfabs_remote_4"
      state_topic: "makerfabs/hvacremote/4/status_out"
      force_update: true
      expire_after: 125

For these to work, you just put them in your "configuration.yaml" file in HA.

[–] corroded@lemmy.world 2 points 4 months ago

The strange part is that the BlueIris integration already has "Motion" devices for each of my cameras. The documentation made it sound like I just needed to start feeding HA with MQTT messages that these devices were expecting.

I may do like you suggested and just manually set up binary MQTT sensors. It would look a lot cleaner to tie it into the existing integration, but I'm not sure if it's worth the extra troubleshooting.