Show sensor value decrease per day

Hi,
I’ve got a soil moisture sensor (sensor.soil_moisture) which sends the moisture value (%) via MQTT every minute. Is it possible to create some kind of a counter that will show how many % soil moisture dropped during the last 24 hours (or every 6, 12 hours etc.)?
For example: day 1 at 8AM soil moisture was 50%, day 2 at 8AM soil moisture was 45% - I want the counter to show something like “Decrease 5% in last 24 hours”.

Can someone point me in the right direction how to achieve this?

Thank you in advance.

1 Like

Wow, that was easy!
Thank you!

Please consider posting the YAML you created for the Statistics Sensor so other users can learn how to use it.

Ah yes, sure thing!

sensor:
  - platform: statistics
    name: "Soil Moisture Change 24h"
    entity_id: sensor.box_soil_moisture
    state_characteristic: change
    max_age:
      hours: 24
    sampling_size: 1000
    precision: 1
  - platform: statistics
    name: "Soil Moisture Change 6h"
    entity_id: sensor.box_soil_moisture
    state_characteristic: change
    max_age:
      hours: 6
    sampling_size: 360
    precision: 1
  - platform: statistics
    name: "Soil Moisture Change 1h"
    entity_id: sensor.box_soil_moisture
    state_characteristic: change
    max_age:
      hours: 1
    sampling_size: 60
    precision: 1