Disable camera from Blue Iris using API

Hi guys,

I was wondering if it is possible to disable / enable a camera using Lovelace card? I have the blue iris integration and it works great (sometimes a bit lag but I’m still happy).
I want to be able to turn of the some indoor cameras on demand with a button that basically sends the call to the API. Did someone get the chance to do something similar? Or I’m open to new ideas as well.

Thanks!
Didi

Hi Didi,

Can you control the power to these cameras via a smart switch or are they always on POE cameras?

You could look into controlling any wifi cameras via smart switch based on person presence or alarm control etc. Or if they are always on cameras you can publish a mqtt payload to BI to enable or disable a camera.

This is what i found worked for me when i was looking into this.
topic: BlueIris/admin
payload examples:

  • enable a camera: camera=&enable=1
  • disable a camera: camera=&enable=0
  • change profile: profile=4

Hope this helps.
Cheers
Nick

Hi Nick,

Thanks for the quick response!
Yes, I forgot to mention that they are poe cameras and connected to my ubiquiti poe switch.
So I was thinking into digging this option in the switch, but I wanted something that will be within the home assistant dashboard (in a view).
The mqtt option sounds interesting and might be perfect.
how do I apply it for a button via Lovelace card?
Im pretty new to HA.

Many thanks!
Didi

Hi Didi,

So this is just one way to achieve this. It’s what i have setup in my environment.

  1. Create a script similar to the following…
alias: 'cctv: DISable camera family_room'
sequence:
  - service: mqtt.publish
    data:
      topic: BlueIris/admin
      payload: camera=family_room&enable=0
      qos: '1'
mode: single

Just replace family_room with the short name for your camera.

  1. Make a duplicate of this script for enabling the camera again. The only technical difference will be for the ‘payload:’ value. Just replace 0 with 1. So it becomes “camera=family_room&enable=1”.

  2. In your Lovelace UI, add some kind of card to your preference. Such as button or entity etc. Several card types allow you to ‘call a service’ for a ‘click’, ‘long click’ or ‘double click’ of the card button, but in this following example i’m simply adding two separate entity cards where the entity attached to each card are the scripts you just created…

type: entity
entity: script.cctv_enable_camera_family_room
attribute: last_triggered
name: Enable Family Room Camera

type: entity
entity: script.cctv_disable_camera_family_room
attribute: last_triggered
name: Disable Family Room Camera

Hope this makes things clearer.

Nick

Hi Nick,

It works great! thank you so much!
I had to create the scripts using the GUI (I guess I was missing something through the yaml file).
If I may, I want to challenge this a bit :slight_smile:
Would it be possible to toggle the script depending on the status of the camera (or previous action). so if the camera is disabled, the next run would enable it and visa versa? (and then I could just have a toggle button or something like that).
one last question and I think we can close this topid, is it possible to have the web GUI URL into a view? I’ve noticed that the BI web GUI is super responsive and loads much much faster than the individual cameras through the BI integration within HA. so to have a card or some other way to display all the cameras through the URL and then the buttons on the bottom of the view.
As you can see in the screenshot below, some cameras doesn’t even load (maybe after a minute or too).

Regards,
Didi

Hey Didi,

As far as a toggle option is concerned, that all depends on how integrated you want it to be with BI itself.

Reading between the lines a bit it seems you want to know about the current BI camera status inside HA. If that were done then you could create an automation that runs the appropriate enable/disable script.

However, so far i have not found a way to always confidently know the actual camera status from HA’s point of view. Inside BI, per camera, there is the ‘Watchdog’ tab that allow for monitoring if the camera loses connection. On loss of connection or restoration of connection you can run some alert, like publishing a custom MQTT topic. This topic can then be monitored by HA via an MQTT switch or MQTT trigger to take some action. This is what i do today for my two “sometimes powered on” wifi cameras.

Unfortunately the Watchdog feature in BI does not seem to detect if a camera is Disabled. It only seems to work if the camera is not sending any signal (powered off). Currently i dont know any way to retrieve the status of enabled or disabled.

So, what options do you have? In HA you could create an input_boolean for each camera you want to work with. Then modify those scripts to turn the boolean on or off depending on which script you run. Problem is that the boolean would not be syncronised with the actual BI camera status. Hence the ‘confidently’ comment from earlier.

Since you are using the HACS BI integration, maybe the developer of that solution has some additional ideas.

As for your second question about displaying BI cameras directly in Lovelace, other than the way it’s being done now. I have some thoughts but no final solution. The issue i have found so far is that if i simply embed the bi ui3 url somewhere in view or card then, the site does not load. Even if using ui3 anonymous connection. I have been thinking about this topic myself & have not yet settled on a final solution but here are a couple of ideas to get you started.

Idea1:

Create a new view & on the settings tab enable ‘Panel Mode’.


Add Webpage card to that new view.

For you card you could add the all cameras index stream using this url. http://yourserver:port/mjpg/index

This option works for me. However, its just the index stream & you can’t drill to a specific camera like this. It’s not ideal & probably not something i will use, other than for testing.

Idea2:

Add a button card to any view like this image.
image
When you click that button the BI UI3 page will load.

Cheers
Nick

Hi Nick,

Thanks so much for your time and effort with this detailed response. I will test it out and see how it goes.
Another option I was thinking about is maybe just to disable the switch port on my switch. I saw that there are some API projects out there to help with that, but not sure how stable and how much effort it would take to achieve this, but I’ll try to find the time on the next few weekends.

Regards,
Didi

Thanks for this thread. I actually figured out a way to determine whether the camera is enabled/disabled using the BlueIris custom component. One of the attributes of the camera entity is Is_Online. It’s false when the camera is disabled and true when it’s working. I used the below template switch to create a toggle switch that will update/reflect the status of the camera.

  - platform: template
    switches:
      basement_camera_toggle:
        friendly_name: "BlueIris Basement Camera"
        value_template: "{{ state_attr('camera.blueiris_basement', 'Is Online') == true}}"
        turn_on:
          service: mqtt.publish
          data:
            topic: BlueIris/admin
            payload: camera=basement&enable=1
        turn_off:
          service: mqtt.publish
          data:
            topic: BlueIris/admin
            payload: camera=basement&enable=0
        icon_template: mdi:cctv
1 Like

Just wanted to say thanks this is working great