pkuehnel / TeslaSolarCharger

A software to let your Tesla charge with solar energy ☀
GNU General Public License v3.0
136 stars 21 forks source link

Feature Request: Lower Minimum Car Power Adjustment Interval #1644

Open rsaul93 opened 1 week ago

rsaul93 commented 1 week ago

Use Case

For setups with low-latency connections (e.g., local Modbus TCP and BLE API), users would benefit from the ability to set the Car Power Adjustment Interval more freely, potentially as low as 5 seconds. The current minimum of 25 seconds can delay responses to rapidly changing solar conditions, such as on partly cloudy days, reducing efficiency in utilizing solar surplus.

Proposed Feature

Allow users to configure the Car Power Adjustment Interval without the current minimum threshold of 25 seconds. Include:

Default Setting: Retain the default interval of 30 seconds for stability. User Warning: Display a warning for intervals below 25 seconds, e.g.: "Short intervals may cause system instability. Recommended only for setups with low-latency connections. Use with caution."

Additional Proposals to Prevent Oscillations (mitigate potential instability from shorter intervals):

Adaptive Minimum Interval: Enforce a dynamic minimum interval based on measured car response lag (e.g., using inverter data to infer response time). Anticipate the Car’s Power Draw: Infer the car's current power draw indirectly, as BLE API does not provide feedback. Use inverter or energy meter data to estimate the draw based on the last issued command and elapsed time. Continuously refine this estimate by monitoring the system’s response and stabilizing patterns after power adjustments. Floating Power Adjustment Interval: Replace fixed intervals with a dynamic, need-based approach. Measure solar generation and estimated car power draw at high frequency (e.g., every second) and intervene only when deviations exceed a defined threshold.

Benefits

Flexibility: Freely configurable intervals suit advanced setups. Efficiency: Improved response to rapid solar power changes. Stability: Safeguards like adaptive intervals prevent oscillations. This balances advanced user needs with system reliability while maintaining robust default behavior for general users.

rsaul93 commented 6 days ago

I observed an error yesterday while charging for several hours:

"Error with key CarRateLimited for car LRW*** in TeslaFleetApiService.SendCommandToTeslaApi: Car is rate limited until 11/25/2024 00:00:00"

I'm puzzled as to why this error was thrown at all since the car is connected via BLE. The "API refresh interval" was set to 30 and was the same on a day when no charging was ongoing.

Shortly before the charging was finished, these errors started to occur, leading to TSC not retrieving the current amperage the car was charging with. This resulted in the following scenario:

Charging was stopped via the charge limit set in the Tesla app. TSC still gathered the correct solar generation and grid power data. However, it continued to anticipate the car to be charging at the last amperage before the error occurred. This led to a negative home consumption reading, even though the four components (solar generation, grid power, house consumption, car consumption) can be inferred directly from data that was still available to TSC, despite the Tesla cloud API being rate-limited. I've attached screenshots from the power draw overview (which shows a negative house consumption—even though I don't have a home battery configured or installed) and the last charging stats (which show a significantly higher used solar energy than expected). IMG_1823

Screenshot 2024-11-25 at 08 07 43
pkuehnel commented 6 days ago

@rsaul93 This is off topic here, Check out my answers here: https://github.com/pkuehnel/TeslaSolarCharger/issues/1650