Tomm206
(Tomm206)
June 21, 2023, 8:31pm
1
Hi all,
I have entity card which shows next cycle of watering sensor.
type: vertical-stack
cards:
- type: entities
entities:
- entity: sensor.watering_1_next_cycle
name: Watering next cycle
I would like to change color of this line (icon, name and remaining time) if sensor state value is today. I wanted to use:
style: |
:host {
{% if states(' sensor.watering_1_next_cycle ') == '???today???' %}
--paper-item-icon-color: #4169E1;
color: #4169E1;
but I donβt want how to define β???today???β.
Thanks
pcwii
(Pcwii)
June 21, 2023, 8:52pm
2
What are the states for this sensor?
sensor.watering_1_next_cycle
Just do a comparison when this sensor is in the range you want.
If the sensor is in hours then the comparison would be anything less than 24.
Tomm206
(Tomm206)
June 21, 2023, 9:28pm
3
The sensor shows date and time like: 2023-06-22T19:23:00+00:00
Try this (untested):
as_datetime(states(config.entity)).date() == now().date()
Tomm206
(Tomm206)
June 22, 2023, 1:34pm
5
Thank you for your suggestion but I donβt know how to implement that into condition. I tried this but it doesnβt work:
type: vertical-stack
cards:
- type: entities
entities:
- entity: sensor.watering_1_next_cycle
name: Watering next cycle
style: |
:host {
{% if states(sensor.watering_1_next_cycle') == now().date() %}
--paper-item-icon-color: #4169E1;
color: #4169E1;
}
Typo, you forgot to add β'β.
And check again my code above, you are comparing different values.
And also you forgot to add β{% endif %}β
Try this:
- entity: xxx
card_mod:
style: |
:host {
{% if as_datetime(states(config.entity)).date() == now().date() %}
--paper-item-icon-color: xxxx;
color: xxxx;
{% endif %}
}
Tomm206
(Tomm206)
June 22, 2023, 6:33pm
7
Great. It works
Thank you a lot. I can see now my mistakes.
1 Like
Tomm206
(Tomm206)
June 30, 2023, 6:26am
8
One more question, anyway. Sometimes it happens on my tablet (in Kiosk mode) that colors are not updated. I need to restart the HA app every time. I checked the HA app on my mobile, and the colors worked normally there. Any idea where the problem could be?
Thanks.