esphome / esphome/feature-requests

Allow defining and filling “user attributes” on sensors

Open
#1,635 15 comments 21 reactions 0 assignees View on GitHub
component: api component: sensor
Dominant language
No language data
Stars
450
Forks
29
PR merge metrics
No merged PRs in 30d

Description

**Describe the problem you have/What new integration you would like**

It is possible to set the value of some predefined attributes (e.g. device_class, state_class…) of a sensor in the yaml configuration file. But I believe it is not possible to define “user attributes” and to return values for such attributes programmatically.
The goal of this request is to allow for a specific sensor to return an extra property with an associated value.

**Please describe your use case for this integration and alternatives you've tried:**

Let’s take the example of the Teleinfo components. This component allows to retrieve data from a French electrical meter. For most of the information, we just need to be transmitting a value for example the instantaneous “energy value”. But for some tags we need to send back two information—for example the “maximum power of the day” has a timestamp associated that indicates when the maximum value happened. The only possibility to transmit this information currently would be to define two “related sensors”: one that send the power value and one that send the timestamp value but this is not a good solution.

What would be nice is to find a way to transmit the timestamp as a property attached to the sensor.
So in this example we would have a sensor "max power" with a property "timestamp"

**Additional context**

Contributor guide

No contributing guide indexed for this repository

Research direction

Review the sensor YAML configuration and the Teleinfo component described in the request to understand how sensor values and related timestamps are currently represented. Define what a user attribute should look like and how its value would be supplied, then verify that the proposed behavior covers the “maximum power of the day” example.

Written by the indexing model from the issue text.

Assessment

Tech stack
yaml
Domain
embedded-iot
Issue type
Feature
Difficulty
5/5
Estimated time
Over a week
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
25/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.