Give your cleverHome one voice: https://h3xagn.com
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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