How to create a trend helper for a sensor

I’m trying to use a trend helper to even out my solar generation sensor

when I create the helper it asked me the attribute I want to track. I want to track the value of the sensor but that is not available?

I’m really confused about whether this is what I think it is

.

I think what I really want is I a helper sensor that will give me the maximum value of my power generation within the last 15 minutes. That will even out my solar generation for any intermittent cloud cover.

And then I want something to take the above helper and plot the trend as it goes up and down during the day.

Leave the attribute field blank to track the state value.

That’s not what a Trend sensor is… A Trend sensor essentially performs a trend line analysis of the values from your sensor, then checks if the slope of that line is >= or < your specified gradient. If greater than or equal too, the binary sensor returns the state “on”, otherwise it returns the state “off”.

You want a Statistics sensor using value_max for the state_characteristic.

I see. Is statistics sensor only via configuration.yaml - no UI?
I’m a bit wary of fiddling with yaml if I can avoid it.

Yes it is YAML-only.

Thanks so much. I have my config

sensor: !include sensors.yaml

I had some existing template sensors and I added a new section for statistics. What is wrong with this?

# Siren
- platform: template
  sensors:
    living_room_humidity:
      friendly_name: "Living Room Humidity"
      unique_id: "siren_h_15_humidity_offset"
      value_template: "{{ states('number.siren_humidity_15') | float(0) + 13 }}"
      device_class: humidity
      unit_of_measurement: "%"
    living_room_temperature:
      friendly_name: "Living Room Temperature"
      unique_id: "siren_h_15_temperature_offset"
      value_template: "{{ states('number.siren_temperature_x10') | multiply(0.1) + 0.2 | float(0) }}"
      device_class: temperature
      unit_of_measurement: "°C"
# Solar
- platform: statistics
  sensors:
    power_generation_trend:
      entity_id: sensor.sa_generation_power
      name: "Power Generation Trend"
      unique_id: "power_generation_trend"
      state_characteristic: value_max
      max_age:
        minutes: 15

I don’t really understand why the order of the platform and sensors are reversed when you put it in a sub file.

# Solar
- platform: statistics
  entity_id: sensor.sa_generation_power
  name: "Power Generation Trend"
  unique_id: "power_generation_trend"
  state_characteristic: value_max
  max_age:
    minutes: 15
1 Like