i have created a sensor with a value_template. It works fine but i have one issue, the history graph looks very raw, not like i expected from a power sensor. Because all many power sensor shows more granular i am sure it is my configuration. Hopefully someone can give me the right hint.
Hi. It’s strange. I also have “flat line” issue since couple of days. History for my sensors was working ok Walker. I haven’t changed my configuration.
Ok, i’ve found the source of the problem.
I had device_class and unit_of_measurement specified for sensors, there should be just device_class. After changing history works fine.
I have the same issue. My template sensors history stay flat, but when I leave the history window open, I do see the changes. Once I re-open the history view, it’s a flat line again.
I have template sensors like this:
- name: "Solar Panel Production W"
unique_id: solar_panel_production_w
unit_of_measurement: "W"
state_class: measurement
device_class: power
icon: mdi:solar-power
state: >
{% set i1_dc_power = states('sensor.solaredge_i1_dc_power') | float(0) %}
{% set i2_dc_power = states('sensor.solaredge_i2_dc_power') | float(0) %}
{% set b1_dc_power = states('sensor.solaredge_b1_dc_power') | float(0) %}
{% if (is_state('sensor.solaredge_i1_dc_power', 'unknown') or (is_state('sensor.solaredge_i2_dc_power', 'unknown')) or is_state('sensor.solaredge_b1_dc_power', 'unknown')) %}
0
{% elif (i1_dc_power + i2_dc_power + b1_dc_power <= 0) %}
0
{% else %}
{{ (i1_dc_power + i2_dc_power + b1_dc_power) }}
{% endif %}
availability: >
{{ states('sensor.solaredge_i1_dc_power') | is_number and states('sensor.solaredge_i2_dc_power') | is_number and states('sensor.solaredge_i1_ac_power') | is_number and states('sensor.solaredge_i2_ac_power') | is_number and states('sensor.solaredge_b1_dc_power') | is_number }}
Here’s a view of the history for that sensor. In the yellow area you can see that it does get data and the graph does update when the history view is opened:
I think I found my issue. I added a package from someone, and in that code, they had a section like the following:
recorder:
include:
entities:
If I understand correctly (I might be completely wrong here though), once you add that include part somewhere in the HA configuration, you need to add all of the entities that are to be recorded? I don’t have that (yet), so before adding the package code, my HA was storing history data for all of my entities, but once I added the package, only history for those entities listed in that package was stored.
I removed that part and now it seems to be back to normal.
I’m having a similar problem - I have created a template sensor and its not recording the history. I’m wondering if I have the same problem here but where do I look in HA to see if a package has added the piece of code you mention?