26.04.2021, 13:06
Generating the new auth_token is working on my SHAC (with the old libraries)
Thank you!!!
I'd like to use this token to automate a change in mode from 'backup-only' (which forces the Powerwall to charge from the Grid when electricity rates are cheap) to 'self-powered' (which discharges the battery to power our home).
Could you please also help me convert the python code to pass this token back to the Tesla Powerwall to change the mode to Backup
https://github.com/fkhera/powerwallCloud...up.py#L132
Many thanks again
Kind Regards
James
Thank you!!!
I'd like to use this token to automate a change in mode from 'backup-only' (which forces the Powerwall to charge from the Grid when electricity rates are cheap) to 'self-powered' (which discharges the battery to power our home).
Could you please also help me convert the python code to pass this token back to the Tesla Powerwall to change the mode to Backup
https://github.com/fkhera/powerwallCloud...up.py#L132
Code:
## Set Powerwall Operation to Charge (Backup) or Discharge (self_consumption)
# Pause PERHAPS WITH (self_consumption) w/ Current SoC as backup_reserve_percent
def operation_set(self, real_mode, backup_reserve_percent):
# auth_header = {'Authorization': 'Bearer ' + self.token}
payload = {"backup_reserve_percent": backup_reserve_percent}
#payload = json.dumps({"real_mode": real_mode, "backup_reserve_percent": backup_reserve_percent})
set_endpoint = '/backup'
set_url = self.energy_base_url + str(self.energy_site_id) + set_endpoint
print ("Setting Operation for Site Id: ", self.energy_site_id)
print ("Trying URL: ", set_url)
print ("Setting mode: " + json.dumps(payload))
try:
result = requests.post(set_url, json=payload, headers=self.auth_header, timeout=50)
print("Set result output: ", result.content)
if result.status_code == 201:
print("Successfully changed reserve mode")
except HTTPError as err:
print("Error: {0}".format(err))
except Timeout as err:
print("Request timed out: {0}".format(err))#
Many thanks again
Kind Regards
James