Is esphome possible to expose entities to ha with attributes?

As we all know, most entities in HA has 1 or more attributes along with the main state, but esphome expose everything separately, and thus introduced too many entities. Is it possible to expose attributes together with the main states?

2 Likes

I don’t think that feature exists in the ESPHome API.

The only reference I can find to attributes is importing them from Home Assistant as sensors in ESPHome.

I thought I saw that attributes might be coming to esphome. I can’t remember where I think I saw it.

But really, why does it concern you how many entities you have?

Typical example is door locks, it could have dozens of data items, most of them shouldn’t be a individual entity in HA, or attributes is a better choice.

Yet all the time we have people asking how to display attributes in lovelace. Hard to please everyone I guess.

emmmm, I think most ha entities could have some attributes, i.e. a sensor with the main state of temperature and an attribute of battery level, a plug with the main state of switch and an attribute of power load. For esphome, the mainly usages is bundled to ha, I guess it will also.

I agree attributes are great, and much easier to access in templates these days. Although in your example, what about a sensor that does temperature, battery AND humidity. Should there be a temp entity and a humidity entity? Buggered if I know.

I found what I was thinking of earlier in the thread - the esphome homeassistant sensor can now import attributes from HA, but that is kind of the converse of what you are after, Home Assistant Sensor — ESPHome

I’m of the opinion that if it measures something important then it should be its own sensor. Attributes should be used for ancillary data that you would not typically display in the frontend but might occasionally have a need to know, like a MAC address. It comes down to a judgement call.

yes, there are 2 directions: pull an attribute of a ha entity as an esphome sensor, and expose an entity to ha with attributes from esphome.

sure, the feature of “Home Assistant Sensor - ESPHome” is appreciated, but I am talking about another direction, which seems not available till now.

Well of course some esp integrations do create attributes, eg my lightbulb has

supported_color_modes:
  - hs
  - rgbw
friendly_name: foyerlight1
supported_features: 185

But there does not seems any way to create your own attributes.

Thanks for your comments, I’ll investigate on the source code later.

Hello,
I am also looking to create an entity with an attached attribute for the battery status. The goal is to send the sensor to Apple HomeKit via Home Assistant. However, on Apple HomeKit, if the battery level is not attached to a device as an attribute, it simply does not appear.
Has anyone found a solution to do this in ESP Home or by creating a dummy sensor directly in Home Assistant?

Create a template sensor. Template - Home Assistant