Decora wifi no longer working

Unfortunately, Leviton support was completely indifferent on the matter saying that this would the a problem with the api and not something at Leviton’s end. They also wondered why I would be using a third party hub (duh…). I have heard rumblings since that other cloud systems are also choosing to become less ‘open’ and pulling people in to their proprietary web.

The final solution was leveraging Boxing Day at Amazon and converting everything to zwave. This has been a total success with no need to rely on a vendor’s cloud back end and has proven to be way more responsive and reliable. Now using a mix of Leviton, Zooz and Inovelli zwave switches, dimmers and receptacles. The Leviton zwave products work very well so i will forgive them. zwave is also not on the (congested) wifi band so again more responsive.

Lesson learned is: Choose zwave over wifi and then build as much of a closed system as you can. That way you are not relying on anyone else or on cloud services and, basic automations will work even without Internet.

1 Like

I was so afraid of this…crap…I have spent so much money on this…14 x $50 USD a pop…if only I knew this was going to be an issue down the line.

Yes, about the same amount of pain here too.

I added the Aeotec zwave stick and replaced a couple items first. That was enough to convince me to switch over.

I might be worth your time to open a ticket with Leviton now. They may have done something about it by now.

So when it goes, this is what I get in the logger.

2020-12-31 18:18:05 WARNING (MainThread) [homeassistant.components.light] Updating decora_wifi light took longer than the scheduled update interval 0:00:30
2020-12-31 18:18:35 WARNING (MainThread) [homeassistant.components.light] Updating decora_wifi light took longer than the scheduled update interval 0:00:30
2020-12-31 18:19:05 WARNING (MainThread) [homeassistant.components.light] Updating decora_wifi light took longer than the scheduled update interval 0:00:30
2020-12-31 18:19:35 WARNING (MainThread) [homeassistant.components.light] Updating decora_wifi light took longer than the scheduled update interval 0:00:30
2020-12-31 18:20:05 WARNING (MainThread) [homeassistant.components.light] Updating decora_wifi light took longer than the scheduled update interval 0:00:30
2020-12-31 18:20:35 WARNING (MainThread) [homeassistant.components.light] Updating decora_wifi light took longer than the scheduled update interval 0:00:30
2020-12-31 18:21:06 WARNING (MainThread) [homeassistant.components.light] Updating decora_wifi light took longer than the scheduled update interval 0:00:30
2020-12-31 18:21:36 WARNING (MainThread) [homeassistant.components.light] Updating decora_wifi light took longer than the scheduled update interval 0:00:30
2020-12-31 18:22:06 WARNING (MainThread) [homeassistant.components.light] Updating decora_wifi light took longer than the scheduled update interval 0:00:30
2020-12-31 18:22:36 WARNING (MainThread) [homeassistant.components.light] Updating decora_wifi light took longer than the scheduled update interval 0:00:30
2020-12-31 18:23:06 WARNING (MainThread) [homeassistant.components.light] Updating decora_wifi light took longer than the scheduled update interval 0:00:30
2020-12-31 18:23:36 WARNING (MainThread) [homeassistant.components.light] Updating decora_wifi light took longer than the scheduled update interval 0:00:30
2020-12-31 18:24:06 WARNING (MainThread) [homeassistant.components.light] Updating decora_wifi light took longer than the scheduled update interval 0:00:30
2020-12-31 18:24:36 WARNING (MainThread) [homeassistant.components.light] Updating decora_wifi light took longer than the scheduled update interval 0:00:30
2020-12-31 18:25:06 WARNING (MainThread) [homeassistant.components.light] Updating decora_wifi light took longer than the scheduled update interval 0:00:30
2020-12-31 18:25:36 WARNING (MainThread) [homeassistant.components.light] Updating decora_wifi light took longer than the scheduled update interval 0:00:30
2020-12-31 18:26:06 WARNING (MainThread) [homeassistant.components.light] Updating decora_wifi light took longer than the scheduled update interval 0:00:30
2020-12-31 18:26:36 WARNING (MainThread) [homeassistant.components.light] Updating decora_wifi light took longer than the scheduled update interval 0:00:30
2020-12-31 18:27:06 WARNING (MainThread) [homeassistant.components.light] Updating decora_wifi light took longer than the scheduled update interval 0:00:30
2020-12-31 18:27:36 WARNING (MainThread) [homeassistant.components.light] Updating decora_wifi light took longer than the scheduled update interval 0:00:30
2020-12-31 18:28:06 WARNING (MainThread) [homeassistant.components.light] Updating decora_wifi light took longer than the scheduled update interval 0:00:30
2020-12-31 18:28:36 WARNING (MainThread) [homeassistant.components.light] Updating decora_wifi light took longer than the scheduled update interval 0:00:30
2020-12-31 18:29:06 WARNING (MainThread) [homeassistant.components.light] Updating decora_wifi light took longer than the scheduled update interval 0:00:30
2020-12-31 18:29:36 WARNING (MainThread) [homeassistant.components.light] Updating decora_wifi light took longer than the scheduled update interval 0:00:30
2020-12-31 18:30:06 WARNING (MainThread) [homeassistant.components.light] Updating decora_wifi light took longer than the scheduled update interval 0:00:30
2020-12-31 18:30:36 WARNING (MainThread) [homeassistant.components.light] Updating decora_wifi light took longer than the scheduled update interval 0:00:30
2020-12-31 18:31:06 WARNING (MainThread) [homeassistant.components.light] Updating decora_wifi light took longer than the scheduled update interval 0:00:30
2020-12-31 18:31:36 WARNING (MainThread) [homeassistant.components.light] Updating decora_wifi light took longer than the scheduled update interval 0:00:30
2020-12-31 18:32:06 WARNING (MainThread) [homeassistant.components.light] Updating decora_wifi light took longer than the scheduled update interval 0:00:30
2020-12-31 18:32:36 WARNING (MainThread) [homeassistant.components.light] Updating decora_wifi light took longer than the scheduled update interval 0:00:30
2020-12-31 18:33:06 WARNING (MainThread) [homeassistant.components.light] Updating decora_wifi light took longer than the scheduled update interval 0:00:30
2020-12-31 18:33:36 WARNING (MainThread) [homeassistant.components.light] Updating decora_wifi light took longer than the scheduled update interval 0:00:30
2020-12-31 18:34:06 WARNING (MainThread) [homeassistant.components.light] Updating decora_wifi light took longer than the scheduled update interval 0:00:30
2020-12-31 18:34:36 WARNING (MainThread) [homeassistant.components.light] Updating decora_wifi light took longer than the scheduled update interval 0:00:30
2020-12-31 18:35:06 WARNING (MainThread) [homeassistant.components.light] Updating decora_wifi light took longer than the scheduled update interval 0:00:30
2020-12-31 18:35:36 WARNING (MainThread) [homeassistant.components.light] Updating decora_wifi light took longer than the scheduled update interval 0:00:30
2020-12-31 18:36:06 WARNING (MainThread) [homeassistant.components.light] Updating decora_wifi light took longer than the scheduled update interval 0:00:30
2020-12-31 18:36:36 WARNING (MainThread) [homeassistant.components.light] Updating decora_wifi light took longer than the scheduled update interval 0:00:30
2020-12-31 18:37:06 WARNING (MainThread) [homeassistant.components.light] Updating decora_wifi light took longer than the scheduled update interval 0:00:30
2020-12-31 18:37:36 WARNING (MainThread) [homeassistant.components.light] Updating decora_wifi light took longer than the scheduled update interval 0:00:30
2020-12-31 18:38:06 WARNING (MainThread) [homeassistant.components.light] Updating decora_wifi light took longer than the scheduled update interval 0:00:30
2020-12-31 18:38:36 WARNING (MainThread) [homeassistant.components.light] Updating decora_wifi light took longer than the scheduled update interval 0:00:30
2020-12-31 18:39:06 WARNING (MainThread) [homeassistant.components.light] Updating decora_wifi light took longer than the scheduled update interval 0:00:30
2020-12-31 18:39:36 WARNING (MainThread) [homeassistant.components.light] Updating decora_wifi light took longer than the scheduled update interval 0:00:30
2020-12-31 18:40:06 WARNING (MainThread) [homeassistant.components.light] Updating decora_wifi light took longer than the scheduled update interval 0:00:30
2020-12-31 18:40:36 WARNING (MainThread) [homeassistant.components.light] Updating decora_wifi light took longer than the scheduled update interval 0:00:30
2020-12-31 18:41:06 WARNING (MainThread) [homeassistant.components.light] Updating decora_wifi light took longer than the scheduled update interval 0:00:30
2020-12-31 18:41:36 WARNING (MainThread) [homeassistant.components.light] Updating decora_wifi light took longer than the scheduled update interval 0:00:30
2020-12-31 18:42:06 WARNING (MainThread) [homeassistant.components.light] Updating decora_wifi light took longer than the scheduled update interval 0:00:30

Yup, that is the behavior. Restarting HA will fix it but it will only last a few hours or perhaps a day or two.

Problems started after the last firmware update from Leviton earlier in the year. I happily updated all switches and it all went south after that. It was subtle at first but it got worse over a few weeks.

When it happens, you will find that you can still control things from the Leviton mobile app just fine but HA is unresponsive or really slow to respond (tens of seconds).

At first, I suspected my network and WiFi. I went from a Pi 3 to a Pi4. I rebuilt my HA instance from scratch. I replaced my router and access points. In the end, I had eliminated every single possibility of hardware or software from the equation.

Leviton only said that it must be a problem with the integration and that their end was fine.

I am going to open an issue in github for HA as I don’t see one addressing it. Do you know if there is a way to restart an integration without restarting HA? I was wondering if I could set a restart in node red when there is this warning.

Created an issue here: https://github.com/home-assistant/core/issues/44734

It looks like people are working on this. Reload integrations indiviudally

wow!! thank you very much!! this would solve some issues across the system. I voted.

I read through all the links. Still can’t figure out if this is coming or already implemented…Github threads confuse me.

I did not try this at the time but it looks like you can reload from Configuration, Integrations, more menu, reload. That would be a good test. To see if that helps.

Not sure if others can verify where the request is in terms of doing it programmatically.

I’m also having this same issue. Has anyone had any movement on it?

Logger: homeassistant.helpers.entity
Source: components/decora_wifi/light.py:143
First occurred: April 17, 2021, 9:21:21 AM (1 occurrences)
Last logged: April 17, 2021, 9:21:21 AM

Update for light.office_light fails
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 445, in _make_request
    six.raise_from(e, None)
  File "<string>", line 3, in raise_from
  File "/usr/local/lib/python3.8/site-packages/urllib3/connectionpool.py", line 440, in _make_request
    httplib_response = conn.getresponse()
  File "/usr/local/lib/python3.8/http/client.py", line 1347, in getresponse
    response.begin()
  File "/usr/local/lib/python3.8/http/client.py", line 307, in begin
    version, status, reason = self._read_status()
  File "/usr/local/lib/python3.8/http/client.py", line 276, in _read_status
    raise RemoteDisconnected("Remote end closed connection without"
http.client.RemoteDisconnected: Remote end closed connection without response

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 532, in increment
    raise six.reraise(type(error), error, _stacktrace)
  File "/usr/local/lib/python3.8/site-packages/urllib3/packages/six.py", line 734, in reraise
    raise value.with_traceback(tb)
  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 445, in _make_request
    six.raise_from(e, None)
  File "<string>", line 3, in raise_from
  File "/usr/local/lib/python3.8/site-packages/urllib3/connectionpool.py", line 440, in _make_request
    httplib_response = conn.getresponse()
  File "/usr/local/lib/python3.8/http/client.py", line 1347, in getresponse
    response.begin()
  File "/usr/local/lib/python3.8/http/client.py", line 307, in begin
    version, status, reason = self._read_status()
  File "/usr/local/lib/python3.8/http/client.py", line 276, in _read_status
    raise RemoteDisconnected("Remote end closed connection without"
urllib3.exceptions.ProtocolError: ('Connection aborted.', RemoteDisconnected('Remote end closed connection without response'))

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 292, in async_update_ha_state
    await self.async_device_update()
  File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 498, in async_device_update
    await task
  File "/usr/local/lib/python3.8/concurrent/futures/thread.py", line 57, in run
    result = self.fn(*self.args, **self.kwargs)
  File "/usr/src/homeassistant/homeassistant/components/decora_wifi/light.py", line 143, in update
    self._switch.refresh()
  File "/usr/local/lib/python3.8/site-packages/decora_wifi/models/iot_switch.py", line 87, in refresh
    result = self._session.call_api(api, {}, 'get')
  File "/usr/local/lib/python3.8/site-packages/decora_wifi/__init__.py", line 48, in call_api
    response = getattr(self._session, method)(uri, data=payload_json)
  File "/usr/local/lib/python3.8/site-packages/requests/sessions.py", line 555, in get
    return self.request('GET', 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 498, in send
    raise ConnectionError(err, request=request)
requests.exceptions.ConnectionError: ('Connection aborted.', RemoteDisconnected('Remote end closed connection without response'))

Glad I came across this thread. I recently installed Leviton Decora dimmers and was considering Home Assistant, but it looks like the support in HA no longer works with the current Leviton products.

I do still use Decora dimmers and in-wall receptacles in the mix but I have moved to Zwave and the replacement Decora products are now Zwave too.

The benefit with Zwave is, that it is a closed system and doesn’t rely on the cloud. Concerns over safety, outages, etc. all are gone.

There are always going to be challenges with any vendor and cloud as their focus is on their products rather than the larger community of users. TP-Link also left HA users in a similar after they added 'security to their devices and locked HA out.

I would encourage everyone to take the time to learn about Zwave in Home Assistant and now that Zwave JS is mature, that is pretty easy. That way as you expand your system, you can have a mix of WiFi and Zwave :slight_smile:

Update - the current Decora dimmers (2nd generation) work with HomeKit. I added them to HA with the Homekit integration and so far, works reliably.

I was having trouble with my Leviton Decora DW15S-1BZ switches (1st gen) and thought maybe Leviton changed the APIs and broke the python-decora_wifi that Home Assistant uses under the covers. I cloned down the repo and was able to run the cli-test.py just fine (it turns on every light in the house, probably shouldn’t have done that at 2AM!). So at least the hard part of the Leviton / Home Assistant integration should be in good shape still. I enabled debug logging in Home Assistant to investigate further, but after a restart Home Assistant is able to control these switches again. I’ll leave the logging enabled and see if it reveals anything interesting if it stops working again.

I was also able to get the Leviton switch working using the HomeKit integration. When you add it using the leviton_wifi, it is added as a light. Through HomeKit though, its actually added as a switch. The response is instantaneous.

I lost function of all my decora switches a couple days ago. Restarting HA would only see the decora_wifi component fail after 60 seconds of trying.
I am really a complete amatuer but did some digging and found another decora_wifi on github (GitHub - markcaldwell0017/python-decora_wifi-cli: Leviton Decora wifi switch command line interface, written in Python.) and downloaded the repository to try the scripts manually from a windows 11 machine.
Anyway, after modifying the __init__.py file, I was able to connect. On a whim, I created a “decora_wifi” folder in the “custom_components” folder of HA, and placed the modified __init__.py file in there and restarted.

All the lights are visible and controllable again. I do realize that this may just be a happy coincidence. I hope that it is not, and that this may fix the issue for others.

Not sure if I can add as an attachment so here is the content of the __init__.py file

# Python module for controlling Leviton Decora Smart WiFi Switches
# Reverse engineered from the myLeviton Android app.
#
# Copyright 2017 Tim Lyakhovetskiy <[email protected]>
#
# This code is released under the terms of the MIT license. See the LICENSE
# file for more details.

import json

import requests

from .person import Person


class DecoraWiFiSession:
    """This class represents an authorized HTTPS session with the LCS API."""

    LEVITON_ROOT = 'https://my.leviton.com/api'

    def __init__(self):
        """Initialize the session, all content is JSON."""
        self._session = requests.Session()
        """self._session.verify = False"""
        self._session.headers.update({'Content-Type': 'application/json'})
        self._email = None
        self._password = None
        self.user = None

    def call_api(self, api, payload=None, method='get'):
        """Generic method for calling LCS REST APIs."""
        # Sanity check parameters first...
        if (method != 'get' and method != 'post' and
           method != 'put' and method != 'delete'):
            msg = "Tried decora.call_api with bad method: {0}"
            raise ValueError(msg.format(method))

        if self.user is None and api != '/Person/login':
            raise ValueError('Tried an API call without a login.')

        uri = self.LEVITON_ROOT + api

        # Payload is always JSON
        if payload is not None:
            payload_json = json.dumps(payload)
        else:
            payload_json = ''

        response = getattr(self._session, method)(uri, data=payload_json)

        # Unauthorized
        if response.status_code == 401 or response.status_code == 403:
            # Maybe we got logged out? Let's try logging in.
            self.login(self._email, self._password)
            # Retry the request...
            response = getattr(self._session, method)(uri, data=payload_json)

        if response.status_code != 200 and response.status_code != 204:
            msg = "myLeviton API call ({0}) failed: {1}, {2}".format(
                          api, response.status_code, response.text)
            raise ValueError(msg)

        if response.text is not None and len(response.text) > 0:
            return json.loads(response.text)
        else:
            return None

    def login(self, email, password):
        """Login to LCS & save the token for future commands."""
        payload = {
            'email': email,
            'password': password
        }

        login_json = Person.login(self, payload)

        if login_json is None:
            return None

        self._session.headers.update({'authorization': login_json['id']})
        self._email = email
        self._password = password
        self.user = Person(self, login_json['userId'])
        self.user.refresh()

        return self.user
1 Like

I’ve been seeing this issue for a few years now.
Sometimes when I restart my HA container, I loose the Leviton lights; but usually I can just restart again and get them back. Today no luck. I also have nothing in the logs for Leviton, just the “Home Assistant is starting, not everything may be available yet” blurb on my buttons that never goes away.

Well after the 5th restart I have them back.
I am trying to go as much local control as possible because of issues like this. I have slowly moving over to Zwave light switches but it takes time and money.

1 Like

I have found once every two months or so I see the dreaded:

[homeassistant.components.light] Updating decora_wifi light took longer than the scheduled update interval

I got a chance to attach a debugger this time and found that the underlying decora_wifi library was getting stuck indefinitely making a routine API call. I sent a PR to add a timeout which should hopefully fix this issue if we can get it released: Add 15sec request timeout to all API calls, fixing indefinite hangs by mitchsw · Pull Request #22 · tlyakhov/python-decora_wifi · GitHub. :crossed_fingers:

2 Likes