tdorssers / TeslaPy

A Python module to use the Tesla Motors Owner API
MIT License
374 stars 84 forks source link

Update __init__.py #10

Closed danielwoz closed 3 years ago

danielwoz commented 3 years ago

Hey this is a first pass at extending your TeslaPy with powerwall support, for basical details and the important things people might want to set.

tdorssers commented 3 years ago

Hi, I have consolidated the code somewhat, can you please verify if it is still doing what its supposed to do? I don't own a Powerwall, so I can't check.

danielwoz commented 3 years ago

Hi, I've santized the data in my outputs (all non-zero identifying numbers changed to 1 and most letters changed to A) so feel free to share.

The BATTERY_SUMMARY does not work the Tesla API and errors with requests.exceptions.HTTPError: 404 Client Error: unknown site for url https://owner-api.teslamotors.com/api/1/powerwalls/1111100-11-A--AAA111110A1A111/status https://owner-api.teslamotors.com/api/1/powerwalls/1111100-11-A--AAA111110A1A111/status I don't think this is a working or usable API call anymore.

I tested SITE_SUMMARY to (a lot of the API's are half migrated to the Site api's for powerwalls) it also errors with

requests.exceptions.HTTPError: 404 Client Error: Not Found for url: https://owner-api.teslamotors.com/api/1/energy_sites/111110110110/status https://owner-api.teslamotors.com/api/1/energy_sites/111110110110/status This might work for actual grid energy sites given the subtly different errors.

For your future reference, successful json responses of the other API calls are listed below, if you ok with it I will send you a pull request with some update documentation.

PRODUCT_LIST [{'energy_site_id': 111110110110, 'resource_type': 'battery', 'site_name': 'J-Smith House', 'id': 'STE10110111-00101', 'gateway_id': '1111100-11-A--AAA11110A1A111', 'asset_site_id': 'a1100111-1a11-1aaa-a111-1a0011aa1111', 'energy_left': 0, 'total_pack_energy': 13746, 'percentage_charged': 0, 'battery_type': 'ac_powerwall', 'backup_capable': True, 'battery_power': 0, 'sync_grid_alert_enabled': False, 'breaker_alert_enabled': False, 'components': {'battery': True, 'battery_type': 'ac_powerwall', 'solar': True, 'solar_type': 'pv_panel', 'grid': True, 'load_meter': True, 'market_type': 'residential'}}]

BATTERY_OPERATION_MODE { "code": 201, "message": "Updated" }

BACKUP_RESERVE { "code": 201, "message": "Updated" }

BATTERY_DATA { "energy_site_id": 111110110110, "resource_type": "battery", "site_name": "J-Smith House", "id": "STE10110111-00101", "gateway_id": "1111100-11-A--AAA11110A1A111", "asset_site_id": "a1100111-1a11-1aaa-a111-1a0011aa1111", "energy_left": 0, "total_pack_energy": 13746, "percentage_charged": 0, "battery_type": "ac_powerwall", "backup_capable": true, "battery_power": 0, "sync_grid_alert_enabled": false, "breaker_alert_enabled": false, "components": { "solar": true, "solar_type": "pv_panel", "battery": true, "grid": true, "backup": true, "gateway": "teg", "load_meter": true, "tou_capable": true, "storm_mode_capable": true, "flex_energy_request_capable": false, "car_charging_data_supported": false, "off_grid_vehicle_charging_reserve_supported": false, "vehicle_charging_performance_view_enabled": false, "vehicle_charging_solar_offset_view_enabled": false, "battery_solar_offset_view_enabled": true, "show_grid_import_battery_source_cards": true, "battery_type": "ac_powerwall", "configurable": false, "grid_services_enabled": false }, "grid_status": "Active", "backup": { "backup_reserve_percent": 0, "events": null }, "user_settings": { "storm_mode_enabled": false, "sync_grid_alert_enabled": false, "breaker_alert_enabled": false }, "default_real_mode": "self_consumption", "operation": "self_consumption", "installation_date": "2020-01-01T10:10:00+08:00", "power_reading": [ { "timestamp": "2021-02-24T04:25:39+08:00", "load_power": 5275, "solar_power": 3, "grid_power": 5262, "battery_power": 10, "generator_power": 0 } ], "battery_count": 1 }

On Wed, Feb 24, 2021 at 4:34 AM Tim Dorssers notifications@github.com wrote:

Hi, I have consolidated the code somewhat, can you please verify if it is still doing what its supposed to do? I don't own a Powerwall, so I can't check.

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/tdorssers/TeslaPy/pull/10#issuecomment-784493021, or unsubscribe https://github.com/notifications/unsubscribe-auth/AIRED6VUWA7OQ6LLFTW3BSDTAQGOTANCNFSM4YB3NGNA .

tdorssers commented 3 years ago

Thank you. Please send the pull request for updated docs.