Oké? I try again soon. Thanks
Sorry, its not working for me.
{% set left = as_timestamp(state_attr('sensor.woonkamer_timers','timers')[0].local_time) - (today_at(states('sensor.time')) + timedelta(seconds= trigger.id | int)).timestamp() %}
Error:
ValueError: could not convert str to datetime: ‘unknown’
Are you trying to add this in the GUI?
You need to use the configuration.yaml file.
That error is kind of expected when there is no timer set.
But when a timer is set then it should work
Yes, it’s in my configuration.yaml file.
And i set a timer.
Do you have a sensor called sensor.time?
I was just looking for it and can not find it anymore??
what is the best way to get it back, i think i delete it somehow when editing my config?
I believe in integrations add integration.
Time & date
(time & Date part) yes that’s it.
After restart “assistent_woonkamer_timer_percentage” stil not available.
Timer is set

When i change the “timedelta(seconds=” the result is ok.
{% set left = as_timestamp(state_attr('sensor.woonkamer_timers','timers')[0].local_time) - (today_at(states('sensor.time')) + timedelta(seconds= 10 | int)).timestamp() %}
{% set duration = (state_attr('sensor.woonkamer_timers','timers')[0].duration).split(":") %}
{% set duration_seconds = duration[0]|int*3600 + duration[1]|int*60 + duration[2]|int %}
{% if (1-(left/duration_seconds)) *100 < 101 %}
{{ (1-(left/duration_seconds)) *100 }}
{% else %}
{% endif %}

Something goes wrong with the trigger.id?
Post the full yaml you use.
default_config:
tts: !include tts.yaml
automation: !include automations.yaml
script: !include scripts.yaml
scene: !include scenes.yaml
#alarm_control_panel: !include alarm.yaml
frontend:
themes: !include_dir_merge_named themes
light: !include light.yaml
#browser_mod: !include browsermod.yaml
homeassistant:
customize: !include customize.yaml
spotcast: !include spotcast.yaml
delete:
bluetooth:
zha:
device_config:
00:15:8d:00:05:4a:0b:f9-2: # format: {ieee}-{endpoint_id}
type: "switch" # corrected device type
00:15:8d:00:05:4e:a9:7f-1:
type: "switch"
00:15:8d:00:05:4e:a9:7f-2:
type: "switch"
00:15:8d:00:08:30:4f:b6-1:
type: "switch"
00:15:8d:00:08:30:4f:b6-2:
type: "switch"
00:15:8d:00:05:4a:0d:47-2:
type: "switch"
a4:c1:38:b6:9c:ea:7d:ca-1:
type: "switch"
template:
# Google Assistent Timer to Wled (Hellis81)
- trigger:
- platform: time_pattern
seconds: 0
id: "0"
- platform: time_pattern
seconds: 10
id: "10"
- platform: time_pattern
seconds: 20
id: "20"
- platform: time_pattern
seconds: 30
id: "30"
- platform: time_pattern
seconds: 40
id: "40"
- platform: time_pattern
seconds: 50
id: "50"
- sensor:
- name: "assistent_woonkamer_timer_percentage"
unique_id: "assistent_woonkamer_timer_percentage"
unit_of_measurement: '%'
state: >-
{% set left = as_timestamp(state_attr('sensor.woonkamer_timers','timers')[0].local_time) - (today_at(states('sensor.time')) + timedelta(seconds= trigger.id | int)).timestamp() %}
{% set duration = (state_attr('sensor.woonkamer_timers','timers')[0].duration).split(":") %}
{% set duration_seconds = duration[0]|int*3600 + duration[1]|int*60 + duration[2]|int %}
{% if (1-(left/duration_seconds)) *100 < 101 %}
{{ (1-(left/duration_seconds)) *100 }}
{% else %}
{% endif %}
I just tested the code and used my entity for timer:

You know the timers are not updated directly do you?
I believe it’s three minutes polling time or something.
When you set the timer, reload the integration google home and it should work.
EDIT:
Here is a better screenshot
I’m sorry, no luck.
still unavailable.
I give up.
thank you for all your help.
Check the spellings of all the entities
Oh and the spellings of the attributes.
I believe I had to restart when I first created the template. Or perhaps that was not needed.
But I did at least
already checked. ![]()
after every change i restarted
This bothers me a lot still.
If you want to give it a try again try this code in developer tools.
I made a fixed timedelta of 10 seconds but it should give us some clues what is going on.
{% set left = as_timestamp(state_attr('sensor.woonkamer_timers','timers')[0].local_time) - (today_at(states('sensor.time')) + timedelta(seconds=10)).timestamp() %}
{{now().time()}}
{{ states('sensor.time') }}
{{ left }}
{% set duration = (state_attr('sensor.woonkamer_timers','timers')[0].duration).split(":") %}
{{ duration }}
{% set duration_seconds = duration[0]|int*3600 + duration[1]|int*60 + duration[2]|int %}
{{ duration_seconds }}
{% if (1-(left/duration_seconds)) *100 < 101 %}
{{ (1-(left/duration_seconds)) *100 }}
{% else %}
{% endif %}
So everything seems to work as it should with the template.
It outputs 18.9999%
Very strange.
I have delete everything and start from “scratch” now it works perfect (for me)
alias: WLED keuken percentage timer keuken
description: ""
triggers:
- entity_id:
- sensor.keuken_timers
attribute: next_timer_status
to: set
trigger: state
conditions: []
actions:
- device_id: f67b7af863ada3ce6ed3af8a0cf478c9
domain: select
entity_id: 06a1bbb816adcc3f9ea3939bf99a0e97
type: select_option
option: Percent
- repeat:
while:
- condition: template
value_template: >-
{{ state_attr('sensor.keuken_timers', 'next_timer_status') == 'set'
}}
sequence:
- target:
entity_id: number.wled_keuken_intensiteit
data:
value: >
{% set timers = state_attr('sensor.woonkamer_timers', 'timers') %}
{% set local_time_str = timers[0].local_time %} {% set finish =
as_datetime(local_time_str) %}
{% set duration_str = timers[0].duration %} {% set parts =
duration_str.split(':') %} {% set total_duration = (parts[0] |
int) * 3600 + (parts[1] | int) * 60 + (parts[2] | int) %} {% set
start_ts = finish.timestamp() - total_duration %} {% set now_ts =
as_timestamp(now()) %} {% set percentage = ((now_ts - start_ts) /
total_duration * 100) | round(0) %} {{ percentage }}
action: number.set_value
- delay: "00:00:05"
- delay: "00:00:30"
- type: turn_off
device_id: 0bf8ed99df156ecdb94fc786ff9f2f7a
entity_id: 21f5763381fb53691e8f54e00fbe3084
domain: light
mode: restart

