Hi,
I’m trying to think how I can capture this mqtt ‘BlueIris/admin’ =‘camera=drive&motion0’
motion0 for off and motion1 for on, and create a binary sensor in HA showing the state of the motion sensor of each cam. Not the trigger but just if the motion state is on or off.
Should be a fairly simple sensor but just head scratching.
Any suggestions? Thanks
You can’t. I mean you can in your example but you can’t because that’s not how that topic works in Blue Iris.
The MQTT topic BlueIris/admin
is how you tell BlueIris to do something. The values accepted there match Blue Iris’s HTTP API. So like if you want to tell it to turn motion on or off on a particular camera you send camera=<camera>&motion=<0|1>
to that topic. And if you want to tell Blue Iris to change the profile being used you send profile=<0-7>&lock=<0|1|2>
to that same topic. Snapshot a camera? camera=<camera>&snapshot
. Rebuild the DB? db=rebuild
. Etc.
So it’s not really something you can make a sensor out of for two reasons:
- The value varies wildly. If you try and parse the camera and motion out of it you’ll fail when it has nothing to do with setting motion on a camera
- It’s not maintained by Blue Iris. On startup it will not update that topic letting you know if motion is active or inactive on a particular camera. Nor will it update it if motion becomes active or inactive on a particular camera either through schedule, profile or manual change.
However what you can parse is that topic above it, BlueIris/status
. That is maintained by Blue Iris and will update anytime the profile changes. So instead of manually changing motion on or off on a particular camera like you’re doing now what I would suggest you do instead is configure profiles in Blue Iris. You could make a “motion on” and “motion off” profile that turns motion detection on or off in particular cameras. Then you can make an MQTT select entity like this:
mqtt:
select:
- availability:
- topic: blueiris/app
value_template: "{{ 'offline' if 'stop' in value else 'online' }}"
entity_category: diagnostic
name: Blue Iris profile
state_topic: blueiris/status
value_template: >-
{% set value = value.split('\n')[1][-1] | int %}
{% set value_map = ["Inactive", "Motion on", "Motion off", "3", "4", "5", "6", "7" %}
{{ value_map[value] }}
icon: mdi:camera-account
command_topic: blueiris/admin
command_template: >-
{% set value_map = ["Inactive", "Motion on", "Motion off", "3", "4", "5", "6", "7" %}
profile={{ value_map.index(value) }}&lock=2
options:
- Inactive
- Motion on
- Motion off
- "3"
- "4"
- "5"
- "6"
- "7"
That’s what I do. Then its easy to change the profile form HA and know what the current profile is. You can also do something similar with “schedule” and “signal” if you want. “Signal” for reference is the lock icon in the Blue Iris app: 0 = “Disarmed” (red), 1 = “Armed” (green), 2 = “Arming” (yellow).
1 Like
Thanks for the info
I also have various switches set up in HA to switch profiles, plus numerous nodered flows for the mqtt flows and ones that control the night day times with sun cron schedules etc.
Just that final piece missing I wanted to show an actual binary sensor icon there, as on the odd occasion I use a switch to send mqtt to BI to switch on motion for a specific camera. e.g. my wife has all the washing out in the back and I just want motion on for the front or drive. I have switches in HA to send the mqtt via nodered but wanted a visual icon like we have for connectivity or app status. I guess not.
I have mainly 3 profiles, home, day and night. I can overide them at any time from my phone or HA. They are also only applicable to specific cameras on BI.
I’ll certainly have a look at your entity in more detail and see if I can get some use out of it or improve my setup.
Many thanks!
Ah ok. Well in that case what you could do I suppose is simply make a binary sensor yourself from NR called something like Drive camera motion
. Anytime your NR flows decide that motion should change from on to off or vice versa set the sensor. And then have another flow that periodically sends camera=drive&motion=<value of binary_sensor.drive_camera_motion>
to BlueIris/admin
on a regular schedule (like maybe every couple minutes).
That way you can be pretty certain your sensor is an accurate reflection of whether motion detection is actually on or off for that camera in Blue Iris. And if its inaccurate then it will only be inaccurate for a couple minutes max (or whatever you set the polling schedule to).
It’s not ideal but to my knowledge there is no way to get Blue Iris to post the state of motion detection on camera to an MQTT topic when it changes. You can get Blue Iris to post whether the camera is online or not to use as an availability sensor in the watchdog options but that’s about it.