Skip to content

Instantly share code, notes, and snippets.

@h3xagn
Created July 7, 2022 19:27
Show Gist options
  • Save h3xagn/c1a7809a29d20234fd560423a100bb7c to your computer and use it in GitHub Desktop.
Save h3xagn/c1a7809a29d20234fd560423a100bb7c to your computer and use it in GitHub Desktop.
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