#Timer card
1 messages ยท Page 1 of 1 (latest)
try creating a template
something like this maby:
value_template: "{{ states('sensor.your_timestamp_sensor') | as_datetime | as_local | timestamp_custom('%H:%M') }}"
I havent tested this atm
i will start my own diswasher soon and try ๐
Have you tested starting it?
i se the card is showing the time stamp, but you can hide the state with "show_state: false"
And you might need to check out the video at 03:00, where he walks you through the sensor creation
Ahh ok I'll have to look at it later will report that then too
That is running right now
I'll post the code later as I said maybe it will be easier to help from your end
ok. I have a sensor in the actual integration stating the % of program completed.. so i do not need to make the template. thats why its working in my end
Here's my use of the timer-bar card. Green bar at the bottom is used for timer entity associated with automation that handles automatic light on/off. (Card_modded entities card shows real-time countdow in the upper left.)
This whole card is around 200 lines long (across a couple of templates) so I'm not sure how to really share it. Plus, it has a bunch of extra stuff not needed for this specific use. I may try to pull bits of the card out and make a simple version just to show how it is applied.
Actually, if you want to look at the entire dashboard's code, the template primary used above is the oversized_custom_button_with_auto. This template refeferences the oversized_custom_button template and that references the generic_custom_button template.
I'll have a look if I have that percentage sensor
But still would love to have thet bar too
You can create what you want manually no problem. Just need to create the template sensor
I can set it up with percentage to right ?
Yes ๐
I'll give that a shot
I can help you with it, if you share the code ๐
Will do and thank you
all right here is the template i am using from the youtuber my smart home not going to reinvent the wheel he is good and it was suggested to me too. I am using the time remaining sensor but as i understood i can also use sensor.geschirrspuler_program_progress wich is with the percentage. Id like to use the remainging time sensor so there it is:
- name: "Washing Remain Percent"
unique_id: "washing_percent"
state: >
{% if state_attr('sensor.washer', 'remain_time') == '0:00:00' %}
0
{% else %}
{%- set start = state_attr('sensor.geschirrspuler_remaining_program_time', 'initial_time') -%}
{%- set end = state_attr('sensor.geschirrspuler_remaining_program_time', 'remain_time') -%}
{%- set start_h = as_timestamp(strptime(start, '%H:%M:%S', '00:00:00')) | timestamp_custom("%H") | multiply(60) | round() -%}
{%- set start_m = as_timestamp(strptime(start, '%H:%M:%S', '00:00:00')) | timestamp_custom("%M") | round() -%}
{%- set start_s = ((as_timestamp(strptime(start, '%H:%M:%S', '00:00:00')) | timestamp_custom("%S") | int) / 60) | round(1) -%}
{%- set end_h = as_timestamp(strptime(end, '%H:%M:%S', '00:00:00')) | timestamp_custom("%H") | multiply(60) | round() -%}
{%- set end_m = as_timestamp(strptime(end, '%H:%M:%S', '00:00:00')) | timestamp_custom("%M") | round() -%}
{%- set end_s = ((as_timestamp(strptime(end, '%H:%M:%S', '00:00:00')) | timestamp_custom("%S") | int) / 60) | round(1) -%}
{%- set initial = start_h + start_m + start_s -%}
{%- set consumed = initial -(end_h + end_m + end_s) -%}
{{ 100 - ((consumed/initial)*100) | round() }}
{% endif %}
how do i use with this now ?
custom_fields:
program: |
[[[
return entity.attributes.geschirrspuler_operation_state
]]]
bar: |
[[[
var color = "blue";
var state = entity.state;
return `
<div>
<div style="background:${'#050C9C'}; height: 12px; width:${state}%">
</div>
</div>
`
]]]
stat1: '0:00:00'
stat2: |
[[[
return states['sensor.geschirrspuler_remaining_program_time'].state;
]]]
stat3: |
[[[
return states['sensor.geschirrspuler_duration'].state;
]]]
how does the sensor look in developer tool?
mmm it seems to xcream at me not sure if i am filling some of te ideas wrong or it is not formated correctly
-
name: "Washing Remain Percent"
unique_id: "sensor.geschirrspuler_remaining_program_time"
state: >
{% if state_attr('sensor.geschirrspuler_remaining_program_time', 'remain_time') == '0:00:00' %}
0
{% else %}
{%- set start = state_attr('sensor.geschirrspuler_remaining_program_time', 'initial_time') -%}
{%- set end = state_attr('sensor.geschirrspuler_remaining_program_time', 'remain_time') -%}{%- set start_h = as_timestamp(strptime(start, '%H:%M:%S', '00:00:00')) | timestamp_custom("%H") | multiply(60) | round() -%}
{%- set start_m = as_timestamp(strptime(start, '%H:%M:%S', '00:00:00')) | timestamp_custom("%M") | round() -%}
{%- set start_s = ((as_timestamp(strptime(start, '%H:%M:%S', '00:00:00')) | timestamp_custom("%S") | int) / 60) | round(1) -%}
{%- set end_h = as_timestamp(strptime(end, '%H:%M:%S', '00:00:00')) | timestamp_custom("%H") | multiply(60) | round() -%}
{%- set end_m = as_timestamp(strptime(end, '%H:%M:%S', '00:00:00')) | timestamp_custom("%M") | round() -%}
{%- set end_s = ((as_timestamp(strptime(end, '%H:%M:%S', '00:00:00')) | timestamp_custom("%S") | int) / 60) | round(1) -%}
{%- set initial = start_h + start_m + start_s -%}
{%- set consumed = initial -(end_h + end_m + end_s) -%}{{ 100 - ((consumed/initial)*100) | round() }}
{% endif %}
I pasted it like this
and it says
ValueError: Template error: as_timestamp got invalid input '00:00:00' when rendering template '- name: "Washing Remain Percent" unique_id: "sensor.geschirrspuler_remaining_program_time" state: > {% if state_attr('sensor.geschirrspuler_remaining_program_time', 'remain_time') == '0:00:00' %} 0 {% else %} {%- set start = state_attr('sensor.geschirrspuler_remaining_program_time', 'initial_time') -%} {%- set end = state_attr('sensor.geschirrspuler_remaining_program_time', 'remain_time') -%} {%- set start_h = as_timestamp(strptime(start, '%H:%M:%S', '00:00:00')) | timestamp_custom("%H") | multiply(60) | round() -%} {%- set start_m = as_timestamp(strptime(start, '%H:%M:%S', '00:00:00')) | timestamp_custom("%M") | round() -%} {%- set start_s = ((as_timestamp(strptime(start, '%H:%M:%S', '00:00:00')) | timestamp_custom("%S") | int) / 60) | round(1) -%} {%- set end_h = as_timestamp(strptime(end, '%H:%M:%S', '00:00:00')) | timestamp_custom("%H") | multiply(60) | round() -%} {%- set end_m = as_timestamp(strptime(end, '%H:%M:%S', '00:00:00')) | timestamp_custom("%M") | round() -%} {%- set end_s = ((as_timestamp(strptime(end, '%H:%M:%S', '00:00:00')) | timestamp_custom("%S") | int) / 60) | round(1) -%} {%- set initial = start_h + start_m + start_s -%} {%- set consumed = initial -(end_h + end_m + end_s) -%} {{ 100 - ((consumed/initial)*100) | round() }} {% endif %}' but no default was specified
๐
please paste the code here: https://pastecode.io/
did you paste this in the card or in your sensors.yaml file?
unique_id: "sensor.geschirrspuler_remaining_program_time" <-- remove the sensor.
what does not to be there ?
that is my entier card
MGFmYzIyZGYtNmI4ZS00MjRjLTk4MDMtNjYwMjBmYTI2ZjM3fDRxcjkwdnAyfDl2dmJjZ25va3h1bQ
your dischwasher already have the geschirrspuler_remaining_program_time sensor right?
so the whole point with sensors.yaml is to create template sensors that you dont have.
your now creating a sensor with the same name as the sensor you already have from your machine
I c so i am to take out that whole line ?
well.. i need to se why hes doing it first, hold on
he converts it into procentage.. so that he gets the width. could you share your card code for 2 sec? i belive we can do it a bit easier for you
ok give me 2 sec
thans for helping bud
sensor.geschirrspuler_duration shows the full duration all the time right?
not sure hehe
i think the percentage shows the whole 100 to 0 the time formats weirdly
do your washing machine have a % sensor? would make life real easy
try something like this
so replce the poogress with percentage ?
sensor.geschirrspuler_program_progress this one displays the percentage
oooooh
you can make this allot easier then... can you screenshot the percentage sensor?
i cant display it since the dishwasher is not running not sure how to simulate it
ah ok. I actually need to go real soon, vacation for 3 days.. but if you have the procentage, this whole thing will be easier.
i will try to make something real quick to simulate
i will use my own sensor to se if i can fix it ok? just give me a few
ok cool thanks I am going to hit sack soon too but id wish you a nice 3 days of and if you like and can help me after again
so its showing how many % its done.. but i can turn it around to -
so my cards are built a bit different, so im using degrees to make this.. but you can change that to a bar if you want.. but i just wanted to show you how it can be done
How id make it in the bar ? The code you shared earlier ?
i just tested to se if it works, now i will try to convert it to your card
@sacred portal try this one: https://pastecode.io/s/oxgxjtf0
that should work (might need some tweaks)
Cool thanjs I'll test it tomorrow
it looks like this now wenn i set the strate on will test it hoe it looks wenn it is running with the bar
Ok ๐ค
If your sensor is like mine, we might need to change something more. Because my bar goes from 0 to 100, not 100 to 0. But we can fix that later. Most important is that the code works
i belive you only need to add this to the code (under the first var line).
var invertedState = 100 - state;
so this would then be the code in the custom_field for bar:
[[[
var state = states['sensor.geschirrspuler_program_progress'].state;
var invertedState = 100 - state;
return `
<div style="background:#050C9C; height: 12px; width:${state}%; text-align: center; color: white;">
${state}%
</div>
`;
]]]
this worked for me ๐ so it should work for you as well.
REF:
i will try that and will let you know how it looks wenn it is running
Good job!
No problemo ๐ let me know if you need more help with it!
hey bud hope you had a good vacation
is there a way to have the bar go down from 100 to 0 percent right now it does the opposite it goes from 0 to 100
Yes there is. I'm working right now, but give me a few hours and I will help
Hey bud do you also by chance know how to use timely reminders that are mite then 1 month ?
I use this to remind me on a monthly bases:
{{ now().day == 8 }}
Need reminder for every three or 2 months. I'm using this in automation to switch on bolean
more then 1 minth? you could create a calender for it, and create
create reminders out of that
Was trying to do that couldn't figure it out
I will try to figure it out with you soon ๐ just need to fix my own theme first, i kind of destroied it hehe
did you add the following to your code, as i suggested earleir ?
var invertedState = 100 - state;
Try reading up on this one, its a real nice blue-print for automation
Cool thanks for the advice
This is already set like that. The bar is filling from left to right how do I get it to fill from right to left?
Can you send me the full code again please ?
I`m Norwegian ๐
If you remove that line if code, what happens?
I'm still not home will try it later ๐
I`m just passing on info ๐ No rush buddy!
I will have some questions later regarding the blueprint ๐
I`m not good with blueprints, you might need to ask in the automation channel
hey bud here the code as promised:
https://pastecode.io/s/47riojok
That was for the bar to move from right to left down ๐
oh yes. we needed to make the calculation go the opisit way hehe i might need @sly thunder for that, as im not quite sure how to make a state with 100% turn to 0%