Sign inSign up

bolagnaise/tesla-sync

By bolagnaise

•Updated 9 months ago

āš ļø DEPRECATED: Please use bolagnaise/power-sync instead

Buildkit cache
Image
0

10K+

bolagnaise/tesla-sync repository overview

PowerSync Logo

⁠PowerSync

Intelligent battery energy management for Australia. Supports Tesla Powerwall and Sigenergy battery systems. Automatically sync with Amber Electric or Flow Power (AEMO wholesale) dynamic pricing, create custom TOU schedules for any provider, and capitalize on AEMO wholesale price spikes to maximize your battery's earning potential.

Buy Me A Coffee

Discord

Docker Hub Docker Pulls Build Status

ā šŸ“± Mobile App (Beta)

iOS TestFlight Android Beta

Monitor your battery, view live pricing, control EV charging, and create powerful automations from your phone.

⁠Disclaimer

This is an unofficial integration and is not affiliated with or endorsed by Tesla, Inc., Sigenergy, or Amber Electric. Use at your own risk. The developers are not responsible for any damages or issues that may arise from the use of this software.

⁠Features

⁠Supported Battery Systems
FeatureTesla PowerwallSigenergy
Automatic TOU Tariff Syncāœ…āœ…
Spike Protectionāœ…āœ…
Export Price Boostāœ…āœ…
Chip Modeāœ…āœ…
DC Solar Curtailmentāœ… Export rulesāœ… Modbus TCP
AC-Coupled Inverter Curtailmentāœ…āœ…
AEMO Spike Detectionāœ…āž– Native via Globird
Force Mode Toggleāœ…āž– N/A
Custom TOU Schedulesāœ…āž– N/A
Automationsāœ…āœ…
EV Charging Controlsāœ… Tesla Fleetāž– N/A

Connection Methods:

  • šŸ”‹ Tesla Powerwall - Fleet API or Teslemetry proxy
  • ⚔ Sigenergy - Sigenergy Cloud API for tariff sync + Modbus TCP for real-time energy data
⁠Core Functionality
  • šŸ”‹ Automatic TOU Tariff Sync - Updates your battery system with Amber Electric pricing every 5 minutes
  • šŸ“Š Real-time Pricing Dashboard - Monitor current and historical electricity prices with live updates
  • ⚔ Near Real-Time Energy Monitoring - Energy usage charts update every 30 seconds
  • šŸŒ Timezone Support - Auto-detects timezone from Amber data for accurate time display across all Australian states
⁠Advanced Features
  • ⚔ AEMO Spike Detection - Automatically monitors Australian wholesale electricity prices and switches to spike tariff during extreme price events (configurable threshold). Includes intelligent operation mode switching - automatically saves your current Powerwall mode and switches to autonomous (TOU) mode during spikes, then restores your original mode when prices normalize
  • šŸŒž Solar Curtailment - Automatically prevents solar export during negative pricing periods (≤0c/kWh). When Amber feed-in prices go negative, the system blocks grid export to avoid paying to export, then restores normal operation when prices return to positive
  • šŸ›”ļø Spike Protection - Prevents your battery from charging from grid during Amber price spikes. Overrides buy prices when Amber detects spike status to eliminate arbitrage opportunities
  • šŸ“¤ Export Price Boost - Artificially increase export prices to trigger battery exports at lower price points. Useful when prices are in the 20-25c range where the battery's algorithm may not trigger exports
  • šŸ”’ Chip Mode - Suppress battery exports during configured hours unless price exceeds a threshold. Keeps your battery stable overnight while still capturing unexpected price spikes (inverse of Export Boost)
  • šŸ”Œ Flow Power + AEMO Support - Full support for Flow Power and other wholesale electricity retailers using direct AEMO NEM pricing with configurable network tariffs
  • šŸŽÆ Custom TOU Schedules - Create and manage custom time-of-use schedules for any electricity provider (not just Amber)
  • šŸ’¾ Saved TOU Profiles - Backup, restore, and manage multiple tariff configurations
  • šŸ“ˆ Demand Charge Tracking - Monitor and track peak demand for electricity plans with capacity-based fees
⁠Technical Features
  • šŸ” Teslemetry Integration - Secure Tesla API access via Teslemetry proxy service (no public domain required)
  • šŸ”’ Secure Credential Storage - All API tokens encrypted at rest using Fernet encryption
  • ā±ļø Background Scheduler - Automatic syncing every 5 minutes (aligned with Amber's forecast updates)
  • šŸ”„ Smart Tariff Deduplication - Only syncs to Tesla when tariff actually changes, preventing duplicate rate plan entries in Tesla dashboard
  • 🐳 Docker Ready - Pre-built multi-architecture (amd64/arm64) images for easy deployment
  • šŸ  Home Assistant Integration - Native HACS integration for seamless HA deployment
  • šŸŒ Australia-Wide Compatibility - Auto-detects timezone from Amber data, works in all Australian states and territories (QLD, NSW, ACT, VIC, SA, TAS, WA, NT)
  • šŸ“Š Intelligent Price Averaging - Averages 5-minute Amber intervals into 30-minute Tesla periods for maximum accuracy
  • šŸŽÆ Period Alignment - Correctly aligns with Amber's forecast labels (e.g., "18:00 forecast" → Tesla PERIOD_17_30)
  • šŸ”„ Rolling 24-Hour Window - Always provides Tesla with 9-24 hours lookahead for optimal battery management
  • šŸ“” Real-Time WebSocket - Connects to Amber's WebSocket API for instant price updates (with automatic reconnection)

⁠Key Features Explained

⁠AEMO Spike Detection šŸ”‹ Tesla only

This option is disabled by default and is primarily intended for Tesla Powerwall users with VPPs that offer AEMO Spike exports (Globird, AGL, Engie) but don't natively support Tesla batteries. Sigenergy users on Globird don't need this feature as Globird natively supports Sigenergy for spike exports. Automatically monitors AEMO NEM wholesale electricity prices for your region (NSW1, QLD1, VIC1, SA1, TAS1). When prices exceed your configured threshold (e.g., $300/MWh), the system:

  • Saves your current tariff configuration
  • Saves your current Powerwall operation mode (self_consumption, autonomous, or backup)
  • Automatically switches to autonomous (TOU) mode (required for TOU tariffs to work)
  • Uploads a spike tariff with very high sell rates to encourage battery export
  • Tesla Powerwall responds by exporting to grid during the spike
  • Automatically restores your original operation mode when spike ends
  • Restores your normal tariff when prices return to normal

Perfect for maximizing revenue during extreme price events! Works seamlessly regardless of your normal Powerwall mode.

Monitoring Frequency: Checks AEMO prices every 1 minute for responsive spike detection.

⁠Solar Curtailment

Prevents paying to export solar during negative pricing periods (≤0c/kWh). Works with both battery systems:

Battery SystemMethodBehavior
TeslaExport rules APISets export to "never", restores to "battery_ok" when positive
SigenergyModbus TCPSets export limit to 0kW (load-following mode)

Sigenergy Load-Following Mode: Unlike full solar shutdown, Sigenergy uses zero-export mode:

  • āœ… Solar continues powering the house
  • āœ… Battery still charges from solar
  • āœ… Only grid export is blocked during negative prices

Configuration:

  • Enable/disable in Amber Settings (Flask web interface)
  • Enable/disable during Home Assistant integration setup
  • Default: Disabled (opt-in feature)
⁠Spike Protection (Amber Only)

Prevents your battery from charging from the grid during Amber price spikes. When wholesale prices spike, your battery may see an arbitrage opportunity and charge from grid - this feature stops that behavior.

Supported Battery Systems: Tesla Powerwall āœ… | Sigenergy āœ…

The Problem: During price spikes, your battery receives 30-minute averaged forecast prices (~$0.85/kWh) rather than the real-time spike prices ($10-$20/kWh). It doesn't "see" the spike and may decide to charge from grid for later arbitrage.

How It Works: When Amber reports spikeStatus: 'potential' or 'spike' for a period, buy prices are overridden:

override_buy = max(all_sell_prices) + $1.00

This ensures charging from grid is always unprofitable during spikes - eliminating any arbitrage opportunity.

Example:

During a spike event:
  Actual import price: $16.48/kWh
  Actual export price: $14.69/kWh
  Max export in forecast: $21.29/kWh

Without spike protection:
  Battery sees forecast: ~$0.85/kWh buy
  Battery thinks: "Charge now, sell later!"
  Result: Grid charging during $16/kWh spike

With spike protection:
  Override buy: $21.29 + $1.00 = $22.29/kWh
  Battery calculates: $22.29 buy - $21.29 sell = $1.00 LOSS
  Result: No grid charging

Key Features:

  • Per-period protection - Only affects periods Amber flags as spikes, not your whole day
  • Uses Amber's detection - Relies on Amber's spikeStatus field, not arbitrary thresholds
  • Works with Export Boost - They complement each other (spike protection = buy prices, export boost = sell prices)

Note for 30-minute billing customers: If you're on 30-minute billing (not 5-minute), spike prices get averaged out in your bill. This feature is most critical for 5-minute billed customers who pay the full spike price.

Configuration:

  • Enable/disable in Amber Settings (Flask web interface)
  • Enable/disable during Home Assistant integration options flow
  • Default: Disabled (opt-in feature)
⁠Export Price Boost

Artificially increases export prices sent to your battery system to trigger exports at lower price points. This is useful when Amber export prices are in the 20-25c range where the battery's algorithm may not trigger exports due to internal hysteresis.

Supported Battery Systems: Tesla Powerwall āœ… | Sigenergy āœ…

How It Works: The feature adds a configurable offset to export prices and/or sets a minimum floor price, but only during a specified time window (default 5pm-9pm evening peak).

Configuration Options:

SettingDescriptionDefault
Enable Export Price BoostToggle the feature on/offOff
Price Offset (c/kWh)Fixed amount added to all export prices0
Minimum Price (c/kWh)Floor for export prices0
Activation Threshold (c/kWh)Boost only applies if actual price is at or above this value (0 = always apply)0
Boost Start TimeWhen to start applying boost17:00
Boost End TimeWhen to stop applying boost21:00

Example Calculation:

With offset=5c, min=20c, and threshold=10c:

Amber export price: 18c/kWh
→ 18 >= 10 (threshold), so boost applies
→ 18 + 5 = 23c (above min, battery sees 23c)

Amber export price: 12c/kWh
→ 12 >= 10 (threshold), so boost applies
→ 12 + 5 = 17c (below min, battery sees 20c floor)

Amber export price: 5c/kWh
→ 5 < 10 (below threshold), boost skipped
→ Battery sees 5c (unchanged)

Amber export price: -3c/kWh
→ -3 < 10 (below threshold), boost skipped
→ Battery sees -3c (unchanged)

Use Cases:

  • Force battery to export during evening peak when prices are moderate (20-25c)
  • Overcome the battery's internal decision-making that may not export at certain price points
  • Maximize battery revenue during predictable high-demand periods
  • Use activation threshold to skip boosting very low or negative prices where exporting doesn't make financial sense

Note: The boosted price is only what your battery sees for decision-making - you still get paid the actual Amber export rate. This feature tricks the battery into exporting when it otherwise wouldn't.

Configuration:

  • Enable/disable in Amber Settings (Flask web interface)
  • Enable/disable during Home Assistant integration options flow
  • Default: Disabled (opt-in feature)
⁠Chip Mode

Suppress battery exports during configured hours (typically overnight) unless the price exceeds a threshold. This is the inverse of Export Price Boost - instead of encouraging exports, it prevents them while still allowing you to capture unexpected price spikes.

Supported Battery Systems: Tesla Powerwall āœ… | Sigenergy āœ…

The Problem: Your battery's algorithm may decide to export overnight based on price signals you don't want to respond to. This drains your battery when you'd rather keep it charged for morning use or to capture genuine price spikes.

How It Works: During the configured time window (default 10pm-6am), the system sets export prices to $0:

  • Battery sees $0 export rate → Won't export (no profit incentive)
  • Exception: If the actual price exceeds your threshold (e.g., 30c), the original price is preserved
  • This allows capturing unexpected overnight spikes while keeping the battery stable otherwise

Configuration Options:

SettingDescriptionDefault
Enable Chip ModeToggle the feature on/offOff
Start TimeWhen to start suppressing exports22:00
End TimeWhen to stop suppressing exports06:00
Price Threshold (c/kWh)Allow exports only above this price30

Example:

With threshold=30c between 22:00-06:00:

Amber export price: 8c/kWh
→ 8 < 30 (below threshold)
→ Battery sees $0 (export suppressed)

Amber export price: 35c/kWh
→ 35 >= 30 (above threshold)
→ Battery sees 35c (export allowed)

Use Cases:

  • Keep battery charged overnight for morning peak usage
  • Prevent the battery's algorithm from exporting during low-value periods
  • Still capture genuine price spikes (e.g., unexpected demand events)
  • Works with Amber SmartShift to let Amber manage overnight charging while preventing unwanted exports

Note: Like Export Price Boost, the modified price is only what your battery sees for decision-making - your actual earnings are based on real Amber rates.

Configuration:

  • Enable/disable in Amber Settings (Flask web interface)
  • Enable/disable during Home Assistant integration options flow
  • Default: Disabled (opt-in feature)
⁠Sigenergy Battery System Support

Full support for Sigenergy DC-coupled battery systems as an alternative to Tesla Powerwall.

Features:

  • Tariff Sync via Cloud API - Uploads Amber pricing to Sigenergy Cloud using the same 30-minute TOU format
  • Real-Time Energy Data via Modbus - Reads solar, battery, grid power and SOC from your inverter
  • DC Solar Curtailment - Controls DC solar via Modbus TCP during negative prices (load-following mode)
  • Load-Following Curtailment - Sets export limit to 0 instead of full PV shutdown, so solar continues to power house and charge battery

Connection Requirements:

ConnectionPurposeRequired
Cloud APITariff sync to Sigenergyāœ… Yes
Modbus TCPReal-time energy data + DC curtailmentāœ… Yes
⁠Getting Sigenergy Cloud API Credentials

To sync Amber prices to your Sigenergy system, you need your Sigenergy account credentials.

What You Need:

CredentialDescriptionWhere to Find
EmailYour Sigenergy account emailYour login email
PasswordYour Sigenergy account passwordJust use your normal password!
Device ID13-digit numeric identifierBrowser dev tools (see below)
Station IDYour Sigenergy station identifierSigenAI or browser dev tools

Password Authentication:

PowerSync automatically encrypts your password using Sigenergy's AES-128-CBC encoding before sending it to the API. Just enter your plain password - no need to capture anything from browser dev tools!

Advanced users: If you already have an encrypted password (from browser dev tools or a previous setup), you can still use it directly in the "Encrypted Password" field. This takes priority over the plain password field.

Getting Device ID:

The Device ID is a 13-digit identifier you need to capture once from browser dev tools:

  1. Open the Sigenergy Web Portal

  2. Open Browser Developer Tools

    • Press F12 or right-click → "Inspect"
    • Go to the Network tab
    • Check "Preserve log" checkbox
  3. Log In Normally

    • Enter your email and password
    • Click Login
  4. Find the Auth Request

    • In the Network tab, look for a request to oauth/token
    • Click on it to see the details
    • Go to the Payload tab (or "Request" in some browsers)
  5. Copy the Device ID

    • userDeviceId: This 13-digit number is your Device ID

Getting Station ID:

  • Easiest: Ask SigenAI in the app: "Tell me my StationID"
  • Alternative: In dev tools, look for requests containing stationId in the response
  • Alternative: Save a tariff manually and look for stationId in the network request

Example Credentials:

Email: [email protected]
Password: MySecurePassword123!
Device ID: 1756353655250
Station ID: 102025092300219

Reference: Based on amber2sigen⁠ by @Talie5in⁠

⁠How DC Curtailment Works

Unlike full solar shutdown, Sigenergy uses load-following mode (zero export):

ModeWhat Happens
Full ShutdownPV limit = 0 → Solar stops completely
Load Following (used)Export limit = 0 → Solar powers house + charges battery, no grid export

This is smarter because:

  • āœ… Solar continues powering the house
  • āœ… Battery still charges from solar
  • āœ… Only grid export is blocked during negative prices

Modbus Registers Used:

⁠Configuration (Home Assistant)

Initial Setup:

  1. Install PowerSync via HACS
  2. Add the integration: Settings → Devices & Services → Add Integration → PowerSync
  3. Select Sigenergy as your battery system
  4. Enter your Sigenergy Cloud credentials (see above)
  5. Select your Sigenergy station from the list
  6. Enter your Sigenergy inverter's Modbus IP address
  7. Optionally enable DC solar curtailment

Adding Cloud Credentials Later: If you set up PowerSync before entering Cloud credentials, you can add them via Options:

  1. Go to Settings → Devices & Services → PowerSync → Configure
  2. Scroll down to the Sigenergy Cloud API section
  3. Enter your credentials (Email, Encrypted Password, Device ID, Station ID)
  4. Save and restart Home Assistant
⁠Configuration (Flask Web App)
  1. Go to Settings → Battery System → Select "Sigenergy"
  2. Enter your Cloud credentials (captured from browser dev tools)
  3. Validate credentials and select your station
  4. Go to Amber Settings → Enter Sigenergy Modbus IP address, port, and slave ID

Note: Sigenergy is a DC-coupled battery system. If you have an AC-coupled solar inverter from another brand (Sungrow, Fronius, etc.) connected to your Sigenergy system, you can configure AC-coupled inverter curtailment separately (see below).

⁠AC-Coupled Inverter Curtailment

Control AC-coupled solar inverters directly during negative pricing periods. This feature works with any battery system (Tesla, Sigenergy, or others) and is useful when you have a separate solar inverter that bypasses the battery.

Supported Inverter Brands:

BrandConnectionModels
SungrowModbus TCPSG series (string), SH series (hybrid)
FroniusModbus TCPPrimo, Symo, Gen24, Tauro, Eco
GoodWeModbus TCPET, EH, BT, BH, ES, EM series (hybrid)
HuaweiModbus TCPSUN2000 L1, M0, M1, M2 series
EnphaseHTTPS APIIQ Gateway, Envoy-S (microinverters)

How It Works: When Amber feed-in price drops below 1c/kWh (configurable), PowerSync sends a curtailment command to your inverter:

  • Sungrow/Fronius/GoodWe/Huawei: Sets export limit to 0W via Modbus registers
  • Enphase: Uses IQ Gateway API to limit production

When prices rise above the threshold, normal operation is restored.

Why Use This: AC-coupled solar inverters export directly to the grid, bypassing your battery. During negative prices, this costs you money. Curtailment stops the export while still powering your home.

Configuration (Home Assistant):

  1. Go to PowerSync options
  2. Enable "AC-Coupled Inverter Curtailment"
  3. Select your inverter brand and model
  4. Enter the inverter's IP address
  5. Configure Modbus port (502 default) and slave ID

Configuration (Flask Web App):

  1. Go to Settings → Amber Settings
  2. Enable "Inverter Curtailment"
  3. Configure inverter connection details

Note: This is separate from Sigenergy DC curtailment. You can use both if you have:

  • Sigenergy battery with DC solar → Use Sigenergy DC curtailment
  • AC-coupled inverter (any brand) → Use AC-coupled inverter curtailment
⁠Force Mode Toggle (Alpha) šŸ”‹ Tesla only

An experimental feature that forces the Powerwall to immediately recalculate its behavior after receiving new tariff prices.

The Problem: After PowerSync uploads a new tariff, the Powerwall may take several minutes to recognize the price changes and adjust its charging/discharging behavior accordingly.

How It Works: After a successful tariff sync, this feature briefly switches the Powerwall to self-consumption mode, waits 5 seconds, then switches back to Time-Based Control (autonomous mode). This mode toggle forces the Powerwall to immediately recalculate its optimal behavior based on the new prices.

Smart Timing: The toggle only triggers when settled/actual prices are synced (at :35/:60 seconds), not on the initial forecast sync (at :00 seconds). This ensures:

  • Only one toggle per 5-minute interval (not two)
  • Powerwall recalculates using actual prices, not potentially different forecast prices
  • Reduced unnecessary mode switches

Trade-offs:

  • May cause a brief interruption (~5 seconds) to battery behavior during the mode switch
  • Some users report faster Powerwall response; others see no difference
  • Experimental feature - results may vary

Configuration:

  • Enable/disable in Amber Settings → Alpha Options (Flask web interface)
  • Enable/disable during Home Assistant integration options flow
  • Default: Disabled (opt-in feature)
⁠Flow Power + AEMO Wholesale Pricing

Full support for Flow Power and other wholesale electricity retailers that pass through AEMO NEM spot prices.

How It Works: AEMO wholesale prices only include the energy cost - they don't include network (DNSP) charges, environmental fees, or GST. PowerSync automatically calculates your total retail price using the aemo_to_tariff⁠ library.

Configuration:

  1. Select Flow Power as your electricity provider

  2. Choose your NEM Region (QLD1, NSW1, VIC1, SA1)

  3. Select AEMO NEM Wholesale as the price source

  4. Configure your Network Tariff:

    Option A: Automatic (Recommended)

    • Select your Network Distributor (DNSP) from the dropdown:
      • Energex, Ergon, Ausgrid, Endeavour, Essential, SA Power Networks
      • Powercor, CitiPower, AusNet, Jemena, United Energy
      • TasNetworks, Evoenergy
    • Enter your Tariff Code from your electricity bill (e.g., NTC6900, EA025)
    • The system automatically calculates network fees, market charges, and GST

    Option B: Manual Rates

    • Check "Use manual rates instead of automatic lookup"
    • Enter your rates manually:
      • Flat Rate: Single rate all day (e.g., 8c/kWh)
      • **Ti

Tag summary

Content type

Image

Digest

sha256:a29fdca0c…

Size

158.6 MB

Last updated

9 months ago

docker pull bolagnaise/tesla-sync