Using openhab 2.5M1 build 1575 on a Rpi.
I´m trying to figure how to get five (5) proxy switched representing the state of the ventilation speed of my Nilan ventilation system to be visual and controled from Google Home as well as from openhab and the Nilan system itself…
The Nilan ventilation system uses one item in steps from 0 - 4 for controling the fan speed. 0 (zero) is standby. Fan speed is off. Step 1 = Fan speed low. Sted 2, Fan speed middle etc…
In short - When ventilation is set to step 2, ProxySwitch2 should be ON.
And in reverse - If I turn on ProxySwitch3 , then the Nilan system should change to step 3.
This is the nilan item to set the step:
Number Nilan_Control_VentSet "User ventilation step select [MAP(nilan_ventset.map):%s]" <fan_ceiling> (gNilan) {channel="modbus:data:myNilan:controlRegisters:hol1003:number", autoupdate="false"}
I have already created the proxyswitch items as well, cause I use it for manually change the speed through openhab/goole home etc… Its very basic, but it works, except, In google home, all the switches are OFF, because I use the expire binding to set the switch to off. Which ofcouse is wrong. But I havnt figured how to leave one ON, and the rest OFF…
These are the proxy switches, again, very simple:
// Ventilation
Switch nilanVent0 "Ventilation trin 0 [%s]" <switch> [ "Switchable" ] { expire="1s,command=OFF"}
Switch nilanVent1 "Ventilation trin 1 [%s]" <switch> [ "Switchable" ] { expire="1s,command=OFF"}
Switch nilanVent2 "Ventilation trin 2 [%s]" <switch> [ "Switchable" ] { expire="1s,command=OFF"}
Switch nilanVent3 "Ventilation trin 3 [%s]" <switch> [ "Switchable" ] { expire="1s,command=OFF"}
Switch nilanVent4 "Ventilation trin 4 [%s]" <switch> [ "Switchable" ] { expire="1s,command=OFF"}
And this is the rule I use to make use of these switches:
rule "Nilan ventilation trin 0"
when
Item nilanVent0 changed from OFF to ON
then
Nilan_Control_VentSet.sendCommand(0)
end
rule "Nilan ventilation trin 1"
when
Item nilanVent1 changed from OFF to ON
then
Nilan_Control_VentSet.sendCommand(1)
end
rule "Nilan ventilation trin 2"
when
Item nilanVent2 changed from OFF to ON
then
Nilan_Control_VentSet.sendCommand(2)
end
rule "Nilan ventilation trin 3"
when
Item nilanVent3 changed from OFF to ON
then
Nilan_Control_VentSet.sendCommand(3)
end
rule "Nilan ventilation trin 4"
when
Item nilanVent4 changed from OFF to ON
then
Nilan_Control_VentSet.sendCommand(4)
end
Again, this is very basic, could probably be optimzed somehow, but it works… Also it works with controle from Google Home, except, in Google Home, it doesnt show which proxyswitch is actually turned on. Thats whats bothering me.
Now… what I really wanted was a way to controle this, just like it is today, but also beeing able to see in Google Home, (or openhab) which proxyswitch (step) is ON.
As said, I know the above wont work like this,cause I use the expire binding to turn the proxyswitch OFF after one sec. But if I dont, then the switches will remain ON, if I change the state on the ventilation system. Thats the part I can seem to figure…
I think I probably have to make use of a rule which either uses cases or quite a few “else if” arguements… Like this:
rule "Manual ventilation steps"
when
Item Nilan_Control_VentSet changed
then
if(Nilan_Control_VentSet.state === 4) {
nilanVent4.sendCommand(ON)
}
else
{
nilanVent4.sendCommand(OFF)
}
else
if(Nilan_Control_VentSet.state === 3) {
nilanVent3.sendCommand(ON)
}
else
{
nilanVent3.sendCommand(OFF)
}
Etc.........
This might work, at least one way. But I fail to see if it´ll work from openhab/Google to the ventilation system… So in that case I tried to find a rule suitable from the other direction by placing all the proxyswitches in a group, I guess I could do something like this:
rule "Manual ventilation steps opposit direction"
when
Item g_nilanVent changed
then
if(nilanVent4.state === ON) {
Nilan_Control_VentSet.sendCommand(4)
}
else
if(nilanVent3.state === ON) {
Nilan_Control_VentSet.sendCommand(3)
}
else ......
This will work. But how do I set the other proxy switches to go OFF except for the activated step/switch?
I guess this is the bottom line of my question in this… It´s probably very simple, I just cant see how…