Giter VIP home page Giter VIP logo

Comments (6)

HeraldCoupe avatar HeraldCoupe commented on September 21, 2024 1

Thank you Rob0101. From my limited testing it seems that in addition, the backup reserve also needs to be different to that currently set otherwise it doesn't change modes.

from teslapy.

DaveTBlake avatar DaveTBlake commented on September 21, 2024 1

Interesting experiences guys, I've not been setting mode since last winter (switching to autonomous to get the faster charge rate over the cheap electricity supply period that I am tricking the Powerwall into charging from the grid by changing the reserve percentage). I always set both reserve percentage and mode so maybe I would not notice this issue.

I wonder if this is another aspect of the Tesla API randomly deprecating the powerwalls endpoints in favour of energy_sites. The endpoints I use are:

  "OPERATION_MODE": {
    "TYPE": "POST",
    "URI": "api/1/energy_sites/{site_id}/operation",
    "AUTH": true
  },
  "BACKUP_RESERVE": {
    "TYPE": "POST",
    "URI": "api/1/energy_sites/{site_id}/backup",
    "AUTH": true
  },

Note I'm using energy_sites for both, and first I get api/1/energy_sites/{site_id}/site_info ("SITE_CONFIG" in endpoints.json) using a routine I added to the battery class (which maybe populates the {site_id} ?) .

@rob0101 in your example you use a mix of energy_sites and powerwalls since

"BATTERY_BACKUP_RESERVE": {
    "TYPE": "POST",
    "URI": "api/1/powerwalls/{battery_id}/backup",
    "AUTH": true
  },

Maybe that is significant? Of course it could all change tomorrow. Hope this could be of use to either of you.

from teslapy.

tdorssers avatar tdorssers commented on September 21, 2024 1

Commit 50bdbfb removed the depricated powerwall API. Please use the energy site API.

from teslapy.

rob0101 avatar rob0101 commented on September 21, 2024

I'm new to teslaPy and not fluent in python.

I've had no luck getting a simple script to toggle between the two states. I was able to change the minimum reserve, so it may be I'm hitting a similar issue to HeraldCoupe.

Can someone share a simple code sample that changes the state as a starting point.

Thanks

from teslapy.

rob0101 avatar rob0101 commented on September 21, 2024

Got this working:

`
import sys
new_mode = sys.argv[1]
new_MRL = int(sys.argv[2])

import teslapy
from teslapy import Tesla, Battery
with teslapy.Tesla('[email protected]') as tesla:
batteries = tesla.battery_list()
batteries[0].command('BACKUP_RESERVE',backup_reserve_percent=new_MRL)
batteries[0].command('BATTERY_OPERATION_MODE',default_real_mode=new_mode)
`

but bizarrely it'll only set the mode if I also set the backup reserve. Remove that line and stop working.

from teslapy.

rob0101 avatar rob0101 commented on September 21, 2024

I've updated to the new teslapy code and my revised script (below) is working.

import sys
new_mode = ""
new_MRL = ""
if len(sys.argv)>1 : new_mode = sys.argv[1]
if len(sys.argv)>2 : new_MRL = int(sys.argv[2])

import teslapy
from teslapy import Tesla, Battery
with teslapy.Tesla('[email protected]') as tesla:
batteries = tesla.battery_list()
battery = batteries[0]
if new_MRL != '':
battery.set_backup_reserve_percent(new_MRL)
if new_mode != '':
battery.set_operation(new_mode)

battery.get_site_info()
print("Mode:" + battery["default_real_mode"])
print("Reserve:" + str(battery["backup_reserve_percent"]))

from teslapy.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.