Hello
I have small engine that works with “rollershutter”. Im using this in my project for studies that imitate smart house. Anyway, I want to control the level of the blind. So I created item:
Dimmer roleta_procent "Opuszczanie automatyczne" <rollershutter>
then I create rule:
import java.lang.Math
val CzasPodnoszenia=2000
val ProcentRolety=0
rule "Roleta automatyczna"
when
Item roleta_procent received command
then
val ZadanyProcent=roleta_procent.state as DecimalType //Input Level
val ProcentRolety=Math::abs(ZadanyProcent-ProcentRolety) //Calculating Real level
val KierunekRolety=if(ZadanyProcent>ProcentRolety) UP else DOWN //Calculating direction
val Czas=(ProcentRolety*CzasPodnoszenia)/100 //Calculating time of blind move
if (KierunekRolety==UP){
executeCommandLine("pigs w 5 0") //Wybor kierunku GORA pin 5 /direction
executeCommandLine("pigs w 22 1") //Wlaczenie silnika pin 22 /turning on engine
executeCommandLine("pigs p 6 35") //Ustawienie predkoscsi pin 6 wartosc 35 na 255 /engine speed
Thread::sleep(Czas) //Podniesienie rolety do danego procentu /time of work
executeCommandLine("pigs p 6 0") //Zatrzymanie rolety /engine stop
}
if(KierunekRolety==DOWN){
executeCommandLine("pigs w 5 1") //Wybor kierunku GORA pin 5
executeCommandLine("pigs w 22 1") //Wlaczenie silnika pin 22
executeCommandLine("pigs p 6 35") //Ustawienie predkoscsi pin 6 wartosc 35 na 255
Thread::sleep(Czas) //Podniesienie rolety do danego procentu
executeCommandLine("pigs p 6 0") //Zatrzymanie rolety
}
end
but the rule doesn’t work and I can see this error in logviewer: