Hi, not quite sure if I’m right in this section…
I’ve a working snippet of a template which is:
{% set t = states('sensor.aeg_waschmaschine_timetoend') %}
{% set t = now() + timedelta(minutes=t | int) if t | is_number else now() %}
{{ t.strftime("%H:%M") }}
How do I get these lines in the right arrangement into my configuration.yaml as a template sensor with name, unique_id ?
Thanks for any help…
The schema for template sensors, including all available configuration variables and examples can be found in the docs at the link above.
I know this instruction. But I’m a little bit overwhelmed regarding the right arrangement of the lines like the indentation…
If you’re not comfortable with YAML, you can just create the sensor as a Helper.
1 Like
I tried this as well and I didn’t find a helper for the given lines…
Other approach…
template:
- sensor:
- name: "Ende Waschmaschine"
unique_id: waschmaschine_ende
{% set t = states('sensor.aeg_waschmaschine_timetoend') %}
{% set t = now() + timedelta(minutes=t | int) if t | is_number else now() %}
{{ t.strftime("%H:%M") }}
Is this the right way to integrate the lines into my configuration.yaml?
You’re missing the state
variable, which is where the template goes.
template:
- sensor:
- name: "Ende Waschmaschine"
unique_id: waschmaschine_ende
state: |
{% set t = states('sensor.aeg_waschmaschine_timetoend') %}
{% set t = now() + timedelta(minutes=t | int) if t | is_number else now() %}
{{ t.strftime("%H:%M") }}