How would I go about creating a device_tracker
which is considered “Away” when either device_tracker.x
or device_tracker.y
is “Away”, and when they are both “Home” then the tracker is considered “Home”?
I can’t use a group as that does the opposite of what I want - if either device is “Home” then the whole group is “Home”.
Create a template sensor
sensor:
- platform: template
sensors:
custom_group_tracker:
friendly_name: "Custom Group Tracker"
value_template: >
{% if states.device_tracker.x.state == 'home' and states.device_tracker.y.state == 'home' %}
home
{% else %}
away
{% endif %}
You can use a group, and reverse the standard behaviour by adding the all:
key and setting it to true.
I’m guessing here, but if what you’re trying to do is combine 2 device trackers to improve accuracy, use this component.
# Composite Device Tracker
> **OUT OF DATE**
> See https://github.com/pnbruckner/ha-composite-tracker
This platform creates a composite device tracker from one or more other device trackers and/or binary sensors. It will update whenever one of the watched entities updates, taking the last_seen/last_updated (and possibly GPS and battery) data from the changing entity. The result can be a more accurate and up-to-date device tracker if the "input" device tracker's update irregularly.
Currently device_tracker's with a source_type of bluetooth, bluetooth_le, gps or router are supported, as well as binary_sensor's.
## Installation
See [Installing and Updating](custom_updater.md) to use Custom Updater. The name of this `"element"` is `"device_tracker.composite"`.
Alternatively, place a copy of:
[`composite/__init__.py`](../custom_components/composite/__init__.py) at `<config>/custom_components/composite/__init__.py`
[`composite/device_tracker.py`](../custom_components/composite/device_tracker.py) at `<config>/custom_components/composite/device_tracker.py`
[`composite/manifest.json`](../custom_components/composite/manifest.json) at `<config>/custom_components/composite/manifest.json`
where `<config>` is your Home Assistant configuration directory.
>__NOTE__: Do not download the file by using the link above directly. Rather, click on it, then on the page that comes up use the `Raw` button.
This file has been truncated. show original
It’s not really to increase accuracy, I have 2 devices which I take out of the house with me, usually only one at a time. I’d like to so that if I leave one of the devices in the house but take one out, it still marks me as being “Away”.