HA Control for a first responder family

Hi all.

tl;dr - I’d like to know if I am solving the proper XY problem regarding first responder-based home automations so I am being loquacious to capture all variables of an obscure situation

I have implemented a (I’ll use the generic term “process” here so as not to actually name it something that it is not) process to assist my family of first responders.

Background

My daughter and I are volunteer firefighters for the fire department for our town. I’ll refer to it as Anytown Fire.

My wife is a volunteer for the first aid squad in our town. I’ll refer to it as Anytown First Aid Squad.

A (few) word(s) about availability/staffing in the context of a first responder agency

Volunteer first response agencies have various methods to satisfy their coverage needs for the service they provide. It boils down to determining the pool of personnel available to respond. It can be thought of as being On Duty or Off Duty.

In its common interpretation, On Duty usually connotes a first responder in an appropriate uniform at a first response building and/or in a first response vehicle. For example, an on duty police officer is thought of as being in his uniform, in his car, driving around the municipality immediately available to provide assistance.

However, in the volunteer fire and first aid squad contexts of the United States, that term means a slightly different, more inclusive term. (Fun fact: About 80% of the fire protection in the US is covered by volunteers.)

Take, for example, myself. Until a request for service comes in, I live my life just like everyone else. I may be at home, or at the barber shop getting a haircut, out front cutting the lawn or far away on vacation. As to my fire department availability, however, I am “On Duty” whenever I feel I am available to respond. And, that can change from minute to minute depending on my personal life’s situation. (Like, on a Friday night enjoying some libations with friends. I’m not going to be responding in that situation.)

The Anytown Fire Department has about 1-2 calls per week. Due to this low volume of calls and the large pool of responders alerted to every call (for every fire call in this agency, all members are always requested to respond), there is no real reason to have a monitored availability status. My daughter and I essentially go On Duty and Off Duty as mentioned above. And, we don’t need to keep anyone updated to that. If we can’t make a certain response, it’s not a big deal as there are many other responders available to handle the call.

Contrast that call volume with the Anytown First Aid Squad, which averages 5 calls per day. No one expects anyone to respond to 35 calls per week for a volunteer organization. That would be a ludicrous amount of time to volunteer. It would leave no time to have a personal life. However, every call must be covered. Therefore, it is important to plan out the staffing commitments.

To do that, the Anytown First Aid Squad implements a schedule of duty periods which need to be covered by designated crews. These designated crews are referred to as Duty Crews. Duty Crews are scheduled for various time periods of typically 12 hours (ie, Saturday night at 6PM until Sunday morning at 6AM). The Duty Crews handle the majority of the responses during their duty period. Calls that are to be handled by the Duty Crews would be dispatched as Duty Calls. In this case, the term “On Duty” aligns with the traditional sense of the term. If a member is “On Duty”, they are covering calls for service during their designated duty period and are likely at the station or already in the apparatus.

My wife is a member of the Tuesdays from 6:00 PM - 6:00 AM Duty Crew. This is the time period should would be traditionally thought of as On Duty.

However, there are instances when the Duty Crew is insufficient to handle the situation. It could be that the duty crew is already handling a response and a second request for service comes in. Or, it could be a large scale incident, such as a bus accident with multiple patients. Under these circumstances, a dispatch is transmitted to all members who are not currently on duty to come in and cover that second call. These members’ statuses can be compared to the Fire Department members. They are excess manpower who may or may not be available at any given time. But, due to the pool of availability, some off duty members will be available and respond. And, like the Fire Department, it is not necessary to strictly monitor these personnel due to the size of the membership pool.

When it is NOT my wife’s designated Duty period (anytime other than Tuesdays from 6P-6A), she MAY listen for and respond to the surplus manpower requests. During these non-designated periods, my wife can be thought of having the same availability status as I do ALL the time for the fire department.

So, the Anytown First Aid Squad has both traditionally On Duty personnel as well as On Duty When Available In Your Personal Life personnel.

So, how do the responders know the occurence and type of call?

The actual alerting process for these agencies (as well as many first responder agencies in the US) is via a radio system with various sequences of tones transmitted over the airwaves. (Information for those who are still with me and are curious about this alerting method can find a Wikipedia article here.) An agency can have multiple “tonepairs” associated with their agency for various scenarios. For example, the Anytone First Aid Squad has two tonepairs. One is for requesting a response from the Duty Crew (the DutyCrew tonepairs) and one is for the surplus manpower request (the AllCall tonepairs).

Having said all of that, there are essentially three tonepairs that are involved in alerting my wife, myself, my daughter and HA that there is a request for an emergency response, or what we’d refer to it as a Call. (No, we do NOT rely on HA to tell us that there IS a Call. We carry radio pagers and/or our mobile phones for the actual notifications. This process I’m detailing is how to have HA set up the house to facilitate the human process of responding to the Call.)

These three tonepairs are:

  • Anytown First Aid Squad Duty Crew tonepair (“DutyCrew”)
  • Anytown First Aid Squad surplus manpower tonepair (“AllCall”)
  • Anytown Fire Department firecall (only one. It’s used for every request for service) (“AnytownFire”)

So, what does OnDuty have to do with the automation? Well, Tuesday nights, the house needs to turn on lights and open the garage door to help my wife safely respond for the DutyCrew tonepair. However, ALL of the other nights, since it is NOT her duty period, we want to sleep soundly. We do NOT want the lights coming on when neither of us have any intention of responding to a DutyCrew tonepair alert. So, we need a way to signal to the house to ONLY control things for the DutyCrew tonepair when it is a Tuesday night. Essentially, a way to indicate whether or not Alice is On Duty.

You might think this is a case for a calendar-based constraint. But, wait! There’s More!

Since I am essentially on duty all of the time, ANYTIME there is a AnytownFire tonepair alert, HA should control the house, even if it is a Wednesday night at 2AM when my wife and I would prefer to sleep.

But, let’s say that I am injured and have to refrain from responding to fire department for calls. Again, Alice and I would like to NOT have the lights turn on in the middle of a Wednesday night for nothing. So, I’d like to be able to control my On Duty status for the Fire Department, for those rare instances where it would be useful.

Same thing goes for my daughter’s On Duty status for the Fire Department. There may be times she does not intend to respond to a call and will toggle her On Duty status off.

Likewise, Alice could control her On Duty status for the AllCall tonepair as she sees fit. If she wants to sleep the night through, she toggles AllCall tonepair off. If she’s willing to get up in the middle of the night for a surplus request, she can toggle the AllCall tonepair on.

My examples focus on overnight periods, but that just the easiest way to convey the impact that unfettered device control could have on a family.

Now, onto the details of the design and operation I’ve implemented.

When ANY of the Calls are transmitted over the radio, I have Home Assistant doing the following (high level):

  • Determine if any responders for “this” Call are home
  • For the responders who ARE home for “this” call, do they WANT the house to be controlled (Are they OnDuty?)
  • Capture the pre-Call state of the things that are about to be controlled
  • If it’s closed, open the garage door
  • If it is dark, turn on various lights
  • Wait for 5 minutes
  • Restore the garage door and the lights to their pre-Call state

Why do I capture the pre-Call state?
A Call may come in while we’re having a party. If we’re having a party, guests have likely intentionally turned on or off some lights. So, I’m trying to be considerate of the pre-Call condition of things and restore them for the benefit of the people remaining at the house.

If you’re still with me, you deserve an award. Thank you, kindly.

How have I done this?
Well, I’m glad you asked!

Configuration
I’ve created three groups, one for each Call heard by the radio system.

  • Duty Responders (group.duty_responders)
  • AllCall Responders (group.allcall_responders)
  • AnytownFire Responders (group.anytownfire_responders)

I’ve populated each group appropriately with the person entities

  • person.bob
  • person.alice
  • person.darlingdaughter

I’ve created one Dropdown Helper, input_select.response_mode, with the following options:

  • Duty
  • AllCall
  • AnytownFire
  • Available

I’ve created Toggle Helpers, one for each person entity for each Call appropriate to them:

  • input_boolean.alice_duty_onduty
  • input_boolean.alice_allcall_onduty
  • input_boolean.bob_anytownfire_onduty
  • input_boolean.darlingdaughter_anytownfire_onduty

The tonepair identification part is handled outside of Home Assistant. It’s a service paid for by the agencies. Part of that service is the ability to fire off a webhook for identified tonepairs. So, when the radio system hears an alert, a curl call is made to a NodeRed flow I’ve created with the name of the Call (“Duty”, “AllCall” or “AnytownFire”) as a parameter.

The flow first does some safety and prep work (sanitizes args, converts the Call name to lowercase, etc).

It then checks to see if this flow is already running by obtaining the value of input_select.response_mode. (If there is a large fire in Anytown, both Anytown Fire AND Anytown First Aid Squad would be dispatched. So, the Call for the First Aid Squad would likely come to the flow while the flow is handling the Fire Call.) (See below for how it determines if the flow is already running).

If the flow thinks it IS running, it checks to see if it is a sane running time. It might be that the flow was interrupted and the (set below) input_select.response_mode entity was never restored to “Available”. If it is sanely running, the flow stops.

If it is NOT running or running insanely (lol, I think I’m insane sometimes), the flow then uses a “Get Entites” node to determine the responders applicable to this Call using group.*tonepair*_responders group as the source of the data. It outputs the responders to an array. Note that due to the design on the radio side, Calls come to the flow that have nothing to do with our family as the radio system is shared by other towns. So, SmithtownFire Calls can and do come to the flow, but result in an empty array as there is not a group.*smithtownfire*_responders. If the flow gets an empty array, it ends.

The flow does a Split on the array to check info for each responder.

For each returned responder, it checks if they are home.

If they are home, the flow does a jsonata expression to determine which input_boolean.*responder*_*call*_onduty helper is appropriate.

Once the flow knows which helper to use (ie, input_boolean.bob_anytownfire_onduty), it uses that to create a new variable in the message (msg.vars.responder_available).

If then joins the flow.

If msg.vars.responder_available is true (effectively meaning that at least one responder is home and on duty), it starts the controlling the house steps.

The first thing the flow does when controlling the house is to adjust the input_select.response_mode helper to contain the Call name (ie. AnytownFire). As referenced above, this is the criteria used back in the beginning of the flow to determine if the house is already being controlled.

The flow then captures the current state of the devices to be controlled.

It then controls the devices appropriately (open the garage door, turn on lights low (cuz in the middle of the night from a dead sleep, you need low lights)),

It then waits a hard-coded 300 seconds.

It then restores the devices to their pre-Call condition.

It then reverts the input_select.response_mode helper to “Available”.

So, that’s it.

WHY did I write all of this?

Basically, the XY thing. I was trying to solve a big scope thing and implemented it this way, with all of its nuances. However, there is probably a TON of better handling to be done, so I thought I’d throw it all out here.

I feel like the onduty helpers are kludgy and could be done better. It’s going to get unwieldy if the agencies should ever add additional tonepair types (like, a call for Chief officers and a call for Structure fires, etc… It’d be a LOT of booleans to manage.

I’d LOVE to have persons have additional attributes (from my searches, it looks like it’s not yet a feature of HA). ie,

person.alice.calls{
   "duty": {"unavailable"},
   "allcall": {"available"}
},
person.bob.calls{
   "anytownfire": {"available"},
   "somefuturecall": {"unavailable"}
},
person.darling_daughter.calls{
   "anytownfire": {"unavailable"}
}

(Forgive my potentially improper formatting of the above. I’m not strong with json)

I could then get rid of the groups entirely.

Maybe the input_select.response_mode helper is weird? It’s probably not the best way to monitor for the status of the flow. BUT, I do like the fact that it also works as a status indicator of sorts. Kinda like, why did the lights just dim? Oh, lookee here on the dashboard, “Response Mode” is showing “AnytownFire”! That’s why.

It would be cool to monitor for departures of all responders and do the cleanup work immediately, without the wait. For example, my daughter and I are usually out of the garage by the 90 second mark, and HA marks us as “not_home” at the 120 second mark. So, start cleanup once we’ve left, rather than waiting the remaining 180 seconds.

1 Like

Hell they do round here, otherwise callouts wouldn’t get answered on Fridays.

1 Like

See my post here as this was an inspiration.