Hello,
I have some beginner questions about helpers and templates
I have created a few helpers that are intended to be used to enter the target room temperature and the temperature tolerance.
Here, for example, the set temperature input_number.max_temperatur_tag should be added to the input_number.temperatur_tolerance (but this is given in %) and it doesn’t do that.
I have a mistake in my thinking somewhere
States are strings. You need to convert them to numbers (e.g. using the floating point filter) before you can do math with them. You also forgot to access the state in a number of places.
Thanks for help!
Ok, I hope this helps me a bit. I thought that if I saw the “number” type in a created helper (if I list my helpers under ==> Settings (Integrations, Devices, Entities, Helpers)), then that would already be a “Number” data type.
Okay, I’ll try it right away.
Thanks for the tip.
I want the following:
The speed of a fan should later be controlled, depending on the room temperature and any tolerance in percent.
Example:
Room temp sensor = 22°
Specification Max. room temp on the HA helper = 21°
Default tolerance in % = 5%
Thats mean
Helper-Room-Max-temp with add 5% = 22,05
I now have to calculate based on the set values whether the room temperature is within the tolerance range, or whether it is above or even below.
If I can calculate these values, then I can also set my fan speed accordingly.
This is the reason why I have to calculate with a sensor temperature and set values for helpers in HA
edit:
i add now this code in my configuration.yaml
but now he not find the template in “states” more
This post was the first time I was aware of a template number. The docs don’t explain — why should we use template sensors instead of numbers, particularly in an application like this, which is a combination of two user input_numbers?
Thats the problem of my thinking too.
i don’t understand when i have to use sensor: or number:
Okay i will try it but expaln would be very good if have anybody a link to this document
You can reload unless you’ve added a new integration for the first time, in this case template, when you need a full restart. Once the integration is added, you can reload to pick up any changes.
You have a syntax error though. Your first two lines need to be:
{% ... %}
but you have
{ % ... % }
with extra spaces.
It’s good practice to paste templates into the editor at Developer Tools / Templates to see what output you get.
You can also create template sensors in the UI under Helpers:
that would be good but where can I find this template editor?
That would help me a lot because then I can see what code he produces and could better identify my mistakes
What you’ve screenshotted there is not the template editor, it’s the template sensor creation tool which you use instead of the YAML in configuration.yaml. Save that sensor, which should now be available in your system, delete the code from your config file and restart. My guess is that you have two template: headers or something like that.
The template editor under Developer Tools (my second screenshot). Use this for testing your templates.
The template sensor creator under Helpers (my first screenshot). Use this for actually creating the sensor with the template you tested in the editor.
We need to see all of your configuration.yaml to diagnose the problem. But it is easier to just delete your code from that file and use the UI template sensor creator instead.
You don’t need to create anything inconfiguration.yaml. This:
is exactly what you need, although change the name from “Testtemplate” to “Temp Tag inclusive Toleranz”. Save that (Absenden) and you will have sensor.temp_tag_inclusive_toleranz in your system.
If you have already saved it, it might appear as sensor.testtemplate. You can change the entity ID if you want.
I haven’t yet understood the difference between a template entry in the configuration.yaml and the template-sensore that I can create under “helper”.
Both are a kind of template… when do you need what? Can you do most of the work with the helpers? is that the better way?
I would like to better understand the syntax of the code so that I can better avoid such errors in the future.
I would also like to understand when and where you need a template entry in the Configuration.yaml and when it is best to create it with the template sensor under Helpers
it’s really crazy:
I’ve now managed it with both variants… the template sensor works
and thetemplate entry in the configuration.yaml now also works
I now have 2 identical results. with 2 different names… great.
Still it’s very confusing for me… sorry for being so stupid
The “helper” version isn’t (easily) visible as YAML code, and you cannot do advanced configuration like adding attributes. But it’s quicker and easier to create, and it is also a “template sensor”.
The UI creation of template sensors is quite new — before that, you had to use YAML.
Thank you for all ( @Troon and all others too)
yaml-percentage-fan
your help and your patience. Editing the yaml file now works wonderfully too. I’m now using VS Code and I think it’s a bit easier for me with the spaces and indenting.
When I look at the state of the fan, I also see the set PWM power in percent.
Where can I find the code for this? I would like to query the PWM percentage with this set value