thanks Rene!
will pass this on to @ludeeus too with this.
edit
still see this:
2020-01-16 14:28:04.286135 WARNING address: ------------------------------------------------------------
2020-01-16 14:28:04.287247 WARNING address: Unexpected error in worker for App address:
2020-01-16 14:28:04.288426 WARNING address: Worker Ags: {'id': 'redacted15743cd807f9a92bd884a4d', 'name': 'address', 'objectid': 'redacted138c7e41deac29e2859f37774f', 'type': 'state', 'function': <bound method Address.get_address of <address.Address object at 0xb4ebf1a8>>, 'attribute': 'state', 'entity': 'device_tracker.life360_marijn', 'new_state': 'bij Marijn', 'old_state': 'home', 'pin_app': True, 'pin_thread': 1, 'kwargs': {'__thread_id': 'thread-1'}}
2020-01-16 14:28:04.289536 WARNING address: ------------------------------------------------------------
2020-01-16 14:28:04.297138 WARNING address: Traceback (most recent call last):
File "/usr/lib/python3.8/urllib/request.py", line 1319, in do_open
h.request(req.get_method(), req.selector, req.data, headers,
File "/usr/lib/python3.8/http/client.py", line 1230, in request
self._send_request(method, url, body, headers, encode_chunked)
File "/usr/lib/python3.8/http/client.py", line 1276, in _send_request
self.endheaders(body, encode_chunked=encode_chunked)
File "/usr/lib/python3.8/http/client.py", line 1225, in endheaders
self._send_output(message_body, encode_chunked=encode_chunked)
File "/usr/lib/python3.8/http/client.py", line 1004, in _send_output
self.send(msg)
File "/usr/lib/python3.8/http/client.py", line 944, in send
self.connect()
File "/usr/lib/python3.8/http/client.py", line 1392, in connect
super().connect()
File "/usr/lib/python3.8/http/client.py", line 915, in connect
self.sock = self._create_connection(
File "/usr/lib/python3.8/socket.py", line 808, in create_connection
raise err
File "/usr/lib/python3.8/socket.py", line 796, in create_connection
sock.connect(sa)
OSError: [Errno 99] Address not available
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "/usr/lib/python3.8/site-packages/geopy/geocoders/base.py", line 355, in _call_geocoder
page = requester(req, timeout=timeout, **kwargs)
File "/usr/lib/python3.8/urllib/request.py", line 525, in open
response = self._open(req, data)
File "/usr/lib/python3.8/urllib/request.py", line 542, in _open
result = self._call_chain(self.handle_open, protocol, protocol +
File "/usr/lib/python3.8/urllib/request.py", line 502, in _call_chain
result = func(*args)
File "/usr/lib/python3.8/urllib/request.py", line 1362, in https_open
return self.do_open(http.client.HTTPSConnection, req,
File "/usr/lib/python3.8/urllib/request.py", line 1322, in do_open
raise URLError(err)
urllib.error.URLError: <urlopen error [Errno 99] Address not available>
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "/usr/lib/python3.8/site-packages/appdaemon/threading.py", line 777, in worker
funcref(entity, attr, old_state, new_state,
File "/config/appdaemon/apps/address.py", line 44, in get_address
data = geo.reverse(lat_long)
File "/usr/lib/python3.8/site-packages/geopy/geocoders/osm.py", line 449, in reverse
self._call_geocoder(url, timeout=timeout), exactly_one
File "/usr/lib/python3.8/site-packages/geopy/geocoders/base.py", line 386, in _call_geocoder
raise GeocoderServiceError(message)
geopy.exc.GeocoderServiceError: [Errno 99] Address not available
using the changed code for the address.py:
"""Address AppDaemon app."""
# pylint: disable=attribute-defined-outside-init, unused-argument, too-many-arguments
import appdaemon.plugins.hass.hassapi as hass
#
# Address App
# requires: "geopy" https://pypi.org/project/geopy/
#
#
# Args:
# entity: entity_id of a device_tracker entity, example "device_tracker.my_entity"
#
class Address(hass.Hass):
"""Address class."""
def initialize(self):
"""initialize Address."""
self.log("App started.")
entity_config = self.args["entity"]
if isinstance(entity_config, str):
entities = []
entities.append(entity_config)
else:
entities = entity_config
for entity in entities:
self.listen_state(self.get_address, entity)
self.log("State listener for {} started.".format(entity))
def get_address(self, entity, attribute, old, new, kwargs):
"""Set the state + attributes of a defined device_tracker entity."""
from geopy.geocoders import Nominatim
geo = Nominatim(user_agent="AppDaemon")
lat = self.get_state(entity_id=entity, attribute="latitude")
long = self.get_state(entity_id=entity, attribute="longitude")
if lat is None or long is None:
self.log("{} does not have lat/long attributes.".format(entity))
return
lat_long = "{}, {}".format(lat, long)
data = geo.reverse(lat_long)
raw = data.raw["address"]
attributes = self.get_state(entity_id=entity, attribute="all")["attributes"]
for attr in raw:
attributes[attr] = raw[attr]
self.log("Updating state for {}".format(entity))
self.set_state(entity, attributes=attributes)
and has now changed into:
2020-01-16 14:50:39.748035 INFO address: Updating state for device_tracker.life360_marijn
2020-01-16 14:50:39.932944 WARNING HASS: Error setting Home Assistant state default.device_tracker.life360_marijn, {'attributes': {'source_type': 'gps', 'latitude': xxxxx, 'longitude': xxxxx, 'gps_accuracy': 15, 'battery': 29, 'address': 'Home', 'at_loc_since': '2020-01-15T15:57:10+00:00', 'battery_charging': False, 'driving': False, 'last_seen': '2020-01-16T13:50:34+00:00', 'moving': False, 'place': 'Home', 'raw_speed': -1, 'speed': 0, 'wifi_on': True, 'friendly_name': 'Life360 Marijn', 'entity_picture': 'https://www.life360.com/img/user_images/be8redacted8058df15c86/44648e5e--9b30-40f6f3717e22.jpg?fd=2', 'custom_ui_state_card': 'state-card-custom-ui', 'show_last_changed': True, 'house_number': 'xx', 'cycleway': 'xxxweg', 'neighbourhood': 'xxxdijk', 'suburb': 'xxxal', 'town': 'xxxal', 'state': 'Noord-Brabant', 'postcode': 'xxxxx', 'country': 'Nederland', 'country_code': 'nl'}}
2020-01-16 14:50:39.934356 WARNING HASS: Code: 400, error: {"message": "No state specified."}
all attributes are correct, but it canāt be set in the final set_state
do I need something else there? @ReneTode please let me know if you can see some, or, if there is an online checker I can run the code in.