Momentary switch?

I’m trying to build an automation up that controls my TV, AV and other stuff but realised where I’m sending commands to the TV I have it currently setup in my switch.yaml as:-

switches:
samsung_youtubes:
command_on: “/usr/bin/curl -X POST http://192.168.1.42:8001/api/v2/applications/111299001912

Trouble is that’s not really an on/off ‘switch’ it’s more a button push, it works but then I have to set it on/off to get it to the correct state and messy.

Is there a type of ‘switch’, button etc that’s momentary as in doesn’t have an on/off state that I can configure somewhere? aka a better way to do it?

I’d prefer it as something I can refer to across multiple automations rather than hard code it into an automation etc.

Use a script or an input button in combination with an automation

Alternatively for your use case take a look at universal media player where you have a seaparate on and off service.

Could I add the curl command as a shell_command in the configuration.yaml then use an automation to call the named shell command?

Is that what you meant?
I set it up as a ‘switch’ originally because it meant I could easily add it to lovelace as a switch and test the command was correct.

Yes.
For a switch you need to provide a state.
You can use buttons in lovelace. One for on and one for off.

So from a quick test I added this to my config.yaml file,

shell_command:
samsung_youtubes: ‘curl -X POST http://192.168.1.42:8001/api/v2/applications/111299001912

and from a helper button it calls an automation script that triggers it, hey presto :slight_smile:

Is there any way to reload the shell_command: part of config.yaml from Developer Tools > YAML configuration reloading save restarting the box every time I make a tweak?