Suggestion: Entity customization with notification to the entity class?

Hi all.
I’d find very useful to let user setting a custom attribute to an entity, save, and get the entity class receiving that attribute.
This can be useful to let the integration send a configuration to a device.
For example, if a hardware module (connected to a bus or wireless) has a port (GPIO) that can be configured as analog or digital input,

  1. the user should set a custom attribute “config” with value “analog”
  2. the integration class received a notification about the attribute “config” changing and
  3. the integration class will send a command to the hardware device so that input port will be configured from digital to analog.
    This is just an example.
    Actually, if I’m not wrong, the entity class (step 2) is not notified about any configuration made through the configuration → customization menu: am I right?
    Is there any other way to achieve this function?
    Maybe this solution can be useful for many integrations…

For example, in Domoticz every entity has a name and a description: description can be used by the user to store some info (where that switch is placed, or what hardware is used) and also to specify a list of commands that can be used by the Domoticz integration to configure that hardware properly.

immagine

Ok, Domoticz UI is quite terrible and not comparable with HA, but the additional “Description” field is very useful.
In this example we have a module with some GPIOs, this GPIO is configured as input, counter, type kWh (in this case it counts the power/energy imported from grid), and the device with ID=99 is the counter that counts in the opposite direction (export power/energy).
When you click on Save button, the integration is notified about the configuration change.
As you can see, the user have the ability to use a simple text field to configure the hardware device very easily.

I’m asking if there is a solution in HA to let user send configuration to their devices.
Thanks.
Paolo

Isn’t that exactly what config_flow is for?
Are your entities configured via configuration.yaml? Then you could just add a field for it to the Schema if you want to stick to yaml.

Afaik this is only for cosmetic / frontend concerns. Eg. icons, device_class etc.
See Customizing entities - Home Assistant

Hi @farmio, thanks for the reply.
I already use config flow to configure a parameter (serial device) when integration is added.
What do you mean exactly?

  1. while adding an integration, to add a management to configure all devices connected? (this is very bad, because devices should be configurable anytime)
  2. to add a “Configure” button to the integration card, that permits to open a dialog box to select and configure one or more entities? (this can be an acceptable solution)
  3. to have a “Configure” button on any entity, so it’s possible to select entity even from dashboard and configure it? (this will be perfect)?

In case the right answer is 3 or 2, please can you tell me the name or 1 or more integrations that have this feature, so I can check them?
Unfortunally in the dev docs I can only see information about how to use config flow while adding an integration.
Thanks a lot.
Paolo

I have not implemented a config_flow myself yet, but I think you can start a flow on discovery of a device/entity.

Not really sure though.

It sounds a little bit like your integration would be a better fit for yaml configuration. But I’d check with core developers if this is even allowed nowadays.

1 Like

I think this is a general gap. I’d classify it as the ability to perform dynamic configuration on the system. My current view, and I’m happy to be corrected if wrong, is that the system is designed around a config change / reload model. I think what you are aiming for is having the config be more like a live entity in the system, such that changes to the config can be listened for on the event bus?

Yes, you’ve hit the problem.
I think it would be convenient to be able to click on an entity, and immediately change its configuration without having to select the integration tab, click on Configure, select the entity from a list (that in my house will be 200 entities long), etc.
Regards. Paolo