hello everyone good night I have made the following rule to control multiple television channels through broadlink,
I use DIRECTV and has declared approximately 40 television channels as Switch, when it is activated the code or channel number is sent to a rule which sends number by number to the broadlink
example TV channel MTV = 1334
sendCommand(One_DirecTv, ON)
sendCommand(Tree_DirecTv, ON)
sendCommand(Tree_DirecTv, ON)
sendCommand(Four_DirecTv, ON)
the problem is that the programming guide of my television is more than 200 TV channels for each television decoder or for each DIRECTV in my house I have 3 televisions and this generates a rule file of more than 9000 lines of code and 600 rules for each channel and that can make me independent of each of the 3 encoders
this works for me, the problem is that I have a rules file that is too large and when the raspberry restarts it takes approximately 45 minutes to load
this is my configuration
my Things
Bridge mqtt:broker:mosquitto [ host="192.168.0.30", port=1883, clientID="Domitic", secure=false]
{
Thing mqtt:topic:directvsala "DIRECTV SALA" {
Channels:
Type switch : Cero_DirecTv [ commandTopic="broadlink/televisor/saladirectv/cero", on="play-780f77b943fb"]
Type number : Uno_DirecTv [ commandTopic="broadlink/televisor/saladirectv/uno", on="play-780f77b943fb"]
Type number : Dos_DirecTv [ commandTopic="broadlink/televisor/saladirectv/dos", on="play-780f77b943fb"]
Type number : Tres_DirecTv [ commandTopic="broadlink/televisor/saladirectv/tres", on="play-780f77b943fb"]
Type number : Cuatro_DirecTv [ commandTopic="broadlink/televisor/saladirectv/cuatro", on="play-780f77b943fb"]
Type number : Cinco_DirecTv [ commandTopic="broadlink/televisor/saladirectv/cinco", on="play-780f77b943fb"]
Type number : Seis_DirecTv [ commandTopic="broadlink/televisor/saladirectv/seis", on="play-780f77b943fb"]
Type number : Siete_DirecTv [ commandTopic="broadlink/televisor/saladirectv/siete", on="play-780f77b943fb"]
Type number : Ocho_DirecTv [ commandTopic="broadlink/televisor/saladirectv/ocho", on="play-780f77b943fb"]
Type number : Nueve_DirecTv [ commandTopic="broadlink/televisor/saladirectv/nueve", on="play-780f77b943fb"]
}
}
items
Switch TV1_Ch1524 "HBO HD" (Switches, Gtv1)
Switch TV1_Ch1525 "HBO 2 HD" (Switches, Gtv1)
Switch TV1_Ch1532 "HBO Plus HD" (Switches, Gtv1)
Switch TV1_Ch1534 "HBO Family HD" (Switches, Gtv1)
Switch TV1_Ch1542 "Max Prime HD" (Switches, Gtv1)
Switch TV1_Ch1552 "Fox Premium Series HD" (Switches, Gtv1)
Switch TV1_Ch1556 "Fox Premium Family HD" (Switches, Gtv1)
Switch TV1_Ch1557 "Fox Premium Comedy HD" (Switches, Gtv1)
Switch TV1_Ch1559 "Fox Premium Movies HD" (Switches, Gtv1)
Switch TV1_Ch1561 "Fox Premium Action HD" (Switches, Gtv1)
Switch TV1_Ch1562 "Fox Premium Cinema HD" (Switches, Gtv1)
Switch TV1_Ch1604 "Fox Sports HD" (Switches, Gtv1)
Switch TV1_Ch1608 "Fox Sports 2 HD" (Switches, Gtv1)
Switch TV1_Ch1609 "Fox Sports 3 HD" (Switches, Gtv1)
Switch TV1_Ch1610 "DIRECTV Sports HD" (Switches, Gtv1)
Switch TV1_Ch1611 "DIRECTV Sports HD Eventos" (Switches, Gtv1)
Switch TV1_Ch1612 "DIRECTV Sports 2 HD" (Switches, Gtv1)
Switch TV1_Ch1613 "DIRECTV Sports 3 HD" (Switches, Gtv1)
Switch TV1_Ch1620 "ESPN HD" (Switches, Gtv1)
Switch TV1_Ch1621 "ESPN + HD" (Switches, Gtv1)
Switch TV1_Ch1623 "ESPN 2 HD" (Switches, Gtv1)
Switch TV1_Ch1626 "ESPN 3 HD" (Switches, Gtv1)
Rules
rule "HBO (ESTE) HD 1524"
when
Item TV1_Ch1524 received command ON
then
sendCommand(Uno_DirecTv, ON)
Thread::sleep(500)
sendCommand(Cinco_DirecTv, ON)
Thread::sleep(500)
sendCommand(Dos_DirecTv, ON)
Thread::sleep(500)
sendCommand(Cuatro_DirecTv, ON)
Thread::sleep(500)
sendCommand(Enter_DirecTv, ON)
sendCommand(Exit_DirecTv, ON)
sendCommand(TV1_Ch1524 , OFF)
sendCommand(InfoCanal, "State")
end
rule "HBO 2 HD 1525"
when
Item TV1_Ch1525 received command ON
then
sendCommand(Uno_DirecTv, ON)
Thread::sleep(500)
sendCommand(Cinco_DirecTv, ON)
Thread::sleep(500)
sendCommand(Dos_DirecTv, ON)
Thread::sleep(500)
sendCommand(Cinco_DirecTv, ON)
Thread::sleep(500)
sendCommand(Enter_DirecTv, ON)
sendCommand(Exit_DirecTv, ON)
sendCommand(TV1_Ch1525 , OFF)
sendCommand(InfoCanal, "State")
end
rule "HBO PLUS HD 1532"
when
Item TV1_Ch1532 received command ON
then
sendCommand(Uno_DirecTv, ON)
Thread::sleep(500)
sendCommand(Cinco_DirecTv, ON)
Thread::sleep(500)
sendCommand(Tres_DirecTv, ON)
Thread::sleep(500)
sendCommand(Dos_DirecTv, ON)
Thread::sleep(500)
sendCommand(Enter_DirecTv, ON)
sendCommand(Exit_DirecTv, ON)
sendCommand(TV1_Ch1532 , OFF)
sendCommand(InfoCanal, "State")
end
rule "HBO FAMILY HD 1534"
when
Item TV1_Ch1534 received command ON
then
sendCommand(Uno_DirecTv, ON)
Thread::sleep(500)
sendCommand(Cinco_DirecTv, ON)
Thread::sleep(500)
sendCommand(Tres_DirecTv, ON)
Thread::sleep(500)
sendCommand(Cuatro_DirecTv, ON)
Thread::sleep(500)
sendCommand(Enter_DirecTv, ON)
sendCommand(Exit_DirecTv, ON)
sendCommand(TV1_Ch1534 , OFF)
sendCommand(InfoCanal, "State")
end
rule "MAX PRIME HD 1542"
when
Item TV1_Ch1542 received command ON
then
sendCommand(Uno_DirecTv, ON)
Thread::sleep(500)
sendCommand(Cinco_DirecTv, ON)
Thread::sleep(500)
sendCommand(Cuatro_DirecTv, ON)
Thread::sleep(500)
sendCommand(Dos_DirecTv, ON)
Thread::sleep(500)
sendCommand(Enter_DirecTv, ON)
sendCommand(Exit_DirecTv, ON)
sendCommand(TV1_Ch1542 , OFF)
sendCommand(InfoCanal, "State")
end
rule "FOX PREMIUM SERIES HD 1552"
when
Item TV1_Ch1552 received command ON
then
sendCommand(Uno_DirecTv, ON)
Thread::sleep(500)
sendCommand(Cinco_DirecTv, ON)
Thread::sleep(500)
sendCommand(Cinco_DirecTv, ON)
Thread::sleep(500)
sendCommand(Dos_DirecTv, ON)
Thread::sleep(500)
sendCommand(Enter_DirecTv, ON)
sendCommand(Exit_DirecTv, ON)
sendCommand(TV1_Ch1552 , OFF)
sendCommand(InfoCanal, "State")
end
rule "FOX PREMIUM FAMILY HD 1556"
when
Item TV1_Ch1556 received command ON
then
sendCommand(Uno_DirecTv, ON)
Thread::sleep(500)
sendCommand(Cinco_DirecTv, ON)
Thread::sleep(500)
sendCommand(Cinco_DirecTv, ON)
Thread::sleep(500)
sendCommand(Seis_DirecTv, ON)
Thread::sleep(500)
sendCommand(Enter_DirecTv, ON)
sendCommand(Exit_DirecTv, ON)
sendCommand(TV1_Ch1556 , OFF)
sendCommand(InfoCanal, "State")
end
rule "FOX PREMIUM COMEDY HD 1557"
when
Item TV1_Ch1557 received command ON
then
sendCommand(Uno_DirecTv, ON)
Thread::sleep(500)
sendCommand(Cinco_DirecTv, ON)
Thread::sleep(500)
sendCommand(Cinco_DirecTv, ON)
Thread::sleep(500)
sendCommand(Siete_DirecTv, ON)
Thread::sleep(500)
sendCommand(Enter_DirecTv, ON)
sendCommand(Exit_DirecTv, ON)
sendCommand(TV1_Ch1557 , OFF)
sendCommand(InfoCanal, "State")
end
rule "FOX PREMIUM MOVIES HD 1559"
when
Item TV1_Ch1559 received command ON
then
sendCommand(Uno_DirecTv, ON)
Thread::sleep(500)
sendCommand(Cinco_DirecTv, ON)
Thread::sleep(500)
sendCommand(Cinco_DirecTv, ON)
Thread::sleep(500)
sendCommand(Nueve_DirecTv, ON)
Thread::sleep(500)
sendCommand(Enter_DirecTv, ON)
sendCommand(Exit_DirecTv, ON)
sendCommand(TV1_Ch1559 , OFF)
sendCommand(InfoCanal, "State")
end
rule "FOX PREMIUM ACTION HD 1561"
when
Item TV1_Ch1561 received command ON
then
sendCommand(Uno_DirecTv, ON)
Thread::sleep(500)
sendCommand(Cinco_DirecTv, ON)
Thread::sleep(500)
sendCommand(Seis_DirecTv, ON)
Thread::sleep(500)
sendCommand(Uno_DirecTv, ON)
Thread::sleep(500)
sendCommand(Enter_DirecTv, ON)
sendCommand(Exit_DirecTv, ON)
sendCommand(TV1_Ch1561 , OFF)
sendCommand(InfoCanal, "State")
end
rule "FOX PREMIUM CINEMA HD 1562"
when
Item TV1_Ch1562 received command ON
then
sendCommand(Uno_DirecTv, ON)
Thread::sleep(500)
sendCommand(Cinco_DirecTv, ON)
Thread::sleep(500)
sendCommand(Seis_DirecTv, ON)
Thread::sleep(500)
sendCommand(Dos_DirecTv, ON)
Thread::sleep(500)
sendCommand(Enter_DirecTv, ON)
sendCommand(Exit_DirecTv, ON)
sendCommand(TV1_Ch1562 , OFF)
sendCommand(InfoCanal, "State")
end
rule "FOX SPORT HD 1604"
when
Item TV1_Ch1604 received command ON
then
sendCommand(Uno_DirecTv, ON)
Thread::sleep(500)
sendCommand(Seis_DirecTv, ON)
Thread::sleep(500)
sendCommand(Cero_DirecTv, ON)
Thread::sleep(500)
sendCommand(Cuatro_DirecTv, ON)
Thread::sleep(500)
sendCommand(Enter_DirecTv, ON)
sendCommand(Exit_DirecTv, ON)
sendCommand(TV1_Ch1604 , OFF)
sendCommand(InfoCanal, "State")
end
rule "FOX SPORT 2 HD 1608"
when
Item TV1_Ch1608 received command ON
then
sendCommand(Uno_DirecTv, ON)
Thread::sleep(500)
sendCommand(Seis_DirecTv, ON)
Thread::sleep(500)
sendCommand(Cero_DirecTv, ON)
Thread::sleep(500)
sendCommand(Ocho_DirecTv, ON)
Thread::sleep(500)
sendCommand(Enter_DirecTv, ON)
sendCommand(Exit_DirecTv, ON)
sendCommand(TV1_Ch1608 , OFF)
sendCommand(InfoCanal, "State")
end
rule "FOX SPORT 3 HD 1609"
when
Item TV1_Ch1609 received command ON
then
sendCommand(Uno_DirecTv, ON)
Thread::sleep(500)
sendCommand(Seis_DirecTv, ON)
Thread::sleep(500)
sendCommand(Cero_DirecTv, ON)
Thread::sleep(500)
sendCommand(Nueve_DirecTv, ON)
Thread::sleep(500)
sendCommand(Enter_DirecTv, ON)
sendCommand(Exit_DirecTv, ON)
sendCommand(TV1_Ch1609 , OFF)
sendCommand(InfoCanal, "State")
end
rule "DIRECTV SPORT HD 1610"
when
Item TV1_Ch1610 received command ON
then
sendCommand(Uno_DirecTv, ON)
Thread::sleep(500)
sendCommand(Seis_DirecTv, ON)
Thread::sleep(500)
sendCommand(Uno_DirecTv, ON)
Thread::sleep(500)
sendCommand(Cero_DirecTv, ON)
Thread::sleep(500)
sendCommand(Enter_DirecTv, ON)
sendCommand(Exit_DirecTv, ON)
sendCommand(TV1_Ch1610 , OFF)
sendCommand(InfoCanal, "State")
end
rule "DIRECTV SPORT EVENTOS HD 1611"
when
Item TV1_Ch1611 received command ON
then
sendCommand(Uno_DirecTv, ON)
Thread::sleep(500)
sendCommand(Seis_DirecTv, ON)
Thread::sleep(500)
sendCommand(Uno_DirecTv, ON)
Thread::sleep(500)
sendCommand(Uno_DirecTv, ON)
Thread::sleep(500)
sendCommand(Enter_DirecTv, ON)
sendCommand(Exit_DirecTv, ON)
sendCommand(TV1_Ch1611 , OFF)
sendCommand(InfoCanal, "State")
end
rule "DIRECTV SPORT 2 HD 1612"
when
Item TV1_Ch1612 received command ON
then
sendCommand(Uno_DirecTv, ON)
Thread::sleep(500)
sendCommand(Seis_DirecTv, ON)
Thread::sleep(500)
sendCommand(Uno_DirecTv, ON)
Thread::sleep(500)
sendCommand(Dos_DirecTv, ON)
Thread::sleep(500)
sendCommand(Enter_DirecTv, ON)
Thread::sleep(500)
sendCommand(Exit_DirecTv, ON)
sendCommand(TV1_Ch1612 , OFF)
sendCommand(InfoCanal, "State")
end
rule "DIRECTV SPORT + HD 1613"
when
Item TV1_Ch1613 received command ON
then
sendCommand(Uno_DirecTv, ON)
Thread::sleep(500)
sendCommand(Seis_DirecTv, ON)
Thread::sleep(500)
sendCommand(Uno_DirecTv, ON)
Thread::sleep(500)
sendCommand(Tres_DirecTv, ON)
Thread::sleep(500)
sendCommand(Enter_DirecTv, ON)
Thread::sleep(500)
sendCommand(Exit_DirecTv, ON)
sendCommand(TV1_Ch1613 , OFF)
sendCommand(InfoCanal, "State")
end
rule "ESPN HD 1620"
when
Item TV1_Ch1620 received command ON
then
sendCommand(Uno_DirecTv, ON)
Thread::sleep(500)
sendCommand(Seis_DirecTv, ON)
Thread::sleep(500)
sendCommand(Dos_DirecTv, ON)
Thread::sleep(500)
sendCommand(Cero_DirecTv, ON)
Thread::sleep(500)
sendCommand(Enter_DirecTv, ON)
Thread::sleep(500)
sendCommand(Exit_DirecTv, ON)
sendCommand(TV1_Ch1620 , OFF)
sendCommand(InfoCanal, "State")
end
rule "ESPN + HD 1621"
when
Item TV1_Ch1621 received command ON
then
sendCommand(Uno_DirecTv, ON)
Thread::sleep(500)
sendCommand(Seis_DirecTv, ON)
Thread::sleep(500)
sendCommand(Dos_DirecTv, ON)
Thread::sleep(500)
sendCommand(Uno_DirecTv, ON)
Thread::sleep(500)
sendCommand(Enter_DirecTv, ON)
Thread::sleep(500)
sendCommand(Exit_DirecTv, ON)
sendCommand(TV1_Ch1621 , OFF)
sendCommand(InfoCanal, "State")
end
rule "ESPN 2 HD 1623"
when
Item TV1_Ch625 received command ON
then
sendCommand(Uno_DirecTv, ON)
Thread::sleep(500)
sendCommand(Seis_DirecTv, ON)
Thread::sleep(500)
sendCommand(Dos_DirecTv, ON)
Thread::sleep(500)
sendCommand(Tres_DirecTv, ON)
Thread::sleep(500)
sendCommand(Enter_DirecTv, ON)
Thread::sleep(500)
sendCommand(Exit_DirecTv, ON)
sendCommand(TV1_Ch1623 , OFF)
sendCommand(InfoCanal, "State")
end
rule "ESPN 3 HD 1626"
when
Item TV1_Ch1626 received command ON
then
sendCommand(Uno_DirecTv, ON)
Thread::sleep(500)
sendCommand(Seis_DirecTv, ON)
Thread::sleep(500)
sendCommand(Dos_DirecTv, ON)
Thread::sleep(500)
sendCommand(Seis_DirecTv, ON)
Thread::sleep(500)
sendCommand(Enter_DirecTv, ON)
Thread::sleep(500)
sendCommand(Exit_DirecTv, ON)
sendCommand(TV1_Ch1626 , OFF)
sendCommand(InfoCanal, "State")
end
Sitemap
Switch item=TV1_Ch1524 label="HBO HD" mappings=[ON="Ver"] icon="tv1524"
Switch item=TV1_Ch1525 label="HBO 2 HD" mappings=[ON="Ver"] icon="tv1525"
Switch item=TV1_Ch1532 label="HBO Plus HD" mappings=[ON="Ver"] icon="tv1532"
Switch item=TV1_Ch1534 label="HBO Family HD" mappings=[ON="Ver"] icon="tv1534"
Switch item=TV1_Ch1542 label="Max Prime HD" mappings=[ON="Ver"] icon="tv1542"
Switch item=TV1_Ch1552 label="Fox Premium Series HD" mappings=[ON="Ver"] icon="tv1552"
Switch item=TV1_Ch1556 label="Fox Premium Family HD" mappings=[ON="Ver"] icon="tv1556"
Switch item=TV1_Ch1557 label="Fox Premium Comedy HD" mappings=[ON="Ver"] icon="tv1557"
Switch item=TV1_Ch1559 label="Fox Premium Movies HD" mappings=[ON="Ver"] icon="tv1559"
Switch item=TV1_Ch1561 label="Fox Premium Action HD" mappings=[ON="Ver"] icon="tv1561"
Switch item=TV1_Ch1562 label="Fox Premium Cinema HD" mappings=[ON="Ver"] icon="tv1562"
Switch item=TV1_Ch1604 label="Fox Sports HD" mappings=[ON="Ver"] icon="tv1604"
Switch item=TV1_Ch1608 label="Fox Sports 2 HD" mappings=[ON="Ver"] icon="tv1608"
Switch item=TV1_Ch1609 label="Fox Sports 3 HD" mappings=[ON="Ver"] icon="tv1609"
Switch item=TV1_Ch1610 label="DIRECTV Sports HD" mappings=[ON="Ver"] icon="tv1610"
Switch item=TV1_Ch1611 label="DIRECTV Sports HD Eventos" mappings=[ON="Ver"] icon="tv1611"
Switch item=TV1_Ch1612 label="DIRECTV Sports 2 HD" mappings=[ON="Ver"] icon="tv1612"
Switch item=TV1_Ch1613 label="DIRECTV Sports 3 HD" mappings=[ON="Ver"] icon="tv1613"
Switch item=TV1_Ch1620 label="ESPN HD" mappings=[ON="Ver"] icon="tv1620"
Switch item=TV1_Ch1621 label="ESPN + HD" mappings=[ON="Ver"] icon="tv1621"
Switch item=TV1_Ch1623 label="ESPN 2 HD" mappings=[ON="Ver"] icon="tv1623"
Switch item=TV1_Ch1626 label="ESPN 3 HD" mappings=[ON="Ver"] icon="tv1626"
I have seen an example in this community where they use toString.substring (0, 1) to create a single rule in which it receives the command in string and then separates it and sends data by command data but it has not worked for me
rule "SEND COMMAND ONLY ONE RULE"
when
Item Channel_select changed
then
if (Channel_select.state == "NULL") return; // If NULL do nothing
var topic = "broadlink/televisor/saladirectv/" + Channel_select.state.toString.substring(0, 1)
publish("mosquitto", topic, "play-780f77b943fb")
createTimer(now.plusSeconds(1)) [ |
topic = "broadlink/televisor/saladirectv/" + Channel_select.state.toString.substring(1, 2)
publish("mosquitto", topic, "play-780f77b943fb")
]
createTimer(now.plusSeconds(2)) [|
topic = "broadlink/televisor/saladirectv/" + Channel_select.state.toString.substring(2)
publish("mosquitto", topic, "play-780f77b943fb")
]
end
in this example I base myself to try to reduce my code but it didn’t work for me
https://community.openhab.org/t/solved-channel-select-with-broadlink-and-mqtt/56680/2
can someone help me or give me an orientation