Identities in Home Assistant

I have a corner case maybe and wondering if there is a good way of approaching my desired output.
I want to create virtual entities, and attach attributes to them.
I am running most of my automation in Node Red.

I want to create myself a profile, so add my license plate for my car, my code for the keypad for access, etc.
Same for each of the people in my household.

So when a car is detected, a picture is captured and sent to Node Red ALPD flow I have. Once the license plate is retrieved, it will pull each of the people and compare the license plate. If it is matched, it will open the garage and send me a notification on my phone.

I have a lot of the middle part working, just need to figure out the best way to create the individuals with their profile information. It is based on a MySQL design I had.
I thought about creating them as “Devices” (yeah I know), and adding entities for each of the pieces of info like license, pictures, etc. But realized it may by totally the wrong approach and may make the whole thing a pain to maintain when I want to add access to certain areas for the cleaning lady, access to the gardener for the backyard and through the gate only, etc. You can see how it may become cumbersome.

Is there a good way in Home Assistant to do that?

add them as a person

Maybe there is a way to have a plate as device tracker but till then yiu can just change there state (home/not_home)

1 Like

This can be done a few ways actually.

If you already have each person as a “person” entity (person.some_one) then you are mostly there.

Or you can create input_text entities with the person’s name as the entyity_id.

then to create fixed custom attributes you can use the “customization” feature and create those custom attributes.

The docs don’t mention it but you can add any attribute you want.

For example:

homeassistant:
  customize:
    person.some_one:
      license_plate: 123_xyz
      keycode: 123456
    input_text.some_one_else:
      license_plate: 456_rst
      keycode: 56789

Thanks. I will try that this weekend. Did not know about the customization feature.

ok, I got it done, but how do I access the attributes?
Trying to access them in YAML or in NodeRed. When I run a test flow in NodeRed, I get the core attributes.
This is my test flow:
image
The output is only latitude, longitude, gps_accuracy, source being my phone, etc. No actual attributes from customize.

Is there something I need to do, or are they tagger differently?
Even in YAML, if I want to create an automation, how do I get access to the license plate or pin in this case?
Thanks in advance.

I have no idea how to do it in NR.

As far as HA itself t depends on how you are trying to utilize the attribute.

if it’s in a trigger:

trigger:
    - platform: state
      entity_id: person.some_one:
      attribute: license_plate
      to: something

if it’s a template:

{{ states_attr('person.some_one', 'license_plate') }}

without knowing what “get access to” means it’s hard to give more specific advice.

Sorry for not being clear. What I meant by access to is based on the message in node red received, this is the content.
You see the attributes which are tied to the person.haz in my case. But the custom attributes do not show up. This output is from the debug node from my flow above.
Once I get the attributes pulled into Node Red, I can then access them using other nodes to run my logic and automation. I do all my automations in Node Red.

I never use node red so I can’t help further with that specifically.

do the custom attributes show up in HA under the attributes column of dev tools->states for the entity?

did you restart HA after you added the custom attributes?

doh!
Nope they do not. I did restart it but I just checked the Dev tools -->states and I do not see them.

I will debug using HA now then move to Node Red

@finity, thanks for the help. That was it. I could not see them in the dev tab, so it turned out to be a spacing issue in my customize code.
Once that was fixed, all worked as planned.

Now I see what I am expecting in Node Red! and in HA

1 Like