No wonder why I couldn’t find it, it’s not even mentioned in the docs how to use attributes with trigger.to/from.
Is where any way to make it completely a trigger?
The automation I want to run this in also has a numeric state trigger, and if that part triggers then this condition will not be true.
Or could I make a sensor with the template from → to that I could make as the trigger?
to_state and from_state are state objects, which are documented at the link there. It would be easier to build a working automation if you share what you already have.
The situation is that when I arrive home by car my phone is in high accuracy mode until I have walked far enough from the car that bluetooth does not reach.
Then it disables the high accuracy mode and I stay on the parking and never arrive home.
I want to maintain the high accuracy mode until I have connected to the wifi at home because I want to see if I can use my proximity to open the door by adding a ESP inside the intercom phone (the ones you have in apartment houses to open the front door).
At first I thought I could have proximity < 150 m only.
But because I park my car less than 150 m away then bluetooth will disable high accuracy mode.
If I set proximity 50 m then it won’t work either since it doesn’t seem to update my position with that small difference and thus does not enable high accuracy mode.
So my current plan is to have trigger 150 m and bluetooth disconnect, and have proximity 150 m as condition so that it doesn’t enable high accuracy mode each time I walk away from my car.
alias: Andreas high accuracy walking home
description: ''
trigger:
- platform: numeric_state
entity_id: proximity.home
below: '150'
condition:
- condition: state
entity_id: sensor.andreas_wifi_bssid
state: <not connected>
- condition: numeric_state
entity_id: proximity.home
below: '150'
action:
- service: notify.mobile_app_andreas
data:
message: command_high_accuracy_mode
title: turn_on
mode: single
And then I have one that disables high accuracy when I connect to wifi.
I think I figured out a way.
If I have both the numeric state as trigger and the bluetooth.
Then in coditions I have an or that is true either if the numeric has triggered or if the bluetooth has triggered.
alias: Andreas high accuracy walking home
description: ''
trigger:
- platform: numeric_state
entity_id: proximity.home
below: '200'
- platform: state
entity_id: sensor.andreas_bluetooth_connection
attribute: connected_paired_devices
condition:
- condition: or
conditions:
- condition: and
conditions:
# This should be true if I'm walking home
- condition: state
entity_id: sensor.andreas_wifi_bssid
state: <not connected>
- condition: numeric_state
entity_id: proximity.home
below: '200'
- condition: and
conditions:
# This should be true if I walk or drive home (disconnects from car)
- condition: template
value_template: >-
{{ '4E:C3:9E:5B:9C:86' in
trigger.from_state.attributes.connected_paired_devices }}
- condition: template
value_template: >-
{{ not '4E:C3:9E:5B:9C:86' in
trigger.to_state.attributes.connected_paired_devices }}
- condition: numeric_state
entity_id: proximity.home
below: '200'
- condition: state
entity_id: sensor.andreas_wifi_bssid
state: <not connected>
action:
- service: notify.mobile_app_andreas
data:
message: command_high_accuracy_mode
title: turn_on
mode: single