Skip to content

Instantly share code, notes, and snippets.

@mikey0000
Last active November 19, 2025 03:46
Show Gist options
  • Select an option

  • Save mikey0000/e1d8bb6222cedb6a5d371486c1d85fdc to your computer and use it in GitHub Desktop.

Select an option

Save mikey0000/e1d8bb6222cedb6a5d371486c1d85fdc to your computer and use it in GitHub Desktop.
Home Assistant blueprint for creating a mower offset, uses location and state to determine if it should update.
blueprint:
name: GPS Offset for Mammotion or Other GPS Devices (Active Only)
description: >
Apply latitude and longitude offsets to a GPS device tracker (e.g. Mammotion mower)
only when it is active (e.g. state = "mowing"). Useful for adjusting GPS
alignment on maps without affecting idle locations.
domain: automation
input:
source_tracker:
name: Source GPS device
description: The device tracker entity of your mower or GPS device.
selector:
entity:
filter:
- domain: device_tracker
source_device:
name: Source Mower
description: The mower entity of your mower.
selector:
entity:
filter:
- domain: lawn_mower
active_state:
name: Active state
description: >
The state of the mower when it should apply the offset (e.g. "mowing", "working").
Check Developer Tools → States for your device's actual value.
default: "mowing"
selector:
text:
latitude_offset:
name: Latitude offset (meters)
description: Offset in meters to apply to latitude (positive = north, negative = south).
default: 0.0
selector:
number:
min: -100.0
max: 100.0
step: 0.1
unit_of_measurement: m
longitude_offset:
name: Longitude offset (meters)
description: Offset in meters to apply to longitude (positive = east, negative = west).
default: 0.0
selector:
number:
min: -100.0
max: 100.0
step: 0.1
unit_of_measurement: m
new_device_id:
name: New device tracker ID
description: The device_tracker ID to create for the offset location.
default: "luba_offset"
selector:
text:
mode: single
triggers:
- trigger: state
entity_id: !input source_tracker
attribute: latitude
- trigger: state
entity_id: !input source_tracker
attribute: longitude
condition:
- condition: template
value_template: >
{{ states(source_device) == active_state or states(source_device) == 'returning' }}
variables:
source_tracker: !input source_tracker
source_device: !input source_device
active_state: !input active_state
latitude_offset: !input latitude_offset
longitude_offset: !input longitude_offset
new_device_id: !input new_device_id
lat: "{{ state_attr(source_tracker, 'latitude') | float }}"
lon: "{{ state_attr(source_tracker, 'longitude') | float }}"
actions:
- action: device_tracker.see
metadata: {}
data:
dev_id: "{{ new_device_id }}"
gps:
- "{{ lat + (latitude_offset / 111320) }}"
- "{{ lon + (longitude_offset / (111320 * cos( lat * (pi/180)))) }}"
gps_accuracy: "{{ state_attr(source_tracker, 'gps_accuracy') | int(0) }}"
battery: "{{ state_attr(source_tracker, 'battery_level') | int(0) }}"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment