I need to know if I am doing something stupid of do I need to post this as an issue?
I think I have the issue boiled down to as simple as possible. I have a app yaml that defines a app. It passes parameters. Some of the parameters are from a secret yaml file. My latitude and longitude works and passes at expected. When I added the device tracker I started getting errors. I can rem it out and the errors go away.
Here is a snippet of the error log.
2018-06-18 09:34:13.287768 INFO AppDaemon: Reading config
2018-06-18 09:34:13.327687 WARNING AppDaemon: ------------------------------------------------------------
2018-06-18 09:34:13.328725 WARNING AppDaemon: Unexpected error loading config file: /config/appdaemon/apps/apps.yaml
2018-06-18 09:34:13.329821 WARNING AppDaemon: ------------------------------------------------------------
2018-06-18 09:34:13.333284 WARNING AppDaemon: Traceback (most recent call last):
File "/usr/lib/python3.6/site-packages/appdaemon/appdaemon.py", line 1674, in read_config_file
new_config = yaml.load(config_file_contents)
File "/usr/lib/python3.6/site-packages/yaml/__init__.py", line 72, in load
return loader.get_single_data()
File "/usr/lib/python3.6/site-packages/yaml/constructor.py", line 37, in get_single_data
return self.construct_document(node)
File "/usr/lib/python3.6/site-packages/yaml/constructor.py", line 46, in construct_document
for dummy in generator:
File "/usr/lib/python3.6/site-packages/yaml/constructor.py", line 398, in construct_yaml_map
value = self.construct_mapping(node)
File "/usr/lib/python3.6/site-packages/yaml/constructor.py", line 204, in construct_mapping
return super().construct_mapping(node, deep=deep)
File "/usr/lib/python3.6/site-packages/yaml/constructor.py", line 129, in construct_mapping
value = self.construct_object(value_node, deep=deep)
2018-06-18 09:34:13.335998 WARNING AppDaemon: File '/config/appdaemon/apps/apps.yaml' invalid structure - ignoring
File "/usr/lib/python3.6/site-packages/yaml/constructor.py", line 86, in construct_object
data = constructor(self, node)
File "/usr/lib/python3.6/site-packages/appdaemon/utils.py", line 104, in _secret_yaml
raise ValueError("{} not found in secrets file".format(node.value))
ValueError: device_tracker_paul not found in secrets file
2018-06-18 09:34:13.337075 INFO AppDaemon: /config/appdaemon/apps/apps.yaml added or modified
2018-06-18 09:34:13.334444 WARNING AppDaemon: ------------------------------------------------------------
I am including all 3 files.
Secrets.yaml
latitude: 3
longitude: -9
device_tracker_paul: google_maps_xxxxxxxxxxxxxxxxxxxxxx
apps.yaml
tell_nancy_paul_is_on_his_way:
module: on_way_home_notify
class: on_way_home_notify
home_coord_lat : !secret latitude
home_coord_lon : !secret longitude
devicetracker_coord : !secret device_tracker_paul
send_alert_to : "textalertsnancy"
toggle_switch : "paul_on_way_home_switch"
send_alert_from : "Paul"
on_way_home_notify.py
import appdaemon.plugins.hass.hassapi as hass
import json
import urllib
class on_way_home_notify(hass.Hass):
def send_text_callback(self, entity, attribute, old, new, kwargs):
self.log("callback started")
dest_coord_lat = self.args["home_coord_lat"]
dest_coord_lon = self.args["home_coord_lon"]
orig_coord_lat = self.get_state(entity = "device_tracker." + self.args["devicetracker_coord"], attribute = "latitude")
orig_coord_lon = self.get_state(entity = "device_tracker." + self.args["devicetracker_coord"], attribute = "longitude")
url = "http://maps.googleapis.com/maps/api/distancematrix/json?origins={0},{1}&destinations={2},{3}&mode=driving&language=en-EN&sensor=false".format(str(orig_coord_lat),str(orig_coord_lon),str(dest_coord_lat),str(dest_coord_lon))
result = json.load(urllib.request.urlopen(url))
self.log("\n***********************************************\n" +
url +
"\n*********\n" +
json.dumps(result) +
"\n***********************************************\n")
driving_time = result['rows'][0]['elements'][0]['duration']['text']
origin_addresses = result['origin_addresses'][0]
self.log(driving_time)
self.log(origin_addresses)
message = self.args["send_alert_from"] + " is on his way home." + "\nThey will be there in about " + driving_time + "\nLeaving from " + origin_addresses
self.log("\n***********************************************\n" +
message +
"\n***********************************************\n")
#self.call_service("notify/textalertspaul",title="",message=message)
#self.call_service("notify/textalertsnancy",title="",message=message)
def initialize(self):
self.listen_state(self.send_text_callback,
"switch." + self.args["toggle_switch"],
new="on")
self.log("Automaintion initialize.")
The secret yaml names (values) has been changed to protect the innocent. Ok, you would need to be a child of the 60’s whose parents watched Dragnet to get that one.
Also, if I want to use the secrets.yaml for HA, would the secret: look like …secerts.yaml ? To reference the directory above?