Request: Give the ability to add attributes to "People" entities

The way I’m imagining this working is in the /config/person menu, you can click to edit a person and it brings up the normal menu it already does, but there’s another tab where you can specify templates to act as attributes for the person.

Being able to combine all these sensors from other integrations to my person would make me very happy :smiley:

This is exactly what I need. Have you found any solution to this?
I’m trying to add MS Teams status to 50+ Persons in our Home Assistant.

2 Likes

You can add custom attributs to person by adding them in configuration.yaml
Example:

default_config:

homeassistant:
  customize:
    person.me:
      - my_attribute: myvalue
      - my_second_attribute: 
        - mysecondvalue_one
        - mysecondvalue_two

That only allows for static attributes though, right? Not other sensors?

What I want as an attribute is their statuses across various other integrations. So like I’d want something like…

homeassistant:
  customize:
    person.me:
      - key_location: [the state of the device_tracker.my_keys]
      - xbox_status: [the state of my sesor.me_xbox_status]

That way I can just drop a person card on my lovelace, click into it, and easily see all the different values that are important to me about that person.

I’m working on something that whould show someone “gaming status” (Steam and Xbox).
And I have to do many things into the javascript card code to parse and merge different sensors data.

I’d love to be able to link sensors to persons, it would make my work a lot easier. Like being able to template the value of an attribute on a person :star_struck:

1 Like

any news on this? i want to save the access point the device is connected to in the person entity.
like this:

1 Like

I would also like this ability, adding things like:
Work_Status: Standard/Vacation/On-Call
Home_Status: Resident/Guest/Privileged_Guest/Overnight_Guest
Voice_Status: LiveMic/Muted/Offline
These attributes could be templated or just changed via an API/Service call.

Would be nice for some automations, information displays and for usage within messaging services. Some of this could be worked through by adding some things to the new calendar, but some of it would be difficult.

Next solution is valid for me: example adding nfc_card attribute to person domain.

Inside configuration.yaml

# Adding attributes to persons
homeassistant:
  customize_domain:
    person:
      nfc_card: ""
# Load python scripts
python_script:

Create: python_scripts/set_cards.py

#---------------------------------
# Set nfc_card attribute to person
#---------------------------------
inputEntity = 'person.fquinto'
inputStateObject = hass.states.get(inputEntity)
inputState = inputStateObject.state
inputAttributesObject = inputStateObject.attributes.copy()
inputAttributesObject['nfc_card'] = '12345678'
hass.states.set(inputEntity, inputState, inputAttributesObject)

Or another script like this: How to manually set state/value of sensor? - #3 by rodpayne

References

Be advised that using hass.states.set to set an entity’s state or attributes property is temporary and only lasts until Home Assistant is restarted.

do you have a better option? I appreciate the advise so everyone can reset the state via automation, but is there something you know about how to do this better?

A better option to do what exactly?

It’s advice with a significant drawback; the value that’s set is temporary.

Generally speaking, a sensor entity in Home Assistant is read-only. That’s why there’s typically no service call to set a sensor’s state. The sensor’s underlying integration has exclusive control of the sensor’s value.

If you need a sensor entity whose state value you can set permanently (i.e. the value survives a restart), consider using a Trigger-based Template Sensor. The Template integration gives you complete control over the behavior of a Template entity.

1 Like

One solution that I starting using for this was helpers, and then on-boot automation to write the appropriate data over to the person entity. This worked well when I had only a couple people and a couple attributes, but it’s ballooned way out of control, and is completely unmanageable.

For the past few years, I’ve been trying to come up with an effective way to manage people better in Home Assistant, and over that time, I’ve come across multiple half-measures, but nothing very solid to say the least.

My new in-development approach is to use AppDaemon and a couple helper text fields. All the attributes are stored in a custom sensor entity (person_attribute.store), and on start, AD applies those attributes to the people. To edit the attributes, I use the helpers to select Person Entity, Attribute name, and value, and then AppDaemon grabs those values and applies them to the person and the attribute store.

I’m about halfway done with writing it all up, so hopefully it works.

Instead, if Home Assistant would just make this easier for me, I’d like it so much better!

2 Likes