mirror of
https://github.com/home-assistant/core.git
synced 2025-07-23 21:27:38 +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):
|
def _handle(self, hass, data):
|
||||||
for i in data["data"]["observations"]:
|
for i in data["data"]["observations"]:
|
||||||
data["data"]["secret"] = "hidden"
|
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"]
|
mac = i["clientMac"]
|
||||||
_LOGGER.debug("clientMac: %s", mac)
|
_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 = {}
|
attrs = {}
|
||||||
if i.get('os', False):
|
if i.get('os', False):
|
||||||
attrs['os'] = i['os']
|
attrs['os'] = i['os']
|
||||||
@ -110,7 +128,9 @@ class MerakiView(HomeAssistantView):
|
|||||||
if i.get('ssid', False):
|
if i.get('ssid', False):
|
||||||
attrs['ssid'] = i['ssid']
|
attrs['ssid'] = i['ssid']
|
||||||
hass.async_add_job(self.async_see(
|
hass.async_add_job(self.async_see(
|
||||||
|
gps=gps_location,
|
||||||
mac=mac,
|
mac=mac,
|
||||||
source_type=SOURCE_TYPE_ROUTER,
|
source_type=SOURCE_TYPE_ROUTER,
|
||||||
|
gps_accuracy=accuracy,
|
||||||
attributes=attrs
|
attributes=attrs
|
||||||
))
|
))
|
||||||
|
Loading…
x
Reference in New Issue
Block a user