I started working on a binding for the Frigate NVR software. I created a bridge for the server connection but events are send through MQTT. Is it possible to have the frigate bridge rely on another MQTT bridge. Right now I am created a separate MQTT client connection and I think it is causing issues. It throws exception when events are called and I think its related to MQTT and threading. Any advise would be appreciated.
If you need a working example on how to connect to MQTT, and also how to do auto discovery from mqtt messages, then check out the ‘espmilighthub’ binding. To get a binding merged you will need to use the framework to connect to MQTT and not use paho or another external library to make the connection.
openhab-addons/bundles/org.openhab.binding.mqtt.espmilighthub at main · openhab/openhab-addons (github.com)
I looked at the ‘espmilighthub’ binding as an example. The problem I have is the MQTT messages do not specify the IP address of the Frigate Server. This is the reason I created a bridge for the user to setup the IP and port of the server.
Is your target device running an on-board MQTT broker? I recall some robot lawnmower or vacuum doing something like that.
Frigate can be configured to use any MQTT server. I personally use one MQTT server for all my stuff so it seems redundant to have multiple connections from different bindings. I did copy the the iRobot code that uses an onboard MQTT server, but I am having some threading issues I think and I was hoping there is a better way.
Alright, so the expected use would be -
User sets up an MQTT broker, if they haven’t already.
User connects NVR to broker as client.
User installs OH MQTT binding, connects it to broker as client with standard bridge Thing, if they haven’t already.
Your OH add-on is told (by configuring a Thing) or finds out (by subscribing to magic topic) about the NVR, and auto-creates suitable channels.
Sounds like you might look at MQTT Homie extension for an example.
Yes I understand more now why your asking this. You can normally have binding level config options, but your binding will show up as part of the MQTT binding, so you will need to create a new broker to have the options available for users to use. This will mean a second connection to the mqtt broker if you have one of each bridge type setup so the broker needs to allow multiple connections.
You can create extra mqtt bridges and 1 did exist until it was recently removed. You can see the source code that was removed here (click on the ‘files changed’ link):
[mqtt] Remove MQTT System Broker by jimtng · Pull Request #12157 · openhab/openhab-addons (github.com)
Your xml file would look something like this. NOTE that the bindingId is just mqtt and that when your jar is in the addons folder, you will click on the mqtt binding to add things to the inbox and your binding will not show up as a separate binding…
<?xml version="1.0" encoding="UTF-8"?>
Also note that I list the supported-bridge-type-refs so the only one that the camera thing can use is the frigateBroker which you will need to define and create your own handler for, PLUS you will need to handle it in your handler factory. I have not created a MQTT bridge before but it should be the same, just you do it as if your mqtt and not your own binding.
FrigateHandlerFactory needs to return TRUE when the framework asks via supportsThingType(ThingTypeUID thingTypeUID). All the handlerFactories get asked if they support the ‘frigateBroker’, you need to say TRUE.
Once the framework gets a true on your handlerFactory, you need to implement createHandler(Thing thing) in your FrigateHandlerFactory to then create a handler for ‘frigateBroker’.
Your XML file needs to define the frigateBroker.
Another way is to scan all your site local internal IP’s and make a http request that only frigate would reply to. This code shows an example of this method but if someone does not use the default port for frigate this would not be useful…
openhab-addons/IpObserverDiscoveryService.java at main · openhab/openhab-addons (github.com)
Have you done any more work on this? It’s promising that frigate sends snapshots over MQTT, so I was hoping to find a simple script to get these snapshots in OpenHAB. Search brought me here.
Hello to all,
I am trying to integrate Frigate into openHAB through MQTT and the HTTP api. Has this evolved or is there any plan to evolve this binding?
Thank you in advanced for your time.
hey @rjduraocosta ,
here is a new frigate binding from jgow. check it out if it solves your requirements.