mariusz-ostoja-swierczynski / tech-controllers

TECH Controllers integration for Home Assistant
MIT License
97 stars 67 forks source link

Create HA entity name based on hub and zone names #61

Closed bpawulski closed 7 months ago

bpawulski commented 8 months ago

just a small improvement. How about creating HA entity names based on combination of hub name and zone name -> if hub is called "Gora" and zone is called "Łazienka" do sensor.gora_lazienka_temperature etc. In this case when i have bathroom at both floors i wouldn't have to change zone name to distinguish it in HA. Ideally this might be a config option, for people with single hub such naming might not be convenient, but i believe for the ones with multiple hubs this will be useful.

anarion80 commented 8 months ago

Ok, I'm a little torn here @bpawulski .

HA docs for entity naming state that "The entity's name property only identifies the data point represented by the entity, and should not include the name of the device or the type of the entity. (...) If the entity represents a single main feature of a device the entity should typically have its name property return None. The "main feature" of a device would for example be the LightEntity of a smart light bulb."

Granted, we don't only have devices, but also the hub, but still, to be aligned with what HA is suggesting and expecting, we should not add those additional names to devices. So for climate/thermostat entities we should really align and have the name determined only by device, as the thermostat is a main feature of the zone.:

image

image

For tiles, which don't really have a higher level entity in the Tech API to map to, we should not really have devices anymore, but just individual entities. With that we perhaps have more flexibility and can have the hub added to entity id/name:

image

Please check the latest approach here if you want: https://github.com/mariusz-ostoja-swierczynski/tech-controllers/tree/feat_61

bpawulski commented 7 months ago
Screenshot 2024-04-04 at 20 30 47 Screenshot 2024-04-04 at 20 30 57

The only thing i can see have changed is the name of outside temp sensor which accommodates the hub name. All zone names stayed the same. As well as i still have not available outside temp sensor connected to "Gora" hub.

daroga0002 commented 7 months ago

In general I think we should stick this:

"The entity's name property only identifies the data point represented by the entity, and should not 
include the name of the device or the type of the entity. (...) If the entity represents a single main 
feature of a device the entity should typically have its name property return None. The "main feature"
of a device would for example be the LightEntity of a smart light bulb."

But @bpawulski regarding your issue screens which you showing above are devices, not entities.

HA itself allow you to change device names:

image

or even entity name:

image

so I am little confused what real issue we trying to solve here?

Additionally in newest HA release you have additional features (for example labels) to organize things https://www.home-assistant.io/blog/2024/04/03/release-20244/

anarion80 commented 7 months ago

Ok, there is a compromise possible here. The latest version (please check here) is not in conflict with HA guidance, as every entity implements _attr_has_entity_name = True and we still use HA mechanism for naming including device name when appropriate.

I added an option to check when adding controllers and include hub names in entity names: image

and then if selected, we get: image image image

By default, when not enabling this option we get: image image image

Please note that:

  1. We now use HA translation placeholders for entity names so they are translated to available languages.
    1. As a result some entities are named by combining device name + entity name and we get sensor.external_temperature_temperature.
  2. Some entities are now without devices - as they should be.

(and all temperature entities now create devices, while only the ones that have battery or signal strength should - that needs to be addressed)

bpawulski commented 7 months ago

I like this approach, It works fine for me. Thanks!