No problem, while it could be done in NodeRED, it’s a pretty complex solution to a simple problem.
The easiest option would be to roll back to an older version of HA with the old TP link components if you need a short term fix.
No problem, while it could be done in NodeRED, it’s a pretty complex solution to a simple problem.
The easiest option would be to roll back to an older version of HA with the old TP link components if you need a short term fix.
does interval_seconds work?
tplink:
switch:
- host: 192.168.2.35
interval_seconds: 5
I tried this, and it did not work. I only want a single energy monitor outlet switch (TP-Link model HS-110) to poll fast. I have it connected to an old Bose sound system controlled with an IR blaster, and on/off is a toggle - so to tell if it is on or off I have implemented a sensor switch that bases it’s state on the energy use of the bose sound system. But I don’t want to wait 30 seconds to figure out if it is on or not - so I want to poll it fast, and I cannot figure out how to do it in 0.89.1
Error is: Invalid config for [tplink]: [interval_seconds] is an invalid option for [tplink]. Check: tplink->tplink->switch->0->interval_seconds. (See /home/homeassistant/.homeassistant/configuration.yaml, line 426). Please check the docs at https://home-assistant.io/components/tplink/
Update: I was able to get the scan interval to 5 seconds using customize.
customize_glob:
switch.bose_amp:
scan_interval: 5
# interval_seconds: 5
I tried both and config check did not complain, but the scan_interval:5 works fine with config (if I look at the switch card it shows a scan interval of 5)
Update 2: Config accepts it, and the switch card shows scan_interval is 5, but the actual scan interval is still slow (30 seconds). Same is true with interval_seconds: 5 specified. It shows up as an attribute in the switch card (in the web ui) but the scan interval remains at 30 seconds.
I perhaps misunderstood, I thought we were talking about the presence detection tp-link component, which is why I suggested that interval_seconds might be relevant.
My stable PI is running the previous release. I have a “Test pi” that I test every new release on to see if it functions as I need it to, and to figure out how to get any breaking changes fixed. the term “happy wife, happy life” prompted this lol.
I had an automation that checked the power usage of a switch every 3 seconds, and did something when over a certain usage. With this new component, that automation reacts much more slowly.
From @Bruce0’s testing it looks like this isn’t possible any more. Anyone else have any ideas? Does this need to be added as a feature request?
Inserting scan_interval and interval_seconds does not work (and oddly seems to cause my HS-110 to go offline too). However there is a solution for most of us:
https://github.com/home-assistant/home-assistant/issues/21768#issuecomment-470959458
Call the service homeassistant.update_entity , it does update the power usage immediately (the HS-110 does some internal averaging so it takes 2 to 3 seconds for the power use feedback to fall (although turn-on feedback seems immediate).
In comment referenced @ljmerza creates a scanning operation by running an automation every 5 seconds. But for me, I just updated the automation that required the data to do the homeassistant.update prior to trying to turn on the switch (if I was turning off I would insert a 3 second delay). So now I am not fast polling but the test of whether the bose system is on works fine so overall performance has improved with no fast polling.
Thanks for the info, @Bruce0, I was able to get everything working as it was before!
Here is my updated automation config, if anyone’s interested:
- alias: Turn off Air Purifier when loud
trigger:
- platform: time_pattern
seconds: '/3' # every 3 seconds
action:
- service: homeassistant.update_entity
data:
entity_id: switch.air_purifier
- condition: or
conditions:
condition: numeric_state
entity_id: switch.air_purifier
above: '15'
value_template: '{{ state.attributes.current_power_w }}'
- service: switch.turn_off
data:
entity_id: switch.air_purifier
- delay: 0:00:01
- service: switch.turn_on
data:
entity_id: switch.air_purifier
You might find a template switch helpful. Using that switch (which is conditional based upon the result of the “current_power_w”, you can then avoid polling. I just call the homeassistant.update before turning a switch on or off (Havent yet figured out how to build that into the template switch) which makes my automations read a lot simpler.
# sensing template switch for bose Cinemate II
- platform: template
switches:
power_bose:
value_template: '{{ states.switch.bose_amp.attributes.current_power_w > "1.50" }}'
turn_on:
service: homeassistant.turn_on
data:
entity_id: switch.power_bose_hidden
turn_off:
service: homeassistant.turn_off
data:
entity_id: switch.power_bose_hidden
icon_template: >-
{% if states.switch.bose_amp.attributes.current_power_w > "1.50" %}
mdi:speaker
{% else %}
mdi:speaker-off
{% endif %}
@Bruce0 could you elaborate a bit on “I just call the homeassistant.update before turning a switch on or off” ?
I am currently trying to have an automation whenever my record player (connected to the TP-Link plug) turns on (meaning when the plug registers current_power_w > 1.5). But currently the HA pulls every 30 seconds, and unless I create a running timer (every 2 seconds) I am not sure how else I could catch the “before turning the switch on-off”.
Key element here is that I want to turn the record player on/off, and not the plug
Hey I figured out a node red solution to this tp link problem that works for me. I have a poll state node, on my switch that is set to poll every 3 seconds it then goes to a [current state] node with domain: home assistant and the service update_entity: switch.tplink then a [RBE] Node then [switch] node then call service to a lamp on or off depending on the original state. it is not the best and i doubt polling is the best thing but its better than the 30 plus seconds i have to wait to get this thing to work originally
@ AlexKalopsia Apologies for the very long delay, I have been away. Here is an example, the first service assures that the status the switch is currently reporting is used.
- service: homeassistant.update_entity
data:
entity_id:
- switch.bose_amp
- service: python_script.turn_on_blind_toggle
data_template:
{ "entity_id": "switch.power_bose" }
- service: homeassistant.turn_off
data:
entity_id: input_boolean.movie_time
I’m a little late to the party, but I thought I’d share what was ultimately the solution for me.
It involved creating the following automation to manually update the state on a predetermined interval for the switches that I specified.
- id: update_tp_link
initial_state: 'on'
trigger:
- platform: time_pattern
seconds: '/5' # every 5 seconds
action:
- service: homeassistant.update_entity
data:
entity_id:
- light.tp_link_light1
- light.tp_link_light
All thanks to ljmerza who posted this solution on GitHub.
i’m super new to HA. my coding level is like a 4/10. i’m trying to do a similar thing to OP, i have a switch, when i turn it on, i want a group of switches to come on, and then also a group of switches turn off when the switch is off.
i did it, no problem, but there is a 20-30 second delay which is just really annoying and confusing to guest who will turn the light on and off a few times thinking my system is broken.
my biggest question, is where am i typing this in. i know its a super noob question but i’ve been at this for about 2 weeks and the documentation is very limited (mainly navigation of home assistant)
i added the add-on file editor, i typed in a similar line to this:
customize_glob:
switch.light_1:
scan_interval: 5
i get an error for project name. i guess i’m just asking if anyone can link me or just really dumb down the basic starting point of where to and how to change my scan interval for my TP link switch.
i’m a visual person and i haven’t seen a solid sketch to give me a road map. thanks
on the TP link side, 24 hs200s and 3 hs220s, about to be 3, 3 way switches as well. when I select on the panel on in the ha app, its almost instant. its when you manually toggle the switch, it takes up to 20-30 seconds to show on HA and to trigger the events. as soon as the events register on HA the automation happens. I’ve been reading and apparently the default scan for TP link is 30 seconds. on Smartthings, it was almost 5 min.
ultimately i’m trying to get past the 3 automation limit in the tp link app and also control some off brand lights I have hung around the house.
I would say, get a better switch
I just spent $600+ and 3 days hooking them up. They have potential aside from the shit Kasa app. 3 automations should have been posted in more places or else I would have gone another route. But these are the best looking and go online less than any other switch I’ve tried.
I am running into the same issues. I don’t have quite any many tp link devices (5 currently) but it’s very annoying and frustrating issue. When having tp link connected to my smartthings app, smartthings app notices almost instantly. I physically turn a switch off, the app shows it off within a second or two. I do that same thing with HA and HA will show it off at some point, maybe a minute.
If you’ve figured out a solution or workaround let me know please.
Thanks!
I wish that I would have seen this before I spent a couple of K redoing all of my home with the TPLink switches and dimmers. They seem to work fine other than this. I only have a few that need this function but they are a critical few. The three limit is ridiculous for automation.