79kiko
(Juraj)
August 21, 2016, 1:05pm
1
I have fan where speed set as follows
relay ON - speed 1
relay ON - speed 2
and 2. relays ON - speed 3
I have MQTT bindings item.
Switch rychlost1 "rekuperacia rychlost 1" <switch> { mqtt=">[localbroker:/mama/rychlost1/Switch:command:ON:1]", mqtt=">[localbroker:/mama/rychlost1/Switch:command:OFF:0]" }
Switch rychlost2 "rekuperacia rychlost 2" <switch> { mqtt=">[localbroker:/mama/rychlost2/Switch:command:ON:1]", mqtt=">[localbroker:/mama/rychlost2/Switch:command:OFF:0]" }
How have I to make switch with 4 buttons (button1=0, button2=1, button3=2 and button4=3)
mstormi
(Markus Storm)
August 21, 2016, 5:17pm
2
Use a single item of type Number
. In sitemap, you can use Switch
and mappings=...
so it gets displayed as bunch of buttons (as many as you need states).
79kiko
(Juraj)
August 22, 2016, 10:39pm
3
Thank you for your time. Solved.
My procedure and Guide for any users with MQTT binding:
You need Items with bindings:
Switch relay1 "relay 1" <switch> { mqtt=">[localbroker:/esp8266/relay1/Switch:command:ON:1],>[localbroker:/esp8266/relay1/Switch:command:OFF:0]"}
Switch relay2 "relay 2" <switch> { mqtt=">[localbroker:/esp8266/relay2/Switch:command:ON:1],>[localbroker:/esp8266/relay2/Switch:command:OFF:0]"}
Switch relay2 "relay 3" <switch> { mqtt=">[localbroker:/esp8266/relay3/Switch:command:ON:1],>[localbroker:/esp8266/relay3/Switch:command:OFF:0]"}
One “virtual Item”
String relay "relay switch [%s]" <switch>
Sitemap
Switch item=relay label="Relay switcher" icon="switch" mappings=[off="OFF", relay1="Relay1", relay2="Relay2", relay3="Relay3"]
and Rule
rule relayCommand
when
Item relay received command
then
if (relay.state == "off") { // all relays OFF
sendCommand(relay1, OFF)
sendCommand(relay2, OFF)
sendCommand(relay3, OFF)
}
else if(relay.state == "relay1") { // activate relay 1
sendCommand(relay1, ON)
sendCommand(relay2, OFF)
sendCommand(relay3, OFF)
}
else if (relay.state == "relay2") {// activate relay 2
sendCommand(relay1, OFF)
sendCommand(relay2, ON)
sendCommand(relay3, OFF)
}
else if (relay.state == "relay3") { // activate relay 3
sendCommand(relay1, OFF)
sendCommand(relay2, OFF)
sendCommand(relay3, ON)
}
end