-
Notifications
You must be signed in to change notification settings - Fork 100
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
Integration no longer exposes Powerwall Battery SoC% (may be Tesla or HA issue) #919
Comments
I'm getting the same issue which appeared this morning, we have done no updates. |
@bmsrecycle Good to know that it isn'y just me then. I hope the guys can figure out what the issue is and devise a fix or workaround as its a huge problem for me as many of my automations are now broken... |
same here, can see everything except battery charge and battery remaining, again no updates on HA, i guess must be an api thing????? |
Yes same I noticed that the percentage was stuck earlier at some low number this morning Sydney but after restarting HA it says unavailable. |
Safe to say this is a Tesla API/data change as it has been said by others (and can see it myself in history) this broke around the same time for everyone and there was no release (I'm also currently on an older version 3.19.11) |
Seems like the log suggests this is the error round(self._energysite.energy_left) It's saying the energy_left is null and can't round it is my guess So an error with energy left missing causing the SOC to not display maybe. |
From looking at teslajsonpy it was looking for a {"response":
{
"resource_type":"battery",
"site_name":"Home",
"gateway_id":"---",
"percentage_charged":76.3465567344732,
"battery_type":"ac_powerwall",
"backup_capable":true,
"battery_power":-5000,
"go_off_grid_test_banner_enabled":null,
"storm_mode_enabled":true,
"powerwall_onboarding_settings_set":true,
"powerwall_tesla_electric_interested_in":null,
"vpp_tour_enabled":null,
"sync_grid_alert_enabled":true,
"breaker_alert_enabled":true
}
} |
Hmm, I would have thought that the 'current soc' would be given by '"percentage_charged":76.3465567344732,'? I'm not sure what the 'battery_power' field represents, but I suspect that it might be the maximum discharge power perhaps. |
I think you might have caught the old message I wrote and then corrected |
Same issue here with Battery % and Battery remaining (Wh) being unavailable. Not sure if connected but Load Power (W) and Solar Power (W) are not updating although not showing as unavailable and did change on restarting HA. (The official integration is showing Load and Solar OK) Also the integration wanted a Token refresh (which was accepted). |
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
Having had the issue for ~24 hours now there also appears to be a lag effect for backup reserve and operations mode. These can still be controlled and viewed via the Integration but I’m seeing a materially lagged response on both directions. |
I've switched to using the HA built-in Powerwall integration for Battery Charge. It uses the local API, not Tesla Cloud, so is working fine. Both integrations work along side each other. |
Not sure if this is relevant to this issue but TBC not working as I expected between 0130 and 0630 today. Was super off-peak (7p) from 0130 to 0500 and off-peak (11p) from 0500 to 0630. All HA automations were off and Tesla set to TBC with 5% backup reserve. It stayed idle from 0000 to 0540 then started charging - so during off-peak rather than super off-peak. Additionally, at 0630, I changed it on the Tesla app to self-powered and matched the reserve to SoC (27%) and it initially stopped charging but 30 minutes later, started charging again and took SOC to 36%. (This would have been Mid Peak). I could only stop it by setting Grid Charging to NO. @Nick-Sills - are you able to control the PW2 mode and Reserve SoC - if so, is there a lag or is it near real-time? |
My observations are you can set all the modes correctly but they do not display what they are set to. Use the Tesla app to confirm settings set, use the Tesla native Powerwall integration to observe behaviour. |
Just be aware that % charge provided by this integration is slightly different, it's percentage of total battery including the 5% which is always reserved and not seen in the Tesla app. So for example when custom integration would have shown zero % this one will show 5%. |
This is definitely an unexpected Tesla API change, other apps (e.g. Powerwall Companion on Android) needed an update to display percentage remaining again. So small update to this integration should correct it when @alandtse gets time. |
Don't know if this will help or just making a mistake. I have 2 ha, one updated and another one that is not. The old ha with the old integration everything works as it should, but the new one not, as everyone said, not reporting battery and power. |
@fernando155 as I said in an earlier comment, I'm on v3.19.11 and this is an API change from Tesla, so all versions would be affected by this. If you're using the built in Home Assistant version of Tesla integration (which uses local API) then it is fine. |
Ahhh. .That explains it. I've always seen this as being inaccurate when I compare with my phone app, so I never used it. I switched to it now while this issue is being worked out, but never knew why. Thanks for explaining this. |
I was hoping this was on of those things that resolve itself over 24-48 hours, but reading above suggest it might be a API end issue as others have said given the common timing. This sucks extra because I only update whenever something is really broken since I end up chasing and cleaning up issues when updating one things breaks another. My last upgrade to v3.20.1 broke views into my car, so I rolled back to the previously working v3.19.11. I suspected the fleet api issue but I did not see the specific log entry folks have comment to search for to validate fleet api issue. I'm on a 2022 car too. This issue here might force me to update at some point and have to go down the proxy rabbit hole which I was trying to avoid staying on the older version. |
Not all versions. I'm using the original Tesla but I'm using the integration in 3 different ha. One is quite old, like a new years I think, and is working fine. The other one is just 2 weeks old and still working fine, but the last version is the only one is completely broken. I'm not able to modify anything due everything is unavailable on this one. I wish I can say what version is on the 2 weeks old one, but I update it but didn't restarted yet... |
If you could give us the version that does work that would help, but I'd be surprised given the API data itself has changed (some things that were there are no longer at all). It would be worth reloading the ones that appear to work as it might be that it is 'stuck' with stale data (I initially got caught out as my battery remaining was reporting 2kWh but my local %age was down to about 7%) as that should cause Home Assistant to update the info and notice if it is no longer being populated. |
I only found the firmware data Firmware: 23.44.0 when the new one is 24.4.0. I don't know where else to look tbh. |
@wanblue Just checked and it takes about 5s. That's real time enough for my usage. |
Looks like tesla removed it but did not update their own API documentation as I was enable to locate energy_left on the site data, site summary or products API. I commented out line 94 in sensors.py for now on my local repo so it will stop giving out errors and to get the backup reserves to appear again. if energysite.resource_type == RESOURCE_TYPE_BATTERY:
entities.append(TeslaEnergyBattery(energysite, coordinator))
# entities.append(TeslaEnergyBatteryRemaining(energysite, coordinator))
entities.append(TeslaEnergyBackupReserve(energysite, coordinator))
for sensor_type in BATTERY_SITE_SENSORS:
entities.append(
TeslaEnergyPowerSensor(energysite, coordinator, sensor_type)
) |
Thanks for the fix. I am still on 3.19.11 and i know 3.20.5 or whatever is going to break it |
As a temporary workaround if you heed the "useable" energy data, the Tesla Powerwall core integration now provides individual battery entities named "Battery capacity" (C), and "Battery remaining" (R). Use basic maths to account for the unusable 5%: Useable charge remaining = R - (C x 0.05) Useable percentage remaining = (R - (C x 0.05)) / (C × 0.95) x 100 [This should be the same figure you see on the Tesla App] Of course, if you have multiple batteries like me you have to sum the individual battery values before applying the above maths. EDIT: added x100 to second calculation. |
Here is my code: (I have two batteries)
|
Nice work I added a couple of formatting things but otherwise exactly what I was going to do / seeing if somebody else already had. 🤣 |
v3.19.7 is the version that my friend is using and is working without issues. I can´t find my version at all because I update it but still waiting for restart. |
Apologies for the silly question, but in what file are you making these additions/changes? And is this in addition to commenting out Line 94 in sensor.py or instead of? |
I used a helper: Settings > Devices & Services > Helpers > Create Helper > Template > Template a sensor. Then enter a name, the template as above, and:
|
Alternatively, just edit your config.yaml file to include ` - platform: template
Just swap out the 'sensor.my_home_tg*********battery_capacity' and 'sensor.my_home*********_battery_remaining' with the name of the sensors in the official Tesla integration. You can get this by going to Settings/Integrations/Tesla/Devices/select your battery/Battery remaining then select the "Gear Cog" and your sensor name will be there - do the same for battery remaining. Once you've saved the new/updated sensor.yaml (and config.yaml if you needed to add Thanks to @Avatar1976 for the original maths and formatting - it's a lot neater than mine would have been! |
@markcocker @wanblue |
Or ME (if you like @wanblue) for the original, 'original' maths and formatting...! 😉 |
Sorry, @ejbatts I stand corrected - just didn't want to get the credit for the harder part of the programming the sensor. Kudos to you! |
Most of the sensors from the Custom Integration don't seem to be updating dynamically - Backup Reserve and Operation Mode seem to be working OK (but see below) and the other's seem to be either available on the official integration or can be derived as detailed above by @ejbatts. All the custom integration sensors/backup reserve number are becoming sporadically becoming unavailable - it was happening when my router rebooted at 0420 every day but I've stopped that happening a few days ago and they all stayed available until last night (0016) they went unavailable and stayed that way until I restarted the integration this morning. That meant none of my overnight charge/hold/discharge automations triggered. Is anyone else seeing this behaviour? I've written an automation in HA triggered when the backup reserve number becomes unavailable, it waits 90 seconds (to allow for network delays or a self-rebooting router),reloads the integration, then checks again after 5 mins - and reloads the integration again if it's still unavailable. I'm aware the automations could still fail if they trigger during the 90 second delay but haven't got the time to build the check into every automation (hoping the integration errors get sorted quickly). Also, it's not very elegant so can anyone think of a better way ? |
Have you tried the workaround from here: |
Thanks @barryperfect, just done that and they seem to be updating now. Not sure if it will affect them all becoming unavailable randomly so I'll leave the automation in place and see if it gets triggered. |
Here is an alternative fix I'm using with a powerwall 3 (no local access), in case you already have automations that depend on the entity. This is at line 444 of sensors.py, and it is based on the fixes above. @property
def native_value(self) -> int:
"""Return battery energy remaining."""
# return round(self._energysite.energy_left)
return round(13500 * self._energysite.percentage_charged / 100) Obviously, the 13500 Wh constant is not going to be very accurate, less so the older your unit is I imagine. Adjust accordingly. |
Why use 13500 when you can use |
I have powerwall 3, so no local integration (yet, hopefully). I should have specified. |
I was able to locate the total capacity of all batteries under nameplate_energy in site_info. Submitted a PR in teslajsonpy to dynamically calculate total Wh remaining. |
Thank you gkwok1 for the fix. Really useful! |
fix: bump teslajsonpy to 3.10.3 (alandtse#919)
I didn't get a chance to go down this custom calculation to hack the SOC readings, but I did notice that this issue magically fixed itself over the recent updates. My SOC on the Telsa app is almost the same as what is reflected in HACS. Specifically it is often the same, but may be off by 1% which may simply be a rounding situation. Whatever it is, it's no longer a problem for me where I need to go down a special calculation to resolve the value. FYI |
I updated the calculation upstream in Teslajsonpy using the total available battery * remaining battery %. This issue was resolved on Teslajsonpy 3.10.3 / tesla 3.20.6.
|
Awesome. In that case, thank YOU! |
Is there an existing issue for this?
Version of the Tesla component
3.20.3
Version of the Powerwall Gateway software
23.44.0 eb113390
Model
2
Current Behavior
Issue is also present in 3.20.4 as well.
I use the sensor.powerwall_name_battery (battery soc) extensively. As of 07:30 GMT on 2024-03-21 the integration is no longer reporting the value of this sensor and the HA UI shows it as 'Unavailable'. Editing the dashboard tells me that 'the integration is no longer providing this sensor'. This doesn't seem likely (it is one of the most critical and useful sensors for the Powerwall) so I am guessing it may be a HA or Tesla Api issue? All the other Powerwall controls and sensors appear to be functioning as they should. My Tesla app is showing the correct SOC% value. Direct access to the local gateway API also returns the correct value. The integration debug logs show that it seems to be getting the value correctly via the Tesla API:
"percentage_charged":92.58090184179486
Expected Behavior
The sensor value should be reported just as it always was.
Debug logs
Anything else?
Some screenshots showing the issue (ZIP file)
The text was updated successfully, but these errors were encountered: