I have the following situation
I create an IR Blaster with ESPHome and I am able to control a dozen or so different pieces of hardware.
To send an IR code I need to provide the protocol, code and command.
For this I am using 3 input_text helpers to get the protocol, code and command to the ESPHome. After that it is just pressing the button to send the IR code.
While this all works nice and neatly I dislikes the way how I need to add this to an automation.
If I do then I have to add 4 service calls (protocol, code, command, press button).
What I would like is to have these 4 calls wrapped in one ‘item’ such that in can add it to an automation in a similar fashion as RGB lights. There you add the light and in the same go you can add the details.
Is this possible and if so can someone give me some pointer to look for to make this happen.
You can create your own services in ESPHome. You can pass parameters to them (protocol, code, etc…), all in one custom service call, no need for input helpers.
Yes you can move the logic from the automation into a script and call the script from the automation with the required parameters (in this case calling a script is also a service call). Then, many automations can call the same script, passing the correct parameters. In the below example I have timere thst turn on lights when the timers are started and turnj off spefific lights when the timers end. In the below example (the parameters I pass are whether or not the automation for this is enabled (which I set on my dashboard as a switch), the duration for that timer (which I set on my dashboard as a slider for the number of seconds), and which timer to (re)start. Note I say restart because if additional motuion is later deteted in the room, the timer just restart even if already running, that way the lights never turn off when someone is in the room):
Automation that is called when motion is detected:
alias: Den Motion Detected (Lamp By Closet Automation)
description: “”
trigger:
I have 2 additional question that i hope relate to this. If not i will open an other topic instead
(To make the user input a bit more fail proof )
First, I can’t find out how to get protocol: string in uppercase when it’s entered in lowercase. It this possible. I tried to use toupper() but no success.