I had to change the command line template sensor from sections under “sensors” to sensor under command line:
command_line:
- sensor:
name: gardena_location
scan_interval: 86060 # we do no want this to update often, because of API limit
command: >-
curl -X GET -H "Authorization:Bearer {{states.sensor.gardena_token.attributes["access_token"]}}" -H "X-Api-Key:YOURAPIKEY" https://api.smart.gardena.dev/v1/locations
value_template: '{{ value_json.data[0].id }}'
- sensor:
name: gardena_status
scan_interval: 86000 # Make sure not to exceed 700 calls/week (including commands) or your api-key will be permanently disabled by the provider
command: >-
curl -H "Authorization:Bearer {{states.sensor.gardena_token.attributes["access_token"]}}" -H "X-Api-Key:YOURAPIKEY" https://api.smart.gardena.dev/v1/locations/{{states.sensor.gardena_location.state}}
| jq '{"activity": .included[1].attributes.activity.value, "timestamp": .included[1].attributes.activity.timestamp, "operatingHours": .included[1].attributes.operatingHours.value, "status": .included[1].attributes.state.value, "batteryLevel": .included[2].attributes.batteryLevel.value, "rfLinkLevel": .included[2].attributes.rfLinkLevel.value, "lastErrorCode": (.included[1].attributes.lastErrorCode.value // "none"), "location": .data.id, "serviceId": .included[0].relationships.services.data[0].id}'
json_attributes:
- status
- activity
- timestamp
- operatingHours
- batteryLevel
- rfLinkLevel
- lastErrorCode
- location
- serviceId
value_template: '{{ value_json.activity }}'