Skip to content

Instantly share code, notes, and snippets.

Created July 7, 2022 19:27
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
Star You must be signed in to star a gist
What would you like to do?
Give your cleverHome one voice:
def GetPowerMeasurement():
"""Get the current power reading from the efergy device"""
url = f"{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