I have no idea how to even go about getting the fix in. Also, the cobbled together ‘fix’ is more a workaround and I don’t know if it will even work with switches that have the older firmware.
We kind of need someone who actually knows what they are doing to come and have a look at it and maybe try to turn it into a usable end product.
@mattyman : Thank you so much. have proceed 1 step further. now it throws following error. I am on pi3. I dont know where the smartdevice.py is stored and there is no file locations as /usr/local/lib/python3.6/site-packages/pyHS100/
2018-04-19 18:39:34 ERROR (MainThread) [homeassistant.components.switch] tplink: Error on device update!
Traceback (most recent call last):
File “/usr/lib/python3.6/site-packages/homeassistant/helpers/entity_platform.py”, line 188, in _async_add_entity
await entity.async_device_update(warning=False)
File “/usr/lib/python3.6/site-packages/homeassistant/helpers/entity.py”, line 327, in async_device_update
yield from self.hass.async_add_job(self.update)
File “/usr/lib/python3.6/concurrent/futures/thread.py”, line 56, in run
result = self.fn(*self.args, **self.kwargs)
File “/config/custom_components/switch/tplink.py”, line 122, in update
emeter_statics = self.smartplug.get_emeter_daily()
File “/usr/lib/python3.6/site-packages/pyHS100/smartdevice.py”, line 417, in get_emeter_daily
for entry in response[‘day_list’]}
File “/usr/lib/python3.6/site-packages/pyHS100/smartdevice.py”, line 417, in
for entry in response[‘day_list’]}
KeyError: ‘energy’
I’ve successfully applied this change to both Windows and Raspberry Pi setups. Try installing tplink.py directly over the switch component file instead of in custom_components. At least that is what I did.
When I have some time I will debug this and see if I can make a proper fix for submission.
So i took these changes, with some slight modifications, and turned then into full blown custom components, but even then i get the Error on device update issue
Unfortunately, if i overwrite the existing classes, it makes the HS100’s i ALSO have not work
Oh dear: I’ve just seen this thread and it’s not what I wanted to see on a Sunday morning! I am about to do a product review of the HS110 and it working with HA. I have never had any problems with mine, which is one of reasons I am recommending it to my followers/viewers. That being said, I have had my unit for well over a year and so it will be old firmware that isn’t affected (I only read up to about post 20/65 so I may have it wrong).
It looks like my video is not getting done today while I research this and maybe find a new energy monitoring socket to test/review/recommend.
I was looking for a good value device and thought the tplink would be the one, but no. If your review comes up with a good alternative, do please let us know or point us at your review?
This has been fixed in git of pyhs100, so that’ll be fine in the future
Regarding to fixing this properly, there is this partial patch/PR from me, but unfortunately I haven’t had time to finish it to include historical records. So if here’s someone who wants to step in and make it happen it’d be very welcome, but if not, I’ll try to look into it again at some point. The only reasonable way to fix this is not by creating partially working custom components, but fix it in upstream.
Because i have a mixture of HS100s and HS110s, all the manual patching suggested in these threads breaks the 100s
For the time being ive just setup the 110 I have as a rest switch, connected to the TP Link cloud API. Atleast that way I can use it as a switch (albeit an expensive one!)
Can you put up the config for the rest switch for the 110 please.
I must have misunderstood something as my hassio build doesn’t seem to have a smartdevice.py anywhere on the pi at all. I have added the switch component, so I get the ‘energy’ error rather than the ‘power’ error now but not sure what to do now.
For those who have issues, the latest is that there is a fix to the underlying pyHS100 module. So you no longer need to patch any HA tplink files (they will be overwritten with the latest update anyhow).
See here:
After upgrading HA just overwrite the two files in this commit and all is well. Next version of pyHS100 should include these fixes so hopefully this is the last patch for this issue.
I’ve come back to this subject today after a while and the HS switch itself comes up fine which is excellent news. However the suggestions on https://www.home-assistant.io/components/switch.tplink/ to set up sensors gives me very odd numbers. The switch is on for about 7 hours a day and has been on for many days - with the switch off at the moment and doing nothing, I get:
Current Consumption 283233.0
Current 292.0
Total Consumption -0.0010
Todays Consumption 0
Voltage 971
This is version 1.2.10 of the firmware
Has anyone managed to find a way to get correct values displayed?