Hello,
is there any suggestions if it’s possible to use exec binding with Switch mappings and Selection?
broadlink.things:
Thing exec:command:remote-send [command="/usr/bin/python3.9 /home/openhabian/BlackBeanControl/BlackBeanControl.py -c %2$s", interval=0, timeout=5, autorun=true]
sitemap:
Text label="Luci" icon="rgb" {
Switch item=BROAD_LINK_SWITCH mappings=["ON"="Switch on","OFF"="Switch off", "CUSTOM_COMMAND"="CUSTOM"]
Selection item=BROAD_LINK_SELECTION mappings=["R"="Red", "G"="Green", "B"="Blue"]
}
How have I to configure items?
Thanks
rossko57
(Rossko57)
November 26, 2022, 11:50am
2
That rather depends on what you need to send.
Note, that Exec input channel is of string type. (String type Items may be used with sitemap Switch and Selection widgets.)
Note, there is only one input channel, you cannot send two Item commands at once (though of course you can combine multiple data points into one command in a rule)
I need to send only 1 command, but dynamic using a mapping or selection
rossko57
(Rossko57)
November 26, 2022, 12:12pm
4
Okeydoke, what difficulty are you having?
Ok, I had to configure the “input” as a String in the items:
String Led_Piscina_Command
String Led_Piscina_Args {channel="exec:command:remote-send:input"}
then sitemap:
Switch item=Led_Piscina_Command mappings=[ "ON"="ON", "OFF"="OFF", "R"="Red" ]
and then a rule to manage dynamically the command:
rule "Led piscina rule"
when
Item Led_Piscina_Command received command
then
Led_Piscina_Args.sendCommand(Led_Piscina_Command.state.toString)
end
rossko57
(Rossko57)
November 26, 2022, 3:20pm
6
You can do this without a rule
Note, that this rule is doomed to failure
Because when the rule triggers on command no state change will yet have happened
This construction is doomed to the failure that you describe.
A command is a “do something” instruction.
A state is a “this is how it is” condition report.
It always takes real time to execute instructions.
If your rule looks at the state of Item immediately after a command issued (which is what you have written it to do) you may get the ‘before’ or ‘after’ state.
Usually you just need to choose rule trigger carefully.
If you want to send your MQTT when the Item changes state, choose the …
1 Like