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

Integration no longer exposes Powerwall Battery SoC% (may be Tesla or HA issue) #919

Closed
1 task done
ChrisJ60 opened this issue Mar 21, 2024 · 49 comments
Closed
1 task done
Labels
tesla_issue Issue with Tesla API; fix may not be possible triage New issues raised that need initial attention

Comments

@ChrisJ60
Copy link

Is there an existing issue for this?

  • I have searched both the existing open issues & recently closed issues and did not find a duplicate of this issue.

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

2024-03-21 08:23:38.036 DEBUG (MainThread) [custom_components.tesla_custom] Running controller.update()
2024-03-21 08:23:38.036 DEBUG (MainThread) [teslajsonpy.controller] Updating SITE_DATA for energysite: 264032220815
2024-03-21 08:23:38.036 DEBUG (MainThread) [teslajsonpy.connection] Token expiration in 7:58:03
2024-03-21 08:23:38.037 DEBUG (MainThread) [teslajsonpy.connection] get: https://owner-api.teslamotors.com/api/1/energy_sites/264032220815/live_status {}
2024-03-21 08:23:38.312 DEBUG (MainThread) [teslajsonpy.connection] 200: {"response":{"solar_power":1194,"percentage_charged":92.58090184179486,"backup_capable":true,"battery_power":-430,"load_power":764,"grid_status":"Active","grid_services_active":false,"grid_power":0,"grid_services_power":0,"generator_power":0,"island_status":"on_grid","storm_mode_active":false,"timestamp":"2024-03-21T08:23:38Z","wall_connectors":[]}}
2024-03-21 08:23:38.312 DEBUG (MainThread) [teslajsonpy.controller] Updating SITE_CONFIG for energysite: 264032220815
2024-03-21 08:23:38.312 DEBUG (MainThread) [teslajsonpy.connection] Token expiration in 7:58:03
2024-03-21 08:23:38.313 DEBUG (MainThread) [teslajsonpy.connection] get: https://owner-api.teslamotors.com/api/1/energy_sites/264032220815/site_info {}
2024-03-21 08:23:38.553 DEBUG (MainThread) [teslajsonpy.connection] 200: {"response":{"id":"1152100-13-J--CN321257G3J8UU","site_name":"Jenkins Family","backup_reserve_percent":20,"default_real_mode":"autonomous","installation_date":"2021-12-12T14:41:51Z","user_settings":{"go_off_grid_test_banner_enabled":false,"storm_mode_enabled":false,"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":false,"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,"rate_plan_manager_supported":true,"battery_type":"ac_powerwall","configurable":true,"grid_services_enabled":false,"customer_preferred_export_rule":"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":2,"tariff_content":{"code":"Tesla_TOU(edited)","name":"Intelligent Octopus","utility":"Octopus","daily_charges":[{"amount":0,"name":"Charge"}],"demand_charges":{"ALL":{"ALL":0},"Summer":{},"Winter":{}},"energy_charges":{"ALL":{"ALL":0},"Summer":{"ON_PEAK":0.31,"SUPER_OFF_PEAK":0.07},"Winter":{}},"seasons":{"Summer":{"fromDay":1,"toDay":31,"fromMonth":1,"toMonth":12,"tou_periods":{"ON_PEAK":[{"fromDayOfWeek":0,"toDayOfWeek":6,"fromHour":5,"fromMinute":30,"toHour":23,"toMinute":30}],"SUPER_OFF_PEAK":[{"fromDayOfWeek":0,"toDayOfWeek":6,"fromHour":23,"fromMinute":30,"toHour":5,"toMinute":30}]}},"Winter":{"fromDay":0,"toDay":0,"fromMonth":0,"toMonth":0,"tou_periods":{}}},"sell_tariff":{"name":"Intelligent Octopus","utility":"Octopus","daily_charges":[{"amount":0,"name":"Charge"}],"demand_charges":{"ALL":{"ALL":0},"Summer":{},"Winter":{}},"energy_charges":{"ALL":{"ALL":0},"Summer":{"ON_PEAK":0.15,"SUPER_OFF_PEAK":0.15},"Winter":{}},"seasons":{"Summer":{"fromDay":1,"toDay":31,"fromMonth":1,"toMonth":12,"tou_periods":{"ON_PEAK":[{"fromDayOfWeek":0,"toDayOfWeek":6,"fromHour":5,"fromMinute":30,"toHour":23,"toMinute":30}],"SUPER_OFF_PEAK":[{"fromDayOfWeek":0,"toDayOfWeek":6,"fromHour":23,"fromMinute":30,"toHour":5,"toMinute":30}]}},"Winter":{"fromDay":0,"toDay":0,"fromMonth":0,"toMonth":0,"tou_periods":{}}}}},"nameplate_power":10000,"nameplate_energy":27000,"installation_time_zone":"Europe/London","max_site_meter_power_ac":1000000000,"min_site_meter_power_ac":-1000000000,"geolocation":{"latitude":51.4273348,"longitude":-0.769474,"source":"Site Address Preference"},"address":{"address_line1":"38 Wilstrode Avenue","city":"Bracknell","state":"BRACKNELL FOREST","zip":"RG42 4UW","country":"GB"},"vpp_backup_reserve_percent":20}}
2024-03-21 08:23:38.553 DEBUG (MainThread) [teslajsonpy.controller] Updating SITE_SUMMARY for energysite: 264032220815
2024-03-21 08:23:38.553 DEBUG (MainThread) [teslajsonpy.connection] Token expiration in 7:58:03
2024-03-21 08:23:38.553 DEBUG (MainThread) [teslajsonpy.connection] get: https://owner-api.teslamotors.com/api/1/energy_sites/264032220815/site_status {}
2024-03-21 08:23:38.743 DEBUG (MainThread) [teslajsonpy.connection] 200: {"response":{"resource_type":"battery","site_name":"Jenkins Family","gateway_id":"1152100-13-J--CN321257G3J8UU","percentage_charged":92.58090184179486,"battery_type":"ac_powerwall","backup_capable":true,"battery_power":-440,"go_off_grid_test_banner_enabled":null,"storm_mode_enabled":false,"powerwall_onboarding_settings_set":true,"powerwall_tesla_electric_interested_in":null,"vpp_tour_enabled":null,"sync_grid_alert_enabled":true,"breaker_alert_enabled":true}}
2024-03-21 08:23:38.743 DEBUG (MainThread) [custom_components.tesla_custom] Finished fetching tesla_custom data in 0.707 seconds (success: True)
2024-03-21 08:23:38.743 ERROR (MainThread) [homeassistant] Error doing job: Task exception was never retrieved
Traceback (most recent call last):
File "/usr/src/homeassistant/homeassistant/helpers/update_coordinator.py", line 261, in _handle_refresh_interval
await self._async_refresh(log_failures=True, scheduled=True)
File "/usr/src/homeassistant/homeassistant/helpers/update_coordinator.py", line 417, in _async_refresh
self.async_update_listeners()
File "/usr/src/homeassistant/homeassistant/helpers/update_coordinator.py", line 183, in async_update_listeners
update_callback()
File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 992, in async_write_ha_state
self._async_write_ha_state()
File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 1113, in _async_write_ha_state
state, attr, capabilities, shadowed_attr = self.__async_calculate_state()
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 1050, in __async_calculate_state
state = self._stringify_state(available)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 998, in _stringify_state
if (state := self.state) is None:
^^^^^^^^^^
File "/usr/src/homeassistant/homeassistant/components/sensor/__init__.py", line 548, in state
value = self.native_value
^^^^^^^^^^^^^^^^^
File "/config/custom_components/tesla_custom/sensor.py", line 443, in native_value
return round(self._energysite.energy_left)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
TypeError: type NoneType doesn't define __round__ method
2024-03-21 08:23:48.038 DEBUG (MainThread) [custom_components.tesla_custom] Running controller.update()
2024-03-21 08:23:48.038 DEBUG (MainThread) [teslajsonpy.controller] Updating SITE_DATA for energysite: 264032220815
2024-03-21 08:23:48.039 DEBUG (MainThread) [teslajsonpy.connection] Token expiration in 7:57:53
2024-03-21 08:23:48.039 DEBUG (MainThread) [teslajsonpy.connection] get: https://owner-api.teslamotors.com/api/1/energy_sites/264032220815/live_status {}
2024-03-21 08:23:48.384 DEBUG (MainThread) [teslajsonpy.connection] 200: {"response":{"solar_power":1197,"percentage_charged":92.58090184179486,"backup_capable":true,"battery_power":-440,"load_power":757,"grid_status":"Active","grid_services_active":false,"grid_power":0,"grid_services_power":0,"generator_power":0,"island_status":"on_grid","storm_mode_active":false,"timestamp":"2024-03-21T08:23:48Z","wall_connectors":[]}}
2024-03-21 08:23:48.385 DEBUG (MainThread) [teslajsonpy.controller] Updating SITE_CONFIG for energysite: 264032220815
2024-03-21 08:23:48.385 DEBUG (MainThread) [teslajsonpy.connection] Token expiration in 7:57:53
2024-03-21 08:23:48.385 DEBUG (MainThread) [teslajsonpy.connection] get: https://owner-api.teslamotors.com/api/1/energy_sites/264032220815/site_info {}
2024-03-21 08:23:48.679 DEBUG (MainThread) [teslajsonpy.connection] 200: {"response":{"id":"1152100-13-J--CN321257G3J8UU","site_name":"Jenkins Family","backup_reserve_percent":20,"default_real_mode":"autonomous","installation_date":"2021-12-12T14:41:51Z","user_settings":{"go_off_grid_test_banner_enabled":false,"storm_mode_enabled":false,"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":false,"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,"rate_plan_manager_supported":true,"battery_type":"ac_powerwall","configurable":true,"grid_services_enabled":false,"customer_preferred_export_rule":"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":2,"tariff_content":{"code":"Tesla_TOU(edited)","name":"Intelligent Octopus","utility":"Octopus","daily_charges":[{"amount":0,"name":"Charge"}],"demand_charges":{"ALL":{"ALL":0},"Summer":{},"Winter":{}},"energy_charges":{"ALL":{"ALL":0},"Summer":{"ON_PEAK":0.31,"SUPER_OFF_PEAK":0.07},"Winter":{}},"seasons":{"Summer":{"fromDay":1,"toDay":31,"fromMonth":1,"toMonth":12,"tou_periods":{"ON_PEAK":[{"fromDayOfWeek":0,"toDayOfWeek":6,"fromHour":5,"fromMinute":30,"toHour":23,"toMinute":30}],"SUPER_OFF_PEAK":[{"fromDayOfWeek":0,"toDayOfWeek":6,"fromHour":23,"fromMinute":30,"toHour":5,"toMinute":30}]}},"Winter":{"fromDay":0,"toDay":0,"fromMonth":0,"toMonth":0,"tou_periods":{}}},"sell_tariff":{"name":"Intelligent Octopus","utility":"Octopus","daily_charges":[{"amount":0,"name":"Charge"}],"demand_charges":{"ALL":{"ALL":0},"Summer":{},"Winter":{}},"energy_charges":{"ALL":{"ALL":0},"Summer":{"ON_PEAK":0.15,"SUPER_OFF_PEAK":0.15},"Winter":{}},"seasons":{"Summer":{"fromDay":1,"toDay":31,"fromMonth":1,"toMonth":12,"tou_periods":{"ON_PEAK":[{"fromDayOfWeek":0,"toDayOfWeek":6,"fromHour":5,"fromMinute":30,"toHour":23,"toMinute":30}],"SUPER_OFF_PEAK":[{"fromDayOfWeek":0,"toDayOfWeek":6,"fromHour":23,"fromMinute":30,"toHour":5,"toMinute":30}]}},"Winter":{"fromDay":0,"toDay":0,"fromMonth":0,"toMonth":0,"tou_periods":{}}}}},"nameplate_power":10000,"nameplate_energy":27000,"installation_time_zone":"Europe/London","max_site_meter_power_ac":1000000000,"min_site_meter_power_ac":-1000000000,"geolocation":{"latitude":51.4273348,"longitude":-0.769474,"source":"Site Address Preference"},"address":{"address_line1":"38 Wilstrode Avenue","city":"Bracknell","state":"BRACKNELL FOREST","zip":"RG42 4UW","country":"GB"},"vpp_backup_reserve_percent":20}}
2024-03-21 08:23:48.679 DEBUG (MainThread) [teslajsonpy.controller] Updating SITE_SUMMARY for energysite: 264032220815
2024-03-21 08:23:48.679 DEBUG (MainThread) [teslajsonpy.connection] Token expiration in 7:57:53
2024-03-21 08:23:48.679 DEBUG (MainThread) [teslajsonpy.connection] get: https://owner-api.teslamotors.com/api/1/energy_sites/264032220815/site_status {}
2024-03-21 08:23:48.871 DEBUG (MainThread) [teslajsonpy.connection] 200: {"response":{"resource_type":"battery","site_name":"Jenkins Family","gateway_id":"1152100-13-J--CN321257G3J8UU","percentage_charged":92.58090184179486,"battery_type":"ac_powerwall","backup_capable":true,"battery_power":-440,"go_off_grid_test_banner_enabled":null,"storm_mode_enabled":false,"powerwall_onboarding_settings_set":true,"powerwall_tesla_electric_interested_in":null,"vpp_tour_enabled":null,"sync_grid_alert_enabled":true,"breaker_alert_enabled":true}}
2024-03-21 08:23:48.872 DEBUG (MainThread) [custom_components.tesla_custom] Finished fetching tesla_custom data in 0.833 seconds (success: True)
2024-03-21 08:23:48.872 ERROR (MainThread) [homeassistant] Error doing job: Task exception was never retrieved
Traceback (most recent call last):
File "/usr/src/homeassistant/homeassistant/helpers/update_coordinator.py", line 261, in _handle_refresh_interval
await self._async_refresh(log_failures=True, scheduled=True)
File "/usr/src/homeassistant/homeassistant/helpers/update_coordinator.py", line 417, in _async_refresh
self.async_update_listeners()
File "/usr/src/homeassistant/homeassistant/helpers/update_coordinator.py", line 183, in async_update_listeners
update_callback()
File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 992, in async_write_ha_state
self._async_write_ha_state()
File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 1113, in _async_write_ha_state
state, attr, capabilities, shadowed_attr = self.__async_calculate_state()
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 1050, in __async_calculate_state
state = self._stringify_state(available)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 998, in _stringify_state
if (state := self.state) is None:
^^^^^^^^^^
File "/usr/src/homeassistant/homeassistant/components/sensor/__init__.py", line 548, in state
value = self.native_value
^^^^^^^^^^^^^^^^^
File "/config/custom_components/tesla_custom/sensor.py", line 443, in native_value
return round(self._energysite.energy_left)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
TypeError: type NoneType doesn't define __round__ method
2024-03-21 08:23:59.035 DEBUG (MainThread) [custom_components.tesla_custom] Running controller.update()
2024-03-21 08:23:59.035 DEBUG (MainThread) [teslajsonpy.controller] Updating SITE_DATA for energysite: 264032220815
2024-03-21 08:23:59.035 DEBUG (MainThread) [teslajsonpy.connection] Token expiration in 7:57:42
2024-03-21 08:23:59.036 DEBUG (MainThread) [teslajsonpy.connection] get: https://owner-api.teslamotors.com/api/1/energy_sites/264032220815/live_status {}
2024-03-21 08:23:59.332 DEBUG (MainThread) [teslajsonpy.connection] 200: {"response":{"solar_power":1198,"percentage_charged":92.58090184179486,"backup_capable":true,"battery_power":-450,"load_power":748,"grid_status":"Active","grid_services_active":false,"grid_power":0,"grid_services_power":0,"generator_power":0,"island_status":"on_grid","storm_mode_active":false,"timestamp":"2024-03-21T08:23:59Z","wall_connectors":[]}}
2024-03-21 08:23:59.333 DEBUG (MainThread) [teslajsonpy.controller] Updating SITE_CONFIG for energysite: 264032220815
2024-03-21 08:23:59.333 DEBUG (MainThread) [teslajsonpy.connection] Token expiration in 7:57:42
2024-03-21 08:23:59.333 DEBUG (MainThread) [teslajsonpy.connection] get: https://owner-api.teslamotors.com/api/1/energy_sites/264032220815/site_info {}
2024-03-21 08:23:59.610 DEBUG (MainThread) [teslajsonpy.connection] 200: {"response":{"id":"1152100-13-J--CN321257G3J8UU","site_name":"Jenkins Family","backup_reserve_percent":20,"default_real_mode":"autonomous","installation_date":"2021-12-12T14:41:51Z","user_settings":{"go_off_grid_test_banner_enabled":false,"storm_mode_enabled":false,"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":false,"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,"rate_plan_manager_supported":true,"battery_type":"ac_powerwall","configurable":true,"grid_services_enabled":false,"customer_preferred_export_rule":"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":2,"tariff_content":{"code":"Tesla_TOU(edited)","name":"Intelligent Octopus","utility":"Octopus","daily_charges":[{"amount":0,"name":"Charge"}],"demand_charges":{"ALL":{"ALL":0},"Summer":{},"Winter":{}},"energy_charges":{"ALL":{"ALL":0},"Summer":{"ON_PEAK":0.31,"SUPER_OFF_PEAK":0.07},"Winter":{}},"seasons":{"Summer":{"fromDay":1,"toDay":31,"fromMonth":1,"toMonth":12,"tou_periods":{"ON_PEAK":[{"fromDayOfWeek":0,"toDayOfWeek":6,"fromHour":5,"fromMinute":30,"toHour":23,"toMinute":30}],"SUPER_OFF_PEAK":[{"fromDayOfWeek":0,"toDayOfWeek":6,"fromHour":23,"fromMinute":30,"toHour":5,"toMinute":30}]}},"Winter":{"fromDay":0,"toDay":0,"fromMonth":0,"toMonth":0,"tou_periods":{}}},"sell_tariff":{"name":"Intelligent Octopus","utility":"Octopus","daily_charges":[{"amount":0,"name":"Charge"}],"demand_charges":{"ALL":{"ALL":0},"Summer":{},"Winter":{}},"energy_charges":{"ALL":{"ALL":0},"Summer":{"ON_PEAK":0.15,"SUPER_OFF_PEAK":0.15},"Winter":{}},"seasons":{"Summer":{"fromDay":1,"toDay":31,"fromMonth":1,"toMonth":12,"tou_periods":{"ON_PEAK":[{"fromDayOfWeek":0,"toDayOfWeek":6,"fromHour":5,"fromMinute":30,"toHour":23,"toMinute":30}],"SUPER_OFF_PEAK":[{"fromDayOfWeek":0,"toDayOfWeek":6,"fromHour":23,"fromMinute":30,"toHour":5,"toMinute":30}]}},"Winter":{"fromDay":0,"toDay":0,"fromMonth":0,"toMonth":0,"tou_periods":{}}}}},"nameplate_power":10000,"nameplate_energy":27000,"installation_time_zone":"Europe/London","max_site_meter_power_ac":1000000000,"min_site_meter_power_ac":-1000000000,"geolocation":{"latitude":51.4273348,"longitude":-0.769474,"source":"Site Address Preference"},"address":{"address_line1":"38 Wilstrode Avenue","city":"Bracknell","state":"BRACKNELL FOREST","zip":"RG42 4UW","country":"GB"},"vpp_backup_reserve_percent":20}}
2024-03-21 08:23:59.611 DEBUG (MainThread) [teslajsonpy.controller] Updating SITE_SUMMARY for energysite: 264032220815
2024-03-21 08:23:59.611 DEBUG (MainThread) [teslajsonpy.connection] Token expiration in 7:57:42
2024-03-21 08:23:59.611 DEBUG (MainThread) [teslajsonpy.connection] get: https://owner-api.teslamotors.com/api/1/energy_sites/264032220815/site_status {}
2024-03-21 08:23:59.802 DEBUG (MainThread) [teslajsonpy.connection] 200: {"response":{"resource_type":"battery","site_name":"Jenkins Family","gateway_id":"1152100-13-J--CN321257G3J8UU","percentage_charged":92.58090184179486,"battery_type":"ac_powerwall","backup_capable":true,"battery_power":-450,"go_off_grid_test_banner_enabled":null,"storm_mode_enabled":false,"powerwall_onboarding_settings_set":true,"powerwall_tesla_electric_interested_in":null,"vpp_tour_enabled":null,"sync_grid_alert_enabled":true,"breaker_alert_enabled":true}}
2024-03-21 08:23:59.802 DEBUG (MainThread) [custom_components.tesla_custom] Finished fetching tesla_custom data in 0.767 seconds (success: True)
2024-03-21 08:23:59.802 ERROR (MainThread) [homeassistant] Error doing job: Task exception was never retrieved
Traceback (most recent call last):
File "/usr/src/homeassistant/homeassistant/helpers/update_coordinator.py", line 261, in _handle_refresh_interval
await self._async_refresh(log_failures=True, scheduled=True)
File "/usr/src/homeassistant/homeassistant/helpers/update_coordinator.py", line 417, in _async_refresh
self.async_update_listeners()
File "/usr/src/homeassistant/homeassistant/helpers/update_coordinator.py", line 183, in async_update_listeners
update_callback()
File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 992, in async_write_ha_state
self._async_write_ha_state()
File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 1113, in _async_write_ha_state
state, attr, capabilities, shadowed_attr = self.__async_calculate_state()
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 1050, in __async_calculate_state
state = self._stringify_state(available)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 998, in _stringify_state
if (state := self.state) is None:
^^^^^^^^^^
File "/usr/src/homeassistant/homeassistant/components/sensor/__init__.py", line 548, in state
value = self.native_value
^^^^^^^^^^^^^^^^^
File "/config/custom_components/tesla_custom/sensor.py", line 443, in native_value
return round(self._energysite.energy_left)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
TypeError: type NoneType doesn't define __round__ method
2024-03-21 08:24:10.040 DEBUG (MainThread) [custom_components.tesla_custom] Running controller.update()
2024-03-21 08:24:10.040 DEBUG (MainThread) [teslajsonpy.controller] Updating SITE_DATA for energysite: 264032220815
2024-03-21 08:24:10.040 DEBUG (MainThread) [teslajsonpy.connection] Token expiration in 7:57:31
2024-03-21 08:24:10.040 DEBUG (MainThread) [teslajsonpy.connection] get: https://owner-api.teslamotors.com/api/1/energy_sites/264032220815/live_status {}
2024-03-21 08:24:10.562 DEBUG (MainThread) [teslajsonpy.connection] 200: {"response":{"solar_power":1198,"percentage_charged":92.58090184179486,"backup_capable":true,"battery_power":-480,"load_power":718,"grid_status":"Active","grid_services_active":false,"grid_power":0,"grid_services_power":0,"generator_power":0,"island_status":"on_grid","storm_mode_active":false,"timestamp":"2024-03-21T08:24:10Z","wall_connectors":[]}}
2024-03-21 08:24:10.562 DEBUG (MainThread) [teslajsonpy.controller] Updating SITE_CONFIG for energysite: 264032220815
2024-03-21 08:24:10.562 DEBUG (MainThread) [teslajsonpy.connection] Token expiration in 7:57:31
2024-03-21 08:24:10.562 DEBUG (MainThread) [teslajsonpy.connection] get: https://owner-api.teslamotors.com/api/1/energy_sites/264032220815/site_info {}
2024-03-21 08:24:10.844 DEBUG (MainThread) [teslajsonpy.connection] 200: {"response":{"id":"1152100-13-J--CN321257G3J8UU","site_name":"Jenkins Family","backup_reserve_percent":20,"default_real_mode":"autonomous","installation_date":"2021-12-12T14:41:51Z","user_settings":{"go_off_grid_test_banner_enabled":false,"storm_mode_enabled":false,"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":false,"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,"rate_plan_manager_supported":true,"battery_type":"ac_powerwall","configurable":true,"grid_services_enabled":false,"customer_preferred_export_rule":"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":2,"tariff_content":{"code":"Tesla_TOU(edited)","name":"Intelligent Octopus","utility":"Octopus","daily_charges":[{"amount":0,"name":"Charge"}],"demand_charges":{"ALL":{"ALL":0},"Summer":{},"Winter":{}},"energy_charges":{"ALL":{"ALL":0},"Summer":{"ON_PEAK":0.31,"SUPER_OFF_PEAK":0.07},"Winter":{}},"seasons":{"Summer":{"fromDay":1,"toDay":31,"fromMonth":1,"toMonth":12,"tou_periods":{"ON_PEAK":[{"fromDayOfWeek":0,"toDayOfWeek":6,"fromHour":5,"fromMinute":30,"toHour":23,"toMinute":30}],"SUPER_OFF_PEAK":[{"fromDayOfWeek":0,"toDayOfWeek":6,"fromHour":23,"fromMinute":30,"toHour":5,"toMinute":30}]}},"Winter":{"fromDay":0,"toDay":0,"fromMonth":0,"toMonth":0,"tou_periods":{}}},"sell_tariff":{"name":"Intelligent Octopus","utility":"Octopus","daily_charges":[{"amount":0,"name":"Charge"}],"demand_charges":{"ALL":{"ALL":0},"Summer":{},"Winter":{}},"energy_charges":{"ALL":{"ALL":0},"Summer":{"ON_PEAK":0.15,"SUPER_OFF_PEAK":0.15},"Winter":{}},"seasons":{"Summer":{"fromDay":1,"toDay":31,"fromMonth":1,"toMonth":12,"tou_periods":{"ON_PEAK":[{"fromDayOfWeek":0,"toDayOfWeek":6,"fromHour":5,"fromMinute":30,"toHour":23,"toMinute":30}],"SUPER_OFF_PEAK":[{"fromDayOfWeek":0,"toDayOfWeek":6,"fromHour":23,"fromMinute":30,"toHour":5,"toMinute":30}]}},"Winter":{"fromDay":0,"toDay":0,"fromMonth":0,"toMonth":0,"tou_periods":{}}}}},"nameplate_power":10000,"nameplate_energy":27000,"installation_time_zone":"Europe/London","max_site_meter_power_ac":1000000000,"min_site_meter_power_ac":-1000000000,"geolocation":{"latitude":51.4273348,"longitude":-0.769474,"source":"Site Address Preference"},"address":{"address_line1":"38 Wilstrode Avenue","city":"Bracknell","state":"BRACKNELL FOREST","zip":"RG42 4UW","country":"GB"},"vpp_backup_reserve_percent":20}}
2024-03-21 08:24:10.844 DEBUG (MainThread) [teslajsonpy.controller] Updating SITE_SUMMARY for energysite: 264032220815
2024-03-21 08:24:10.844 DEBUG (MainThread) [teslajsonpy.connection] Token expiration in 7:57:31
2024-03-21 08:24:10.844 DEBUG (MainThread) [teslajsonpy.connection] get: https://owner-api.teslamotors.com/api/1/energy_sites/264032220815/site_status {}
2024-03-21 08:24:11.060 DEBUG (MainThread) [teslajsonpy.connection] 200: {"response":{"resource_type":"battery","site_name":"Jenkins Family","gateway_id":"1152100-13-J--CN321257G3J8UU","percentage_charged":92.58090184179486,"battery_type":"ac_powerwall","backup_capable":true,"battery_power":-480,"go_off_grid_test_banner_enabled":null,"storm_mode_enabled":false,"powerwall_onboarding_settings_set":true,"powerwall_tesla_electric_interested_in":null,"vpp_tour_enabled":null,"sync_grid_alert_enabled":true,"breaker_alert_enabled":true}}
2024-03-21 08:24:11.060 DEBUG (MainThread) [custom_components.tesla_custom] Finished fetching tesla_custom data in 1.020 seconds (success: True)
2024-03-21 08:24:11.060 ERROR (MainThread) [homeassistant] Error doing job: Task exception was never retrieved
Traceback (most recent call last):
File "/usr/src/homeassistant/homeassistant/helpers/update_coordinator.py", line 261, in _handle_refresh_interval
await self._async_refresh(log_failures=True, scheduled=True)
File "/usr/src/homeassistant/homeassistant/helpers/update_coordinator.py", line 417, in _async_refresh
self.async_update_listeners()
File "/usr/src/homeassistant/homeassistant/helpers/update_coordinator.py", line 183, in async_update_listeners
update_callback()
File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 992, in async_write_ha_state
self._async_write_ha_state()
File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 1113, in _async_write_ha_state
state, attr, capabilities, shadowed_attr = self.__async_calculate_state()
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 1050, in __async_calculate_state
state = self._stringify_state(available)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 998, in _stringify_state
if (state := self.state) is None:
^^^^^^^^^^
File "/usr/src/homeassistant/homeassistant/components/sensor/__init__.py", line 548, in state
value = self.native_value
^^^^^^^^^^^^^^^^^
File "/config/custom_components/tesla_custom/sensor.py", line 443, in native_value
return round(self._energysite.energy_left)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
TypeError: type NoneType doesn't define __round__ method
2024-03-21 08:24:21.038 DEBUG (MainThread) [custom_components.tesla_custom] Running controller.update()
2024-03-21 08:24:21.039 DEBUG (MainThread) [teslajsonpy.controller] Updating SITE_DATA for energysite: 264032220815
2024-03-21 08:24:21.039 DEBUG (MainThread) [teslajsonpy.connection] Token expiration in 7:57:20
2024-03-21 08:24:21.039 DEBUG (MainThread) [teslajsonpy.connection] get: https://owner-api.teslamotors.com/api/1/energy_sites/264032220815/live_status {}
2024-03-21 08:24:21.289 DEBUG (MainThread) [teslajsonpy.connection] 200: {"response":{"solar_power":1197,"percentage_charged":92.58090184179486,"backup_capable":true,"battery_power":-470,"load_power":727,"grid_status":"Active","grid_services_active":false,"grid_power":0,"grid_services_power":0,"generator_power":0,"island_status":"on_grid","storm_mode_active":false,"timestamp":"2024-03-21T08:24:21Z","wall_connectors":[]}}
2024-03-21 08:24:21.289 DEBUG (MainThread) [teslajsonpy.controller] Updating SITE_CONFIG for energysite: 264032220815
2024-03-21 08:24:21.289 DEBUG (MainThread) [teslajsonpy.connection] Token expiration in 7:57:20
2024-03-21 08:24:21.289 DEBUG (MainThread) [teslajsonpy.connection] get: https://owner-api.teslamotors.com/api/1/energy_sites/264032220815/site_info {}
2024-03-21 08:24:21.523 DEBUG (MainThread) [teslajsonpy.connection] 200: {"response":{"id":"1152100-13-J--CN321257G3J8UU","site_name":"Jenkins Family","backup_reserve_percent":20,"default_real_mode":"autonomous","installation_date":"2021-12-12T14:41:51Z","user_settings":{"go_off_grid_test_banner_enabled":false,"storm_mode_enabled":false,"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":false,"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,"rate_plan_manager_supported":true,"battery_type":"ac_powerwall","configurable":true,"grid_services_enabled":false,"customer_preferred_export_rule":"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":2,"tariff_content":{"code":"Tesla_TOU(edited)","name":"Intelligent Octopus","utility":"Octopus","daily_charges":[{"amount":0,"name":"Charge"}],"demand_charges":{"ALL":{"ALL":0},"Summer":{},"Winter":{}},"energy_charges":{"ALL":{"ALL":0},"Summer":{"ON_PEAK":0.31,"SUPER_OFF_PEAK":0.07},"Winter":{}},"seasons":{"Summer":{"fromDay":1,"toDay":31,"fromMonth":1,"toMonth":12,"tou_periods":{"ON_PEAK":[{"fromDayOfWeek":0,"toDayOfWeek":6,"fromHour":5,"fromMinute":30,"toHour":23,"toMinute":30}],"SUPER_OFF_PEAK":[{"fromDayOfWeek":0,"toDayOfWeek":6,"fromHour":23,"fromMinute":30,"toHour":5,"toMinute":30}]}},"Winter":{"fromDay":0,"toDay":0,"fromMonth":0,"toMonth":0,"tou_periods":{}}},"sell_tariff":{"name":"Intelligent Octopus","utility":"Octopus","daily_charges":[{"amount":0,"name":"Charge"}],"demand_charges":{"ALL":{"ALL":0},"Summer":{},"Winter":{}},"energy_charges":{"ALL":{"ALL":0},"Summer":{"ON_PEAK":0.15,"SUPER_OFF_PEAK":0.15},"Winter":{}},"seasons":{"Summer":{"fromDay":1,"toDay":31,"fromMonth":1,"toMonth":12,"tou_periods":{"ON_PEAK":[{"fromDayOfWeek":0,"toDayOfWeek":6,"fromHour":5,"fromMinute":30,"toHour":23,"toMinute":30}],"SUPER_OFF_PEAK":[{"fromDayOfWeek":0,"toDayOfWeek":6,"fromHour":23,"fromMinute":30,"toHour":5,"toMinute":30}]}},"Winter":{"fromDay":0,"toDay":0,"fromMonth":0,"toMonth":0,"tou_periods":{}}}}},"nameplate_power":10000,"nameplate_energy":27000,"installation_time_zone":"Europe/London","max_site_meter_power_ac":1000000000,"min_site_meter_power_ac":-1000000000,"geolocation":{"latitude":51.4273348,"longitude":-0.769474,"source":"Site Address Preference"},"address":{"address_line1":"38 Wilstrode Avenue","city":"Bracknell","state":"BRACKNELL FOREST","zip":"RG42 4UW","country":"GB"},"vpp_backup_reserve_percent":20}}
2024-03-21 08:24:21.523 DEBUG (MainThread) [teslajsonpy.controller] Updating SITE_SUMMARY for energysite: 264032220815
2024-03-21 08:24:21.524 DEBUG (MainThread) [teslajsonpy.connection] Token expiration in 7:57:20
2024-03-21 08:24:21.524 DEBUG (MainThread) [teslajsonpy.connection] get: https://owner-api.teslamotors.com/api/1/energy_sites/264032220815/site_status {}
2024-03-21 08:24:21.742 DEBUG (MainThread) [teslajsonpy.connection] 200: {"response":{"resource_type":"battery","site_name":"Jenkins Family","gateway_id":"1152100-13-J--CN321257G3J8UU","percentage_charged":92.58090184179486,"battery_type":"ac_powerwall","backup_capable":true,"battery_power":-470,"go_off_grid_test_banner_enabled":null,"storm_mode_enabled":false,"powerwall_onboarding_settings_set":true,"powerwall_tesla_electric_interested_in":null,"vpp_tour_enabled":null,"sync_grid_alert_enabled":true,"breaker_alert_enabled":true}}
2024-03-21 08:24:21.742 DEBUG (MainThread) [custom_components.tesla_custom] Finished fetching tesla_custom data in 0.704 seconds (success: True)
2024-03-21 08:24:21.742 ERROR (MainThread) [homeassistant] Error doing job: Task exception was never retrieved
Traceback (most recent call last):
File "/usr/src/homeassistant/homeassistant/helpers/update_coordinator.py", line 261, in _handle_refresh_interval
await self._async_refresh(log_failures=True, scheduled=True)
File "/usr/src/homeassistant/homeassistant/helpers/update_coordinator.py", line 417, in _async_refresh
self.async_update_listeners()
File "/usr/src/homeassistant/homeassistant/helpers/update_coordinator.py", line 183, in async_update_listeners
update_callback()
File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 992, in async_write_ha_state
self._async_write_ha_state()
File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 1113, in _async_write_ha_state
state, attr, capabilities, shadowed_attr = self.__async_calculate_state()
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 1050, in __async_calculate_state
state = self._stringify_state(available)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 998, in _stringify_state
if (state := self.state) is None:
^^^^^^^^^^
File "/usr/src/homeassistant/homeassistant/components/sensor/__init__.py", line 548, in state
value = self.native_value
^^^^^^^^^^^^^^^^^
File "/config/custom_components/tesla_custom/sensor.py", line 443, in native_value
return round(self._energysite.energy_left)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
TypeError: type NoneType doesn't define __round__ method
2024-03-21 08:24:31.040 DEBUG (MainThread) [custom_components.tesla_custom] Running controller.update()
2024-03-21 08:24:31.041 DEBUG (MainThread) [teslajsonpy.controller] Updating SITE_DATA for energysite: 264032220815
2024-03-21 08:24:31.041 DEBUG (MainThread) [teslajsonpy.connection] Token expiration in 7:57:10
2024-03-21 08:24:31.042 DEBUG (MainThread) [teslajsonpy.connection] get: https://owner-api.teslamotors.com/api/1/energy_sites/264032220815/live_status {}
2024-03-21 08:24:31.296 DEBUG (MainThread) [teslajsonpy.connection] 200: {"response":{"solar_power":1202,"percentage_charged":92.58090184179486,"backup_capable":true,"battery_power":-430,"load_power":772,"grid_status":"Active","grid_services_active":false,"grid_power":0,"grid_services_power":0,"generator_power":0,"island_status":"on_grid","storm_mode_active":false,"timestamp":"2024-03-21T08:24:31Z","wall_connectors":[]}}
2024-03-21 08:24:31.296 DEBUG (MainThread) [teslajsonpy.controller] Updating SITE_CONFIG for energysite: 264032220815
2024-03-21 08:24:31.296 DEBUG (MainThread) [teslajsonpy.connection] Token expiration in 7:57:10
2024-03-21 08:24:31.296 DEBUG (MainThread) [teslajsonpy.connection] get: https://owner-api.teslamotors.com/api/1/energy_sites/264032220815/site_info {}
2024-03-21 08:24:31.534 DEBUG (MainThread) [teslajsonpy.connection] 200: {"response":{"id":"1152100-13-J--CN321257G3J8UU","site_name":"Jenkins Family","backup_reserve_percent":20,"default_real_mode":"autonomous","installation_date":"2021-12-12T14:41:51Z","user_settings":{"go_off_grid_test_banner_enabled":false,"storm_mode_enabled":false,"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":false,"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,"rate_plan_manager_supported":true,"battery_type":"ac_powerwall","configurable":true,"grid_services_enabled":false,"customer_preferred_export_rule":"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":2,"tariff_content":{"code":"Tesla_TOU(edited)","name":"Intelligent Octopus","utility":"Octopus","daily_charges":[{"amount":0,"name":"Charge"}],"demand_charges":{"ALL":{"ALL":0},"Summer":{},"Winter":{}},"energy_charges":{"ALL":{"ALL":0},"Summer":{"ON_PEAK":0.31,"SUPER_OFF_PEAK":0.07},"Winter":{}},"seasons":{"Summer":{"fromDay":1,"toDay":31,"fromMonth":1,"toMonth":12,"tou_periods":{"ON_PEAK":[{"fromDayOfWeek":0,"toDayOfWeek":6,"fromHour":5,"fromMinute":30,"toHour":23,"toMinute":30}],"SUPER_OFF_PEAK":[{"fromDayOfWeek":0,"toDayOfWeek":6,"fromHour":23,"fromMinute":30,"toHour":5,"toMinute":30}]}},"Winter":{"fromDay":0,"toDay":0,"fromMonth":0,"toMonth":0,"tou_periods":{}}},"sell_tariff":{"name":"Intelligent Octopus","utility":"Octopus","daily_charges":[{"amount":0,"name":"Charge"}],"demand_charges":{"ALL":{"ALL":0},"Summer":{},"Winter":{}},"energy_charges":{"ALL":{"ALL":0},"Summer":{"ON_PEAK":0.15,"SUPER_OFF_PEAK":0.15},"Winter":{}},"seasons":{"Summer":{"fromDay":1,"toDay":31,"fromMonth":1,"toMonth":12,"tou_periods":{"ON_PEAK":[{"fromDayOfWeek":0,"toDayOfWeek":6,"fromHour":5,"fromMinute":30,"toHour":23,"toMinute":30}],"SUPER_OFF_PEAK":[{"fromDayOfWeek":0,"toDayOfWeek":6,"fromHour":23,"fromMinute":30,"toHour":5,"toMinute":30}]}},"Winter":{"fromDay":0,"toDay":0,"fromMonth":0,"toMonth":0,"tou_periods":{}}}}},"nameplate_power":10000,"nameplate_energy":27000,"installation_time_zone":"Europe/London","max_site_meter_power_ac":1000000000,"min_site_meter_power_ac":-1000000000,"geolocation":{"latitude":51.4273348,"longitude":-0.769474,"source":"Site Address Preference"},"address":{"address_line1":"38 Wilstrode Avenue","city":"Bracknell","state":"BRACKNELL FOREST","zip":"RG42 4UW","country":"GB"},"vpp_backup_reserve_percent":20}}
2024-03-21 08:24:31.534 DEBUG (MainThread) [teslajsonpy.controller] Updating SITE_SUMMARY for energysite: 264032220815
2024-03-21 08:24:31.534 DEBUG (MainThread) [teslajsonpy.connection] Token expiration in 7:57:10
2024-03-21 08:24:31.534 DEBUG (MainThread) [teslajsonpy.connection] get: https://owner-api.teslamotors.com/api/1/energy_sites/264032220815/site_status {}
2024-03-21 08:24:31.737 DEBUG (MainThread) [teslajsonpy.connection] 200: {"response":{"resource_type":"battery","site_name":"Jenkins Family","gateway_id":"1152100-13-J--CN321257G3J8UU","percentage_charged":92.58090184179486,"battery_type":"ac_powerwall","backup_capable":true,"battery_power":-430,"go_off_grid_test_banner_enabled":null,"storm_mode_enabled":false,"powerwall_onboarding_settings_set":true,"powerwall_tesla_electric_interested_in":null,"vpp_tour_enabled":null,"sync_grid_alert_enabled":true,"breaker_alert_enabled":true}}
2024-03-21 08:24:31.737 DEBUG (MainThread) [custom_components.tesla_custom] Finished fetching tesla_custom data in 0.697 seconds (success: True)
2024-03-21 08:24:31.738 ERROR (MainThread) [homeassistant] Error doing job: Task exception was never retrieved
Traceback (most recent call last):
File "/usr/src/homeassistant/homeassistant/helpers/update_coordinator.py", line 261, in _handle_refresh_interval
await self._async_refresh(log_failures=True, scheduled=True)
File "/usr/src/homeassistant/homeassistant/helpers/update_coordinator.py", line 417, in _async_refresh
self.async_update_listeners()
File "/usr/src/homeassistant/homeassistant/helpers/update_coordinator.py", line 183, in async_update_listeners
update_callback()
File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 992, in async_write_ha_state
self._async_write_ha_state()
File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 1113, in _async_write_ha_state
state, attr, capabilities, shadowed_attr = self.__async_calculate_state()
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 1050, in __async_calculate_state
state = self._stringify_state(available)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 998, in _stringify_state
if (state := self.state) is None:
^^^^^^^^^^
File "/usr/src/homeassistant/homeassistant/components/sensor/__init__.py", line 548, in state
value = self.native_value
^^^^^^^^^^^^^^^^^
File "/config/custom_components/tesla_custom/sensor.py", line 443, in native_value
return round(self._energysite.energy_left)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
TypeError: type NoneType doesn't define __round__ method
2024-03-21 08:24:41.036 DEBUG (MainThread) [custom_components.tesla_custom] Running controller.update()
2024-03-21 08:24:41.036 DEBUG (MainThread) [teslajsonpy.controller] Updating SITE_DATA for energysite: 264032220815
2024-03-21 08:24:41.036 DEBUG (MainThread) [teslajsonpy.connection] Token expiration in 7:57:00
2024-03-21 08:24:41.036 DEBUG (MainThread) [teslajsonpy.connection] get: https://owner-api.teslamotors.com/api/1/energy_sites/264032220815/live_status {}
2024-03-21 08:24:41.358 DEBUG (MainThread) [teslajsonpy.connection] 200: {"response":{"solar_power":1216,"percentage_charged":92.58090184179486,"backup_capable":true,"battery_power":-530,"load_power":686,"grid_status":"Active","grid_services_active":false,"grid_power":0,"grid_services_power":0,"generator_power":0,"island_status":"on_grid","storm_mode_active":false,"timestamp":"2024-03-21T08:24:41Z","wall_connectors":[]}}
2024-03-21 08:24:41.358 DEBUG (MainThread) [teslajsonpy.controller] Updating SITE_CONFIG for energysite: 264032220815
2024-03-21 08:24:41.358 DEBUG (MainThread) [teslajsonpy.connection] Token expiration in 7:57:00
2024-03-21 08:24:41.358 DEBUG (MainThread) [teslajsonpy.connection] get: https://owner-api.teslamotors.com/api/1/energy_sites/264032220815/site_info {}
2024-03-21 08:24:41.584 DEBUG (MainThread) [teslajsonpy.connection] 200: {"response":{"id":"1152100-13-J--CN321257G3J8UU","site_name":"Jenkins Family","backup_reserve_percent":20,"default_real_mode":"autonomous","installation_date":"2021-12-12T14:41:51Z","user_settings":{"go_off_grid_test_banner_enabled":false,"storm_mode_enabled":false,"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":false,"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,"rate_plan_manager_supported":true,"battery_type":"ac_powerwall","configurable":true,"grid_services_enabled":false,"customer_preferred_export_rule":"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":2,"tariff_content":{"code":"Tesla_TOU(edited)","name":"Intelligent Octopus","utility":"Octopus","daily_charges":[{"amount":0,"name":"Charge"}],"demand_charges":{"ALL":{"ALL":0},"Summer":{},"Winter":{}},"energy_charges":{"ALL":{"ALL":0},"Summer":{"ON_PEAK":0.31,"SUPER_OFF_PEAK":0.07},"Winter":{}},"seasons":{"Summer":{"fromDay":1,"toDay":31,"fromMonth":1,"toMonth":12,"tou_periods":{"ON_PEAK":[{"fromDayOfWeek":0,"toDayOfWeek":6,"fromHour":5,"fromMinute":30,"toHour":23,"toMinute":30}],"SUPER_OFF_PEAK":[{"fromDayOfWeek":0,"toDayOfWeek":6,"fromHour":23,"fromMinute":30,"toHour":5,"toMinute":30}]}},"Winter":{"fromDay":0,"toDay":0,"fromMonth":0,"toMonth":0,"tou_periods":{}}},"sell_tariff":{"name":"Intelligent Octopus","utility":"Octopus","daily_charges":[{"amount":0,"name":"Charge"}],"demand_charges":{"ALL":{"ALL":0},"Summer":{},"Winter":{}},"energy_charges":{"ALL":{"ALL":0},"Summer":{"ON_PEAK":0.15,"SUPER_OFF_PEAK":0.15},"Winter":{}},"seasons":{"Summer":{"fromDay":1,"toDay":31,"fromMonth":1,"toMonth":12,"tou_periods":{"ON_PEAK":[{"fromDayOfWeek":0,"toDayOfWeek":6,"fromHour":5,"fromMinute":30,"toHour":23,"toMinute":30}],"SUPER_OFF_PEAK":[{"fromDayOfWeek":0,"toDayOfWeek":6,"fromHour":23,"fromMinute":30,"toHour":5,"toMinute":30}]}},"Winter":{"fromDay":0,"toDay":0,"fromMonth":0,"toMonth":0,"tou_periods":{}}}}},"nameplate_power":10000,"nameplate_energy":27000,"installation_time_zone":"Europe/London","max_site_meter_power_ac":1000000000,"min_site_meter_power_ac":-1000000000,"geolocation":{"latitude":51.4273348,"longitude":-0.769474,"source":"Site Address Preference"},"address":{"address_line1":"38 Wilstrode Avenue","city":"Bracknell","state":"BRACKNELL FOREST","zip":"RG42 4UW","country":"GB"},"vpp_backup_reserve_percent":20}}
2024-03-21 08:24:41.584 DEBUG (MainThread) [teslajsonpy.controller] Updating SITE_SUMMARY for energysite: 264032220815
2024-03-21 08:24:41.584 DEBUG (MainThread) [teslajsonpy.connection] Token expiration in 7:57:00
2024-03-21 08:24:41.584 DEBUG (MainThread) [teslajsonpy.connection] get: https://owner-api.teslamotors.com/api/1/energy_sites/264032220815/site_status {}
2024-03-21 08:24:41.765 DEBUG (MainThread) [teslajsonpy.connection] 200: {"response":{"resource_type":"battery","site_name":"Jenkins Family","gateway_id":"1152100-13-J--CN321257G3J8UU","percentage_charged":92.58090184179486,"battery_type":"ac_powerwall","backup_capable":true,"battery_power":-530,"go_off_grid_test_banner_enabled":null,"storm_mode_enabled":false,"powerwall_onboarding_settings_set":true,"powerwall_tesla_electric_interested_in":null,"vpp_tour_enabled":null,"sync_grid_alert_enabled":true,"breaker_alert_enabled":true}}
2024-03-21 08:24:41.765 DEBUG (MainThread) [custom_components.tesla_custom] Finished fetching tesla_custom data in 0.729 seconds (success: True)
2024-03-21 08:24:41.765 ERROR (MainThread) [homeassistant] Error doing job: Task exception was never retrieved
Traceback (most recent call last):
File "/usr/src/homeassistant/homeassistant/helpers/update_coordinator.py", line 261, in _handle_refresh_interval
await self._async_refresh(log_failures=True, scheduled=True)
File "/usr/src/homeassistant/homeassistant/helpers/update_coordinator.py", line 417, in _async_refresh
self.async_update_listeners()
File "/usr/src/homeassistant/homeassistant/helpers/update_coordinator.py", line 183, in async_update_listeners
update_callback()
File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 992, in async_write_ha_state
self._async_write_ha_state()
File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 1113, in _async_write_ha_state
state, attr, capabilities, shadowed_attr = self.__async_calculate_state()
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 1050, in __async_calculate_state
state = self._stringify_state(available)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 998, in _stringify_state
if (state := self.state) is None:
^^^^^^^^^^
File "/usr/src/homeassistant/homeassistant/components/sensor/__init__.py", line 548, in state
value = self.native_value
^^^^^^^^^^^^^^^^^
File "/config/custom_components/tesla_custom/sensor.py", line 443, in native_value
return round(self._energysite.energy_left)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
TypeError: type NoneType doesn't define __round__ method

Anything else?

Some screenshots showing the issue (ZIP file)

@ChrisJ60 ChrisJ60 added the triage New issues raised that need initial attention label Mar 21, 2024
@bmsrecycle
Copy link

I'm getting the same issue which appeared this morning, we have done no updates.

@ChrisJ60
Copy link
Author

@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...

@vintner123
Copy link

same here, can see everything except battery charge and battery remaining, again no updates on HA, i guess must be an api thing?????

@Avatar1976
Copy link

Yes same I noticed that the percentage was stuck earlier at some low number this morning Sydney but after restarting HA it says unavailable.

@skipishere
Copy link
Collaborator

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)

@skipishere skipishere added the tesla_issue Issue with Tesla API; fix may not be possible label Mar 21, 2024
@BrettLynch
Copy link

BrettLynch commented Mar 21, 2024

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.

@skipishere
Copy link
Collaborator

skipishere commented Mar 21, 2024

From looking at teslajsonpy it was looking for a energy_left segment in the json which no longer appears in the response. eg mine right now

{"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
  }
}

@ChrisJ60
Copy link
Author

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.

@skipishere
Copy link
Collaborator

I think you might have caught the old message I wrote and then corrected battery_power indeed is the current discharge (I was charging the battery at that time, hence the -5000) but energy_left no longer appears to be populated either at the same time the %age left also broke

@wanblue
Copy link

wanblue commented Mar 21, 2024

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).
Seem to still have the ability to set Mode and Reserve and these report correctly.

@guy-BW

This comment has been minimized.

@ejbatts

This comment has been minimized.

@andrew2408
Copy link

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.

@Nick-Sills
Copy link

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.

@wanblue
Copy link

wanblue commented Mar 22, 2024

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?

@Avatar1976
Copy link

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.

@monkga1
Copy link

monkga1 commented Mar 22, 2024

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.

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%.

@monkga1
Copy link

monkga1 commented Mar 22, 2024

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.

@fernando155
Copy link

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.

@skipishere
Copy link
Collaborator

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.

@niveknow
Copy link

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.

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%.

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.

@niveknow
Copy link

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.

@fernando155
Copy link

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.

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...

@skipishere
Copy link
Collaborator

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.

@fernando155
Copy link

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.

@Nick-Sills
Copy link

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?

@wanblue Just checked and it takes about 5s. That's real time enough for my usage.

@gkwok1
Copy link
Contributor

gkwok1 commented Mar 22, 2024

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)
                )

@rm-rf-asterisk
Copy link

entities.append(TeslaEnergyBatteryRemaining(energysite, coordinator))

Thanks for the fix. I am still on 3.19.11 and i know 3.20.5 or whatever is going to break it

@ejbatts
Copy link

ejbatts commented Mar 22, 2024

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.

@ejbatts
Copy link

ejbatts commented Mar 22, 2024

Here is my code: (I have two batteries)

- name: Useable Battery Remaining        
        unique_id: useable_battery_remaining
        state: >
          {% set totalcapacity = (states('sensor.powerwall_tg122xxxxxxxxx_battery_capacity') | float(0)) 
          + ((states('sensor.powerwall_tg123xxxxxxxxx_battery_capacity') | float(0))) %}
          {% set totalcharge = (states('sensor.powerwall_tg122xxxxxxxxx_battery_remaining') | float(0)) 
          + ((states('sensor.powerwall_tg123xxxxxxxxx_battery_remaining') | float(0))) %}
          {{ '{:.3f}'.format(totalcharge - totalcapacity * 0.05) }}

 - name: Useable Percentage Remaining
        unique_id: useable_percentage_remaining   
        state: >
          {% set totalcapacity = (states('sensor.powerwall_tg122xxxxxxxxx_battery_capacity') | float(0)) 
          + ((states('sensor.powerwall_tg123xxxxxxxxx_battery_capacity') | float(0))) %}
          {% set totalcharge = (states('sensor.powerwall_tg122xxxxxxxxx_battery_remaining') | float(0)) 
          + ((states('sensor.powerwall_tg123xxxxxxxxx_battery_remaining') | float(0))) %}
          {{ '{:.1f}'.format((100 * (totalcharge - totalcapacity * 0.05)) | float(0) 
          / (totalcapacity * 0.95) | float(0)) }}   

@Avatar1976
Copy link

Here is my code: (I have two batteries)

- name: Useable Battery Remaining        
        unique_id: useable_battery_remaining
        state: >
          {% set totalcapacity = (states('sensor.powerwall_tg122xxxxxxxxx_battery_capacity') | float(0)) 
          + ((states('sensor.powerwall_tg123xxxxxxxxx_battery_capacity') | float(0))) %}
          {% set totalcharge = (states('sensor.powerwall_tg122xxxxxxxxx_battery_remaining') | float(0)) 
          + ((states('sensor.powerwall_tg123xxxxxxxxx_battery_remaining') | float(0))) %}
          {{ '{:.3f}'.format(totalcharge - totalcapacity * 0.05) }}

 - name: Useable Percentage Remaining
        unique_id: useable_percentage_remaining   
        state: >
          {% set totalcapacity = (states('sensor.powerwall_tg122xxxxxxxxx_battery_capacity') | float(0)) 
          + ((states('sensor.powerwall_tg123xxxxxxxxx_battery_capacity') | float(0))) %}
          {% set totalcharge = (states('sensor.powerwall_tg122xxxxxxxxx_battery_remaining') | float(0)) 
          + ((states('sensor.powerwall_tg123xxxxxxxxx_battery_remaining') | float(0))) %}
          {{ '{:.1f}'.format((100 * (totalcharge - totalcapacity * 0.05)) | float(0) 
          / (totalcapacity * 0.95) | float(0)) }}   

Nice work I added a couple of formatting things but otherwise exactly what I was going to do / seeing if somebody else already had. 🤣

@fernando155
Copy link

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.

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.

@barryperfect
Copy link

barryperfect commented Mar 26, 2024

Here is my code: (I have two batteries)

- name: Useable Battery Remaining        
        unique_id: useable_battery_remaining
        state: >
          {% set totalcapacity = (states('sensor.powerwall_tg122xxxxxxxxx_battery_capacity') | float(0)) 
          + ((states('sensor.powerwall_tg123xxxxxxxxx_battery_capacity') | float(0))) %}
          {% set totalcharge = (states('sensor.powerwall_tg122xxxxxxxxx_battery_remaining') | float(0)) 
          + ((states('sensor.powerwall_tg123xxxxxxxxx_battery_remaining') | float(0))) %}
          {{ '{:.3f}'.format(totalcharge - totalcapacity * 0.05) }}

 - name: Useable Percentage Remaining
        unique_id: useable_percentage_remaining   
        state: >
          {% set totalcapacity = (states('sensor.powerwall_tg122xxxxxxxxx_battery_capacity') | float(0)) 
          + ((states('sensor.powerwall_tg123xxxxxxxxx_battery_capacity') | float(0))) %}
          {% set totalcharge = (states('sensor.powerwall_tg122xxxxxxxxx_battery_remaining') | float(0)) 
          + ((states('sensor.powerwall_tg123xxxxxxxxx_battery_remaining') | float(0))) %}
          {{ '{:.1f}'.format((100 * (totalcharge - totalcapacity * 0.05)) | float(0) 
          / (totalcapacity * 0.95) | float(0)) }}   

Nice work I added a couple of formatting things but otherwise exactly what I was going to do / seeing if somebody else already had. 🤣

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?

@markcocker
Copy link

I used a helper: Settings > Devices & Services > Helpers > Create Helper > Template > Template a sensor. Then enter a name, the template as above, and:

  • For Useable Percentage Remaining use Unit of measurement: %, Device class: Battery, State class: Measurement
  • For Useable Battery Remaining"use Unit of measurement: kWh, Device class: Stored energy, State class: Measurement

@wanblue
Copy link

wanblue commented Mar 26, 2024

Here is my code: (I have two batteries)

- name: Useable Battery Remaining        
        unique_id: useable_battery_remaining
        state: >
          {% set totalcapacity = (states('sensor.powerwall_tg122xxxxxxxxx_battery_capacity') | float(0)) 
          + ((states('sensor.powerwall_tg123xxxxxxxxx_battery_capacity') | float(0))) %}
          {% set totalcharge = (states('sensor.powerwall_tg122xxxxxxxxx_battery_remaining') | float(0)) 
          + ((states('sensor.powerwall_tg123xxxxxxxxx_battery_remaining') | float(0))) %}
          {{ '{:.3f}'.format(totalcharge - totalcapacity * 0.05) }}

 - name: Useable Percentage Remaining
        unique_id: useable_percentage_remaining   
        state: >
          {% set totalcapacity = (states('sensor.powerwall_tg122xxxxxxxxx_battery_capacity') | float(0)) 
          + ((states('sensor.powerwall_tg123xxxxxxxxx_battery_capacity') | float(0))) %}
          {% set totalcharge = (states('sensor.powerwall_tg122xxxxxxxxx_battery_remaining') | float(0)) 
          + ((states('sensor.powerwall_tg123xxxxxxxxx_battery_remaining') | float(0))) %}
          {{ '{:.1f}'.format((100 * (totalcharge - totalcapacity * 0.05)) | float(0) 
          / (totalcapacity * 0.95) | float(0)) }}   

Nice work I added a couple of formatting things but otherwise exactly what I was going to do / seeing if somebody else already had. 🤣

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?

Alternatively, just edit your config.yaml file to include
sensor: !include sensors.yaml
if it's not already there then put this in a new (or add to existing) sensors.yaml file in the config directory (note slightly different format to @Avatar1976 as it's in sensors.yaml, I only have one battery and have a different system of naming sensors.

` - platform: template
sensors:
pw_useable_battery_remaining:
unique_id: pw_useable_battery_remaining
value_template: >
{% set totalcapacity = (states('sensor.my_home_tg*********_battery_capacity') | float(0)) %}

      {% set totalcharge = (states('sensor.my_home_*********_battery_remaining') | float(0)) %}

      {{ '{:.3f}'.format(totalcharge - totalcapacity * 0.05) }}
      
  

  pw_useable_percentage_remaining:
    unique_id: pw_useable_percentage_remaining   
    value_template: >
      {% set totalcapacity = (states('sensor.my_home_tg*********_battery_capacity') | float(0)) %}

      {% set totalcharge = (states('sensor.my_home_*********_battery_remaining') | float(0)) %}

      {{ '{:.1f}'.format((100 * (totalcharge - totalcapacity * 0.05)) | float(0) 
      / (totalcapacity * 0.95) | float(0)) }}   `

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 sensor: !include sensors.yaml ), go to Developer tools, check the config [If it fails the check then go back and check your formatting - don't try the next step until it passes the test as in the worst scenario it could brick your HA install] then "Reload all YAML". You should then have two new sensors which can be added to desktops or used in automations etc.

Thanks to @Avatar1976 for the original maths and formatting - it's a lot neater than mine would have been!

@barryperfect
Copy link

@markcocker @wanblue
Thank you, that makes it clear, I wasn't sure if you were changing the code in the integration to fix the "unavailables" or adding new sensors.

@ejbatts
Copy link

ejbatts commented Mar 26, 2024

Thanks to @Avatar1976 for the original maths and formatting - it's a lot neater than mine would have been!

Or ME (if you like @wanblue) for the original, 'original' maths and formatting...! 😉

@wanblue
Copy link

wanblue commented Mar 27, 2024

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!

@wanblue
Copy link

wanblue commented Mar 29, 2024

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 ?

@barryperfect
Copy link

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:
#919 (comment)
That fixed the sensors not updating for me

@wanblue
Copy link

wanblue commented Mar 29, 2024

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.

@ericdegroot
Copy link

ericdegroot commented Apr 2, 2024

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.

@ejbatts
Copy link

ejbatts commented Apr 2, 2024

Why use 13500 when you can use sensor.powerwall_tg122xxxxxxxxx_battery_capacity ?

@ericdegroot
Copy link

Why use 13500 when you can use sensor.powerwall_tg122xxxxxxxxx_battery_capacity ?

I have powerwall 3, so no local integration (yet, hopefully). I should have specified.

@gkwok1
Copy link
Contributor

gkwok1 commented Apr 3, 2024

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.

zabuldon/teslajsonpy#465

@unbroken75
Copy link

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)
                )

Thank you gkwok1 for the fix. Really useful!

gkwok1 added a commit to gkwok1/tesla that referenced this issue Apr 13, 2024
@niveknow
Copy link

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

@gkwok1
Copy link
Contributor

gkwok1 commented Apr 22, 2024

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.

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

@niveknow
Copy link

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.

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

Awesome. In that case, thank YOU!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
tesla_issue Issue with Tesla API; fix may not be possible triage New issues raised that need initial attention
Projects
None yet
Development

No branches or pull requests