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.