123
(Taras)
April 22, 2025, 12:12pm
21
You’re welcome!
Before you go, please consider marking my post above with the Solution tag. It will automatically place a check-mark next to the topic’s title which indicates to others that the topic has been solved. This helps other users find answers to similar questions.
Mabaelst
(Bart Teuwen)
April 29, 2025, 10:22am
22
Ok, This was the solution for my first problem. But if I wanted to make a sensor from this code how do I do this or is that not possible? Thanks for thinking along.
123
(Taras)
April 29, 2025, 11:56am
23
Which code exactly? Your automation contains a repeat
and you can’t use that in a Template Sensor.
If it’s just a small part of the code, like the condition made with an if-then-else, a Trigger-based Template Sensor supports a condition
option.
If you need to include code like repeat
then that can go in the action
section of a Trigger-based Template Sensor (where you can define variables).
All this to say that you should explore the capabilities of a Trigger-based Template Sensor and see if it meets your needs.
Mabaelst
(Bart Teuwen)
April 29, 2025, 4:23pm
24
- if:
- condition: template
value_template: |
{{states('sensor.max_temp_gevraagd') <=
states('input_number.verwarming_normaal')}}
then:
- if:
- condition: time
after: input_datetime.living_thermostaat_tijd_dag
before: input_datetime.living_thermostaat_tijd_nacht
then:
- variables:
Temp: |
{{ states('input_number.living_thermostaat_temp_dag') }}
else:
- variables:
Temp: |
{{ states('input_number.living_thermostaat_temp_nacht') }}
else:
- if:
- condition: template
value_template: |
{{state_attr('climate.thuis', 'current_temperature')|float + 0.5 >
state_attr('climate.thuis', 'temperature')|float}}
then:
- variables:
Temp: >
{{ state_attr('climate.thuis', 'current_temperature')|float +
2}}
else:
- if:
- condition: time
after: input_datetime.living_thermostaat_tijd_dag
before: input_datetime.living_thermostaat_tijd_nacht
then:
- variables:
Temp: |
{{ states('input_number.living_thermostaat_temp_dag') }}
else:
- variables:
Temp: |
{{ states('input_number.living_thermostaat_temp_nacht') }}
Thanks for your response.
Above you will find the piece of code that is the issue.