Append custom data to Devices

Hello!

I’ve seen that owntracks is sending the value of battery to the mqtt broker of HA. But this value isn’t listed at the corresponding device sensor.
So, is it possible to append or customize any sensor to add custom values to it?

Thanks in advance.

If I understand correctly what you’re looking for are the device_state_attributes as seen here: https://github.com/home-assistant/home-assistant/blob/d7452f9d5d100d126d52dca3e46ae709fab8b339/homeassistant/components/sensor/demo.py#L51

Values saved in those attributes can be evaluated by using templates in automations etc…

Here’s a page in the docs that explains how to turn those attributes into sensors.

I’m using the solar_angle example on my own server as it’s easier to use the sensor value than it is to use the template in my automation configurations.

Ok the template sensor makes sense for the battery status, but I would like to go one step further.
Let me explain a little bit more:
I got a device tracking sensor which displays some data, such as coordinates and so on. Now I want to append to this existing sensor another data, such as the battery status or something else new.

Bump

It is possible to add new attributes to sensors via the web interface (http://my-ha-url:8123/dev-state):

How to do this with a custom component sensor (device_tracker)?

EDIT:
Simple solution was: Copy an device_tracker component, change it up and append all attributes to the function “async_see()”.