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

Can view state but not update state #46

Closed deroses closed 3 years ago

deroses commented 3 years ago

Thank you for creating this integration!

Describe the bug I followed the directions and can see my lights and their current state, but if I attempt to toggle the state it reverts itself after about one second.

To Reproduce I followed the install instructions and then enabled the devices. Then I went to the dashboard, where they were all there. But attempting to toggle any device does not change the state.

Expected behavior If bulb is off and the toggle is moved to on, the bulb turns on :)

System configuration System: HASS.IO on RPi 3b+ HA Version: supervisor-2021.06.3, core-2021.6.6 SengledApi Version: v0.2.1

configuration.yaml

sengledapi:
  username: [email-here]
  password: [pw-here]
  country: 1 {also attempted USA}
  wifi: true

home-assistant.log

2021-06-22 11:05:50 ERROR (MainThread) [homeassistant] Error doing job: Task exception was never retrieved
Traceback (most recent call last):
  File "/usr/local/lib/python3.8/site-packages/aiohttp/connector.py", line 999, in _create_direct_connection
    hosts = await asyncio.shield(host_resolved)
  File "/usr/local/lib/python3.8/site-packages/aiohttp/connector.py", line 865, in _resolve_host
    addrs = await self._resolver.resolve(host, port, family=self._family)
  File "/usr/local/lib/python3.8/site-packages/aiohttp/resolver.py", line 31, in resolve
    infos = await self._loop.getaddrinfo(
  File "/usr/local/lib/python3.8/asyncio/base_events.py", line 825, in getaddrinfo
    return await self.run_in_executor(
  File "/usr/local/lib/python3.8/concurrent/futures/thread.py", line 57, in run
    result = self.fn(*self.args, **self.kwargs)
  File "/usr/local/lib/python3.8/socket.py", line 918, in getaddrinfo
    for res in _socket.getaddrinfo(host, port, family, type, proto, flags):
socket.gaierror: [Errno -2] Name does not resolve
The above exception was the direct cause of the following exception:
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 54, in async_get_response
    async with session.post(
  File "/usr/local/lib/python3.8/site-packages/aiohttp/client.py", line 1117, in __aenter__
    self._resp = await self._coro
  File "/usr/local/lib/python3.8/site-packages/aiohttp/client.py", line 520, in _request
    conn = await self._connector.connect(
  File "/usr/local/lib/python3.8/site-packages/aiohttp/connector.py", line 535, in connect
    proto = await self._create_connection(req, traces, timeout)
  File "/usr/local/lib/python3.8/site-packages/aiohttp/connector.py", line 892, in _create_connection
    _, proto = await self._create_direct_connection(req, traces, timeout)
  File "/usr/local/lib/python3.8/site-packages/aiohttp/connector.py", line 1011, in _create_direct_connection
    raise ClientConnectorError(req.connection_key, exc) from exc
aiohttp.client_exceptions.ClientConnectorError: Cannot connect to host usa-elements.cloud.sengled.com:443 ssl:<ssl.SSLContext object at 0x6a7d0f10> [Name does not resolve]
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
  File "/usr/local/lib/python3.8/site-packages/urllib3/connection.py", line 169, in _new_conn
    conn = connection.create_connection(
  File "/usr/local/lib/python3.8/site-packages/urllib3/util/connection.py", line 73, in create_connection
    for res in socket.getaddrinfo(host, port, family, socket.SOCK_STREAM):
  File "/usr/local/lib/python3.8/socket.py", line 918, in getaddrinfo
    for res in _socket.getaddrinfo(host, port, family, type, proto, flags):
socket.gaierror: [Errno -2] Name does not resolve
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
  File "/usr/local/lib/python3.8/site-packages/urllib3/connectionpool.py", line 699, in urlopen
    httplib_response = self._make_request(
  File "/usr/local/lib/python3.8/site-packages/urllib3/connectionpool.py", line 382, in _make_request
    self._validate_conn(conn)
  File "/usr/local/lib/python3.8/site-packages/urllib3/connectionpool.py", line 1010, in _validate_conn
    conn.connect()
  File "/usr/local/lib/python3.8/site-packages/urllib3/connection.py", line 353, in connect
    conn = self._new_conn()
  File "/usr/local/lib/python3.8/site-packages/urllib3/connection.py", line 181, in _new_conn
    raise NewConnectionError(
urllib3.exceptions.NewConnectionError: <urllib3.connection.HTTPSConnection object at 0x69a3ddf0>: Failed to establish a new connection: [Errno -2] Name does not resolve
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
  File "/usr/local/lib/python3.8/site-packages/requests/adapters.py", line 439, in send
    resp = conn.urlopen(
  File "/usr/local/lib/python3.8/site-packages/urllib3/connectionpool.py", line 755, in urlopen
    retries = retries.increment(
  File "/usr/local/lib/python3.8/site-packages/urllib3/util/retry.py", line 574, in increment
    raise MaxRetryError(_pool, url, error or ResponseError(cause))
urllib3.exceptions.MaxRetryError: HTTPSConnectionPool(host='usa-elements.cloud.sengled.com', port=443): Max retries exceeded with url: /zigbee/device/deviceSetOnOff.json (Caused by NewConnectionError('<urllib3.connection.HTTPSConnection object at 0x69a3ddf0>: Failed to establish a new connection: [Errno -2] Name does not resolve'))
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
  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.8/site-packages/requests/api.py", line 119, in post
    return request('post', url, data=data, json=json, **kwargs)
  File "/usr/local/lib/python3.8/site-packages/requests/api.py", line 61, in request
    return session.request(method=method, url=url, **kwargs)
  File "/usr/local/lib/python3.8/site-packages/requests/sessions.py", line 542, in request
    resp = self.send(prep, **send_kwargs)
  File "/usr/local/lib/python3.8/site-packages/requests/sessions.py", line 655, in send
    r = adapter.send(request, **kwargs)
  File "/usr/local/lib/python3.8/site-packages/requests/adapters.py", line 516, in send
    raise ConnectionError(e, request=request)
requests.exceptions.ConnectionError: HTTPSConnectionPool(host='usa-elements.cloud.sengled.com', port=443): Max retries exceeded with url: /zigbee/device/deviceSetOnOff.json (Caused by NewConnectionError('<urllib3.connection.HTTPSConnection object at 0x69a3ddf0>: Failed to establish a new connection: [Errno -2] Name does not resolve'))
bnieves1994 commented 3 years ago

I am experiencing the same issue. I also followed the proper country code as outlined by the readme. I am able to monitor the lights but cannot control any function it just immediately reverts.

bnieves1994 commented 3 years ago

I actually changed the country to "us" How it suggests in the read me and about a half hour later I was able to control the lights.

sengledapi:
  username: your email
  password: !secret sengled_password
  country: us
  wifi: true
deroses commented 3 years ago

@bnieves1994 nice - can confirm that was my issue as well. Thank you!