New comprehensive Frigate binding

Wow, that’s great news!
Thank you very much for this great binding!

thanks for the good binding, so far almost everything is working great.

Is it possible to start an action via the binding, e.g. create a snapshot now?

See above: I think what you are asking for is similar to @fmeili1 's request? It’s a great suggestion - I’ll look at getting it added to the next release.

Hi @jgow , i discovered your work… a very good binding, congratulations ! :slight_smile:

Do you plan to release as official openhab addon ? If you agree to do this work i can help you for the approval phases (i refactored souliss binding and i must say the approval path of an oh binding it’s quite laborious).

If you are interested we should create a fork of openhab addons and add your binding , plus work on all code analysis errors

Let me know …
Luca

Hi @Luca_Calcaterra - thanks, and thanks for your kind offer of help.

The question of releasing as an ‘official’ addon is a difficult one. Currently, when it is finished (I am working on some additional functionality at the moment) I had planned to release it via the ‘marketplace’. Having written it, it is only right that OH and the community benefit from having a decent Frigate binding available.

However, essentially I wrote this binding for two reasons: 1) I needed it to be able to successfully integrate OH+Frigate in my environment and 2) it is fun to do. As I am doing this in what little spare time I have, anything that mitigates against these two reasons would be a good reason to discontinue work on it. Without wishing to appear overly negative, I really don’t have the time or the interest in jumping through ‘laborious’ approval hoops (I do enough of this in my day job - and it isn’t fun :unamused:).

I do intend to clean up and improve the code and any help with testing, bugfixes, suggestions or contribution of patches is most welcome.

So - while I am more than happy for the OH maintainers to include it if they so wished, I really don’t want to expend time eviscerating the code for reasons unrelated either to improving its functionality or to fixing bugs.

1 Like

Hi @fmeili1 - I have implemented the ability to trigger an event through a ThingAction but can’t test it fully in my environment as I am currently not able to run the required beta version of Frigate. If you are able, would you mind testing it? Any comments welcome. Note I did my testing against a 4.0.4 version of OH.
(Note the docs for this are in the README.md).

Hi @jgow
great news - and thanks a lot for your work on this binding!

I’ll try to test the external trigger feature tomorrow. In the meantime, I’ve updated my installation to OH 4.1.0 but I hope it will work. As soon as I have results, I’ll give feedback.

Hi,

many thanks for this binding @jgow ! I downloaded pre-built Version org.openhab.binding.mqtt.frigatesvr-4.0.3.jar working with OH 4.1.1. Then i added my “Server” Thing and auto-discovered my Cameras. But whatever i do, the camera things stay always “offline” with the comment “CONFIGURATION_PENDING”.

Any Idea what i may have done wrong? oO

Thanks in advance!

It’s worth rebuilding the binding against your running version of OH as you seem to have a version mismatch: check out the 4.1.1 openhab-addons branch, then build the frigateSVR binding against this (sorry I haven’t provided a .jar release for a while as I am working on new features at the moment). If you still get the issues, please reply and let me know. Build instructions are in the README.md.

I had some ‘strangeness’ in my development environment recently with a mismatch between binding version and OH version, so it is certainly worth ruling this out before going further.

I have released 1.8 of the binding (with a .jar only for 4.1.1 stable so far, as I haven’t yet got round to changing all the dates in the header files to stop the compilation process from its ridiculous whining about the comments in the headers ‘not matching pattern…’ when built against 4.2.0-SNAPSHOT because it hasn’t got this year’s date in it).

This has some fixes in the streaming servers, and all the streams seem to work with vlc. More importantly, I am slowly bringing in access to the Frigate API through ThingActions on the camera Things (and later on the server Things for the non-camera specific actions). If this is helpful to you, please give it a try. Also, please let me know if there are any Frigate APIs you would like to see as a matter of priority - and I will see if I can get these in first. The documentation for the ThingActions is in the doc/ folder.

OH 4.1.1
Binding 1.8
Frigate 0.13.1.

Hey, has anything changed with the new 1.8 Binding regarding the CameraThings? The ServerThing with the Birdeye View works, the CamThings are also displayed online, but I no longer receive an update of the camera items.

I didn’t have this problem with the 1.7 binding. I have already created a new CameraThing. In Frigate I have a stream for Record and a SubStream for Detect for each camera. I have also entered ffmpegCameraNameOverride in the CameraThing.

I only see that the Snapshot_Time is updated to NULL. In Frigate itself, the events are recorded normally as a clip and snapshot

In the MQTT Broker it looks like this.
image

Interesting…I’ll have a look at this. It is working here and I haven’t seen a failure where an event is not being picked up by the binding.
There have been some quite significant changes ‘under the bonnet’ between v1.7 and 1.8, mostly to the inter-Thing communications (openHAB doesn’t provide a mechanism for Thing handlers to ‘know’ about each other, and nested bridges aren’t supported, so I have had to work around this for architectures such as Frigate). I will check this.
In the meantime, if you have upgraded the binding and you haven’t done this already, could you try re-creating your Things (particularly the camera Thing) as I have added new channels in v1.8, and sometimes these are not picked up when just the binding .jar is updated.

I have now deleted all Things/Items and recreated the ServerThing and a CameraThing. Of the four items used in the CameraThing, only the Event Start Time is updated. In Frigate itself, everything works, everything is recorded, snapshots are created, etc.

OH: 4.1.1 Release Build
Binding: org.openhab.binding.mqtt.frigatesvr-4.1.1.jar
Frigate: 0.13.1-34FB1C2

ServerThing

UID: mqtt:frigateServer:mqttbroker:camera_nvr
label: Camera NVR
thingTypeUID: mqtt:frigateServer
configuration:
  ffDASHPackageCommands: -seg_duration 1 -streaming 1
  serverClientID: ""
  ffDASHTranscodeCommands: -acodec copy -vcodec copy
  enableAPIForwarder: true
  ffMJPEGTranscodeCommands: -q:v 5 -r 2 -vf scale=640:-2 -update 1
  ffmpegLocation: /usr/bin/ffmpeg
  ffHLSStartProducerOnLoad: false
  enableStream: false
  streamWhitelist: DISABLE
  ffTempDir: ""
  ffMJPEGStartProducerOnLoad: false
  ffHLSTranscodeCommands: -acodec copy -vcodec copy
  ffMinFramesToStart: 10
  serverURL: http://nvr:5000/
  serverKeepAlive: 5
  ffDASHStartProducerOnLoad: false
  ffKeepalivesBeforeExit: 2
bridgeUID: mqtt:broker:mqttbroker
channels:
  - id: fgAPIVersion
    channelTypeUID: mqtt:fgAPIVersion
    label: API version
    description: Version of current Frigate API
    configuration: {}
  - id: fgUI
    channelTypeUID: mqtt:fgUI
    label: Frigate UI URL
    description: URL to Frigate user interface
    configuration: {}
  - id: fgAPIForwarderURL
    channelTypeUID: mqtt:fgAPIForwarderURL
    label: URL of API forwarder
    description: Local URL of Frigate HTTP API forwarder
    configuration: {}
  - id: fgBirdseyeURL
    channelTypeUID: mqtt:fgBirdseyeURL
    label: Birdseye stream URL
    description: URL to re-streamed birdseye view
    configuration: {}

CameraThing

UID: mqtt:frigateCamera:mqttbroker:Hof-nvr-fknetwork-de5000
label: Camera Hof
thingTypeUID: mqtt:frigateCamera
configuration:
  ffDASHPackageCommands: -seg_duration 1 -streaming 1
  ffmpegCameraNameOverride: Hof_sub
  ffDASHTranscodeCommands: -acodec copy -vcodec copy
  ffMJPEGTranscodeCommands: -q:v 5 -r 2 -vf scale=640:-2 -update 1
  ffHLSStartProducerOnLoad: false
  enableStream: false
  serverID: mqtt:frigateServer:mqttbroker:camera_nvr
  ffTempDir: ""
  ffMJPEGStartProducerOnLoad: false
  ffHLSTranscodeCommands: -acodec copy -vcodec copy
  ffMinFramesToStart: 10
  ffDASHStartProducerOnLoad: false
  ffKeepalivesBeforeExit: 2
  cameraName: Hof
bridgeUID: mqtt:broker:mqttbroker
channels:
.....
	Line 36020: 2024-02-16 09:44:54.738 [INFO ] [openhab.event.ItemStateUpdatedEvent ] - Item 'Camera_Hof_Current_Start_time' updated to NULL
	Line 36186: 2024-02-16 09:44:58.554 [INFO ] [openhab.event.ItemStateUpdatedEvent ] - Item 'Camera_Hof_Current_Snapshot_Time' updated to NULL
	Line 42519: 2024-02-16 09:47:37.452 [INFO ] [openhab.event.ItemStateUpdatedEvent ] - Item 'Camera_Hof_Current_Snapshot_Time' updated to NULL
	Line 42520: 2024-02-16 09:47:37.452 [INFO ] [openhab.event.ItemStateUpdatedEvent ] - Item 'Camera_Hof_Current_Start_time' updated to 2024-02-16T09:47:35.819432973+0100
	Line 42521: 2024-02-16 09:47:37.452 [INFO ] [openhab.event.ItemStateChangedEvent ] - Item 'Camera_Hof_Current_Start_time' changed from NULL to 2024-02-16T09:47:35.819432973+0100
	Line 42701: 2024-02-16 09:47:42.689 [INFO ] [openhab.event.ItemStateUpdatedEvent ] - Item 'Camera_Hof_Current_Snapshot_Time' updated to NULL
	Line 42702: 2024-02-16 09:47:42.689 [INFO ] [openhab.event.ItemStateUpdatedEvent ] - Item 'Camera_Hof_Current_Start_time' updated to 2024-02-16T09:47:35.819432973+0100
	Line 42929: 2024-02-16 09:47:47.858 [INFO ] [openhab.event.ItemStateUpdatedEvent ] - Item 'Camera_Hof_Current_Snapshot_Time' updated to NULL
	Line 42930: 2024-02-16 09:47:47.858 [INFO ] [openhab.event.ItemStateUpdatedEvent ] - Item 'Camera_Hof_Current_Start_time' updated to 2024-02-16T09:47:35.819432973+0100
	Line 43107: 2024-02-16 09:47:52.879 [INFO ] [openhab.event.ItemStateUpdatedEvent ] - Item 'Camera_Hof_Current_Snapshot_Time' updated to NULL
	Line 43108: 2024-02-16 09:47:52.879 [INFO ] [openhab.event.ItemStateUpdatedEvent ] - Item 'Camera_Hof_Current_Start_time' updated to 2024-02-16T09:47:51.632031917+0100
	Line 43109: 2024-02-16 09:47:52.879 [INFO ] [openhab.event.ItemStateChangedEvent ] - Item 'Camera_Hof_Current_Start_time' changed from 2024-02-16T09:47:35.819432973+0100 to 2024-02-16T09:47:51.632031917+0100
	Line 43110: 2024-02-16 09:47:53.077 [INFO ] [openhab.event.ItemStateUpdatedEvent ] - Item 'Camera_Hof_Current_Snapshot_Time' updated to NULL
	Line 43111: 2024-02-16 09:47:53.077 [INFO ] [openhab.event.ItemStateUpdatedEvent ] - Item 'Camera_Hof_Current_Start_time' updated to 2024-02-16T09:47:35.819432973+0100
	Line 43112: 2024-02-16 09:47:53.079 [INFO ] [openhab.event.ItemStateChangedEvent ] - Item 'Camera_Hof_Current_Start_time' changed from 2024-02-16T09:47:51.632031917+0100 to 2024-02-16T09:47:35.819432973+0100
	Line 43189: 2024-02-16 09:47:54.779 [INFO ] [openhab.event.ItemStateUpdatedEvent ] - Item 'Camera_Hof_Current_Snapshot_Time' updated to NULL
	Line 43190: 2024-02-16 09:47:54.779 [INFO ] [openhab.event.ItemStateUpdatedEvent ] - Item 'Camera_Hof_Current_Start_time' updated to 2024-02-16T09:47:35.819432973+0100
	Line 43258: 2024-02-16 09:47:58.087 [INFO ] [openhab.event.ItemStateUpdatedEvent ] - Item 'Camera_Hof_Current_Snapshot_Time' updated to NULL
	Line 43259: 2024-02-16 09:47:58.088 [INFO ] [openhab.event.ItemStateUpdatedEvent ] - Item 'Camera_Hof_Current_Start_time' updated to 2024-02-16T09:47:51.632031917+0100
	Line 43260: 2024-02-16 09:47:58.088 [INFO ] [openhab.event.ItemStateChangedEvent ] - Item 'Camera_Hof_Current_Start_time' changed from 2024-02-16T09:47:35.819432973+0100 to 2024-02-16T09:47:51.632031917+0100
	Line 43660: 2024-02-16 09:48:06.076 [INFO ] [openhab.event.ItemStateUpdatedEvent ] - Item 'Camera_Hof_Current_Snapshot_Time' updated to NULL
	Line 43661: 2024-02-16 09:48:06.076 [INFO ] [openhab.event.ItemStateUpdatedEvent ] - Item 'Camera_Hof_Current_Start_time' updated to 2024-02-16T09:47:51.632031917+0100
	Line 44388: 2024-02-16 09:48:24.465 [INFO ] [openhab.event.ItemStateUpdatedEvent ] - Item 'Camera_Hof_Current_Snapshot_Time' updated to NULL
	Line 44389: 2024-02-16 09:48:24.465 [INFO ] [openhab.event.ItemStateUpdatedEvent ] - Item 'Camera_Hof_Current_Start_time' updated to 2024-02-16T09:47:51.632031917+0100

I think I have found the bug causing this behaviour in the release .jar. Give me a couple of days to do some testing and if confirmed I will create a new release.

I’ve implemented a rule which sends an image with the snapshot of the current camera event via messenger (Telegram via it’s OH binding). I’ve noticed that the snapshot image is not longer the current valid image, instead it always shows (the same) old one for all new events.

In Frigate GUI the snapshot images are correct for each new event (checked via download snapshot in Frigate GUI).

The items channel definition is:

Camera : CamBackyardEastView
Last snapshot
mqtt:frigateCamera:mymosquittobroker:CamBackyardEastView-myserver5000:fgLastSnapshot (Image)

The current data is shown as it’s type in OH GUI and if I click at the item, I can see the old snapshot image itself:

data:image/jpeg;base64,…

The items type is shown in the channel definition as:

Item: raw type (image/jpeg): 1705…

The rule uses the following code snippets to get the image and send it to Telegram:


const lastSnapshotItem = items.getItem(“Camera_Backyard_Last_snapshot”);
telegramAction.sendTelegramPhoto(lastSnapshotItem.rawState.toFullString(), “alarm from backyard camera”);

This worked for the first couple of weeks without issues and with always correct snapshot images. For unknown reasons, I’ll never get correct snapshot images again. I’ve tried the following:

  • I’ve restarted OH (4.1.1)
  • I’ve re-installed the OH frigate binding V1.8 (4.1.1 STABLE)
  • I’ve restarted Frigate server
  • I’ve completely deleted and re-installed the whole Frigate server (including all saved images/mpg’s and database and re-created the Frigate docker image)

Nothing helps, I still only see in OH the old image if I click in the OH main gui at the snapshot item. Because the Frigate does not longer contains these old images (because I’ve completely deleted and re-installed the Frigate server), I ask myself where these old images come from?

Does OH store items with type image (base64) also in it’s database (I’ve configures persistence for all items but I don’t know if this will also used for type image)?
If yes, it looks like that the Frigate OH binding does not longer provide a new image to OH or OH does not store the new image? I can’t see any error/warning in any logfile. As I’ve mentioned, in the Frigate event view, everything looks ok.

Maybe someone have an idea what’s wrong.

Btw.: I’m using InfluxDB in OH

@fmeili1 There’s a bug in v1.8 of the binding which stops snapshots being updated (along with a couple of other channels) under certain circumstances. Your issue sounds like it is related to this. I have a fix here, which I am testing at the moment and if successful I am planning to release v1.9 very shortly with this fix. If you still get the issue with v1.9 when it is released, please let me know.

1 Like

I have released v1.9 (built against openhab-addons 4.1.1 stable). This is a bugfix release (no new features) and should solve the issues with snapshot updates. Please give this a try and let me know if it fixes the issues reported.

1 Like

awesome!
Just installed it, and the first snapshot pictures are looking correct! I’ll observe for some days with all cameras and events and will let you know if the problem is solved reliable.

Thanks a lot for your fantastic support and maintaining the binding!

@jgow Thanks, with the new binding everything is working fine again so far.

Could you please publish the new actions as an example rule in DSL and perhaps also how you can actively create a snapshot using it?

Thanks for letting me know that the fixes in v1.9 seem to have solved the snapshot problem.

I can add a small example in JS rules. I don’t use DSL rules here and to be honest, I’m by no means an authority on writing DSL rules so I may have to defer to someone with a wider knowledge of the DSL syntax.

It may be a short while. I wrote the snapshot-on-demand feature on request, and at the time it was a feature of a beta version of Frigate, which I can’t run at the moment. If and when Frigate release this into the stable version I’ll add something a little more substantial to the docs. In the meantime, the docs do describe the basic sequence of using the camera Thing API.