home-assistant / core

:house_with_garden: Open source home automation that puts local control and privacy first.
https://www.home-assistant.io
Apache License 2.0
73.24k stars 30.59k forks source link

Cannot set custom scan_interval on new tplink: component #21768

Closed RealGandy closed 5 years ago

RealGandy commented 5 years ago

Home Assistant release with the issue:

0.89

Last working Home Assistant release (if known): 0.88.2

Operating environment (Hass.io/Docker/Windows/etc.):

Windows Component/platform:

tplink Description of problem: With the new tplink component, cannot set custom scan_interval

Problem-relevant configuration.yaml entries and (fill out even if it seems unimportant):

tplink:
  switch:
    - host: 192.168.2.120
    - host: 192.168.2.121
      scan_interval: 15

Traceback (if applicable):

2019-03-07 21:19:15 ERROR (MainThread) [homeassistant.config] Invalid config for [tplink]: [scan_interval] is an invalid option for [tplink]. Check: tplink->tplink->switch->1->scan_interval. (See c:\ProgramData\.homeassistant\configuration.yaml, line 93). Please check the docs at https://home-assistant.io/components/tplink/

Additional information:

ljmerza commented 5 years ago

Is there a reason you need scan_interval? Now that tplink devices are discoverable we don't really need this.

dandelionclock commented 5 years ago

I have some HS210 (3-way switches). Without setting sacn_interval, when I turn on a light in HA, it'll turn on the light, but on HA it'll go back to "off" and takes like 10 seconds before flipping back to "on."

ljmerza commented 5 years ago

is this only for the 3 way switch? I have the HS105 and HS110 and dont have this issue.

dandelionclock commented 5 years ago

I only have the 3-way switch. Same issue happened with the old implementation but setting scan_interval to a low number (eg 2) fixed it

RealGandy commented 5 years ago

Is there a reason you need scan_interval? Now that tplink devices are discoverable we don't really need this.

Yes, I use the power consumption data to drive some automations. For example when the washing machine has finished I send notifications. The logic uses some arithmetic based on last three data points to determine if the drop in consumption is really the end of the cycle or if it is just a pause.

Having to wait for the default scan interval means this automation is much delayed.

Also, none of my plugs are discovered so I have to add them manually. I have HS110s.

rytilahti commented 5 years ago

I don't think there is currently a way to allow changing the scan intervals of componentized platforms. Maybe someone from @home-assistant/core can confirm and propose a solution for this.

For the time being you could add an automation calling homeassistant.update_entity on the entity on regular basis, see https://www.home-assistant.io/docs/scripts/service-calls/#homeassistant-services .

ljmerza commented 5 years ago

yeah i was wondering how you could scan, I didn't see a way it could be added. This will work

- 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
balloob commented 5 years ago

Scan interval is being deprecated, as it was being abused to hammer devices. The integration decides the optimal scan interval for devices.

WorksOnMyBox commented 5 years ago

I don't think this is reasonable. As far as hammering devices, it's my device in my network, so that's my problem. This level of control is the entire reason I'm trying to build my own automation.

In my instance, I have an unused switch in the wall that I replaced with a smart switch, and then tied that by an automation to turn on 3 lamps around the living room. An average 15-20 second delay is completely unacceptable. I'd rather the light switch do a push notification that I could intercept, but that doesn't seem possible.

WorksOnMyBox commented 5 years ago

@ljmerza You are a hero! This will work for me. I've been searching for this for hours. Would be nice if it was listed in the documentation as an update to scan_interval. I'm fine with the method being deprecated as long as I can functionally accomplish the same tasks, which this does!

marc-gist commented 5 years ago

I believe this should be re-opened and scan_interval returned to user controlled if we want it. I like the interval to be rather long, so that some "automatic" method isn't hammering my network. too much can go wrong with automatic settings... for instance, discover doesn't work reliably anyways, and now we have less control that the old 'platform' method that worked well for me!

rytilahti commented 5 years ago

The real solution for this is to document somewhere how to automate forced updates, as this is not a tplink-specific issue. At the moment I'm not sure where the scan_interval is even standardized, can someone point out where the scan_intervalis documented?

ragaskar commented 5 years ago

Yeah, I just got bit by this too -- finally got my tp-link hs220 hooked up to a feit bulb w/ tasmota, and the light takes nearly 10 seconds to turn on from the physical switch (the switch itself is dumb). Not only was it difficult to find the scan_interval solution, I also was disappointed to find out it is no longer supported and I'll need to add this automation to update state, but it would be neater if the parameter was exposed.

In the long run, if it's the same net effect, I guess I don't care, although it feels like a hack if there's an option that could be passed.

jzee commented 4 years ago

this bit me as well. I'm turning on a device and subsequently need to periodically monitor its current consumption to conclude on the state it's in. The way I observe the component's behavior now is that after it ramp down the scan interval over the course of half an hour basically comes to a stop so that the results are completely unusable.

@balloob can you comment on the intended way of how to achieve permanent current monitoring using the component? Would it work to add another device state (e.g. off/on/monitoring) where periodic readouts are possible?

boost4brains commented 4 years ago

so i'll admit i'm super noob on home assistant. i have the same problem as OP, my switch takes too lunch to update status and ruins my automations. i need the physical actation of a switch to be registered faster, or else people just stand there hitting the switch several times thinking its broken.

here is what i input under developer tools>services then i left the service selection tab blank because none of the options seemed to be relevant.

here is all i put, `- id: update_tp_link initial_state: 'off' trigger:

here is the error i recieved:

Failed to call service/null. expected dict for dictionary value @data['service_data']. Got[{'id':'update_tp_link','initial_state':'off','trigger':[{'platform':'time_pattern','seconds':?5}],'action':[{'service':'homeassistant.update_entity','data':{'entity_id':['switch.back_porch_2']}}]}] expected str for dictionary value @ data['service']. Got None

any help or guidance would be greatly appreciated

dandelionclock commented 4 years ago

so i'll admit i'm super noob on home assistant. i have the same problem as OP, my switch takes too lunch to update status and ruins my automations. i need the physical actation of a switch to be registered faster, or else people just stand there hitting the switch several times thinking its broken.

here is what i input under developer tools>services then i left the service selection tab blank because none of the options seemed to be relevant.

here is all i put, - id: update_tp_link initial_state: 'off' trigger: - platform: time_pattern seconds: '/5' # every 5 seconds action: - service: homeassistant.update_entity data: entity_id: - switch.back_porch - switch.back_porch_2

here is the error i recieved:

Failed to call service/null. expected dict for dictionary value @DaTa['service_data']. Got[{'id':'update_tp_link','initial_state':'off','trigger':[{'platform':'time_pattern','seconds':?5}],'action':[{'service':'homeassistant.update_entity','data':{'entity_id':['switch.back_porch_2']}}]}] expected str for dictionary value @ data['service']. Got None

any help or guidance would be greatly appreciated

Shouldn’t that be put in automations.yaml?

boost4brains commented 4 years ago

@dandelionclock i have no idea, which is part of my problem. I’m trying to figure out what to put where to get the results I want. I saw it was a service request so that’s what I tried. Under automations it won’t let me save it.

I tried the scan_interval with glob_config and it showed accepted but still took on average 20 seconds to initiate an automation.

oneseventhree commented 4 years ago

Is there anyway to change the scan interval? My device appears unavailable until I reset the home assistant server

dandelionclock commented 4 years ago

https://community.home-assistant.io/t/tp-link-switches-going-unavailable/62286?page=2

Sent from my iPhone

On Oct 10, 2020, at 22:01, oneseventhree notifications@github.com wrote:

 Is there anyway to change the scan interval? My device appears unavailable until I reset the home assistant server

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub, or unsubscribe.

oneseventhree commented 3 years ago

This worked for me for the longest time but now has stopped working:

alias: TP-Link Switch polling update description: '' trigger:

I am not sure why homeassistant.update_entity doesn't update the plug anymore..

JustACrazy commented 3 years ago

I know this is closed, but this is our network, if we are done to protect ourselves I don't like that. I have a few k invested in tplink switches and need the scan_interval to be set to have a quicker controls on some of my switches.

boost4brains commented 3 years ago

ok so an update after successfully running for upwards of a month.

the only way i could get the constant updating to work was to make an automation that updated every 3 seconds if i did "trigger type" 'time pattern' 3 seconds it would update the status every minute, at the 3 second mark.
i.e. 12:00:03->12:01:03->12:02:03 i researched and researched and never found anyone with the same problem. i even copied, pasted and just change the automation name and my device names and that's still how my TP link switches would update.

so what my fix was: i did the type: time pattern-> 3 second but then made a trigger at 6 sec, 9 sec, 12sec....59 sec. then under action i did call service and used "homeassistant.update_entity" then my switch. i made a service call for each switch that will be used in an automation.

also when i tried to edit in YAML, every time i saved and came back to look at the automation, it was back in UI and would only do one device or trigger. so i had to duplicate the trigger 20 times and change the seconds on all of them. same for the actions(i only have 6 actions as i only need the quick updates for 6 switches)

i hope this helps someone who is also super new. sometimes we forget that not everyone just jumps into open source knowing everything and it helps to start at the basics. this solution worked for me and if someone knows a better way with a decent write up, please attach a link.

side note: i'm only using home assistant for the automation reach around with TP link. i'm using smart things for all my panels and interfaces and with this method of using a mix of HA and ST my system works flawlessly. ST is just more user friendly and more customizable when it comes to a home panel display.

JustACrazy commented 3 years ago

I like that trial. I am going to see if that impacts the cloud or not. If it does not, I am going to try it. I wish that we could just do manual discovery.

chancez commented 3 years ago

ok so an update after successfully running for upwards of a month.

the only way i could get the constant updating to work was to make an automation that updated every 3 seconds if i did "trigger type" 'time pattern' 3 seconds it would update the status every minute, at the 3 second mark. i.e. 12:00:03->12:01:03->12:02:03 i researched and researched and never found anyone with the same problem. i even copied, pasted and just change the automation name and my device names and that's still how my TP link switches would update.

so what my fix was: i did the type: time pattern-> 3 second but then made a trigger at 6 sec, 9 sec, 12sec....59 sec. then under action i did call service and used "homeassistant.update_entity" then my switch. i made a service call for each switch that will be used in an automation.

also when i tried to edit in YAML, every time i saved and came back to look at the automation, it was back in UI and would only do one device or trigger. so i had to duplicate the trigger 20 times and change the seconds on all of them. same for the actions(i only have 6 actions as i only need the quick updates for 6 switches)

i hope this helps someone who is also super new. sometimes we forget that not everyone just jumps into open source knowing everything and it helps to start at the basics. this solution worked for me and if someone knows a better way with a decent write up, please attach a link.

side note: i'm only using home assistant for the automation reach around with TP link. i'm using smart things for all my panels and interfaces and with this method of using a mix of HA and ST my system works flawlessly. ST is just more user friendly and more customizable when it comes to a home panel display.

The syntax is cron like. You need to do /3 for “every 3 seconds”. Otherwise the value is interpreted as the 3rd (or 15th, etc) second of every minute of every hour, ... etc.