jfarmer08 / ha-sengledapi

Home Assistant Integration for Sengled Bulbs. This is a custom component to allow control of Sengled Bulbs in Homeassistant using the unofficial Sengled API. Please note this mimics the Sengled app and therefore Sengled may cut off access at anytime.
Apache License 2.0
104 stars 34 forks source link

[Bug] #49

Closed jc1483 closed 2 years ago

jc1483 commented 2 years ago

Describe the bug

API crash on component initialization - device request

To Reproduce Steps to reproduce the behavior:

  1. Installed and configured as directed.
  2. Restart HA

Expected behavior

SengledAPI to start normally and list bulbs normally.

System configuration System: Home Assistant OS in VM HA Version: core-2021.9.7 SengledApi Version: 0.2 as listed in the manifest

configuration.yaml

#Configure a default setup of Home Assistant (frontend, api, etc)
default_config:

# Text to speech
tts:
  - platform: google_translate

group: !include groups.yaml
...
...

# Sengled API stuff
sengledapi:
  username: <my actual username>
  password: <my password>
  country: us
  wifi: false

#Logger
logger:
  default: warning
  logs:
    custom_components.sengledapi: debug 

home-assistant.log

2021-09-22 17:05:46 WARNING (SyncWorker_1) [homeassistant.loader] We found a custom integration sengledapi which has not been tested by Home Assistant. This component might cause stability problems, be sure to disable it if you experience issues with Home Assistant
2021-09-22 17:05:46 WARNING (SyncWorker_0) [homeassistant.loader] We found a custom integration hacs which has not been tested by Home Assistant. This component might cause stability problems, be sure to disable it if you experience issues with Home Assistant
2021-09-22 17:05:55 INFO (MainThread) [custom_components.sengledapi.sengledapi.devices.bulbs.bulb] SengledApi: Initializing Bulbs
2021-09-22 17:05:55 INFO (MainThread) [custom_components.sengledapi.sengledapi.devices.request] SengledApi: Initializing Request
2021-09-22 17:05:55 INFO (MainThread) [custom_components.sengledapi]
-------------------------------------------------------------------
Sengled Bulb Home Assistant Integration Created from Config
Version: v0.2
This is a custom integration
If you have any issues with this you need to open an issue here:
https://github.com/jfarmer08/ha-sengledapi
-------------------------------------------------------------------
2021-09-22 17:05:55 INFO (MainThread) [custom_components.sengledapi] Creating new SengledApi component
2021-09-22 17:05:55 INFO (MainThread) [custom_components.sengledapi.sengledapi.sengledapi] Sengled Api initializing.
2021-09-22 17:05:55 INFO (MainThread) [custom_components.sengledapi.sengledapi.sengledapi] Sengled Api initializing async.
2021-09-22 17:05:55 INFO (MainThread) [custom_components.sengledapi.sengledapi.sengledapi] Sengledapi: Login
2021-09-22 17:05:55 INFO (MainThread) [custom_components.sengledapi.sengledapi.sengledapi] SengledApi: Login Request.
2021-09-22 17:05:55 INFO (MainThread) [custom_components.sengledapi.sengledapi.devices.request] SengledApi: Sengled Request initializing.
2021-09-22 17:05:55 INFO (MainThread) [custom_components.sengledapi.sengledapi.devices.request] SengledApi: Get Login Response async.
2021-09-22 17:05:56 DEBUG (MainThread) [custom_components.sengledapi.sengledapi.devices.request] SengledApi: Get Login Response {'ret': 2, 'msg': '用户名或密码错误', 'customerId': None, 'mobileId': None, 'nick_name': '', 'relative_path': '', 'jsessionId': '', 'ucenterAddr': '', 'appServerAddr': '', 'serAddressess': None, 'privacyPolicyStatus': None}
2021-09-22 17:05:56 DEBUG (MainThread) [custom_components.sengledapi.sengledapi.sengledapi] SengledApi Login {'ret': 2, 'msg': '用户名或密码错误', 'customerId': None, 'mobileId': None, 'nick_name': '', 'relative_path': '', 'jsessionId': '', 'ucenterAddr': '', 'appServerAddr': '', 'serAddressess': None, 'privacyPolicyStatus': None}
2021-09-22 17:05:56 INFO (MainThread) [custom_components.sengledapi] SengledApi Connected to Sengled account
2021-09-22 17:05:56 DEBUG (MainThread) [custom_components.sengledapi.sengledapi.sengledapi] SengledApi: Get Devices.
2021-09-22 17:05:56 INFO (MainThread) [custom_components.sengledapi.sengledapi.devices.request] SengledApi: Sengled Request initializing.
2021-09-22 17:05:57 INFO (MainThread) [custom_components.sengledapi.sengledapi.devices.request] SengledApi: Sengled Request initializing.
2021-09-22 17:05:57 WARNING (MainThread) [homeassistant.util.async_] Detected I/O inside the event loop. This is causing stability issues. Please report issue to the custom component author for sengledapi doing I/O at custom_components/sengledapi/sengledapi/devices/request.py, line 40: r = requests.post(self._url, headers=self._header, data=self._payload)
2021-09-22 17:05:57 ERROR (MainThread) [homeassistant.setup] Error during setup of component sengledapi
Traceback (most recent call last):
File "/config/custom_components/sengledapi/sengledapi/sengledapi.py", line 253, in async_do_request
return await Request(url, payload).async_get_response(jsessionId)
File "/config/custom_components/sengledapi/sengledapi/devices/request.py", line 57, in async_get_response
data = await resp.json()
File "/usr/local/lib/python3.9/site-packages/aiohttp/client_reqrep.py", line 1097, in json
raise ContentTypeError(
aiohttp.client_exceptions.ContentTypeError: 0, message='Attempt to decode JSON with unexpected mimetype: ', url=URL('https://element.cloud.sengled.com/zigbee/device/getDeviceDetails.json')
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "/usr/src/homeassistant/homeassistant/setup.py", line 255, in _async_setup_component
result = await task
File "/config/custom_components/sengledapi/__init__.py", line 64, in async_setup
sengledapi_devices = await sengledapi_account.async_get_devices()
File "/config/custom_components/sengledapi/sengledapi/sengledapi.py", line 182, in async_get_devices
data = await self.async_do_request(url, payload, SESSION.jsession_id)
File "/config/custom_components/sengledapi/sengledapi/sengledapi.py", line 255, in async_do_request
return Request(url, payload).get_response(jsessionId)
File "/config/custom_components/sengledapi/sengledapi/devices/request.py", line 40, in get_response
r = requests.post(self._url, headers=self._header, data=self._payload)
File "/usr/local/lib/python3.9/site-packages/requests/api.py", line 119, in post
return request('post', url, data=data, json=json, **kwargs)
File "/usr/local/lib/python3.9/site-packages/requests/api.py", line 61, in request
return session.request(method=method, url=url, **kwargs)
File "/usr/local/lib/python3.9/site-packages/requests/sessions.py", line 542, in request
resp = self.send(prep, **send_kwargs)
File "/usr/local/lib/python3.9/site-packages/requests/sessions.py", line 655, in send
r = adapter.send(request, **kwargs)
File "/usr/local/lib/python3.9/site-packages/requests/adapters.py", line 439, in send
resp = conn.urlopen(
File "/usr/local/lib/python3.9/site-packages/urllib3/connectionpool.py", line 699, in urlopen
httplib_response = self._make_request(
File "/usr/local/lib/python3.9/site-packages/urllib3/connectionpool.py", line 394, in _make_request
conn.request(method, url, **httplib_request_kw)
File "/usr/local/lib/python3.9/site-packages/urllib3/connection.py", line 234, in request
super(HTTPConnection, self).request(method, url, body=body, headers=headers)
File "/usr/local/lib/python3.9/http/client.py", line 1279, in request
self._send_request(method, url, body, headers, encode_chunked)
File "/usr/local/lib/python3.9/http/client.py", line 1290, in _send_request
self.putrequest(method, url, **skips)
File "/usr/local/lib/python3.9/site-packages/urllib3/connection.py", line 214, in putrequest
return _HTTPConnection.putrequest(self, method, url, *args, **kwargs)
File "/usr/src/homeassistant/homeassistant/util/async_.py", line 151, in protected_loop_func
check_loop()
File "/usr/src/homeassistant/homeassistant/util/async_.py", line 140, in check_loop
raise RuntimeError(
RuntimeError: I/O must be done in the executor; Use `await hass.async_add_executor_job()` at custom_components/sengledapi/sengledapi/devices/request.py, line 40: r = requests.post(self._url, headers=self._header, data=self._payload)
jc1483 commented 2 years ago

Translated the text and it was a wrong password lol