I am having trouble capturing data from an android intent.
I suspect it is because the of the decimals in the intent data, but not sure.
Companion app is setup and working properly.
Here is Developer Tools / Events / android.intent_received:
Event 0 fired 1:37 PM:
{
"event_type": "android.intent_received",
"data": {
"android.bluetooth.device.extra.BATTERY_LEVEL": "20",
"android.bluetooth.device.extra.DEVICE": "35:84:A6:60:6A:08",
"intent": "android.bluetooth.device.action.BATTERY_LEVEL_CHANGED",
"device_id": "ed6a27e8610a611d"
},
"origin": "REMOTE",
"time_fired": "2021-10-26T20:37:40.351179+00:00",
"context": {
"id": "4a83d4dc447d94cee53e0fffe50e7358",
"parent_id": null,
"user_id": "bdad29b228aa4efa9ed620b5d6082916"
}
}
The automation triggers succesfully, but the action (input_number.set_value) fails.
Here is the automation:
- id: '1634663270084'
alias: Bluetooth Speaker Battery Level monitor
description: ''
trigger:
- platform: event
event_type: android.intent_received
context:
user_id:
- bdad29b228aa4efa9ed620b5d6082916
condition: []
action:
- service: input_number.set_value
target:
entity_id: input_number.bluetooth_speaker_battery_level
data:
value: '{{ trigger.event.data.android.bluetooth.device.extra.BATTERY_LEVEL }}'
- device_id: 17145cd82f9fb23cf9254326d09b9f96
domain: mobile_app
type: notify
title: Bluetooth Speaker Battery Level monitor
message: 'Intent received: {{ trigger.event.data.intent }} {{ trigger.event.data.android.bluetooth.device.extra.BATTERY_LEVEL
}}'
data:
ttl: 0
priority: high
mode: single
Automation trace / Step Config:
service: input_number.set_value
target:
entity_id: input_number.bluetooth_speaker_battery_level
data:
value: '{{ trigger.event.data.android.bluetooth.device.extra.BATTERY_LEVEL }}'
Automation trace / Step Details:
Executed: October 26, 2021, 1:37:40 PM
Error: Error rendering data template: UndefinedError: 'dict object' has no attribute 'android'
So I think my question is, how do I reference this with trigger.event.data?:
"data": {
"android.bluetooth.device.extra.BATTERY_LEVEL": "20",