Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add EnergySite Tariff Support #174

Open
KevM opened this issue May 13, 2024 · 0 comments · May be fixed by #175
Open

Add EnergySite Tariff Support #174

KevM opened this issue May 13, 2024 · 0 comments · May be fixed by #175

Comments

@KevM
Copy link

KevM commented May 13, 2024

Related to #173 I noticed that energy sites do not encode the tariff details. I would be happy to help with this but am pretty new to Swift. I'm investigating now...

Here is a sample raw payload from GET api/1/energy_sites/{energy_site_id}/site_info:

{
    "response": {
      "id": "12345667-00-H--GF70837403H0",
      "site_name": "MySite",
      "backup_reserve_percent": 11,
      "default_real_mode": "autonomous",
      "installation_date": "2022-09-14T11:09:47-06:00",
      "user_settings": {
        "go_off_grid_test_banner_enabled": false,
        "storm_mode_enabled": true,
        "powerwall_onboarding_settings_set": true,
        "powerwall_tesla_electric_interested_in": false,
        "vpp_tour_enabled": true,
        "sync_grid_alert_enabled": true,
        "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": true,
        "vehicle_charging_performance_view_enabled": false,
        "vehicle_charging_solar_offset_view_enabled": false,
        "battery_solar_offset_view_enabled": true,
        "solar_value_enabled": true,
        "energy_value_header": "Energy Value",
        "energy_value_subheader": "Estimated Value",
        "energy_service_self_scheduling_enabled": true,
        "show_grid_import_battery_source_cards": true,
        "set_islanding_mode_enabled": true,
        "wifi_commissioning_enabled": true,
        "backup_time_remaining_enabled": true,
        "battery_type": "ac_powerwall",
        "configurable": true,
        "grid_services_enabled": false,
        "gateways": [
          {
            "device_id": "ffffffff-24d5-46c5-9b68-ffff9b295160",
            "din": "1234567-00-H--GF12345672H0",
            "serial_number": "GF12345672H0",
            "part_number": "12334500-00-H",
            "part_type": 10,
            "part_name": "Tesla Backup Gateway 2",
            "is_active": true,
            "site_id": "ffffffff-62e3-4e07-aa07-ffffffff56bf6",
            "firmware_version": "23.44.0 eb113390",
            "updated_datetime": "2024-05-13T15:04:53.86Z"
          }
        ],
        "batteries": [
          {
            "device_id": "ffffffff-9c6a-49a7-93fc-ffffffff2ab4",
            "din": "ffffffff-05-E--TG123456781TJF",
            "serial_number": "TG123456781TJF",
            "part_number": "3012170-05-E",
            "part_type": 2,
            "part_name": "Powerwall 2",
            "nameplate_max_charge_power": 5000,
            "nameplate_max_discharge_power": 5000,
            "nameplate_energy": 13500
          }
        ],
        "net_meter_mode": "pv_only",
        "edit_setting_permission_to_export": true,
        "edit_setting_grid_charging": true,
        "edit_setting_energy_exports": true,
        "system_alerts_enabled": true
      },
      "version": "23.44.0 eb113390",
      "battery_count": 1,
      "nameplate_power": 5000,
      "nameplate_energy": 13500,
      "installation_time_zone": "America/Los_Angeles",
      "off_grid_vehicle_charging_reserve_percent": 70,
      "max_site_meter_power_ac": 1000000000,
      "min_site_meter_power_ac": -1000000000,
      "tariff_content_v2": {
        "code": "(edited)",
        "name": "CGS NM",
        "utility": "PGNE ",
        "daily_charges": [
          {
            "name": "Charge"
          }
        ],
        "demand_charges": {
          "ALL": {
            "rates": {
              "ALL": 0
            }
          },
          "Summer": {},
          "Winter": {}
        },
        "energy_charges": {
          "ALL": {
            "rates": {
              "ALL": 0
            }
          },
          "Summer": {
            "rates": {
              "OFF_PEAK": 0.11,
              "ON_PEAK": 0.23
            }
          },
          "Winter": {
            "rates": {
              "OFF_PEAK": 0.11,
              "ON_PEAK": 0.23
            }
          }
        },
        "seasons": {
          "Summer": {
            "fromDay": 1,
            "toDay": 31,
            "fromMonth": 10,
            "toMonth": 5,
            "tou_periods": {
              "OFF_PEAK": {
                "periods": [
                  {
                    "toDayOfWeek": 4,
                    "toHour": 8
                  },
                  {
                    "toDayOfWeek": 4,
                    "fromHour": 20
                  },
                  {
                    "fromDayOfWeek": 5,
                    "toDayOfWeek": 6
                  }
                ]
              },
              "ON_PEAK": {
                "periods": [
                  {
                    "toDayOfWeek": 4,
                    "fromHour": 8,
                    "toHour": 20
                  }
                ]
              }
            }
          },
          "Winter": {
            "fromDay": 1,
            "toDay": 30,
            "fromMonth": 6,
            "toMonth": 9,
            "tou_periods": {
              "OFF_PEAK": {
                "periods": [
                  {
                    "toDayOfWeek": 4,
                    "toHour": 8
                  },
                  {
                    "toDayOfWeek": 4,
                    "fromHour": 20
                  },
                  {
                    "fromDayOfWeek": 5,
                    "toDayOfWeek": 6
                  }
                ]
              },
              "ON_PEAK": {
                "periods": [
                  {
                    "toDayOfWeek": 4,
                    "fromHour": 8,
                    "toHour": 20
                  }
                ]
              }
            }
          }
        },
        "sell_tariff": {
          "name": "CGS NM",
          "utility": "PGNE",
          "daily_charges": [
            {
              "name": "Charge"
            }
          ],
          "demand_charges": {
            "ALL": {
              "rates": {
                "ALL": 0
              }
            },
            "Summer": {},
            "Winter": {}
          },
          "energy_charges": {
            "ALL": {
              "rates": {
                "ALL": 0
              }
            },
            "Summer": {
              "rates": {
                "OFF_PEAK": 0.03,
                "ON_PEAK": 0.04
              }
            },
            "Winter": {
              "rates": {
                "OFF_PEAK": 0.03,
                "ON_PEAK": 0.06
              }
            }
          },
          "seasons": {
            "Summer": {
              "fromDay": 1,
              "toDay": 31,
              "fromMonth": 10,
              "toMonth": 5,
              "tou_periods": {
                "OFF_PEAK": {
                  "periods": [
                    {
                      "toDayOfWeek": 4,
                      "toHour": 8
                    },
                    {
                      "toDayOfWeek": 4,
                      "fromHour": 20
                    },
                    {
                      "fromDayOfWeek": 5,
                      "toDayOfWeek": 6
                    }
                  ]
                },
                "ON_PEAK": {
                  "periods": [
                    {
                      "toDayOfWeek": 4,
                      "fromHour": 8,
                      "toHour": 20
                    }
                  ]
                }
              }
            },
            "Winter": {
              "fromDay": 1,
              "toDay": 30,
              "fromMonth": 6,
              "toMonth": 9,
              "tou_periods": {
                "OFF_PEAK": {
                  "periods": [
                    {
                      "toDayOfWeek": 4,
                      "toHour": 8
                    },
                    {
                      "toDayOfWeek": 4,
                      "fromHour": 20
                    },
                    {
                      "fromDayOfWeek": 5,
                      "toDayOfWeek": 6
                    }
                  ]
                },
                "ON_PEAK": {
                  "periods": [
                    {
                      "toDayOfWeek": 4,
                      "fromHour": 8,
                      "toHour": 20
                    }
                  ]
                }
              }
            }
          }
        },
        "version": 1
      },
      "vpp_backup_reserve_percent": 11
    }
  }

Note: I did remove the tariff_content key as this is a simpler duplication of tariff_content_v2

KevM pushed a commit to KevM/TeslaSwift that referenced this issue May 13, 2024
…ger populated

* `tou_settings` is no longer present at energy sites.
* `tariff_content_v2` encodes details of time of use details for powerwall sites.

Closes jonasman#174
@KevM KevM linked a pull request May 13, 2024 that will close this issue
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant