Good morning,
I’ve got a pretty decent mushroom card dashboard set up, but I’m struggling to do some text manipulation based upon time. I have some basic text setup for primary information on one card, based upon time of day, it’ll greet me "Good morning, Good evening, etc.
{% set time = now().hour %}
{% if (time >= 18) %}
Good Evening, {{user}}!
{% elif (time >= 12) %}
Good Afternoon, {{user}}!
{% elif (time >= 5) %}
Good Morning, {{user}}!
{% else %}
Hello, {{user}}!
{% endif %}
I’m trying to take this one step further…
I have entity cards setup that display when the next sunrise is, next sunset is.
type: custom:mushroom-entity-card
entity: sensor.nextsunrise
tap_action:
action: none
hold_action:
action: none
double_tap_action:
action: none
name: Sunrise today at
icon_type: none
What I want to be able to do is change the “today” text, because obviously that next sunrise could be tomorrow.
So, as I’m writing this, it’s 9 am EST. The next sunrise value is 7:20 am, so what I need to do is take the next sunrise value, subtract the current time, which will give me a negative number. So long as it’s a negative number, I know the math has to work out and that value is tomorrow.
If it was 3 am currently, and sunrise was at 7:20 am, 7:20 - 3:00 = 4, so positive values would be for today.
I should be able to apply this to sunrise, sunset, moonrise, moonset and get that today/tomorrow value.
So, how do I implement this
name: >- {% set time = now().hour % + now().minute) {% if (sensor.nextsunrise - time < 0) %} Sunrise is tomorrow at {% else %} Sunrise is today at {% endif %}
Just not sure of the context of the math in the first line. Can anyone provide assistance?