TPLINK HS110 switch, use energy consumption as sensor

The code looks exactly the same as mine (apart from I don’t hide the IP address in a separate file).

Not sure why it doesn’t work, maybe try adding the IP address there, or checking the link to the .yaml file containing the IP address, or even checking the smart plug still has that IP address?

Did you by any chance upgrade the firmware of the switch? I’ve seen people running firmware 2.0 on their switches, and firmware 2.0 is not compatible (yet) with the library that handles the communication with the switch. Load the Kasa app and check out the firmware version - 1.0.8 and I think 1.1.0 are known to work.

Just as an FYI: my HS110s are working fine on firmware version 1.2.2.

Nevermind, the plug wasn’t reporting to the app neither, so I restarted the plug and is working like a charm right now.

I’ve noticed that if the grid’s voltage is not stable and has sudden drops the switch becomes unresponsive until it’s restarted. Maybe that’s what happened in your case.

My “laundry started” and “laundry done” notification automations were working fine for months and then I noticed I stopped getting notifications. I checked and it was because my sensors stopped working. The sensors are just like Nelbu’s.

It the switch attribute I can see the instantaneous measurements, but the sensors aren’t showing anything. I’ve tried restarting the switch twice. My friend also has a TP-Link switch and noticed the same thing as me.

I am on firmware 1.0.8. It looks like the problem is the syntax of the switch itself. Can anyone with working sensors confirm if mine are correct?

  - platform: template
        value_template: '{{ states.switch.washing_machine.attributes["Current"] | replace(" A", "") | float }}'
        unit_of_measurement: 'A'
        friendly_name: 'Washing Machine'
        value_template: '{{ states.switch.washing_machine.attributes["Current consumption"] | replace(" W", "") | float }}'
        unit_of_measurement: 'W'
        friendly_name: 'Washing Machine'
        value_template: '{{ states.switch.washing_machine.attributes["Total consumption"] | replace(" kW", "") | float }}'
        unit_of_measurement: 'kW'
        friendly_name: 'Washing Machine'
        value_template: '{{ states.switch.washing_machine.attributes["Voltage"] | replace(" V", "") | float }}'
        unit_of_measurement: 'V'
        friendly_name: 'Washing Machine'

A few versions ago the attribute names in the component changed to:

Looks like this needs adjusting in your config.

1 Like

Thanks that worked!

Are you happy with the sensor? The kW meter seems legit?

In principle I’m happy with the sensor, it shows the value for Current Watt nicely and consistently:

The value for Current Amp on the other hand seems to not update that consistently:

Mine was working fine, but for some reason now the values are totally wrong. For example, the Kasa app shows total consumption over today, 7 days and 30 days as 0, 6.64 and 10.1kWh. HA on the other hand, is showing the following values:

total_consumption: 0.72 kW
daily_consumption: 0.00 kW
current_consumption: 0.0 W

No idea where it’s getting 0.72 from…

Would you guys buy it again? At the moment I am deciding which power consumption meter I should buy.

Broadlink SP3S
Sonoff POW, flashed with Tasmota
TP-Link HS110

Somehow I am leaning towards the Sonoff with custom firmware, but I don’t like that I have to add 2 cables and I’ve read that even the replacement models are overheating.

I’m using three of the HS110 with HA without any problems. Totaly recommended.

1 Like

Yeah, I’ve bought quite a few. In fact I usually buy one or two when they go on sale from time to time.

1 Like

Hey! Can anyone point me in the right direction here as I’ve been sat scratching my head a lot!

My config looks like this but I can’t seem to get anything but “unknown” from all items other than the “current” which works fine??

- platform: template
      value_template: '{{ states.switch.tplink_hs100.attributes["daily_consumption"] | replace(" kW", "") | float }}'
      unit_of_measurement: 'kW'
      value_template: '{{ states.switch.tplink_hs110.attributes["current"] | replace(" A", "") | float }}'
      unit_of_measurement: 'A'
      value_template: '{{ states.switch.tplink_hs100.attributes["total_consumption"] | replace(" kW", "") | float }}'
      unit_of_measurement: 'kW'
      value_template: '{{ states.switch.tplink_hs100.attributes["voltage"] | replace(" V", "") | float }}'
      unit_of_measurement: 'V'
      value_template: '{{ states.switch.tplink_hs100.attributes["current_consumption"] | replace(" W", "") | float }}'
      unit_of_measurement: 'W'

Does ant one have any pointers please?


If you’re on the latest release take a look at the release notes for V0.61 - there was a breaking change for the TPLink Switches:

Hey! Thanks for this,

I wasn’t on the the latest but being as it wasn’t working, i thought I’d give it a go and update.

However, same problem?! My new config is:

- platform: template
      value_template: '{{ states.switch.tplink_hs100.attributes["voltage"] }}'
      unit_of_measurement: 'V'
      value_template: '{{ states.switch.tplink_hs110.attributes["current_a"] }}'
      unit_of_measurement: 'A'
      value_template: '{{ states.switch.tplink_hs100.attributes["total_energy_kwh"] }}'
      unit_of_measurement: 'kW'
      value_template: '{{ states.switch.tplink_hs100.attributes["current_power_w"] }}'
      unit_of_measurement: 'W'
      value_template: '{{ states.switch.tplink_hs100.attributes["today_energy_kwh"]}}'
      unit_of_measurement: 'kW'

They match those attributes listed by the switch :

However again, all i seem to get is unknown for everything but the current:

I’m sure I’m just doing something simple stupid but really can’t work out what!!

Can anyone see anything wrong with my config?

1 Like

Ha! Just spotted my own mistake!


should be


bloody typo’s! haha

My config worked fine until the 0.61 update. I read the release notes and updated my config accordingly but it stills says state unknown. Anyone else having the same problem?

Post ya yaml and I’ll look over it if you want :slight_smile:

Post the stuff from your states section and where you setup the switch too. :smile: