davidusb-geek / emhass-add-on

The Home Assistant Add-on for EMHASS: Energy Management Optimization for Home Assistant
MIT License
89 stars 26 forks source link

Values published to Home Assistant do not have unique_id and cannot be managed through the UI. #91

Open HACS-bank opened 5 months ago

HACS-bank commented 5 months ago

Using core emhass version: 0.8.6

In the HA user interface, the settings dialog for e.g. sensor.p_pv_forecast can be accessed but produces the message:

_This entity ('sensor.p_pv_forecast') does not have a unique ID, therefore its settings cannot be managed from the UI. See the documentation for more detail._

This makes it harder for a user to e.g. put the EMHASS data into an "Area" in HA and put onto dashboards etc.

davidusb-geek commented 5 months ago

How come it is not unique? In any case, you can change your sensor name using the custom names functionalities (see the docs) and then you will surely have unique ID names.

purcell-lab commented 4 months ago

UniqueIDs, is a feature of the Home assistant registry for individual entries, which is supposed to be set by the creating integration, in our case this should be EMHASS.

EMHASS doesn't correctly set these uniqueIDs so I would request this issue be reopened pending further investigation.

davidusb-geek commented 4 months ago

Reopened. I just thought that this was easily solved by a user-provided unique custom ID. I don't how this can be automatically set within EMHASS. But there is maybe an option that I don't know of.

purcell-lab commented 4 months ago

unique_id can be registered at the same time as the entity creation:

https://developers.home-assistant.io/docs/entity_registry_index

_Any entity that is added to Home Assistant which specifies the unique_id attribute will be registered in the registry._

Unique ID of last resort For entities that are setup by a config entry, the Config Entry ID can be used as a last resort if no other Unique ID is available.

GeoDerp commented 4 months ago

Just an update to this. I cant seem to find any possibility of adding a unique_id via a REST call. This seems to be a issue a few people have come across, the only solution, so far, I can find is setting each sensor into the configuration.yaml before REST API POST. Please let me know if this changes.

davidusb-geek commented 4 months ago

I don't know if the POST /api/states/<entity_id> endpoint accepts the unique_id key in the JSON? It is not listed as an option on the documentation: https://developers.home-assistant.io/docs/api/rest/

GeoDerp commented 4 months ago

I don't know if the POST /api/states/<entity_id> endpoint accepts the unique_id key in the JSON? It is not listed as an option on the documentation: https://developers.home-assistant.io/docs/api/rest/

I agree, I hope this could be change in the future, or separate rest call option to generate a sensor with a unique_id first.