Tesla Fleet Needs device_class type Energy
The problem
When configuring the Energy tab, adding a Grid Consumption sensor does not list any sensor from the Tesla Fleet sensors. Following the help link (https://www.home-assistant.io/docs/energy/faq/#troubleshooting-missing-entities) explains that power is measured in Watts and energy in kiloWatt-hour.
Tesla Fleet provides sensors for grid_power, load_power, solar_power, and battery_power with a unit of measure of kW and a device_class of power.
In order to use the information from these sensors in the Energy tab, the device_class needs to be energy. The state_class must be total or total_increasing. The unit_of_measure should be kWh.
These sensors cannot currently be used in the Energy tab as they are.
What version of Home Assistant Core has the issue?
core-2024.8.3
What was the last working version of Home Assistant Core?
No response
What type of installation are you running?
Home Assistant OS
Integration causing the issue
Tesla Fleet
Link to integration documentation on our website
https://www.home-assistant.io/integrations/tesla_fleet
Diagnostics information
No response
Example YAML snippet
No response
Anything in the logs that might be useful for us?
No response
Additional information
To reproduce, simply add a Tesla account with a solar system and attempt to add the consumption information.
Hey there @bre77, mind taking a look at this issue as it has been labeled with an integration (tesla_fleet) you are listed as a code owner for? Thanks!
Code owner commands
Code owners of tesla_fleet can trigger bot actions by commenting:
@home-assistant closeCloses the issue.@home-assistant rename Awesome new titleRenames the issue.@home-assistant reopenReopen the issue.@home-assistant unassign tesla_fleetRemoves the current integration label and assignees on the issue, add the integration domain after the command.@home-assistant add-label needs-more-informationAdd a label (needs-more-information, problem in dependency, problem in custom component) to the issue.@home-assistant remove-label needs-more-informationRemove a label (needs-more-information, problem in dependency, problem in custom component) on the issue.
(message by CodeOwnersMention)
tesla_fleet documentation tesla_fleet source (message by IssueLinks)
@eddy-r the information provided by Tesla is power, not energy. Changing the device_class will make it show up in the energy dashboard, but the information will be incorrect.
You need to create an integration helper to estimate the energy value from the power.
https://www.home-assistant.io/integrations/integration/#energy
@Bre77 exactly right, the information provided by Tesla is power, but a full integration for Home Assistant should provide the data points for useful features within Home Assistant. If this have been posted under feature request, please feel free to move it.
I have it working and showing data in the Energy tab, but it took some delving into the inner workings of the system. For instance, Tesla Fleet provides power as a single number, with a positive number meaning flow of power away from the given source (whether it's the grid, battery, or panels), and a negative value being power flowing towards the source of the reading. Taking this and producing a straight-forward integration helper that also shows positive and negative kWh is not what the Energy tab expects. First, I had to split the data from the grid and battery power into positive-only values.
For example, grid_power in the positive value became grid_import_kw. grid_power in the negative became a positive value for grid_export_kw. grid_import_kw and grid_export_kw then have to be used in the integration template to create grid_input_kwh and grid_export_kwh.
To extract the positive value from grid_power I wound up using {{ [ states('sensor.my_home_grid_power')|float(0), 0.0 ] | max }}, which because I am not fluent in the language used, I had to adapt from a search result. The method to convert a negative value into a positive value I wound up using was {{ [ ( -1 * states('sensor.my_home_grid_power')|float(0)), 0.0 ] | max }}.
Rinse and repeat for the battery, and create an integration helper for the solar panels, and it was done, but only after trial and error. After setting the Device section to the Tesla Fleet device name ("My Home" by default), all of these show up as entities and sensors for the device.
Isn't it possible to set this up programmatically so that users don't each have to go hunting for how to do those steps?
Isn't it possible to set this up programmatically so that users don't each have to go hunting for how to do those steps?
It sure is, but as far as I am aware Home Assistant has rules against me doing it in the integration itself. I've asked the question on Discord because if I am allowed to then I defintely will for Tessie, Teslemetry, and Tesla Fleet.
update: there was a communication issue with gateway seems to be functioning but the kwh data sensor isn't reporting any data even though the fleet sensor shows it
~~i thought i had this setup properly last night but because it was night i assumed thats why solar value was 0. i'm getting the energy from grid sensor just fine but still no solar readout, so it seems its properly portioned just not getting solar info? (complete newb to HA, just installed green box yesterday)~~
sensor:
-
platform: integration source: sensor.energy_site_solar_power # <-- the actual name of your sensor name: tesla_solar_panels_kWh unit_prefix: k unit_time: h round: 2
-
platform: integration source: sensor.energy_site_grid_power # <-- the actual name of your sensor name: APS_usage_kWh unit_prefix: k unit_time: h round: 2
Hey - so total novice first time user of HA which I primarily purchased for energy tracking to start with. I have the Tesla Fleet connected and obviously ran into the same problem as I was trying to setup the energy dashboard. I really tried my best to understand what was done in this thread but honestly getting nowhere. Would it be too much to ask for steps to create these sensors so I could use them in the energy dashboard? Thanks.
Hey - so total novice first time user of HA which I primarily purchased for energy tracking to start with. I have the Tesla Fleet connected and obviously ran into the same problem as I was trying to setup the energy dashboard. I really tried my best to understand what was done in this thread but honestly getting nowhere. Would it be too much to ask for steps to create these sensors so I could use them in the energy dashboard? Thanks.
No that's a really good idea, I'll add a section to the documentation.
That would be so awesome and maybe stop me returning my HA green box
So for the silly, does that mean I will find it at the bottom of https://www.home-assistant.io/integrations/tesla_fleet once you add it? (Please write for the stupid)
Documentation was updated with high level information, however we are working on adding actual history data for the energy dashboard now.
Thanks for that, I did see that but will need to take time as thats still above my current 0 education level.
Actual history data --> does that mean above steps not required or this is for something else?
While we wait on official documentation, I've put together my method to get the Energy Dashboard and Tesla Fleet talking to each other here. Please feel free to use this if it helps get instructions going.
While we wait on official documentation, I've put together my method to get the Energy Dashboard and Tesla Fleet talking to each other here. Please feel free to use this if it helps get instructions going.
cool thanks will try to dig into it tomorrow, it should be fine if we don't have a powerwall and just solar?
It should work without the Powerwall information in the Energy dashboard. I guess I named the file the way I did because I have a Powerwall and wanted something that would work completely offline. This is the closest I could get.
If you ignore all the Powerwall settings you should be able to get the Energy dashboard working with these instructions. I should rename the file "Tesla Fleet and the Energy dashboard."
From: gatsntatsdad @.> Sent: Wednesday, September 18, 2024 10:37:07 PM To: home-assistant/core @.> Cc: Eddy Redondo @.>; Mention @.> Subject: Re: [home-assistant/core] Tesla Fleet Needs device_class type Energy (Issue #124671)
While we wait on official documentation, I've put together my method to get the Energy Dashboard and Tesla Fleet talking to each other herehttps://docs.google.com/document/d/15yREpCgAmLnLrfSl11WUsUsDJvxq8RdonRP0JsWMAxQ/pub. Please feel free to use this if it helps get instructions going.
cool thanks will try to dig into it tomorrow, it should be fine if we don't have a powerwall and just solar?
— Reply to this email directly, view it on GitHubhttps://github.com/home-assistant/core/issues/124671#issuecomment-2359860460, or unsubscribehttps://github.com/notifications/unsubscribe-auth/ABPXJ23TOUSBLHD2OJLTLWTZXI2FHAVCNFSM6AAAAABNFJUBESVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZDGNJZHA3DANBWGA. You are receiving this because you were mentioned.Message ID: @.***>
While we wait on official documentation, I've put together my method to get the Energy Dashboard and Tesla Fleet talking to each other here. Please feel free to use this if it helps get instructions going.
@eddy-r this was exactly what I was looking for, I followed your steps, all the helpers are in, setup the energy board now just in the countdown for the hourly to see if I done it right, bit late here so I am hoping for a nice surprise in the morning.
Thank you so much for this.
@gatsntatsdad, I tested and can confirm that after installing the sensors under Home Assistant version 2024.9.2 this error exists. I just updated to 2024.9.3 and the error does not happen again.
From: gatsntatsdad @.> Sent: Tuesday, September 24, 2024 2:41:23 PM To: home-assistant/core @.> Cc: Eddy Redondo @.>; Mention @.> Subject: Re: [home-assistant/core] Tesla Fleet Needs device_class type Energy (Issue #124671)
Screenshot.2024-09-24.at.11-37-27.Settings.Home.Assistant.png (view on web)https://github.com/user-attachments/assets/29c4758d-7951-48b1-b376-49b3c42ef087
— Reply to this email directly, view it on GitHubhttps://github.com/home-assistant/core/issues/124671#issuecomment-2372032627, or unsubscribehttps://github.com/notifications/unsubscribe-auth/ABPXJ26JWAMJ3B5VP6WT6MLZYGW5HAVCNFSM6AAAAABNFJUBESVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZDGNZSGAZTENRSG4. You are receiving this because you were mentioned.Message ID: @.***>
@eddy-r So getting figures and looking ok, just trying to get my head around understanding the numbers and checking them. The energy flow I assume is an accumulation rather than a live view?
my energy configuration is showing an error re negative figure, attaching image
@gatsntatsdad, I tested and can confirm that after installing the sensors under Home Assistant version 2024.9.2 this error exists. I just updated to 2024.9.3 and the error does not happen again. … ________________________________ From: gatsntatsdad @.> Sent: Tuesday, September 24, 2024 2:41:23 PM To: home-assistant/core @.> Cc: Eddy Redondo @.>; Mention @.> Subject: Re: [home-assistant/core] Tesla Fleet Needs device_class type Energy (Issue #124671) Screenshot.2024-09-24.at.11-37-27.Settings.Home.Assistant.png (view on web)https://github.com/user-attachments/assets/29c4758d-7951-48b1-b376-49b3c42ef087 — Reply to this email directly, view it on GitHub<#124671 (comment)>, or unsubscribehttps://github.com/notifications/unsubscribe-auth/ABPXJ26JWAMJ3B5VP6WT6MLZYGW5HAVCNFSM6AAAAABNFJUBESVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZDGNZSGAZTENRSG4. You are receiving this because you were mentioned.Message ID: @.***>
so there is still something wrong, my energy panel is showing no data (its been 3+ hours since setting it up) not sure if i set it up wrong or what but in the 'master' panel it shows data for the tesla entities but nothing is getting to the energy panel
@eddy-r So getting figures and looking ok, just trying to get my head around understanding the numbers and checking them. The energy flow I assume is an accumulation rather than a live view?
my energy configuration is showing an error re negative figure, attaching image
@jeegnesh-patel it looks to me like you may have copied something wrong during the process. I have updated my process with additional notes to help catch errors.
@gatsntatsdad, I tested and can confirm that after installing the sensors under Home Assistant version 2024.9.2 this error exists. I just updated to 2024.9.3 and the error does not happen again. … ________________________________ From: gatsntatsdad @.> Sent: Tuesday, September 24, 2024 2:41:23 PM To: home-assistant/core _@**._> Cc: Eddy Redondo _@.>; Mention @._> Subject: Re: [home-assistant/core] Tesla Fleet Needs device_class type Energy (Issue #124671) Screenshot.2024-09-24.at.11-37-27.Settings.Home.Assistant.png (view on web)https://github.com/user-attachments/assets/29c4758d-7951-48b1-b376-49b3c42ef087 — Reply to this email directly, view it on GitHub<#124671 (comment)>, or unsubscribehttps://github.com/notifications/unsubscribe-auth/ABPXJ26JWAMJ3B5VP6WT6MLZYGW5HAVCNFSM6AAAAABNFJUBESVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZDGNZSGAZTENRSG4. You are receiving this because you were mentioned.Message ID: _@_.*>
so there is still something wrong, my energy panel is showing no data (its been 3+ hours since setting it up) not sure if i set it up wrong or what but in the 'master' panel it shows data for the tesla entities but nothing is getting to the energy panel
@stromdriver,
Looking at your list of sensors, you may have created an extra sensor that wasn't needed for the solar panels. Also, the grid export and grid import template sensors don't look like they are reading from your Grid power sensor.
I've edited my process with additional notes to help catch errors. You many need to delete these sensors and start over.
@gatsntatsdad, I tested and can confirm that after installing the sensors under Home Assistant version 2024.9.2 this error exists. I just updated to 2024.9.3 and the error does not happen again. … ________________________________ From: gatsntatsdad @.> Sent: Tuesday, September 24, 2024 2:41:23 PM To: home-assistant/core _@**._> Cc: Eddy Redondo _@.>; Mention @._> Subject: Re: [home-assistant/core] Tesla Fleet Needs device_class type Energy (Issue #124671) Screenshot.2024-09-24.at.11-37-27.Settings.Home.Assistant.png (view on web)https://github.com/user-attachments/assets/29c4758d-7951-48b1-b376-49b3c42ef087 — Reply to this email directly, view it on GitHub<#124671 (comment)>, or unsubscribehttps://github.com/notifications/unsubscribe-auth/ABPXJ26JWAMJ3B5VP6WT6MLZYGW5HAVCNFSM6AAAAABNFJUBESVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZDGNZSGAZTENRSG4. You are receiving this because you were mentioned.Message ID: _@_.*>
so there is still something wrong, my energy panel is showing no data (its been 3+ hours since setting it up) not sure if i set it up wrong or what but in the 'master' panel it shows data for the tesla entities but nothing is getting to the energy panel
@stromdriver,
Looking at your list of sensors, you may have created an extra sensor that wasn't needed for the solar panels. Also, the grid export and grid import template sensors don't look like they are reading from your Grid power sensor.
I've edited my process with additional notes to help catch errors. You many need to delete these sensors and start over.
thanks, i think i figured it out, i'd removed the ' ' around the sensor entities because i mistakenly assumed the quotes weren't necessary and just denoted what needed to be replaced with my values (i'm completely new to css coding) it's dark now so there's no solar data but if it's still not showing tomorrow i'll double check to try to see what it's doing
Nice, went thru again - I think I found one issue, my internal sensor has measurement as kwh your doc states hours, this actually seems to be on all sensors, when I try to change it only power types appear, hours is not an option -- I am sure I set it up as hours on all, could you check when you edit yours what it says?
ok, i have no idea whats going on, but now my panels and sensors are all wacked out, attached is the tesla fleet panel information (i'd fixed the decimal place the other day and now it's even more messed up) and my tesla app screen showing it's information, also sometimes when i open the energy panel it shows wildly different data/trends, especially on different devices...
I’d write a longer explanation, but I had shoulder surgery today and I’m one-handed, so the short explanation is that this is normal from what I see on your screenshots. Two things to compare:
- The Sensors reading kW, such as your Grid Export kW showing 1.2 kW, should match their equivalent sensor on the Tesla app main screen (the GRID reading in this sensor’s case).
- The Sensors reading kWh will not match without some filtering. This is because the Tesla app screenshot you have has already filtered the reading to a date range, while Home Assistant does not filter it in the Sensors list. The Energy tab in Home Assistant does this filtering automatically like the Tesla app does. You could filter it on the Sensors list by clicking the sensor and then selecting Show More and setting the date and time to match the Tesla app. Keep in mind that because of latency and how often Tesla Fleet is allowed to read the sensors online (they are not read directly from your gateway, battery, or whichever device reports the reading), there will always be a difference between Home Assistant’s reading and what’s reported on the Tesla App. In fact, I’m working with my installer because the Tesla app overreported how many kWh I used by 200 compared to my meter.
From: gatsntatsdad @.> Sent: Thursday, September 26, 2024 8:26:43 PM To: home-assistant/core @.> Cc: Eddy Redondo @.>; Mention @.> Subject: Re: [home-assistant/core] Tesla Fleet Needs device_class type Energy (Issue #124671)
ok, i have no idea whats going on, but now my panels and sensors are all wacked out, attached is the tesla fleet panel information (i'd fixed the decimal place the other day and now it's even more messed up) and my tesla app screen showing it's information, also sometimes when i open the energy panel it shows wildly different data/trends, especially on different devices...
Screenshot.2024-09-26.at.17-21-10.Settings.Home.Assistant.png (view on web)https://github.com/user-attachments/assets/b7f9d7f8-7c18-49dd-aa35-008237a6c440 26861.jpeg (view on web)https://github.com/user-attachments/assets/201cf343-621e-47d0-b68d-fa0b6367b978
— Reply to this email directly, view it on GitHubhttps://github.com/home-assistant/core/issues/124671#issuecomment-2378173931, or unsubscribehttps://github.com/notifications/unsubscribe-auth/ABPXJ25TOZ26EHQEWURAC33ZYSQ4HAVCNFSM6AAAAABNFJUBESVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZDGNZYGE3TGOJTGE. You are receiving this because you were mentioned.Message ID: @.***>
sorry about your shoulder man, speedy recovery
i get that there is latency and therefore a slight difference in values, but i'm not sure how reading hundreds of millions of kW is normal?
everything worked and displayed fine after fixing the ' ' issues 2 days ago that i'd messed up initially, but it's gone increasingly insane per the screen shots, the numbers are flying up in a blur
Delete the two sensors and Rex add them if you think you might have had a bad prefix in there at any point. I remember doing something dumb like that and winding up with kkWh readings at some point. I didn’t wait to see what reading it gave. I do know it was easier to delete and recreate the sensor than to fix it.
To delete a sensor, I go to Settings -> Devices & services -> Helpers. Select the sensor, click the settings gear, and select Delete at the bottom.
From: gatsntatsdad @.> Sent: Thursday, September 26, 2024 11:27:34 PM To: home-assistant/core @.> Cc: Eddy Redondo @.>; Mention @.> Subject: Re: [home-assistant/core] Tesla Fleet Needs device_class type Energy (Issue #124671)
sorry about your shoulder man, speedy recovery
i get that there is latency and therefore a slight difference in values, but i'm not sure how reading hundreds of millions of kW is normal? everything worked and displayed fine after fixing the ' ' issues 2 days ago that i'd messed up initially, but it's gone increasingly insane per the screen shots, the numbers are flying up in a blur
— Reply to this email directly, view it on GitHubhttps://github.com/home-assistant/core/issues/124671#issuecomment-2378332299, or unsubscribehttps://github.com/notifications/unsubscribe-auth/ABPXJ27W6VPBLTW2VB5GFL3ZYTGCNAVCNFSM6AAAAABNFJUBESVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZDGNZYGMZTEMRZHE. You are receiving this because you were mentioned.Message ID: @.***>
Delete the two sensors and Rex add them if you think you might have had a bad prefix in there at any point. I remember doing something dumb like that and winding up with kkWh readings at some point. I didn’t wait to see what reading it gave. I do know it was easier to delete and recreate the sensor than to fix it. To delete a sensor, I go to Settings -> Devices & services -> Helpers. Select the sensor, click the settings gear, and select Delete at the bottom. … ________________________________ From: gatsntatsdad @.> Sent: Thursday, September 26, 2024 11:27:34 PM To: home-assistant/core @.> Cc: Eddy Redondo @.>; Mention @.> Subject: Re: [home-assistant/core] Tesla Fleet Needs device_class type Energy (Issue #124671) sorry about your shoulder man, speedy recovery i get that there is latency and therefore a slight difference in values, but i'm not sure how reading hundreds of millions of kW is normal? everything worked and displayed fine after fixing the ' ' issues 2 days ago that i'd messed up initially, but it's gone increasingly insane per the screen shots, the numbers are flying up in a blur — Reply to this email directly, view it on GitHub<#124671 (comment)>, or unsubscribehttps://github.com/notifications/unsubscribe-auth/ABPXJ27W6VPBLTW2VB5GFL3ZYTGCNAVCNFSM6AAAAABNFJUBESVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZDGNZYGMZTEMRZHE. You are receiving this because you were mentioned.Message ID: @.***>
ok i'll give that a try tomorrow thanks
Delete the two sensors and Rex add them if you think you might have had a bad prefix in there at any point. I remember doing something dumb like that and winding up with kkWh readings at some point. I didn’t wait to see what reading it gave. I do know it was easier to delete and recreate the sensor than to fix it. To delete a sensor, I go to Settings -> Devices & services -> Helpers. Select the sensor, click the settings gear, and select Delete at the bottom. … ________________________________ From: gatsntatsdad @.> Sent: Thursday, September 26, 2024 11:27:34 PM To: home-assistant/core @.> Cc: Eddy Redondo @.>; Mention @.> Subject: Re: [home-assistant/core] Tesla Fleet Needs device_class type Energy (Issue #124671) sorry about your shoulder man, speedy recovery i get that there is latency and therefore a slight difference in values, but i'm not sure how reading hundreds of millions of kW is normal? everything worked and displayed fine after fixing the ' ' issues 2 days ago that i'd messed up initially, but it's gone increasingly insane per the screen shots, the numbers are flying up in a blur — Reply to this email directly, view it on GitHub<#124671 (comment)>, or unsubscribehttps://github.com/notifications/unsubscribe-auth/ABPXJ27W6VPBLTW2VB5GFL3ZYTGCNAVCNFSM6AAAAABNFJUBESVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZDGNZYGMZTEMRZHE. You are receiving this because you were mentioned.Message ID: @.***>
ok i deleted the sensors (i did it thru the listing in tesla fleet device though....) and followed all the directions again to create, this is what i've got, not sure why templates and integral sensors is doubled up, they each contain the exact same entities... i'll give it some time and see what happens