Skip to content

Home Assistant Python Script which calculates the distance between two (gps) devices

License

Notifications You must be signed in to change notification settings

H89P/ps-device_distance_script

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

15 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

ps-device-distance-script

hacs_badge

Installation

Download the device_distance_script.py.py file and put it in your /config/python_scripts directory or install via HACS.

Add https://github.com/H89P/ps-device_distance_script as a custom repo to the hacs installation with type python_script

Script arguments

key required type description
device_1: true string Name of the first device_tracker e.g. phone
device_2: true string Name of the econd device_tracker e.g. car
unit: true string metric or imperial

Usage:

device_id_1: <name of device_tracker device 1>
device_id_2: <name of device_tracker device 2>
unit: metric

Example:

device_id_1: phone
device_id_2: car
unit: metric

Result:

A result a sensor is created:

sensor.distance_<name of device_tracker device 1>_<name of device_tracker device 1>
state: <distance>
icon: mdi:map-marker-distance
friendly_name: Distance between <name of device_tracker device 1> and <name of device_tracker device 2>
unit_of_measurement: mi
devices: <name of device_tracker device 1> & <name of device_tracker device 2>

and for the example:

sensor.phone_cr
state: 62.23
icon: mdi:map-marker-distance
friendly_name: Distance between phone and car
unit_of_measurement: m
devices: phone & car

Example Automation to update the sensor:

automation:
- alias: Update Phone in Car Sensor
  trigger:
  - platform: time_pattern
    minutes: "/5"
  action:
  - service: python_script.device_distance_script
    data:
      device_id_1: phone
      device_id_2: car
      unit: metric

Credits

About

Home Assistant Python Script which calculates the distance between two (gps) devices

Topics

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages

  • Python 100.0%