utilities/tp-link-to-influxdb#8: Reports "Not Supplied" for daily consumption if it's 0



Issue Information

Issue Type: issue
Status: closed
Reported By: btasker
Assigned To: btasker

Milestone: v0.25
Created: 22-Dec-23 10:57



Description

If a plug reports no consumption at all, the script will report "Not Supplied":

Plug: slow-cooker using 0.0W, today: Not Supplied

This is because we do this:

if today_usage:
    print(f"Plug: {kasa['name']} using {now_usage_w}W, today: {today_usage/1000} kWh")
else:
    print(f"Plug: {kasa['name']} using {now_usage_w}W, today: Not Supplied")    

0 is equivalent to False. Need to update those checks to something like

if today_usage !== False

It doesn't have any impact on the data written to Influx (the field is simply omitted), only the CLI output



Toggle State Changes

Activity


assigned to @btasker

mentioned in issue #7

Fixed in commit 81339f18010036505393456215ea17b59ed79eb0

verified

mentioned in commit github-mirror/tplink_to_influxdb@81339f18010036505393456215ea17b59ed79eb0

Commit: github-mirror/tplink_to_influxdb@81339f18010036505393456215ea17b59ed79eb0 
Author: B Tasker                            
                            
Date: 2023-12-23T10:26:48.000+00:00 

Message

fix: don't report "not supplied" if today_usage = 0 (utilities/tp-link-to-influxdb#8)

+7 -6 (13 lines changed)