Skip to content
This repository has been archived by the owner on Jun 5, 2021. It is now read-only.

Commit

Permalink
add actor consumption reset
Browse files Browse the repository at this point in the history
  • Loading branch information
H4R0 committed Oct 20, 2020
1 parent 84cbd7c commit ec28f1c
Show file tree
Hide file tree
Showing 2 changed files with 32 additions and 1 deletion.
8 changes: 7 additions & 1 deletion fritzhome/actor.py
Original file line number Diff line number Diff line change
Expand Up @@ -148,12 +148,18 @@ def set_temperature(self, temp):
logger.info("Actor " + self.name + ": Temperature control set to " + str(temp))

return self.box.homeautoswitch("sethkrtsoll", self.actor_id, param)

def get_consumption(self, timerange="10"):
"""
Return the energy report for the device.
"""
return self.box.get_consumption(self.device_id, timerange)

def reset_consumption(self):
"""
Resets the energy data stored on fritzbox for reports.
"""
return self.box.reset_consumption(self.device_id)

def __repr__(self):
return u"<Actor {}>".format(self.name)
25 changes: 25 additions & 0 deletions fritzhome/fritz.py
Original file line number Diff line number Diff line change
Expand Up @@ -267,6 +267,31 @@ def get_consumption(self, deviceid, timerange="10"):

return result

def reset_consumption(self, deviceid):
"""
Resets the energy data stored on fritzbox for reports.
Atention: User needs permissions for "Alle Einstellungen der FRITZ!Box sehen und bearbeiten"
:return: bool
"""

url = self.base_url + "/net/home_auto_query.lua"
response = self.session.post(url, data={
'sid': self.sid,
'command': 'ResetEnergyData',
'id': deviceid,
'xhr': 0,
}, headers={
'Content-Type': 'application/x-www-form-urlencoded'
}, timeout=15)
response.raise_for_status()

if response.text == "":
raise Exception("consumption reset failed, missing user permission to change settings ?")

return response.json()["RequestResult"] == True

def get_logs(self):
"""
Return the system logs since the last reboot.
Expand Down

0 comments on commit ec28f1c

Please sign in to comment.