core/homeassistant/components/tplink
J. Nick Koston 269429aa0c
Only calculate the tplink emeter values once per update cycle (#115587)
The sensor platform has to read the native_value multiple times
during the state write cycle which means the integration calculated
the value multiple times. Switch to using _attr_native_value to
ensure the calculations in the library are only done once per
state write.

To demonstrate this issue,
+        _LOGGER.warning("Fetch name value for %s", self.entity_id)
was added to `def native_value`:
```
2024-04-14 06:58:52.506 WARNING (MainThread) [homeassistant.components.tplink.sensor] Fetch name value for sensor.kasa_smart_plug_542b_0_kasa_smart_plug_542b_0_current_consumption
2024-04-14 06:58:52.506 WARNING (MainThread) [homeassistant.components.tplink.sensor] Fetch name value for sensor.kasa_smart_plug_542b_0_kasa_smart_plug_542b_0_total_consumption
2024-04-14 06:58:52.507 WARNING (MainThread) [homeassistant.components.tplink.sensor] Fetch name value for sensor.kasa_smart_plug_542b_0_kasa_smart_plug_542b_0_today_s_consumption
2024-04-14 06:58:52.507 WARNING (MainThread) [homeassistant.components.tplink.sensor] Fetch name value for sensor.kasa_smart_plug_542b_0_kasa_smart_plug_542b_0_voltage
2024-04-14 06:58:52.508 WARNING (MainThread) [homeassistant.components.tplink.sensor] Fetch name value for sensor.kasa_smart_plug_542b_0_kasa_smart_plug_542b_0_current
2024-04-14 06:58:52.509 WARNING (MainThread) [homeassistant.components.tplink.sensor] Fetch name value for sensor.kasa_smart_plug_542b_0_kasa_smart_plug_542b_0_current_consumption
2024-04-14 06:58:52.510 WARNING (MainThread) [homeassistant.components.tplink.sensor] Fetch name value for sensor.kasa_smart_plug_542b_0_kasa_smart_plug_542b_0_total_consumption
2024-04-14 06:58:52.510 WARNING (MainThread) [homeassistant.components.tplink.sensor] Fetch name value for sensor.kasa_smart_plug_542b_0_kasa_smart_plug_542b_0_today_s_consumption
2024-04-14 06:58:52.510 WARNING (MainThread) [homeassistant.components.tplink.sensor] Fetch name value for sensor.kasa_smart_plug_542b_0_kasa_smart_plug_542b_0_voltage
2024-04-14 06:58:52.510 WARNING (MainThread) [homeassistant.components.tplink.sensor] Fetch name value for sensor.kasa_smart_plug_542b_0_kasa_smart_plug_542b_0_current
```
2024-04-14 20:38:28 +02:00
..
__init__.py
config_flow.py Ensure test async_create_task eager start behavior matches production (#115517) 2024-04-13 15:58:52 -05:00
const.py
coordinator.py
diagnostics.py
entity.py
icons.json
light.py
manifest.json
models.py
sensor.py Only calculate the tplink emeter values once per update cycle (#115587) 2024-04-14 20:38:28 +02:00
services.yaml
strings.json
switch.py