Pushing data from HA to a macro in Blue Iris

There’s been a couple posts about Blue Iris and leveraging macros, but I struggled to get this to work properly. While I really want Blue Iris to read an MQTT string as a macro, it doesn’t allow you to do this natively within Blue Iris, as you can only publish to MQTT. In the past I had mosquitto_sub in a scheduled task to write to a text file to have the macro read that file, but this can get pretty messy.

A much simpler way is by using a rest_command.

Within configuration.yaml:

rest_command:
  blue_iris_macro:
    url: http://camera-server.home/admin?macro={{ macro }}&text={{ text | urlencode }}

Then you can call it from a service to use in automations, and use a template from a sensor:

service: rest_command.blue_iris_macro
data:
  macro: 3
  text: "{{ states('sensor.test_sensor') }}"

Hopefully this helps out someone else in the future!

Original references:

Would it be possible for you to give another example of this? I am trying to make this work but having no success

Post what you’ve tried and what isn’t working and I’ll see if I can try to help you out.

rest_command:
  blue_iris_macro:
    url: http://192.168.0.100:81/admin?macro={{ macro }}&text={{ text | urlencode }}

then automation

service: rest_command.blue_iris_macro
data:
  macro: 21
  text: "{{ states('sensor.my_daily_change') }}"

I inserted %21 in overlay in BI image, but nothing ever comes from sensor.
Maybe it’s something onm the BI side, but i am not sure where to look. thanks

It’s probably something on the BI side. Take the HA rest sensor out of the mix for a minute. Access the terminal of your HA instance, and do this:

curl "http://192.168.0.100:81/admin?macro=1&text=foo"

Once you do that, look in BI under the macros tab, and make sure that macro 1 has the text of foo. While you can do macros >9, it will only show macros 1-9 in the BlueIris Settings UI.

It’s possible that you need to authorize the HA server to be able to write the macro to BlueIris. Within BI, go to Settings > Web Server > Advanced, and mess with some settings here. At a minimum, you’ll want the IP of your Home Assistant server bypassed with a ^ under the “Limit by IP Address” section, so for example ^192.168.10.10. It has to be an IP address, hostname will not work here. The ^ essentially bypasses auth for the host you specify, but you can find more details about that in the BI help.

If I’m remembering this correctly, if you have the option of “use secure session keys and login page” checked, this won’t work properly.

well that helps, it is something to do with the proxmox server i think, I can talk to it when I put the server i address in with ^192.168.0.107 but I still can’t pass anything thru HA

For anyone finding this, I went with mqtt and it was super simple at least for my setup. example action in automation for macro 21

service: mqtt.publish
data:
  qos: 0
  retain: false
  topic: BlueIris/admin
  payload: macro=21&text={{ states('sensor.my_daily_change') }}

Nice - that’s a WAY better solution than what I had been using with the rest sensor. I wasn’t aware that BlueIris could subscribe to a topic like that!