Add Dawarich stack
This commit is contained in:
@@ -0,0 +1,47 @@
|
||||
# Add `dawarich_api_key` to Home Assistant `secrets.yaml`.
|
||||
# The endpoint is the current OwnTracks-compatible Dawarich endpoint:
|
||||
# https://<host>/api/v1/owntracks/points?api_key=<api-key>
|
||||
|
||||
rest_command:
|
||||
dawarich_push_owntracks:
|
||||
url: "https://dawarich.kaleschke.info/api/v1/owntracks/points?api_key={{ api_key }}"
|
||||
method: POST
|
||||
content_type: "application/json"
|
||||
payload: >-
|
||||
{
|
||||
"_type": "location",
|
||||
"lat": {{ latitude }},
|
||||
"lon": {{ longitude }},
|
||||
"tst": {{ timestamp }},
|
||||
"acc": {{ accuracy | default(0) }},
|
||||
"alt": {{ altitude | default(0) }},
|
||||
"batt": {{ battery | default(0) }},
|
||||
"tid": "{{ tracker_id[:2] }}"
|
||||
}
|
||||
|
||||
automation:
|
||||
- id: dawarich_push_device_tracker_location
|
||||
alias: Dawarich - push device tracker location
|
||||
mode: queued
|
||||
max: 20
|
||||
trigger:
|
||||
- platform: state
|
||||
entity_id:
|
||||
- device_tracker.your_phone
|
||||
condition:
|
||||
- condition: template
|
||||
value_template: >-
|
||||
{{ trigger.to_state is not none
|
||||
and state_attr(trigger.entity_id, 'latitude') is number
|
||||
and state_attr(trigger.entity_id, 'longitude') is number }}
|
||||
action:
|
||||
- service: rest_command.dawarich_push_owntracks
|
||||
data:
|
||||
api_key: !secret dawarich_api_key
|
||||
tracker_id: "{{ trigger.entity_id.split('.')[1] }}"
|
||||
latitude: "{{ state_attr(trigger.entity_id, 'latitude') }}"
|
||||
longitude: "{{ state_attr(trigger.entity_id, 'longitude') }}"
|
||||
accuracy: "{{ state_attr(trigger.entity_id, 'gps_accuracy') | default(0, true) }}"
|
||||
altitude: "{{ state_attr(trigger.entity_id, 'altitude') | default(0, true) }}"
|
||||
battery: "{{ state_attr(trigger.entity_id, 'battery_level') | default(0, true) }}"
|
||||
timestamp: "{{ as_timestamp(trigger.to_state.last_updated) | int }}"
|
||||
Reference in New Issue
Block a user