-
|
I'm using a timer as an entity and i need it to update every minute as it displays the time left in minutes, however because the state isn't changing it doesn't update, is there a option to refresh it every minute or so...? |
Beta Was this translation helpful? Give feedback.
Answered by
exetico
Feb 27, 2021
Replies: 2 comments 4 replies
-
|
Code as follows... |
Beta Was this translation helpful? Give feedback.
3 replies
-
|
Hi narrcom. Did you find some time to try phozel's solution? Here's the code from phozel's post: - entity: sensor.date_time
element: sleep_timer
state_action:
- service: floorplan.text_set
service_data:
element: sleep_timer
text: |
>
if (entity.state === 'idle') {
return "OFF";
}
else if (entity.state === 'paused') {
return "Paused";
}
if (entity.state === 'active') {
var currentD = new Date();
var targetD = Date.parse(entity.attributes.finishes_at);
var spanD = targetD - currentD;
var mins = Math.round(spanD / 1000 / 60);
return mins.toString();
}
else {
return "Unknown";
}I would just like to have this one marked as "Solved"/Answered, if everything is like it should be :-) |
Beta Was this translation helpful? Give feedback.
1 reply
Answer selected by
pkozul
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Hi narrcom.
Did you find some time to try phozel's solution?
Here's the code from phozel's post: