mirror of
https://github.com/home-assistant/core.git
synced 2025-07-11 07:17:12 +00:00
Style fixes
This commit is contained in:
parent
6a969208e9
commit
1eb3610a11
@ -24,9 +24,9 @@ def setup_scanner(hass, config, see):
|
|||||||
global _SEE
|
global _SEE
|
||||||
_SEE = see
|
_SEE = see
|
||||||
|
|
||||||
""" POST would be semantically better, but that currently does not work
|
# POST would be semantically better, but that currently does not work
|
||||||
since Geofancy sends the data as key1=value1&key2=value2 in the request body,
|
# since Geofancy sends the data as key1=value1&key2=value2
|
||||||
while Home Assistant expects json there. """
|
# in the request body, while Home Assistant expects json there.
|
||||||
|
|
||||||
hass.http.register_path(
|
hass.http.register_path(
|
||||||
'GET', URL_API_GEOFANCY_ENDPOINT, _handle_get_api_geofancy)
|
'GET', URL_API_GEOFANCY_ENDPOINT, _handle_get_api_geofancy)
|
||||||
@ -39,15 +39,18 @@ def _handle_get_api_geofancy(handler, path_match, data):
|
|||||||
|
|
||||||
if not isinstance(data, dict):
|
if not isinstance(data, dict):
|
||||||
handler.write_json_message(
|
handler.write_json_message(
|
||||||
"Error while parsing Geofancy message.", HTTP_INTERNAL_SERVER_ERROR)
|
"Error while parsing Geofancy message.",
|
||||||
|
HTTP_INTERNAL_SERVER_ERROR)
|
||||||
return
|
return
|
||||||
if 'latitude' not in data or 'longitude' not in data:
|
if 'latitude' not in data or 'longitude' not in data:
|
||||||
handler.write_json_message(
|
handler.write_json_message(
|
||||||
"Location not specified.", HTTP_UNPROCESSABLE_ENTITY)
|
"Location not specified.",
|
||||||
|
HTTP_UNPROCESSABLE_ENTITY)
|
||||||
return
|
return
|
||||||
if 'device' not in data or 'id' not in data:
|
if 'device' not in data or 'id' not in data:
|
||||||
handler.write_json_message(
|
handler.write_json_message(
|
||||||
"Device id or location id not specified.", HTTP_UNPROCESSABLE_ENTITY)
|
"Device id or location id not specified.",
|
||||||
|
HTTP_UNPROCESSABLE_ENTITY)
|
||||||
return
|
return
|
||||||
|
|
||||||
try:
|
try:
|
||||||
@ -55,10 +58,10 @@ def _handle_get_api_geofancy(handler, path_match, data):
|
|||||||
except ValueError:
|
except ValueError:
|
||||||
# If invalid latitude / longitude format
|
# If invalid latitude / longitude format
|
||||||
handler.write_json_message(
|
handler.write_json_message(
|
||||||
"Invalid latitude / longitude format.", HTTP_UNPROCESSABLE_ENTITY)
|
"Invalid latitude / longitude format.",
|
||||||
|
HTTP_UNPROCESSABLE_ENTITY)
|
||||||
return
|
return
|
||||||
|
|
||||||
|
|
||||||
# entity id's in Home Assistant must be alphanumerical
|
# entity id's in Home Assistant must be alphanumerical
|
||||||
device_uuid = data['device']
|
device_uuid = data['device']
|
||||||
device_entity_id = device_uuid.replace('-', '')
|
device_entity_id = device_uuid.replace('-', '')
|
||||||
|
Loading…
x
Reference in New Issue
Block a user