Skip to content

wbyoung/movement

Folders and files

NameName
Last commit message
Last commit date

Latest commit

ย 

History

28 Commits
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 

Repository files navigation

Movement for Home Assistant

HACS HACS installs Version Downloads Build

This integration does its best to try to determine both how far and with what mode of transit you are traveling throughout the day. It builds off of the device tracker integration and assumes you carry a device with you as you travel.

Because it is based on the frequency with which your device sends GPS information back to Home Assistant, all of the gotchas that apply to location updating from the Companion Apps will affect its ability to provide accurate data.

Said another way: do not expect this integration to provide you with perfection.

Distance examples

There are a few more example graphs below.

Installation

HACS

Installation through HACS is the preferred installation method.

Open the Movement integration in HACS

  1. Click the button above or go to HACS โ†’ Integrations โ†’ search for "Movement" โ†’ select it.
  2. Press DOWNLOAD.
  3. Select the version (it will auto select the latest) โ†’ press DOWNLOAD.
  4. Restart Home Assistant then continue to the setup section.

Manual Download

  1. Go to the release page and download the movement.zip attached to the latest release.
  2. Unpack the zip file and move custom_components/movement to the following directory of your Home Assistant configuration: /config/custom_components/.
  3. Restart Home Assistant then continue to the setup section.

Setup

Open your Home Assistant instance and start setting up by following these steps:

  1. Navigate to "Settings" โ†’ "Devices & Services"
  2. Click "+ Add Integration"
  3. Search for and select โ†’ "Movement"

Or you can use the My Home Assistant Button below.

Add Integration

Follow the instructions to configure the integration.

Configuration Settings

  1. Choose a person or a device to track from the main dropdown.
  2. If desired, configure any of the additional options below.
  • Distance to add to the start of each driving trip
    Set in kilometers the distance you want added to the start of each driving trip. This will add an adjustment to your total distance traveled each time the integration determines you're moving fast enough to be considered driving. The reason you may wish to do this is because some devices can take a little longer to "wake up" and start reporting data back to Home Assistant when in the car. This may change based on your phone type, use of GPS or mapping apps, whether or not you have Android Auto or Apple CarPlay that connect automatically, or if you charge your phone in the car.

  • Driving multipliers
    These settings allow you to scale up or down the distance traveled while driving. Driving is not in a straight line, so depending on the types of roads you frequent, you may find that these settings can help you tweak the integration to get closer to the actual distance you are driving.

  • Advanced options
    Advanced options will only appear when re-configuring the integration via the CONFIGURE button. These are described in more detail in the dedicated section below.

Sensors

Each of the sensors that the integration provides are described in detail below. All sensors are reset at the beginning of a new day.

sensor.<name>_distance_traveled

This represents the total distance the person on device tracker has traveled.

Note: if this sensor is disabled, state will not be restored for all sensors in the configuration when Home Assistant is restarted.

Attributes

  • adjustments The adjustments that have been added to the distance traveled; mirrors the sensor value*.
  • speed The speed that the person or device is moving; mirrors the sensor value*.
  • mode_of_transit The assumed mode of transit the person is using; mirrors the sensor value*.
  • ignore_count The number of location changes that have been ignored. Changes are ignored when the GPS accuracy is poor and/or when updates arrive clustered together (a workaround for home-assistant/core#126972).
  • update_rate: The rate at which distance changes are being calculated per minute.

* These attributes mirror their respective sensors and are provided as part of the main distance traveled sensor for use by more complex automations. Some automations may require an understanding of the way the state is changing across all of the values simultaneously which cannot be obtained from individual sensors since state change triggers would be delivered to automations for each independently.

sensor.<name>_distance_adjustments

The adjustments to the distance traveled that can be attributed to the adjustments in the configuration settings.

sensor.<name>_distance_walking

The distance that has been determined to be for walking.

Note: The value calculated by this sensor takes into account the possibility that you may be in transition between two modes of transit. It will do its best to assign values to the distance sensor that is the most logical for the given situation. This means the value is not simply the sum of all distance changes from sensor.<name>_distance_traveled while in this mode.

Attributes

  • trip_start: The starting time of the current or last walking trip.
  • trip_distance: The distance traveled for the current trip.
  • trip_adjustments: The distance adjustments for the current trip.

sensor.<name>_distance_biking

The distance that has been determined to be for biking.

See notes in under the walking sensor about how this value is calculated.

Attributes

  • trip_start: The starting time of the current or last biking trip.
  • trip_distance: The distance traveled for the current trip.
  • trip_adjustments: The distance adjustments for the current trip.

sensor.<name>_distance_driving

The distance that has been determined to be for driving.

See notes in under the walking sensor about how this value is calculated.

Attributes

  • trip_start: The starting time of the current or last driving trip.
  • trip_distance: The distance traveled for the current trip.
  • trip_adjustments: The distance adjustments for the current trip.

sensor.<name>_speed

The speed that the person or device is moving based on recent updates.

Attributes

  • speed_recent_avg: The average speed at which you've been traveling recently.
  • speed_recent_max: The maximum speed at which you've been traveling recently.

sensor.<name>_mode_of_transit

The assumed mode of transit the person is using based on recent updates.

Attributes

  • transitioning: Whether it has been determined that the person or device is likely transitioning from one mode of transit to another.

sensor.<name>_gps_accuracy

The GPS accuracy person or device from the most recent update.

sensor.<name>_distance_updates

The number of updates to distance that have been made for the person or device throughout the day.

Actions

movement.add_distance

Add a certain distance manually.

This can be used, for instance if you travel on a certain schedule without a device.

Note: using this action will result in the speed being cleared and may result in the mode of transit needing to be recalculated. It is best to use this action when you know that your device is not moving (much).

Service Data Attributes

  • config_entry: required Config entry to use. Example: 1b4a46c6cba0677bbfb5a8c53e8618b0.
  • distance: The distance to add in kilometers.
  • adjustments: The adjustments to add in kilometers. This will increment both the distance traveled and the distance adjustments. So adding a distance of 1.2 with adjustments of 0.2 will result in the distance traveled being
  • mode_of_transit: The mode of transit that should be switched to.

Events

movement.template_entity_should_apply_update

This event will be fired for custom distance tracking template sensors. See the documentation for more details on how to configure this advanced option.

Event Data

Improving Location Reporting Frequency

There are a few things that may help with increasing the frequency with which your device reports its location back to Home Assistant. Be sure to check out the companion app docs as well.

  • Get into the habit of plugging in your phone in the car, connecting it to the infotainment system, and ensuring the map app is visible.
  • Consider adding zones intersections you walk or drive through frequenly. This can be especially helpful if you are turning or if the road turns at a given location.
  • Request location updates via an automation while driving.

Various factors will affect whether or not these will work for you or not. Try out different ideas and see what works best. Different devices manage battery life differently. Most try to strike a good balance, and this is in conflict with constantly obtaining and reporting GPS location.

Your mileage will vary with each of these solutions.

Advanced Configuration Settings

Custom Distance Tracking Template Sensors

This can be used to build complex scenarios of distance tracking, for instance combining several drivers for a single vehicle:

Using this setting, you can build custom sensors like the walking, biking, or driving sensors. but where you control when the distance changes applies to the sensor.

This can be used to have multiple configurations update the same (template entity) sensor which is what the multiple driver example does. For each driver in this example, you would press the CONFIGURE button, open the Advanced options section, and then select the shared template sensor.

For each trigger template sensor entity that you select, the integration will emit an event that can be consumed by a trigger, and you can change how it gets applied to the sensor as you see fit. See the example YAML configuration linked above for more details.

Example Graphs

Speed example Update rate example GPS accuracy example

About

Distance and mode of transit tracking for Home Assistant

Topics

Resources

License

Stars

Watchers

Forks

Sponsor this project

 

Packages

No packages published