Hey @tenly ever thought about adding places to the custom updater ? so that users can update via it ?
just ping @ludeeus if you want to add it
Hey @tenly ever thought about adding places to the custom updater ? so that users can update via it ?
just ping @ludeeus if you want to add it
You were right, I did not set the timezone of my pi right. I changed it and now it works fine!
thanks
Thanks for your response.
I updated my configuration.yaml to reflect your suggested code but still receive the following error in the log:
ERROR (MainThread) [homeassistant.loader] Unable to find component sensor.places
Looking at your suggested code I note that you do not have the “- platform: places” line indented beneath “sensor:” Is this a typo? My configuration looks like:
sensor:
- platform: places
name: places_alan
devicetrackerid: device_tracker.iphone_
options: zone, street, city
display_zone: show
map_provider: google
map_zoom: 18
home_zone: zone.alastair_home
api_key: !secret email_alan
Hi Texangeek,
Yes - sorry. There was a typo in what I posted in my last reply and the missing indent is required. I’ve edited my previous reply with examples that should be correct. The examples come from the GitHub documentation I posted when I uploaded the component.
There are also a couple of examples on how to configure automations.yaml that send notifications based on this sensor. Here’s a link to the GitHub page:
Github “Places” Project
Hi Toast,
Thanks for your message/suggestion. I’m not currently actively updating the “Places” component because it seems to be pretty stable and I’m putting all my free time into trying to learn Swift programming for the iPhone - but if/when an update is required, or need to add new features - I’ll definitely look into the custom_updater integration.
OK, so this what I now have I configuration.yaml:
Sensor places_alan:
- platform: places
name: Alan
devicetrackerid: device_tracker.iphone_
options: zone, street, city
display_zone: show
map_provider: google
map_zoom: 18
home_zone: zone.alan_home
api_key: !secret email_alan
The sensor place_alan line is aligned with column zero of the file, i.e. it is not indented under the sensor component. Is this correct?
I apologize for all the queries - I’m new to HA and still trying to get my head around the YAML syntax. Thanks for you feedback and the great component.
Hi Texangeek,
Your config looks okay to me - except that the word “Sensor” should not be capitalized.
The only other thing that looks weird is the name of your device_tracker entity.
Does it really end with an underscore as the last character? (“iphone_”)
What error message are you actually getting?
Have you double-checked to make sure that the places.py file exists in the correct location?
All of the directory names and the file name should be all lowercase characters.
If you’re still having trouble after double-checking all of those things, please send your log file.
Tenly
Thank you so much for your continued feedback and assistance.
Based on your last note I amended my config slightly. Changed ‘devicetrackerid’ to ‘devicetracker_id’ - stupid typo but easy to overlook! Also removed the capitalization on Sensor. So now my configuration looks like:
sensor places_alan:
- platform: places
name: alan
devicetracker_id: device_tracker.alan_iphone_
options: zone, street, city
display_zone: show
map_provider: google
map_zoom: 18
home_zone: zone.alan_home
api_key: !secret email_alan
Regarding the device tracker name - this is the name that is allocated within the Known_devices file. I think I previously tried amending this by changing the first line of the definition, i.e:
_iphone_:
to
alan_phone
but it failed to work. I’ll try again and see if I can get a more sensible device tracker name into the system.
So what I now see in the log file is (note I actually have two device trackers defined):
2018-09-03 13:51:21 INFO (MainThread) [homeassistant.loader] Loaded sensor.places from custom_components.sensor.places
2018-09-03 13:51:21 WARNING (MainThread) [homeassistant.loader] You are using a custom component for sensor.places which has not been tested by Home Assistant. This component might cause stability problems, be sure to disable it if you do experience issues with Home Assistant.
2018-09-03 13:51:26 INFO (MainThread) [homeassistant.components.sensor] Setting up sensor.places
2018-09-03 13:51:26 INFO (MainThread) [homeassistant.components.sensor] Setting up sensor.places
2018-09-03 13:51:26 ERROR (MainThread) [homeassistant.components.sensor] Error while setting up platform places
File "/config/custom_components/sensor/places.py", line 312, in setup_platform
add_devices([Places(hass, devicetracker_id, name, api_key, options, home_zone, map_provider, map_zoom)])
File "/config/custom_components/sensor/places.py", line 330, in __init__
2018-09-03 13:51:26 ERROR (MainThread) [homeassistant.components.sensor] Error while setting up platform places
File "/config/custom_components/sensor/places.py", line 312, in setup_platform
add_devices([Places(hass, devicetracker_id, name, api_key, options, home_zone, map_provider, map_zoom)])
File "/config/custom_components/sensor/places.py", line 330, in __init__
I upgraded my Home Assistant to the latest version to try and replicate your problem. I renamed one of my devices so the name ended with an underscore, I pointed it at a DeviceTracker entity that did not contains lat/long and even configured it to look for a non-existent DeviceTracker entity - but I can’t reproduce the error you are seeing.
Are you still having the problem?
What does your logging setup look like?
Hi Tenly
Unfortunately, yes, I am still having a problem with the component. I just restarted HA with logging set to ‘Warning’ (so I could easily filter out all of the INFO entries). Log messages relating to the Places component are:
2018-09-07 16:04:09 ERROR (MainThread) [homeassistant.components.sensor] Error while setting up platform places
Traceback (most recent call last):
File "/usr/src/app/homeassistant/helpers/entity_platform.py", line 128, in _async_setup_platform
SLOW_SETUP_MAX_WAIT, loop=hass.loop)
File "/usr/local/lib/python3.6/asyncio/tasks.py", line 358, in wait_for
return fut.result()
File "/usr/local/lib/python3.6/concurrent/futures/thread.py", line 56, in run
result = self.fn(*self.args, **self.kwargs)
File "/config/custom_components/sensor/places.py", line 312, in setup_platform
add_devices([Places(hass, devicetracker_id, name, api_key, options, home_zone, map_provider, map_zoom)])
File "/config/custom_components/sensor/places.py", line 330, in __init__
home_latitude = str(hass.states.get(home_zone).attributes.get('latitude'))
AttributeError: 'NoneType' object has no attribute 'attributes'
My Python understanding isn’t great but it looks to me as if the error is being generated where Places is attempting to obtain the latitude for my ‘home zone’. No idea however regarding the ‘NoneType’ object has no attribute message. Do you understand what this means?
With regard to logging I did try to enable debug logging for the Places Component but I don’t see any additional information in the log:
logger:
default: warning
logs:
custom_components.sensor.places: debug
Sounds like the home_zone attribute isn’t set or is set incorrectly. Can you confirm that there is no typo and that the home_zone you are referencing actually exists…?
My sensor definition looks like this:
sensor places_alan:
- platform: places
name: alan
devicetracker_id: device_tracker.alan_iphone_
options: zone, street, city
display_zone: show
map_provider: google
map_zoom: 18
home_zone: zone.alan_home
api_key: !secret email_alan
Under zones I have:
Within HA an entity is created with the name zone.zonealan_home which has the friendly name zone.alan_home.
I think your zone name is misconfigured. It doesn’t need the “zone.” to be part of the name and the actual entity name you just reported does not the match the name of the entity you have specified in the places config section. So…you have 2 options here:
Or…
Do one of the above or the other - not both - and then try it again…
That seems to have done the trick!
Thank you for all the effort that you have put in helping me make this work. Much appreciated.
Good news! You’re welcome!
When looking at your Github site a couple of minutes ago I noted that the sample YAML configurations contain the “zone.name” format for “home_zone” (see below).
Sample Configuration.yaml configurations:
sensor places_jim:
- platform: places
name: jim
devicetracker_id: device_tracker.jim_iphone8
options: zone,place
display_zone: show
map_provider: google
map_zoom: 19
home_zone: zone.jim_home
api_key: !secret email_jim
I wonder if it might be worth updating the documentation so that others do not run into the same issues as I did.
Nope…
The problem wasn’t with my documentation, it was with the way you named your zone in your zones.yaml file. You specified the name of your zone as “zone.alan_home” instead of just “alan_home”. Since a “.” is an invalid character for an entity name, HA stripped it and created your zone name as “zonealan_home”.
My home zone is specified in zones.yaml as:
name: jim_home
And thus, like the documentation shows - I need to refer to it as zone.jim_home
In your case, you specified in zones.yaml:
name: zone.alan_home
And thus, to follow the documentation example, you could make “Places” work by entering “zone.zonealan_home” although the correct “fix” for you would have been to edit your zone.yaml file and set:
name: alan_home
Get it? Because you are creating Zone entities via the zones.yaml file, the “zone.” refers to the entity type and just appends the “name”. You were trying to specify it again. You get “zones.” because it is a zone entity - and then you add the zone name to it - which in my case was “jim_home” but in your case was “zone.alan_home”.
So you tried to create an entity named “zone.zone.alan_home” - but the extra dot made it illegal so HomeAssistant stripped it and created “zone.zonealan_home” for you - and so that’s what you need to either fix - or you need to refer to it using the weird looking syntax “zone.zonealan_home” in all other areas of your configuration.
So I have one last query (I think!).
The “since” times that are displayed use UTC which isn’t really surprising since a bug in Docker for Mac prevents me passing local time to the container. What is strange however is that when I look at the information displayed by the Logbook or History options times are displayed correctly as local time.
Do you have any insight into why this should be the case?
None whatsoever. I run Home Assistant on a Raspberry Pi and all of my date/time values correctly show as local time to me - both in the log files and in the Places outputs. They Python datetime calls I use in the Places component return local time (as seen by Python) so I’m not sure why they are different on your system. Sorry I can’t help with that. Maybe someone else reading this thread can provide advice and/or help?
Will this automation work with telegram notification? Does it needs some adjustments?
- alias: ReverseLocateEveryone
initial_state: 'on'
trigger:
platform: event
event_type: places_state_update
action:
- service: notify.telegram # using telegram
data_template:
title: 'ReverseLocate: {{ trigger.event.data.entity }} ({{ trigger.event.data.devicetracker_zone }}) {{ trigger.event.data.place_name }}'
message: |-
{{ trigger.event.data.entity }} ({{ trigger.event.data.devicetracker_zone }})
{{ trigger.event.data.place_name }}
{{ trigger.event.data.distance_from_home }} from home and traveling {{ trigger.event.data.direction }}
{{ trigger.event.data.to_state }} ({{ trigger.event.data.mtime }})
data:
attachment:
url: '{{ trigger.event.data.map }}'
hide_thumbnail: false