mirror of
https://github.com/python-kasa/python-kasa.git
synced 2025-05-02 20:51:10 +00:00
return None instead of False for emeter related actions
This commit is contained in:
parent
0927930f41
commit
92c9cddfd4
@ -338,12 +338,12 @@ class SmartDevice(object):
|
|||||||
Retrive current energy readings from device.
|
Retrive current energy readings from device.
|
||||||
|
|
||||||
:returns: current readings or False
|
:returns: current readings or False
|
||||||
:rtype: dict, False
|
:rtype: dict, None
|
||||||
False if device has no energy meter or error occured
|
None if device has no energy meter or error occured
|
||||||
:raises SmartDeviceException: on error
|
:raises SmartDeviceException: on error
|
||||||
"""
|
"""
|
||||||
if not self.has_emeter:
|
if not self.has_emeter:
|
||||||
return False
|
return None
|
||||||
|
|
||||||
return self._query_helper(self.emeter_type, "get_realtime")
|
return self._query_helper(self.emeter_type, "get_realtime")
|
||||||
|
|
||||||
@ -355,12 +355,12 @@ class SmartDevice(object):
|
|||||||
:param month: month for which to retrieve statistcs (default: this
|
:param month: month for which to retrieve statistcs (default: this
|
||||||
month)
|
month)
|
||||||
:return: mapping of day of month to value
|
:return: mapping of day of month to value
|
||||||
False if device has no energy meter or error occured
|
None if device has no energy meter or error occured
|
||||||
:rtype: dict
|
:rtype: dict
|
||||||
:raises SmartDeviceException: on error
|
:raises SmartDeviceException: on error
|
||||||
"""
|
"""
|
||||||
if not self.has_emeter:
|
if not self.has_emeter:
|
||||||
return False
|
return None
|
||||||
|
|
||||||
if year is None:
|
if year is None:
|
||||||
year = datetime.datetime.now().year
|
year = datetime.datetime.now().year
|
||||||
@ -384,12 +384,12 @@ class SmartDevice(object):
|
|||||||
|
|
||||||
:param year: year for which to retrieve statistics (default: this year)
|
:param year: year for which to retrieve statistics (default: this year)
|
||||||
:return: dict: mapping of month to value
|
:return: dict: mapping of month to value
|
||||||
False if device has no energy meter
|
None if device has no energy meter
|
||||||
:rtype: dict
|
:rtype: dict
|
||||||
:raises SmartDeviceException: on error
|
:raises SmartDeviceException: on error
|
||||||
"""
|
"""
|
||||||
if not self.has_emeter:
|
if not self.has_emeter:
|
||||||
return False
|
return None
|
||||||
|
|
||||||
response = self._query_helper(self.emeter_type, "get_monthstat",
|
response = self._query_helper(self.emeter_type, "get_monthstat",
|
||||||
{'year': year})
|
{'year': year})
|
||||||
@ -412,7 +412,7 @@ class SmartDevice(object):
|
|||||||
:raises SmartDeviceException: on error
|
:raises SmartDeviceException: on error
|
||||||
"""
|
"""
|
||||||
if not self.has_emeter:
|
if not self.has_emeter:
|
||||||
return False
|
return None
|
||||||
|
|
||||||
self._query_helper(self.emeter_type, "erase_emeter_stat", None)
|
self._query_helper(self.emeter_type, "erase_emeter_stat", None)
|
||||||
|
|
||||||
@ -425,11 +425,11 @@ class SmartDevice(object):
|
|||||||
Get the current power consumption in Watt.
|
Get the current power consumption in Watt.
|
||||||
|
|
||||||
:return: the current power consumption in Watt.
|
:return: the current power consumption in Watt.
|
||||||
False if device has no energy meter.
|
None if device has no energy meter.
|
||||||
:raises SmartDeviceException: on error
|
:raises SmartDeviceException: on error
|
||||||
"""
|
"""
|
||||||
if not self.has_emeter:
|
if not self.has_emeter:
|
||||||
return False
|
return None
|
||||||
|
|
||||||
response = self.get_emeter_realtime()
|
response = self.get_emeter_realtime()
|
||||||
if self.emeter_units:
|
if self.emeter_units:
|
||||||
|
Loading…
x
Reference in New Issue
Block a user