I have my vehicles speed as a sensor pulled in from traccar and formatted into mph.
I want to be able to read the maximum speed of my car from history and show it as a sensor in mph.
I have tried with the min_max and history_statistics to no avail.
That is for when there are multiple sensors and it is working out an average using min/max sensor.
It can then pull the min value and max value from that sensor.
I am only getting data from 1 sensor so i cannot use the min/max sensor since it requires 2 or more different values.
The topic I posted is about one sensor. You create a statistics sensor for this sensor, which then has some attributes like “min_value”, “max_value” etc… Afterwards you create a template sensor to extract the attribute “max_value” from the statistic sensor.
Something like this:
sensor:
# this creates a sensor "sensor.car_speed_statistics_mean"
- platform: statistics
entity_id: sensor.speed_measurment #entity_id of your speed sensor
name: Car Speed Statistics
# this extracts the attribute "max_value" from "sensor.car_speed_statistics_mean"
- platform: template
sensors:
car_speed_max:
value_template: "{{ state_attr('sensor.car_speed_statistics_mean', 'max_value') }}"
Thanks for your help, guess i’ll find out when i leave work. Also what is the sampling_size for? I’ve left it in at 144 but not sure what it actually does…
I know i would be able to do it that way but i mean so that it starts fresh every Monday. This is how all my other sensors work. I use this on my history sensors: