Hi,
Okay, so are not using the legacy protocol. The recent changes in the PyW215 was only affecting the legacy protocol. It does not change anything for the newer protocol…
And it seems that the issue arises as soon as the first connection to the plug. My suspicion is that it more comes from a change in another library.
One way to confirm it is not the pyW215, is if you can place in the config folder of HASS or HASSIO the following:
Create folders /custom_components/switch/
Add the file dlink.py from there: https://raw.githubusercontent.com/home-assistant/home-assistant/0.52.1/homeassistant/components/switch/dlink.py
Restart HA. It basically forces HA to use the dlink version from HA 0.52.1
Can you please test on an updated version of HA ?
(or else, you could do contrary and try the new version of the dlink on an old version of HA, it would be this dlink file then:
https://raw.githubusercontent.com/home-assistant/home-assistant/0.56.2/homeassistant/components/switch/dlink.py)
Now, to help correctly fix the issue going forward, we would need to understand what exactly go wrong.
If you are able to help us, in the /custom_components/switch/ folder replace the dlink.py file available here: https://pastebin.com/TmentLhN
Also make sure you have this in the configuration.yaml:
logger:
default: error
logs:
custom_components.switch: debug
Restart HA (possibly test under 0.52 and 0.53+)
Paste here the output
Let me know if you need clarifications