Hi Per,
Sorry for the late reply.
The latest changes makes the services work, both enable
and disable
.
However, the error handling is still not that great.
If you try to connect using an invalid/non existing device_serial
you still get an unkown error
. the same goes if you use an invalid user or password for verisure. Seems the returned response from Verisure is not handled correctly:
2019-11-09 22:26:59 DEBUG (MainThread) [homeassistant.core] Bus:Handling <Event call_service[L]: domain=verisure, service=enable_autolock, service_data=device_serial=3ANF BKTT>
2019-11-09 22:26:59 ERROR (MainThread) [homeassistant.components.websocket_api.http.connection.139740416218768] Expecting value: line 1 column 1 (char 0)
Traceback (most recent call last):
File "/usr/src/homeassistant/homeassistant/components/websocket_api/commands.py", line 133, in handle_call_service
connection.context(msg),
File "/usr/src/homeassistant/homeassistant/core.py", line 1233, in async_call
await asyncio.shield(self._execute_service(handler, service_call))
File "/usr/src/homeassistant/homeassistant/core.py", line 1258, in _execute_service
await handler.func(service_call)
File "/config/custom_components/verisure/__init__.py", line 128, in enable_autolock
await hass.async_add_executor_job(HUB.enable_autolock, device_id)
File "/usr/local/lib/python3.7/concurrent/futures/thread.py", line 57, in run
result = self.fn(*self.args, **self.kwargs)
File "/config/custom_components/verisure/__init__.py", line 214, in enable_autolock
self.session.set_lock_config(device_id, auto_lock_enabled=True)
File "/usr/local/lib/python3.7/site-packages/verisure/session.py", line 394, in set_lock_config
_validate_response(response)
File "/usr/local/lib/python3.7/site-packages/verisure/session.py", line 16, in _validate_response
raise ResponseError(response.status_code, response.text)
File "/usr/local/lib/python3.7/site-packages/verisure/session.py", line 43, in __init__
self.text = json.loads(text)
File "/usr/local/lib/python3.7/json/__init__.py", line 348, in loads
return _default_decoder.decode(s)
File "/usr/local/lib/python3.7/json/decoder.py", line 337, in decode
obj, end = self.raw_decode(s, idx=_w(s, 0).end())
File "/usr/local/lib/python3.7/json/decoder.py", line 355, in raw_decode
raise JSONDecodeError("Expecting value", s, err.value) from None
json.decoder.JSONDecodeError: Expecting value: line 1 column 1 (char 0)
2019-11-09 22:26:59 DEBUG (MainThread) [homeassistant.components.websocket_api.http.connection.139740416218768] Sending {'id': 18, 'type': 'result', 'success': False, 'error': {'code': 'unknown_error', 'message': 'Expecting value: line 1 column 1 (char 0)'}}