Hi everyone. I have a question if my current setup can be simplified.
I have a HDMI Switch connected by Tasmota MQTT.
This switch has 5 input ports which can be activated with MQTT.
To control them I have created 5 switch items.
I created rules to send the specific MQTT command based on the selected switch.
This rules are also disabling the other switches so only the current active input switch is ON.
Is there a possibility to simplify this?
Thing:
Group HDMI_Wohnzimmer “HDMI Switch Wohnzimmer” (Wohnzimmer) [“HDMI”, “Equipment”]
Switch HDMI_Wohnzimmer_Power “HDMI Switch” (HDMI_Wohnzimmer) [“Point”] {channel=“mqtt:topic:mosquitto:MQTT_HDMI_Wohnzimmer:Power”, ga=“Switch” [roomHint=“Wohnzimmer”]}
String HDMI_Wohnzimmer_Value “Aktueller Wert” (HDMI_Wohnzimmer) [“Point”] {channel=“mqtt:topic:mosquitto:MQTT_HDMI_Wohnzimmer:Value”}
String HDMI_Wohnzimmer_Input “Input [%s]” (HDMI_Wohnzimmer) [“Point”] {channel=“mqtt:topic:mosquitto:MQTT_HDMI_Wohnzimmer:Input”}
Items:
Switch HDMI_Switch_1
Switch HDMI_Switch_2
Switch HDMI_Switch_3
Switch HDMI_Switch_4
Switch HDMI_Switch_5
rules:
rule “HDMI Switch 1”
when
Item HDMI_Switch_1 changed
then
if(HDMI_Switch_1.state == ON){
HDMI_Wohnzimmer_Input.sendCommand(“port0R”)
HDMI_Switch_2.sendCommand(OFF)
HDMI_Switch_3.sendCommand(OFF)
HDMI_Switch_4.sendCommand(OFF)
HDMI_Switch_5.sendCommand(OFF)
} else {
Kodi.sendCommand(OFF)
}
end
rule “HDMI Switch 2”
when
Item HDMI_Switch_2 changed
then
if(HDMI_Switch_2.state==ON){
HDMI_Wohnzimmer_Input.sendCommand(“port1R”)
HDMI_Switch_1.sendCommand(OFF)
HDMI_Switch_3.sendCommand(OFF)
HDMI_Switch_4.sendCommand(OFF)
HDMI_Switch_5.sendCommand(OFF)
}
end
rule “HDMI Switch 3”
when
Item HDMI_Switch_3 changed
then
if(HDMI_Switch_3.state==ON){
HDMI_Wohnzimmer_Input.sendCommand(“port2R”)
HDMI_Switch_1.sendCommand(OFF)
HDMI_Switch_2.sendCommand(OFF)
HDMI_Switch_4.sendCommand(OFF)
HDMI_Switch_5.sendCommand(OFF)
}
end
rule “HDMI Switch 4”
when
Item HDMI_Switch_4 changed
then
if(HDMI_Switch_4.state==ON){
HDMI_Wohnzimmer_Input.sendCommand(“port3R”)
HDMI_Switch_1.sendCommand(OFF)
HDMI_Switch_2.sendCommand(OFF)
HDMI_Switch_3.sendCommand(OFF)
HDMI_Switch_5.sendCommand(OFF)
}
end
rule “HDMI Switch 5”
when
Item HDMI_Switch_5 changed
then
if(HDMI_Switch_5.state==ON){
HDMI_Wohnzimmer_Input.sendCommand(“port4R”)
HDMI_Switch_1.sendCommand(OFF)
HDMI_Switch_2.sendCommand(OFF)
HDMI_Switch_3.sendCommand(OFF)
HDMI_Switch_4.sendCommand(OFF)
}
end