Hello. Sorry for my English. Maybe someone can suggest a solution. It is necessary to change the color of the icon depending on the state of the object and the time the object is in this state. Let’s say a temperature sensor: if the temperature is more than 25°C for 10 minutes, then the icon is orange, if the temperature is more than 25°C for 20 minutes, then it is red.
goto to a huge card-mod thread
Changing color depending on the state is understandable. How to take into account the time, how long the object was in this state?
history_stats
I understand correctly that you need to create a sensor template, then two sensor history stats?
template:
- sensor:
- name: “temperature1”
state: “{{ (states(‘sensor.temperature’) | float ) >= 25 }}”
- name: “temperature1”
sensor:
-
platform: history_stats
name: temperature2
entity_id: sensor.temperature1
state: “True”
type: count
start: ???
duration: “00:10:00” -
platform: history_stats
name: temperature3
entity_id: sensor.temperature1
state: “True”
type: count
start: ???
duration: “00:20:00”
It’s not clear what to indicate at the start sensors history stats.
I think a history_stats sensor will not help here.
My bad.
The HS sensor can give a TOTAL time when some condition is met.
Another idea: what about a trigger-based binary sensor? A “state” trigger can use a “for” condition.
So - assume you got 2 trigger-based binary sensors for 10 minutes & 20 minutes; each sensor becomes OFF if a temperature < 25.
Then in card-mod you can check these binary sensors.
how about a single state automation like this?
trigger:
- platform: numeric_state
entity_id:
- sensor.t_h_sensor_2_temperature
for:
minutes: 10
above: 25
id: "1"
- platform: numeric_state
entity_id:
- sensor.t_h_sensor_2_temperature
for:
minutes: 20
id: "2"
- platform: numeric_state
entity_id:
- sensor.t_h_sensor_2_temperature
below: 25
id: "0"
condition: []
action:
- service: input_number.set_value
data:
value: >
{{ trigger.id}}
target:
entity_id: input_number.test_number
(take as proto cocept only, i didn’t test it)
you can then set the icon color based off input_number.test_number