How does Switch update it's status?

I’d like to know how the TP Link switch status gets updated in Home Assistant. I can switch the switch using TP’s app and up to 30 seconds later Home Assistant updates.

I’ve looked in the tplink.py and I can’t see any kind of polling ditto in the library it uses (unless I missed it…)

I’m wondering about getting more of these devices but want to make sure they are reliable (to be fair they always have been so far!) so I was thinking of adding a retry count if the first message doesn’t change the status of the switch.

In the documentation it says local polling on the top right. So if that’s still valid, the state is polled in certain intervalls.

How is that set then and how do you set the interval? Or is there just some home assistant magic happening in the background?

I just had a quick look at the code, so I don’t really know anything specific. But the update of the entity in Home Assistant uses this (not sure if it’s exactly that repository though) to do the communication with the device.
I assume the state gets updated once every minute. With the current code it’s not possible to customize this I think. Except there’s a possibility to set the update interval somewhere else (like the customization part of the config). But I don’t know about that either.

Hi. I’m on the road myself to do my first component implementation for sonoff devices with original firmware. I got hit by the same problem(s) :expressionless: to put it short, to update the device status just fill the update/is_on/available/etc entity functions with proper logic (pull data from where you need it and parse it) and HA will take care of everything.

you can re-write the scan interval like this entity platform options or you can define SCAN_INTERVAL variable inside your component with desired value