I have a Tesla Powerwall and am trying to use the grid, solar and battery entities in my energy dashboard config. These are provided by the Tesla custom integration.
For grid and battery, a single entity is provided for each, with a positive or negative figure depending on whether consuming from or exporting to the grid, for example.
So the first thing I needed to do was split them into separate sensors that provide a positive value, like this:
template:
- sensor:
- name: "Current Grid Consumption"
unique_id: current_grid_consumption
device_class: power
state_class: measurement
unit_of_measurement: "W"
state: >
{% if states('sensor.mr_a_williams_grid_power')|float >= 0 %}
{{ states('sensor.mr_a_williams_grid_power') | float }}
{% else %}
0
{% endif %}
- name: "Current Grid Export"
unique_id: current_grid_export
device_class: power
state_class: measurement
unit_of_measurement: "W"
state: >
{% if states('sensor.mr_a_williams_grid_power')|float < 0 %}
{{ -1 * states('sensor.mr_a_williams_grid_power')|float }}
{% else %}
0
{% endif %}
- name: "Current Battery Out"
unique_id: current_battery_out
device_class: power
state_class: measurement
unit_of_measurement: "W"
state: >
{% if states('sensor.mr_a_williams_battery_power')|float >= 0 %}
{{ states('sensor.mr_a_williams_battery_power') | float }}
{% else %}
0
{% endif %}
- name: "Current Battery In"
unique_id: current_battery_in
device_class: power
state_class: measurement
unit_of_measurement: "W"
state: >
{% if states('sensor.mr_a_williams_battery_power')|float < 0 %}
{{ -1 * states('sensor.mr_a_williams_battery_power')|float }}
{% else %}
0
{% endif %}
I then created Riemann Sum Integral helpers for each of them (using the “Left” method), to convert them to kWh:
The problem: Only the “solar production” and “battery in” sensors are available to select in the energy dashboard config.
They were all created the same way, valid non-zero values are showing in Developer Tools and it’s been 2 days since I created them, so I have no idea why they aren’t showing!
Has anyone else experienced this or have any ideas?