Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Give your cleverHome one voice: https://h3xagn.com
def GetPowerMeasurement():
"""Get the current power reading from the efergy device"""
try:
url = f"http://www.energyhive.com/mobile_proxy/getCurrentValuesSummary?token={efergy_token}"
response = requests.get(url)
data = response.json()[0]["data"][0]
timestamp = datetime.fromtimestamp(int(list(data.keys())[0]) / 1000)
measurement = list(data.values())[0]
print(f"Power measurement at {timestamp} was {measurement}W.")
return measurement
except Exception as e:
print(f"Error getting power measurement: {e}")
return None
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment