I’ve tried looking through previous posts to see if any could solve my issue but with no success. Any help would be greatly appreciated, thanks.
I essentially want to calibrate a bunch of pumps and I do this by defining the pump I want to calibrate in a dropdown. That way I can select from a list of available entity’s and test and calibrate. I don’t want to create the list in a input select.
I originally wrote the select like this - but of course, it only worked for the first pump in the list and would always run for the first pump regardless of what pump was select in the dropdown
A Template Select creates an entity that acts like an Input Select Helper in the front end, but more like an automation behind the scenes.
The actions sequence defined in select_option is what should happen when a new option is selected from the Dashboard or by a script or automation. If you don’t want it to do anything it would be better to use a short delay or have it call a script that doesn’t do anything than to have it call select.select_option on itself.
IIRC, the variable option doesn’t exist there, it only exists within the select_option sequence.
EDIT:
After reading your post a few times I think what you want is to use the select in optimistic mode.
Hi @Didgeridrew thanks for sending the info. I hadn’t seen the Template Select Entities (hyperlink didn’t seem to work ) but you were spot on, I wasn’t trying it. I have update my code below and works almost** perfectly
**Both snippets of code work in exactly the same way where by I am getting a weird result where two pumps are triggered. I have 10 all together. I select pump1 and both pumps 1 and 5 run. I select pump 2 and both pumps 2 and 6 run and so on😂
just for clarity, my wiring is all good and of course my esp32 code is good too. As you hopefully will have guessed.
The Studio Code extension is quite a bit behind right now so it throws a lot of false positives.
Overall it looks fine… but I’m a little confused. Why set it up as a blueprint if you aren’t using any inputs?
The one thing I would suggest is to DRY your templates so that state changes can’t cause the targets or values to change mid-run. At a minimum, do it for {{ states('select.test_dropdown') }}:
Good question! I don’t know. I seem to have gotten into the habit of writing everything as a blueprint but I do see that in this case there is no point.
It is quite odd. I did try and google what you meant but is that want you meant by “Dry my templates”, by adding a variable for the dropdown, so that the entity is only set once?
Instead of running the states() function multiple times to get what should be the same information, run it once and save that value to a variable. It’s a little bit more efficient, but in this case it’s mainly to prevent a situation where Priming is performed on pump 1, then during the delay someone changes the Select, and Feeding gets performed on pump 3… By saving it to a variable you guarantee the target pump stays the same throughout. Consider doing the same for your other templates if warranted.
Thanks for clarifying. DRY now makes sense and will certainly apply it where necessary.
It turns out there is nothing wrong with the code and it’s something to do with the esp32-s3 controller I am using. I have two and installed everything on my spare controller and the same thing happens. When I trigger the L298N motor driver module for pins 6 and 7, it also triggers pins 4 and 5. Strange behaviour and I’ll need to do some research into why that is. My esphome(esp32) code below for reference: