rename service to action

This commit is contained in:
Joseph Abbey
2025-10-20 09:24:12 +01:00
parent 2fca0ef3a3
commit cac94fecd4
17 changed files with 249 additions and 198 deletions

View File

@@ -11,7 +11,7 @@ A simple example using a scene as a `tap` menu item.
"name": "Telly Scene",
"type": "tap",
"tap_action": {
"service": "scene.turn_on"
"action": "scene.turn_on"
}
},
```
@@ -62,7 +62,7 @@ Note that for notify events, you _must_ not supply an `entity_id` or the API cal
"name": "Message",
"type": "tap",
"tap_action": {
"service": "notify.mobile_app_on_phone",
"action": "notify.mobile_app_on_phone",
"data": {
"title": "This is a title",
"message": "This is the message"
@@ -73,9 +73,9 @@ Note that for notify events, you _must_ not supply an `entity_id` or the API cal
```
> [!IMPORTANT]
> Be careful with the value of the `service` field.
> Be careful with the value of the `action` field.
Note that the `service` field will need to be a locally custom `script.<something>` as soon as any `data` fields are populated and not something more generic like `script.turn_on`. If the `service` field is wrong, the application will fail with a [`Communications.INVALID_HTTP_BODY_IN_NETWORK_RESPONSE`](https://developer.garmin.com/connect-iq/api-docs/Toybox/Communications.html) error in the response from your HomeAssistant and show the error message as _"No JSON returned from HTTP request"_ on your device. In the [web-based editor](https://house-of-abbey.github.io/GarminHomeAssistant/web/) you can use the standard developer tools to observe an `HTTP 400` error which the application does not see. Here we are limited by the [Garmin Connect IQ](https://developer.garmin.com/connect-iq/overview/) software development kit (SDK). We do not have enough information at the point of execution in the application to determine the cause of the error. Nor is there an immediately obvious way of identifying this issue using the JSON schema checks.
Note that the `action` field will need to be a locally custom `script.<something>` as soon as any `data` fields are populated and not something more generic like `script.turn_on`. If the `action` field is wrong, the application will fail with a [`Communications.INVALID_HTTP_BODY_IN_NETWORK_RESPONSE`](https://developer.garmin.com/connect-iq/api-docs/Toybox/Communications.html) error in the response from your HomeAssistant and show the error message as _"No JSON returned from HTTP request"_ on your device. In the [web-based editor](https://house-of-abbey.github.io/GarminHomeAssistant/web/) you can use the standard developer tools to observe an `HTTP 400` error which the application does not see. Here we are limited by the [Garmin Connect IQ](https://developer.garmin.com/connect-iq/overview/) software development kit (SDK). We do not have enough information at the point of execution in the application to determine the cause of the error. Nor is there an immediately obvious way of identifying this issue using the JSON schema checks.
## Exit on Tap
@@ -87,7 +87,7 @@ You can choose individual items that will quit after they have completed their a
"name": "Turn off Stuff",
"type": "tap",
"tap_action": {
"service": "automation.trigger"
"action": "automation.trigger"
},
"exit": true
}
@@ -103,7 +103,7 @@ If you would like to temporarily disable an item in your menu, e.g. for seasonal
"name": "Turn off Stuff",
"type": "tap",
"tap_action": {
"service": "automation.trigger"
"action": "automation.trigger"
},
"enabled": false
}

View File

@@ -48,12 +48,12 @@ switch:
friendly_name: <name>
value_template: <value>
turn_on:
service: <service>
action: <action>
data:
entity_id: <entity>
<attribute>: <value>
turn_off:
service: <service>
action: <action>
data:
entity_id: <entity>
<attribute>: <value>
@@ -90,11 +90,11 @@ switch:
friendly_name: Cover
value_template: "{{ is_state('cover.cover', 'open') }}"
turn_on:
service: cover.open_cover
action: cover.open_cover
data:
entity_id: cover.cover
turn_off:
service: cover.close_cover
action: cover.close_cover
data:
entity_id: cover.cover
```

View File

@@ -116,7 +116,7 @@ Note: Only when you use the `tap_action` field do you also need to include the `
"type": "tap",
"content": "{% if is_state('binary_sensor.garage_connected', 'on') %}{{state_translated('cover.garage_door')}} - {{state_attr('cover.garage_door', 'current_position')}}%{%else%}Unconnected{% endif %}",
"tap_action": {
"service": "cover.toggle",
"action": "cover.toggle",
"pin": true
}
}
@@ -173,7 +173,7 @@ An example of a dimmer light with 4 brightness settings 0..3. Here our light wor
"type": "tap",
"content": "{% if not (is_state('light.green_house', 'off') or is_state('light.green_house', 'unavailable')) %}{{ (((state_attr('light.green_house', 'brightness') | float) / 255 * 100) | round(0)) | int }}%{% else %}Off{% endif %}",
"tap_action": {
"service": "light.turn_on",
"action": "light.turn_on",
"data": {
"brightness_pct": 12
}
@@ -184,7 +184,7 @@ An example of a dimmer light with 4 brightness settings 0..3. Here our light wor
"name": "LEDs 1",
"type": "tap",
"tap_action": {
"service": "light.turn_on",
"action": "light.turn_on",
"data": {
"brightness_pct": 37
}
@@ -196,7 +196,7 @@ An example of a dimmer light with 4 brightness settings 0..3. Here our light wor
"type": "tap",
"content": "{% if not (is_state('light.green_house', 'off') or is_state('light.green_house', 'unavailable')) %}{{ (((state_attr('light.green_house', 'brightness') | float) / 255 * 100) | round(0)) | int }}%{% else %}Off{% endif %}",
"tap_action": {
"service": "light.turn_on",
"action": "light.turn_on",
"data": {
"brightness_pct": 62
}
@@ -208,7 +208,7 @@ An example of a dimmer light with 4 brightness settings 0..3. Here our light wor
"type": "tap",
"content": "{% if not (is_state('light.green_house', 'off') or is_state('light.green_house', 'unavailable')) %}{{ (((state_attr('light.green_house', 'brightness') | float) / 255 * 100) | round(0))| int }}%{% else %}Off{% endif %}",
"tap_action": {
"service": "light.turn_on",
"action": "light.turn_on",
"data": {
"brightness_pct": 87
}