Hi everyone
I try to control my rollershutter via the mysensors binding (arduino based switch) It contains two switches, one for UP and one for DOWN.
I tried to create a rule which sends UP on first press and STOP on second press (and the other way around), so I can control the shutter with just two buttons.
Unfortunately my rule just sends STOP. Dont know if this could actually work this way. Please be so kind and point me in the right direction.
var boolean RlGaFed_s = false
var boolean RlGaFeu_s = false
rule "RlGadown"
when
Item RlGaFeSchadown changed
then
if(RlGaFe.state==OFF)
{
sendCommand(RlGaFe, DOWN)
RlGaFed_s = true
}
else
{
sendCommand(RlGaFe, STOP)
RlGaFed_s = false
}
end
rule "RlGaup"
when
Item RlGaFeSchaup changed
then
if(RlGaFe.state==OFF)
{
sendCommand(RlGaFe, UP)
RlGaFeu_s = true
}
else
{
sendCommand(RlGaFe, STOP)
RlGaFeu_s = false
}
end
My basic philosophy with automation is that any controller should be as ‘stupid’ as it can be, however, it has to function autonomously. OH augments the functionality; sometime it is unavoidable that OH does a bit more…
In your case – and I have to solve the same problem – I would program the Arduino to interpret the duration of “switch pressed” to either trigger up or down or stop.
I would realise this with a state machine: up, down, stop, idle.
Since I work with MQTT where I can, OH would do both subscribing and publishing to the rollo states.
Since you can have 3 buttons on OH, your problem is solved.
I have also presets on the sitemap to go 0, 25, 50, 75, 99 and 100%
I think you’re right with the dumb controller, but this should be a secondary “remote” for a zwave device.
The normal wallswitches are installed and they are hardwired, so functionality is provided. Sorry forgot to mention this.
I’d like to stick with the sketch I’m using because it’s working great and is easily extendable. So I came up with the idea of a rule, just cant work out how to switch between the two states.
var RlGaFed_s = 0
var RlGaFeu_s = 0
rule "RlGadown"
when
Item RlVomiSchadown changed from 0 to 1
then
if(RlGaFed_s==0)
{
RlGaFe.sendCommand(DOWN)
RlGaFed_s = 1
}
else
{
RlGaFe.sendCommand(STOP)
RlGaFed_s = 0
}
end
rule "RlGaup"
when
Item RlVomiSchaup changed from 0 to 1
then
if(RlGaFeu_s==0)
{
RlGaFe.sendCommand(UP)
RlGaFeu_s = 1
}
else
{
RlGaFe.sendCommand(STOP)
RlGaFeu_s = 0
}
end