Is update() necessary only once, or prior to every call to a @requires_update method? #195
-
If I'm looking for a latest emeter readings from my smart plugs, do I need to run update() on the device every time prior to running the likes of dev.emeter_realtime() or dev.emeter_this_month() ? Or do I simply need to run update() once? My use case is populating a time series database with the emeter information, so I'm polling the devices once every 10 seconds or so. |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment
-
All properties marked with |
Beta Was this translation helpful? Give feedback.
All properties marked with
@requires_update
do no I/O but use the results from the lastupdate()
call, so in order to get the most recent information you need to call it before accessing them. Alternatively, you can also use the methods that query the device for specific piece of information, e.g.,get_emeter_realtime()
(https://github.com/python-kasa/python-kasa/blob/master/kasa/smartdevice.py#L441). The latter also requires an initial update to find out if the device supports emeter.