I can’t get this automation to work. When I check it simply does not exist. Logs don’t show errors.
Is there something wrong with the template after the condition?
The idea is:
when sensor.pv_zonder_home_verbruik_ex_boiler is between X and Y, brightness should be Z
I have a table of 30 rows.
If there is a way to do this more easily, ideas are welcome.
You are checking the state of a sensor and when you write ‘I have a table of 30 rows’ … I guess these values are not in the state of the sensor as this is limited to 256 char. Suggest post the details of the sensor too
The sensor has only a value of (eg) 370.
This is between 350 and 400, so I want to set brightness of the light-entity to 110.
When the sensor has a value of 520, I want to set the brightness of the light-entity to 119.
The table is only in a google-sheet
Since I don’t have an idea on how to create a nice and polished automation my idea was to create an automation with choose in the action, and repeat that 30 times for each of the values, but even that is not working. The automation is not being created (probably because of an error or typo ?).
Did you use the GUI for creating the automation?
This is quite straightforward
EDIT: lets wait till didgerydrew answers… he is more advanced than me
EDIT2: dd stopped typing so might not respond…so repeating, did you use the GUI to try and create the automation?
No, I did not use the GUI. I never did. I have tons of automations. Most of them are copy/paste from other automations. But I constantly try to find other ways to do different things, here in the community, just to learn, make things simpler, …
Suggest tp try the gui as things have changed … I tried to replicate a bit what you did and found a few differences in the config. The gui will also help to save a proper automation
First, is triggering every 10 seconds absolutely necessary? Short cycle time pattern triggers are rarely the best way to trigger an automation. They require more processing power and often don’t add anything in terms of accuracy or reliability. If your goal was to throttle how often the light is updated when the boiler temp is changing rapidly, you can do that with a condition.
Second, you can use templating to find the current range the temperature is in and relate that to a brightness level.
@vingerha
I know it can be done the way you are proposing, but as I wrote I always try to find different ways to achieve the same. That’s why I tried to do this with a template immediately after condition:
Your solution is 4 lines, where I was looking for a more compact code.
@Didgeridrew his code is very compact, and above all, very readable. Understandable for the “casual programmer”.
I like that very much.
Again, thank you both for a very quick solution. I can start building on this with more conditions.
The idea behind the fact that I was looking for compact code:
I was hoping that (since I want this specific automation to run very frequently) I could gain execution time (CPU time). Does compact code result in faster execution? I don’t know.
Having only 1 location where my sensor is referenced makes it more easy when making changes to the automation.
Making changes to my initial automation could result in typo’s (since I would have to make many edits to the automation).
Let me also explain what this automation will actually do:
I’m charging my home-battery with solar power.
I have a heat pump to warm up the house and to heat up the water.
The COP for heating water is very low (COP is less than 2, the heat pump is close to 15 years old now).
I have an electrical heating installed in the boiler, with a COP of 1 (needed for bringing the water temperature above 60°c every few weeks - security/health reason).
I pay 42ct for my electricity.
I get 16ct for injecting electricity.
What I do now (see the sensor for the calculation) determine how much electricity I want to go to the battery and how much electricity I want to use for heating my boiler (50/50 at the moment).
I have an SSR (Solid State Relay) with a 0-10v input. This input is driven by a Qubino Z-Wave dimmer (0-255), what is not actually a light source, but HA sees it as one.
The electrical heating for the boiler is 3kw (actually consuming 3300w when not connected via the SSR).
I’m now able to redirect the power to the battery and the boiler instead of injecting all to the grid.
To be done:
I now have a fixed divider (50% battery, 50% boiler) when calculation the sensor, but what when my battery is full. I must make this also dynamic.
I better inject left over power when the boiler is hot enough. (I’ll probably add a second condition next to the time condition in this automation). I have to determine the cut-off point based on occupancy in the house, weather conditions the next day, …
adding a few lines to the mapper
Again, I’m very grateful that you two have sought a solution for me.