Add missing service icon documentation (#2048)

Co-authored-by: Joost Lekkerkerker <joostlek@outlook.com>
This commit is contained in:
Franck Nijhof 2024-01-20 14:05:38 +01:00 committed by GitHub
parent af26c20de5
commit c1a8a111bb
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 34 additions and 0 deletions

View File

@ -34,4 +34,20 @@ Icon translations also support translating entity attribute states.
[Read more about icon translations in our documentation](/docs/core/entity#icons).
## Service icons
This change is backward-compatible. The existing `icon` property of entities will continue to work as it did before. However, we recommend the use of the icon translation over the `icon` property.
Additionally, services provided by integrations now also support icons and can be provided in the same icon translations file. These icons are used in the Home Assistant UI when displaying the service in places like the automation and script editors. The following example shows how to provide icons for the `light.turn_on` and `light.turn_off` services:
```json
{
"service": {
"turn_on": "mdi:lightbulb-on",
"turn_off": "mdi:lightbulb-off"
}
}
```
[Read more about service icons in our documentation](/docs/dev_101_services#icons).

View File

@ -169,6 +169,24 @@ This is a partial example of a field which is only shown if at least one selecte
- light.ColorMode.HS
```
## Icons
Services can also have icons. These icons are used in the Home Assistant UI when displaying the service in places like the automation and script editors.
The icon to use for each service can be defined in the `icons.json` translation file in the integration folder, under the `service` key. The key should be the service name, and the value should be the icon to use.
The following example, shows how to provide icons for the `turn_on` and `turn_off` services of an integration:
```json
{
"service": {
"turn_on": "mdi:lightbulb-on",
"turn_off": "mdi:lightbulb-off"
}
}
```
## Entity Services
Sometimes you want to provide extra services to control your entities. For example, the Sonos integration provides services to group and ungroup devices. Entity services are special because there are many different ways a user can specify entities. It can use areas, a group or a list of entities.