Skip to content

Commit

Permalink
Copy entiry_picture from the triggered device tracker to the output s…
Browse files Browse the repository at this point in the history
…ensor
  • Loading branch information
rodpayne committed May 30, 2022
1 parent f3bf305 commit 3eeecab
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 3 deletions.
4 changes: 3 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -174,7 +174,8 @@ Input:
latitude
longitude
person_name (if different from what is implied by entity_id = device_tracker.<person_name>_whatever)
altitude (optional, passed thru to output sensor)
altitude (optional, passed thru to the output sensor)
entity_picture (optional, passed thru to the output sensor)
gps_accuracy (optional)
source_type (optional)
vertical_accuracy (optional)
Expand Down Expand Up @@ -284,6 +285,7 @@ person_location:
- name: Pam
devices: person.pam
```
In this example, `sensor.rod_location` will reflect changes detected in three devices; `sensor.pam_location` will reflect changes in the `person.pam` entity.

* [Open Street Map Geocoding Configuration](#open-street-map-geocoding-configuration)
* [Google Maps Geocoding Configuration](#google-maps-geocoding-configuration)
Expand Down
2 changes: 1 addition & 1 deletion custom_components/person_location/const.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
API_STATE_OBJECT = DOMAIN + "." + DOMAIN + "_integration"
INTEGRATION_NAME = "Person Location"
ISSUE_URL = "https://github.com/rodpayne/home-assistant/issues"
VERSION = "2022.02.09"
VERSION = "2022.05.30"

# Fixed parameters:
MIN_DISTANCE_TRAVELLED_TO_GEOCODE = 5
Expand Down
2 changes: 1 addition & 1 deletion custom_components/person_location/manifest.json
Original file line number Diff line number Diff line change
Expand Up @@ -19,5 +19,5 @@
],
"iot_class": "calculated",
"requirements": [],
"version": "2022.02.09"
"version": "2022.05.30"
}
9 changes: 9 additions & 0 deletions custom_components/person_location/process_trigger.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
ATTR_VERTICAL_ACCURACY,
)
from homeassistant.const import (
ATTR_ENTITY_PICTURE,
ATTR_GPS_ACCURACY,
ATTR_LATITUDE,
ATTR_LONGITUDE,
Expand Down Expand Up @@ -431,6 +432,14 @@ def handle_process_trigger(call):
if ATTR_VERTICAL_ACCURACY in target.attributes:
target.attributes.pop(ATTR_VERTICAL_ACCURACY)

if ATTR_ENTITY_PICTURE in trigger.attributes:
target.attributes[ATTR_ENTITY_PICTURE] = trigger.attributes[
ATTR_ENTITY_PICTURE
]
else:
if ATTR_ENTITY_PICTURE in target.attributes:
target.attributes.pop(ATTR_ENTITY_PICTURE)

target.attributes["source"] = trigger.entity_id
target.attributes["reported_state"] = trigger.state
target.attributes["person_name"] = string.capwords(
Expand Down

1 comment on commit 3eeecab

@rodpayne
Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

entity_picture

Please sign in to comment.