Hi, @anon43302295
I have a set of switches i like to command. On, Off, State. for each command i have separate scripts, or even shell_commands and rest_commands available.
Id like to compress that in the Frontend by having 2 input selects,1 for selecting the Switch, the second for selecting the Command. Press activate and all set. Exactly like with the hue_scenes, which i based the below package on.
I need a template of course for the final command, filling in the selected state from the input selectors. but need some help there…
this is what ive got so far, all in one package:
##########################################################################################
# Small package for selecting and activating Switches: On. Off, State
# 17103018
# MtHvdB
##########################################################################################
homeassistant:
customize:
script.run_switch_command:
icon: mdi:power
show_last_changed: true
group.select_switch_command:
control: hidden
# hide_control: true
#### script to be adjusted
script:
run_switch_command:
alias: Run switch command
sequence:
- service: xxx.xxx.xxx?
data_template:
switch_name: '{{ states.input_select.switch.state }}'
command_name: '{{ states.input_select.switch_command.state }}'
### Automation to be added?? Is that even necessary?
automation:
select_command_switches:
alias: Select and command switches
id:
trigger:
condition:
action:
group:
select_switch_command:
name: Hue Light Control
icon: mdi:spotlight
entities:
- input_select.switch
- input_select.switch_command
- script.run_switch_command
input_select:
switch:
name: Select Switches
icon: mdi:toggle-switch
options:
- Select
- Audio Auditorium
- Tv Auditorium
- Espresso Keuken
- Tv Library
- Kantoor
- Audio Gym
- Tester
- Dorm
- Boiler Bijkeuken
- Quooker Keuken
initial: Select
switch_command:
name: Select Switch Command
icon: mdi:toggle-switch-off
options:
- 'On'
- 'Off'
- 'State'
initial: 'Off'
the scripts i have available are in this form for all of the mentioned switches:
audio_auditorium_force_off:
alias: "Audio Auditorium Off"
sequence:
- service: switch.turn_off
data:
entity_id: switch.sw_audio_auditorium_cl
audio_auditorium_force_on:
alias: "Audio Auditorium On"
sequence:
- service: switch.turn_on
data:
entity_id: switch.sw_audio_auditorium_cl
audio_auditorium_state:
alias: "Audio Auditorium State"
sequence:
- service: rest_command.rc_audio_auditorium_state
or the shell_commands:
sc_audio_auditorium_on: >-
curl -X POST -d '{"seq":1, "method":"object_prop_set", "arguments":{"oid":"0e56e15c", "prop":"command", "value":"on"}}' http://192.168.xxx.xxx/iungo/api_request
sc_audio_auditorium_off: >-
curl -X POST -d '{"seq":1, "method":"object_prop_set", "arguments":{"oid":"0e56e15c", "prop":"command", "value":"off"}}' http://192.168.xxx.xxx/iungo/api_request
sc_audio_auditorium_state: >-
curl -X POST -d '{"seq":1, "method":"object_prop_get", "arguments":{"oid":"0e56e15c", "prop":"state"}}' http://192.168.xxx.xxx/iungo/api_request
could i create a template that uses something like this:
script.{{states.input_select.switch.state}}_force_{{states.input_select.switch_command.state}}
or the equivalent with the shell_commands?
Also, do i need an extra automation to do this?
this is what is showing now, so you get the idea:
just need to tie together in the backend
Please have a look?
Cheers, and thanks,
Marius