Hi developpers
I want to use an entity service for a custom integration that filters for supported entity features. According to the developper docs, the entitfy feature must be defined as a string in the format domain.class.attribute.
However, when I do so, I always get an error that the class or feature is not know when the integration is started.
The only way I got it to work was by specifying the interger which represents the value defined in the IntFlag class for the integration entity attributes.
However, the hassfest validation of the git repo now complains that a string must be specfied in services.yaml, which I could not get to work by lots of various combinations that I tried.
Error: R] [SERVICES] Invalid services.yaml: expected str @ data[‘get_solarbank_schedule’][‘fields’][‘entity_id’][‘selector’][‘filter’][0][‘supported_features’][0][0]. Got None
Here is the code I use now that works:
selector:
entity:
filter:
integration: anker_solix
domain: sensor
supported_features:
- 1
The class is defined in the entity.py module of the integration:
class AnkerSolixEntityFeature(IntFlag):
"""Supported features of the Anker Solix Entities."""
SOLARBANK_SCHEDULE = 1
I also tried to specify it in const.py but that does not make a difference. The AnkerSolixEntityFeature class is imported in sensor.py where the entity service is being registered:
# register the entity services
platform = entity_platform.async_get_current_platform()
platform.async_register_entity_service(
name=SERVICE_GET_SOLARBANK_SCHEDULE,
schema=SOLARBANK_ENTITY_SCHEMA,
func=SERVICE_GET_SOLARBANK_SCHEDULE,
required_features=[AnkerSolixEntityFeature.SOLARBANK_SCHEDULE],
supports_response=SupportsResponse.ONLY,
)
The big question to me is what kind of string I have to specify in services.yaml to have the feature accepted as valid entity feature?
I tried:
supported_features:
- sensor.AnkerSolixEntityFeature.SOLARBANK_SCHEDULE
and
supported_features:
- anker_solix.AnkerSolixEntityFeature.SOLARBANK_SCHEDULE
None of those formats is accepted or known when the services are being registered.
Does anybody have a clue how entity supported features must be specified to be accepted by supported_features specification in services.yaml ?