#Timer card

1 messages ยท Page 1 of 1 (latest)

gray thistle
#

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

sacred portal
#

Ahh ok I'll have to look at it later will report that then too

gray thistle
#

Timre card

#

Timer card

sacred portal
#

I'll post the code later as I said maybe it will be easier to help from your end

gray thistle
#

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

sly thunder
#

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.

sacred portal
#

I'll have a look if I have that percentage sensor

#

But still would love to have thet bar too

gray thistle
sacred portal
gray thistle
sacred portal
gray thistle
sacred portal
sacred portal
#

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 %}
sacred portal
#

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;
]]]

gray thistle
#

how does the sensor look in developer tool?

sacred portal
#

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

#

๐Ÿ˜†

gray thistle
#

did you paste this in the card or in your sensors.yaml file?

sacred portal
#

in sensor.yml

gray thistle
#

unique_id: "sensor.geschirrspuler_remaining_program_time" <-- remove the sensor.

sacred portal
#

what does not to be there ?

#

that is my entier card
MGFmYzIyZGYtNmI4ZS00MjRjLTk4MDMtNjYwMjBmYTI2ZjM3fDRxcjkwdnAyfDl2dmJjZ25va3h1bQ

gray thistle
#

your dischwasher already have the geschirrspuler_remaining_program_time sensor right?

sacred portal
#

yes it does

#

it just formarts weirdly wenn used

#

i guess that is why the template

gray thistle
#

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

sacred portal
#

I c so i am to take out that whole line ?

gray thistle
#

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

sacred portal
gray thistle
#

ok give me 2 sec

sacred portal
#

thans for helping bud

gray thistle
#

sensor.geschirrspuler_duration shows the full duration all the time right?

sacred portal
#

is there a way for me to test that ?

#

without having to turn on the dishwasher ?

gray thistle
#

not sure hehe

sacred portal
#

i think the percentage shows the whole 100 to 0 the time formats weirdly

gray thistle
#

do your washing machine have a % sensor? would make life real easy

#

try something like this

sacred portal
#

so replce the poogress with percentage ?

#

sensor.geschirrspuler_program_progress this one displays the percentage

gray thistle
#

oooooh

#

you can make this allot easier then... can you screenshot the percentage sensor?

sacred portal
#

i cant display it since the dishwasher is not running not sure how to simulate it

gray thistle
#

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

sacred portal
#

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

gray thistle
#

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

sacred portal
#

How id make it in the bar ? The code you shared earlier ?

gray thistle
#

i just tested to se if it works, now i will try to convert it to your card

#

that should work (might need some tweaks)

sacred portal
#

Cool thanjs I'll test it tomorrow

gray thistle
#

ok let me know if it works ๐Ÿ™‚ im headed onto vacation! good nigt ๐Ÿ™‚

#

night

sacred portal
#

it looks like this now wenn i set the strate on will test it hoe it looks wenn it is running with the bar

gray thistle
#

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:

sacred portal
#

i will try that and will let you know how it looks wenn it is running

sacred portal
gray thistle
#

Good job!

sacred portal
#

Changed it to that

#

Might tweak it w bir more

#

Thank you for the help

gray thistle
#

No problemo ๐Ÿ™‚ let me know if you need more help with it!

sacred portal
#

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

gray thistle
#

Yes there is. I'm working right now, but give me a few hours and I will help

sacred portal
#

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

gray thistle
#

more then 1 minth? you could create a calender for it, and create

#

create reminders out of that

sacred portal
gray thistle
#

I will try to figure it out with you soon ๐Ÿ™‚ just need to fix my own theme first, i kind of destroied it hehe

gray thistle
sacred portal
#

Cool thanks for the advice

sacred portal
gray thistle
#

Can you send me the full code again please ?

sacred portal
#

Sure will do that tonight ๐Ÿ˜ƒ

#

We're you from if I may ask ๐Ÿ˜ƒ. I'm from Germany

gray thistle
gray thistle
sacred portal
#

I'm still not home will try it later ๐Ÿ˜ƒ

gray thistle
sacred portal
#

I will have some questions later regarding the blueprint ๐Ÿ˜ƒ

gray thistle
#

I`m not good with blueprints, you might need to ask in the automation channel

sacred portal
gray thistle