Add GPS coords to meraki (#10998)

This commit is contained in:
Adde Lovein 2017-12-10 18:47:14 +01:00 committed by Paulus Schoutsen
parent 04cb893d10
commit b2c5a9f5fe

View File

@ -94,8 +94,26 @@ class MerakiView(HomeAssistantView):
def _handle(self, hass, data):
for i in data["data"]["observations"]:
data["data"]["secret"] = "hidden"
lat = i["location"]["lat"]
lng = i["location"]["lng"]
try:
accuracy = int(float(i["location"]["unc"]))
except ValueError:
accuracy = 0
mac = i["clientMac"]
_LOGGER.debug("clientMac: %s", mac)
if lat == "NaN" or lng == "NaN":
_LOGGER.debug(
"No coordinates received, skipping location for: " + mac
)
gps_location = None
accuracy = None
else:
gps_location = (lat, lng)
attrs = {}
if i.get('os', False):
attrs['os'] = i['os']
@ -110,7 +128,9 @@ class MerakiView(HomeAssistantView):
if i.get('ssid', False):
attrs['ssid'] = i['ssid']
hass.async_add_job(self.async_see(
gps=gps_location,
mac=mac,
source_type=SOURCE_TYPE_ROUTER,
gps_accuracy=accuracy,
attributes=attrs
))