TPLINK HS110 switch, use energy consumption as sensor

is your swtich named “switch.tplink_hs100”?

Also do you see the attribute of voltage displayed next to it? I didn’t think the HS100 pulled power info, only the HS110.

No it’s not called anything - does it need to have a ‘friendly name’?
And it is a HS110, I can see current voltage in the pop-up when U click on it - together with total consumption, current consumption, etc.

Plus:
Wow @silvrr - that was easy :-S
I just gave it a name, replaced the string “switch.tplink_hs100” in the template section and now the voltage is showing up :wink:

Awesome work :D.

quick question, if i know how much my power company charges me per kW, would it be possible to calculate a daily cost for example ?

I assume you know the cost per kWh not kW. If so then just create a template sensor and in the template multiply by your cost in kWh using the daily Kwh consumption.

you are correct about the kWh.

so that would then be : value_template: ‘{{ states.switch.tplink_switch_hs110.attributes[“Daily consumption”] | replace(" kW", “”) | float * 0.095}}’ in which 0.095 is the cost in euro per kWh, right ?

Thanks @kirichkov, that’s a pretty neat bit of templating. :smiley:

Some of you maybe interested in voting for the auto-discovery feature request I just created to simplify your configuration.yaml:

I don’t know where you live, but in Europe prices are (including all type of taxes) in the 0,20 range (0,20Euro/KWh = 200 Euro/MWh

Guys, you recommend this plug? Does it sync well the state on/of? Considerin the price, this seems a good option to integrate with HA.

It does sync the state and the underlying library is actively maintained, so software-wise it’s a solid choice. BUT, I’ve encountered occasional crashes of the plug itself. It stops responding unless you remove it and re-add it. I think it gets worse if you have severe voltage drops. At a place where electricity was unstable I had to reconnect it every few hours. If the voltage was stable at 230-240V, crashes happen once every few months, which I’d consider acceptable given the price.

My choice was to go with Z-wave plugs, however. They are marginally more expensive in Europe, if you are on the lookout for the Amazon deals.

1 Like

I have a few of them, and they’ve worked flawless for me. So I’d recommend them :+1:t3:

1 Like

I like the plug, but I ran into an issue that I documented here:

I still like the plug, though, and it works reliably for me apart from the issue above which I learned to live with.

Tks for the feedback! Bought one to see how things go! Was a bit apprehensive with kirichkov comentary regarding the restart of the plug. Will give it a try for one month to see how things go.

I’ve also had the recomendation of a sonoff S20 with an firmware replacement, and since it’s quite cheaper I’m considering also buying one just to compare both and decide. In the majority of the plugs I have the monitoring is not that important.

Hi all,

I don’t know why but since few updates ago the template sensor doesn’t work.

If I click on the switch info I see all the infos (consuption etc) but none of them are avaible in the template sensor.

Here’s the code:

  - platform: template
    sensors: 
      tp_link_amps:
        value_template: '{{ states.switch.presa_smart.attributes["Current"] | replace(" A", "") | float }}'
        unit_of_measurement: 'A'
      tp_link_watts:
        value_template: '{{ states.switch.presa_smart.attributes["Current consumption"] | replace(" W", "") | float }}'
        unit_of_measurement: 'W'
      tp_link_kwd:
        value_template: '{{ states.switch.presa_smart.attributes["Daily consumption"] | replace(" kW", "") | float }}'
        unit_of_measurement: 'kW'
      tp_link_kwt:
        value_template: '{{ states.switch.presa_smart.attributes["Total consumption"] | replace(" kW", "") | float }}'
        unit_of_measurement: 'kW'
      tp_link_kwdh:
        value_template: '{{ states.switch.presa_smart.attributes["Daily consumption"] | replace(" kW", "") | float * 0.20}}'
        unit_of_measurement: '€'
      tp_link_volts:
        value_template: '{{ states.switch.presa_smart.attributes["Voltage"] | replace(" V", "") | float }}'
        unit_of_measurement: 'V'

Can someone please help me ?

Thank you in advance!

It was a breaking change is 0.55

TP-Link Switch: Attribute names now uses underscores and unnecessary capitalization was removed. (@djchen - #9607) (switch.tplink docs) (breaking change)

3 Likes

it worked! Thank you very much!

Hi, maybe I’m stupid but I can’t make my HS110 work since the last upgrades. The switch works and I can opperate it from HA, but I’cant see any values besides on/off.

So, in my sensors.yaml it looks like this:

  - platform: template
    name: Termo
    sensors:
    tp_link_amps:
      value_template: '{{ states.switch.termo.attributes["current"] | replace(" A", "") | float }}'
      unit_of_measurement: 'A'
    tp_link_watts:
      value_template: '{{ states.switch.termo.attributes["current_consumption"] | replace(" W", "") | float }}'
      unit_of_measurement: 'W'
    tp_link_kw:
      value_template: '{{ states.switch.termo.attributes["total_consumption"] | replace(" kW", "") | float }}'
      unit_of_measurement: 'kW'
    tp_link_volts:
      value_template: '{{ states.switch.termo.attributes["voltage"] | replace(" V", "") | float }}'
      unit_of_measurement: 'V'

and in the switch.yaml it looks like:

- platform: tplink
  host: !secret iptermo
  name: "Termo"

Also, the group is:

termo_info:
name: Termo
icon: mdi:hot-tub
view: yes
entities:
- group.Termo

Termo:
- sensor.tp_link_current_consumption
- sensor.tp_link_watts
- sensor.tp_link_kw
- sensor.tp_link_volts

I can’t find what is wrong with that

1 Like

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.