mirror of
https://github.com/home-assistant/core.git
synced 2025-07-22 20:57:21 +00:00
Add GPS coords to meraki (#10998)
This commit is contained in:
parent
04cb893d10
commit
b2c5a9f5fe
@ -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
|
||||
))
|
||||
|
Loading…
x
Reference in New Issue
Block a user