876 lines
26 KiB
Plaintext
876 lines
26 KiB
Plaintext
import java.util.Random
|
|
|
|
var Timer timer = null
|
|
val Random random = new Random()
|
|
// val resList = newArrayList("640/480", "320/240", "480/360")
|
|
// val urlList = newArrayList("https://www.fillmurray.com", "https://www.fillmurray.com/g",
|
|
// "https://www.placecage.com", "https://www.placecage.com/c", "https://www.placecage.com/g")
|
|
|
|
|
|
/**********************************************************************
|
|
* Rules x calcoli valori ENERGIA
|
|
**********************************************************************/
|
|
rule "Fix Fronius FullLoad"
|
|
when
|
|
Item Fn_FullLoadNeg changed
|
|
then
|
|
if (Fn_FullLoadNeg.state instanceof Number) {
|
|
Fn_FullLoadPos.postUpdate((Fn_FullLoadNeg.state as Number) * -1)
|
|
} else {
|
|
Fn_FullLoadPos.postUpdate(Undefined) // or UNDEF on OH2
|
|
}
|
|
end
|
|
|
|
rule "Prelievo Rete Quotidiano (IN - FV)"
|
|
when
|
|
Item Fn_PrelRete changed
|
|
//Time cron "0 * * * * *"
|
|
then
|
|
// inizio creando variabile derivata del SOLO valore prelevato
|
|
if(Fn_PrelRete.state >= 0) {
|
|
Fn_PrelReteNet.postUpdate(Fn_PrelRete.state as Number)
|
|
}
|
|
else {
|
|
Fn_PrelReteNet.postUpdate(0)
|
|
}
|
|
//logInfo("Fn_PrelRete.rules", "Fn_PrelReteNet:{}", Fn_PrelReteNet.state)
|
|
// calcolo parametri delle ore cumulate giornaliere, del valore medio giornaliero
|
|
var double dayTime = (now.getMinute() as Number) / 60 + now.getHour()
|
|
//logInfo("Fn_PrelRete.rules", "inizio:{}, dayTime: {}", inizio, dayTime)
|
|
|
|
// var Number mediaGiorn = Fn_PrelRete.averageSince(now.withTimeAtStartOfDay).doubleValue
|
|
// logInfo("Fn_PrelRete.rules", "mediaGiorn: {}", mediaGiorn)
|
|
|
|
// var Number mediaGiornNet = Fn_PrelReteNet.averageSince(now.withTimeAtStartOfDay).doubleValue
|
|
var Number mediaGiornNet = Fn_PrelReteNet.averageSince(now.withHour(0).withMinute(0).withSecond(0)).doubleValue
|
|
// logInfo("Fn_PrelRete.rules", "mediaGiornNet: {}", mediaGiornNet)
|
|
|
|
// to-do: usare ALTRA media...
|
|
//var double kWh = mediaGiorn * dayTime / 1000
|
|
var double kWh = mediaGiornNet * dayTime / 1000
|
|
//logInfo("Fn_PrelRete.rules", "kWh:{}", kWh)
|
|
Fn_PrelReteDay.postUpdate(kWh)
|
|
end
|
|
|
|
/**********************************************************************
|
|
* Rules x automazione CLIMA ALWAYS
|
|
**********************************************************************/
|
|
|
|
rule "Accensione mattino 7.40 uffici Samuele / Dario"
|
|
when
|
|
Time cron "0 40 7 * * MON-SAT"
|
|
then
|
|
Heating_GU120_CL_C4_Switch.sendCommand(ON)
|
|
Heating_GU100_CL_C8_Switch.sendCommand(ON)
|
|
end
|
|
|
|
rule "Accensione mattino 7.45 ufficio Emmanuele / Sala Riunioni"
|
|
when
|
|
Time cron "0 45 7 * * MON-SAT"
|
|
then
|
|
Heating_GU120_CL_C5_Switch.sendCommand(ON)
|
|
Heating_GU100_CL_C9_Switch.sendCommand(ON)
|
|
end
|
|
|
|
|
|
rule "Accensione mattino 7.50 finestra / OpenSpace"
|
|
when
|
|
Time cron "0 50 7 * * MON-SAT"
|
|
then
|
|
Heating_GU120_CL_C3_Switch.sendCommand(ON)
|
|
Heating_GU100_CL_C7_Switch.sendCommand(ON)
|
|
end
|
|
|
|
rule "Accensione mattino 8.00 desk / ingresso / corridoio"
|
|
when
|
|
Time cron "0 0 8 * * MON-SAT"
|
|
then
|
|
Heating_GU120_CL_C1_Switch.sendCommand(ON)
|
|
Heating_GU120_CL_C2_Switch.sendCommand(ON)
|
|
Heating_GU100_CL_C6_Switch.sendCommand(ON)
|
|
end
|
|
|
|
// rule "Accensione Impianto OGNI mattino 8.15 Standard (NO ufficio e sala riunioni)"
|
|
// when
|
|
// Time cron "0 15 8 * * MON-SAT"
|
|
// then
|
|
// Heating_GU120_CL_C1_Switch.sendCommand(ON)
|
|
// Heating_GU120_CL_C2_Switch.sendCommand(ON)
|
|
// Heating_GU120_CL_C3_Switch.sendCommand(ON)
|
|
// Heating_GU120_CL_C4_Switch.sendCommand(ON)
|
|
// Heating_GU120_CL_C5_Switch.sendCommand(ON)
|
|
// Heating_GU100_CL_C6_Switch.sendCommand(ON)
|
|
// Heating_GU100_CL_C7_Switch.sendCommand(ON)
|
|
// Heating_GU100_CL_C8_Switch.sendCommand(ON)
|
|
// Heating_GU100_CL_C9_Switch.sendCommand(ON)
|
|
// end
|
|
|
|
rule "Accensione Impianto OGNI mattino 8.30"
|
|
when
|
|
Time cron "0 30 8 * * ?"
|
|
then
|
|
Heating_GU120_CL_C1_Switch.sendCommand(ON)
|
|
Heating_GU120_CL_C2_Switch.sendCommand(ON)
|
|
Heating_GU120_CL_C3_Switch.sendCommand(ON)
|
|
Heating_GU120_CL_C4_Switch.sendCommand(ON)
|
|
Heating_GU120_CL_C5_Switch.sendCommand(ON)
|
|
Heating_GU100_CL_C6_Switch.sendCommand(ON)
|
|
Heating_GU100_CL_C7_Switch.sendCommand(ON)
|
|
Heating_GU100_CL_C8_Switch.sendCommand(ON)
|
|
Heating_GU100_CL_C9_Switch.sendCommand(ON)
|
|
end
|
|
|
|
// rule "Spegnimento Impianto OGNI pomeriggio 14.30 FERIE"
|
|
// when
|
|
// Time cron "0 30 14 * * ?"
|
|
// then
|
|
// Heating_GU120_CL_C1_Switch.sendCommand(OFF)
|
|
// Heating_GU120_CL_C2_Switch.sendCommand(OFF)
|
|
// Heating_GU120_CL_C3_Switch.sendCommand(OFF)
|
|
// Heating_GU120_CL_C4_Switch.sendCommand(OFF)
|
|
// Heating_GU120_CL_C5_Switch.sendCommand(OFF)
|
|
// Heating_GU100_CL_C6_Switch.sendCommand(OFF)
|
|
// Heating_GU100_CL_C7_Switch.sendCommand(OFF)
|
|
// Heating_GU100_CL_C8_Switch.sendCommand(OFF)
|
|
// Heating_GU100_CL_C9_Switch.sendCommand(OFF)
|
|
// end
|
|
// //-------------------------------------------------------------------------------
|
|
|
|
|
|
// rule "Accensione Impianto OGNI mattino 8.30 SmartWorking"
|
|
// when
|
|
// Time cron "0 30 8 * * ?"
|
|
// then
|
|
// Heating_GU120_CL_C1_Switch.sendCommand(ON)
|
|
// Heating_GU120_CL_C2_Switch.sendCommand(ON)
|
|
// Heating_GU120_CL_C3_Switch.sendCommand(ON)
|
|
// Heating_GU120_CL_C4_Switch.sendCommand(ON)
|
|
// Heating_GU120_CL_C5_Switch.sendCommand(ON)
|
|
// Heating_GU100_CL_C6_Switch.sendCommand(ON)
|
|
// Heating_GU100_CL_C7_Switch.sendCommand(ON)
|
|
// Heating_GU100_CL_C8_Switch.sendCommand(ON)
|
|
// Heating_GU100_CL_C9_Switch.sendCommand(ON)
|
|
// end
|
|
|
|
// rule "Spegnimento Clima sabato-domenica pomeriggio 17:0"
|
|
// when
|
|
// Time cron "0 0 17 ? * SAT,SUN"
|
|
// then
|
|
// Heating_GU120_CL_C1_Switch.sendCommand(OFF)
|
|
// Heating_GU120_CL_C2_Switch.sendCommand(OFF)
|
|
// Heating_GU120_CL_C3_Switch.sendCommand(OFF)
|
|
// Heating_GU120_CL_C4_Switch.sendCommand(OFF)
|
|
// Heating_GU120_CL_C5_Switch.sendCommand(OFF)
|
|
// Heating_GU100_CL_C6_Switch.sendCommand(OFF)
|
|
// Heating_GU100_CL_C7_Switch.sendCommand(OFF)
|
|
// Heating_GU100_CL_C8_Switch.sendCommand(OFF)
|
|
// Heating_GU100_CL_C9_Switch.sendCommand(OFF)
|
|
// end
|
|
|
|
|
|
// rule "Spegnimento Clima OGNI sera 16:30 SmartWorking"
|
|
// when
|
|
// Time cron "0 30 16 * * ?"
|
|
// then
|
|
// Heating_GU120_CL_C1_Switch.sendCommand(OFF)
|
|
// Heating_GU120_CL_C2_Switch.sendCommand(OFF)
|
|
// Heating_GU120_CL_C3_Switch.sendCommand(OFF)
|
|
// Heating_GU120_CL_C4_Switch.sendCommand(OFF)
|
|
// Heating_GU120_CL_C5_Switch.sendCommand(OFF)
|
|
// Heating_GU100_CL_C6_Switch.sendCommand(OFF)
|
|
// Heating_GU100_CL_C7_Switch.sendCommand(OFF)
|
|
// Heating_GU100_CL_C8_Switch.sendCommand(OFF)
|
|
// Heating_GU100_CL_C9_Switch.sendCommand(OFF)
|
|
// end
|
|
|
|
// rule "Spegnimento Clima OGNI sera 19:00"
|
|
// when
|
|
// Time cron "0 0 19 * * ?"
|
|
// then
|
|
// Heating_GU120_CL_C1_Switch.sendCommand(OFF)
|
|
// Heating_GU120_CL_C2_Switch.sendCommand(OFF)
|
|
// Heating_GU120_CL_C3_Switch.sendCommand(OFF)
|
|
// Heating_GU120_CL_C4_Switch.sendCommand(OFF)
|
|
// Heating_GU120_CL_C5_Switch.sendCommand(OFF)
|
|
// Heating_GU100_CL_C6_Switch.sendCommand(OFF)
|
|
// Heating_GU100_CL_C7_Switch.sendCommand(OFF)
|
|
// Heating_GU100_CL_C8_Switch.sendCommand(OFF)
|
|
// Heating_GU100_CL_C9_Switch.sendCommand(OFF)
|
|
// end
|
|
|
|
rule "Spegnimento Clima OGNI sera 20:00"
|
|
when
|
|
Time cron "0 0 20 * * ?"
|
|
then
|
|
Heating_GU120_CL_C1_Switch.sendCommand(OFF)
|
|
Heating_GU120_CL_C2_Switch.sendCommand(OFF)
|
|
Heating_GU120_CL_C3_Switch.sendCommand(OFF)
|
|
Heating_GU120_CL_C4_Switch.sendCommand(OFF)
|
|
Heating_GU120_CL_C5_Switch.sendCommand(OFF)
|
|
Heating_GU100_CL_C6_Switch.sendCommand(OFF)
|
|
Heating_GU100_CL_C7_Switch.sendCommand(OFF)
|
|
Heating_GU100_CL_C8_Switch.sendCommand(OFF)
|
|
Heating_GU100_CL_C9_Switch.sendCommand(OFF)
|
|
end
|
|
|
|
// rule "Spegnimento Clima OGNI sera 20:30"
|
|
// when
|
|
// Time cron "0 30 20 * * ?"
|
|
// then
|
|
// Heating_GU120_CL_C1_Switch.sendCommand(OFF)
|
|
// Heating_GU120_CL_C2_Switch.sendCommand(OFF)
|
|
// Heating_GU120_CL_C3_Switch.sendCommand(OFF)
|
|
// Heating_GU120_CL_C4_Switch.sendCommand(OFF)
|
|
// Heating_GU120_CL_C5_Switch.sendCommand(OFF)
|
|
// Heating_GU100_CL_C6_Switch.sendCommand(OFF)
|
|
// Heating_GU100_CL_C7_Switch.sendCommand(OFF)
|
|
// Heating_GU100_CL_C8_Switch.sendCommand(OFF)
|
|
// Heating_GU100_CL_C9_Switch.sendCommand(OFF)
|
|
// end
|
|
|
|
rule "Spegnimento Clima OGNI sera 21:00"
|
|
when
|
|
Time cron "0 0 21 * * ?"
|
|
then
|
|
Heating_GU120_CL_C1_Switch.sendCommand(OFF)
|
|
Heating_GU120_CL_C2_Switch.sendCommand(OFF)
|
|
Heating_GU120_CL_C3_Switch.sendCommand(OFF)
|
|
Heating_GU120_CL_C4_Switch.sendCommand(OFF)
|
|
Heating_GU120_CL_C5_Switch.sendCommand(OFF)
|
|
Heating_GU100_CL_C6_Switch.sendCommand(OFF)
|
|
Heating_GU100_CL_C7_Switch.sendCommand(OFF)
|
|
Heating_GU100_CL_C8_Switch.sendCommand(OFF)
|
|
Heating_GU100_CL_C9_Switch.sendCommand(OFF)
|
|
end
|
|
/**********************************************************************/
|
|
|
|
|
|
/**********************************************************************
|
|
* Rules x automazione CLIMA
|
|
**********************************************************************/
|
|
|
|
|
|
// rule "Accensione Riscaldamento mattino ingresso SAM in inverno"
|
|
// when
|
|
// Item gNet_Mobile_Sam changed to ON
|
|
// //and
|
|
// //Time cron "* * * * JAN,FEB,NOV,DEC ?"
|
|
// then
|
|
// // if (CL_Temp.state < 19)
|
|
// // {
|
|
// Heating_GU120_CL_C1_Switch.sendCommand(ON)
|
|
// Heating_GU120_CL_C2_Switch.sendCommand(ON)
|
|
// Heating_GU120_CL_C3_Switch.sendCommand(ON)
|
|
// Heating_GU120_CL_C4_Switch.sendCommand(ON)
|
|
// Heating_GU120_CL_C5_Switch.sendCommand(ON)
|
|
// // }
|
|
// end
|
|
|
|
|
|
/**********************************************************************/
|
|
|
|
|
|
/**********************************************************************
|
|
* Rules x automazione spegnimento aria VMC
|
|
**********************************************************************/
|
|
// rule "Spegnimento serale VMC"
|
|
// when
|
|
// Time cron "0 30 19 * * ?"
|
|
// then
|
|
// SonoffServizi01_VorticeVCM.sendCommand(OFF)
|
|
// SonoffServizi02_VorticeVCM.sendCommand(OFF)
|
|
// end
|
|
|
|
// rule "Accensione mattutina VMC"
|
|
// when
|
|
// Time cron "0 30 8 * * ?"
|
|
// then
|
|
// SonoffServizi01_VorticeVCM.sendCommand(ON)
|
|
// SonoffServizi02_VorticeVCM.sendCommand(ON)
|
|
// end
|
|
|
|
/**********************************************************************/
|
|
|
|
|
|
/**********************************************************************
|
|
* Rules x automazione gestione aria freddo/ventilazione
|
|
**********************************************************************/
|
|
rule "Fine tuning temperatura Ingresso"
|
|
when
|
|
Item Heating_GU120_CL_C1_Temp changed or
|
|
Item Heating_GU120_CL_C1_Set changed
|
|
then
|
|
val offset = 0.15 //House_HeatingOffset.state as Number
|
|
val target = Heating_GU120_CL_C1_Set.state as Number
|
|
val ambient = Heating_GU120_CL_C1_Temp.state as Number
|
|
val currMode = Heating_GU120_CL_C1_Mode.state as Number
|
|
var turnOnTemp = target + offset
|
|
var turnOffTemp = target - offset
|
|
if (ambient >= turnOnTemp) {
|
|
if(currMode != 3)
|
|
{
|
|
Heating_GU120_CL_C1_Mode.sendCommand(3)
|
|
}
|
|
} else if (ambient <= turnOffTemp) {
|
|
if(currMode != 3)
|
|
{
|
|
Heating_GU120_CL_C1_Mode.sendCommand(2)
|
|
}
|
|
}
|
|
end
|
|
|
|
rule "Fine tuning temperatura Corridoio"
|
|
when
|
|
Item Heating_GU120_CL_C2_Temp changed or
|
|
Item Heating_GU120_CL_C2_Set changed
|
|
then
|
|
val offset = 0.15 //House_HeatingOffset.state as Number
|
|
val target = Heating_GU120_CL_C2_Set.state as Number
|
|
val ambient = Heating_GU120_CL_C2_Temp.state as Number
|
|
val currMode = Heating_GU120_CL_C2_Mode.state as Number
|
|
var turnOnTemp = target + offset
|
|
var turnOffTemp = target - offset
|
|
if (ambient >= turnOnTemp) {
|
|
if(currMode != 3)
|
|
{
|
|
Heating_GU120_CL_C2_Mode.sendCommand(3)
|
|
}
|
|
} else if (ambient <= turnOffTemp) {
|
|
if(currMode != 2)
|
|
{
|
|
Heating_GU120_CL_C2_Mode.sendCommand(2)
|
|
}
|
|
}
|
|
end
|
|
|
|
rule "Fine tuning temperatura Finestra"
|
|
when
|
|
Item Heating_GU120_CL_C3_Temp changed or
|
|
Item Heating_GU120_CL_C3_Set changed
|
|
then
|
|
val offset = 0.15 //House_HeatingOffset.state as Number
|
|
val target = Heating_GU120_CL_C3_Set.state as Number
|
|
val ambient = Heating_GU120_CL_C3_Temp.state as Number
|
|
val currMode = Heating_GU120_CL_C3_Mode.state as Number
|
|
var turnOnTemp = target + offset
|
|
var turnOffTemp = target - offset
|
|
if (ambient >= turnOnTemp) {
|
|
if(currMode != 3)
|
|
{
|
|
Heating_GU120_CL_C3_Mode.sendCommand(3)
|
|
}
|
|
} else if (ambient <= turnOffTemp) {
|
|
if(currMode != 2)
|
|
{
|
|
Heating_GU120_CL_C3_Mode.sendCommand(2)
|
|
}
|
|
}
|
|
end
|
|
|
|
rule "Fine tuning temperatura UFF SAM"
|
|
when
|
|
Item Heating_GU120_CL_C4_Temp changed or
|
|
Item Heating_GU120_CL_C4_Set changed
|
|
then
|
|
val offset = 0.15 //House_HeatingOffset.state as Number
|
|
val target = Heating_GU120_CL_C4_Set.state as Number
|
|
val ambient = Heating_GU120_CL_C4_Temp.state as Number
|
|
val currMode = Heating_GU120_CL_C4_Mode.state as Number
|
|
var turnOnTemp = target + offset
|
|
var turnOffTemp = target - offset
|
|
if (ambient >= turnOnTemp) {
|
|
if(currMode != 3)
|
|
{
|
|
Heating_GU120_CL_C4_Mode.sendCommand(3)
|
|
}
|
|
} else if (ambient <= turnOffTemp) {
|
|
if(currMode != 2)
|
|
{
|
|
Heating_GU120_CL_C4_Mode.sendCommand(2)
|
|
}
|
|
}
|
|
end
|
|
|
|
rule "Fine tuning temperatura UFF Emmanuele"
|
|
when
|
|
Item Heating_GU120_CL_C5_Temp changed or
|
|
Item Heating_GU120_CL_C5_Set changed
|
|
then
|
|
val offset = 0.15
|
|
val target = Heating_GU120_CL_C5_Set.state as Number
|
|
val ambient = Heating_GU120_CL_C5_Temp.state as Number
|
|
val currMode = Heating_GU120_CL_C5_Mode.state as Number
|
|
var turnOnTemp = target + offset
|
|
var turnOffTemp = target - offset
|
|
if (ambient >= turnOnTemp) {
|
|
if(currMode != 3)
|
|
{
|
|
Heating_GU120_CL_C5_Mode.sendCommand(3)
|
|
}
|
|
} else if (ambient <= turnOffTemp) {
|
|
if(currMode != 2)
|
|
{
|
|
Heating_GU120_CL_C5_Mode.sendCommand(2)
|
|
}
|
|
}
|
|
end
|
|
|
|
rule "Fine tuning temperatura Desk"
|
|
when
|
|
Item Heating_GU100_CL_C6_Temp changed or
|
|
Item Heating_GU100_CL_C6_Set changed
|
|
then
|
|
val offset = 0.15
|
|
val target = Heating_GU100_CL_C6_Set.state as Number
|
|
val ambient = Heating_GU100_CL_C6_Temp.state as Number
|
|
val currMode = Heating_GU100_CL_C6_Mode.state as Number
|
|
var turnOnTemp = target + offset
|
|
var turnOffTemp = target - offset
|
|
if (ambient >= turnOnTemp) {
|
|
if(currMode != 3)
|
|
{
|
|
Heating_GU100_CL_C6_Mode.sendCommand(3)
|
|
}
|
|
} else if (ambient <= turnOffTemp) {
|
|
if(currMode != 2)
|
|
{
|
|
Heating_GU100_CL_C6_Mode.sendCommand(2)
|
|
}
|
|
}
|
|
end
|
|
|
|
rule "Fine tuning temperatura OpenSpace"
|
|
when
|
|
Item Heating_GU100_CL_C7_Temp changed or
|
|
Item Heating_GU100_CL_C7_Set changed
|
|
then
|
|
val offset = 0.15
|
|
val target = Heating_GU100_CL_C7_Set.state as Number
|
|
val ambient = Heating_GU100_CL_C7_Temp.state as Number
|
|
val currMode = Heating_GU100_CL_C7_Mode.state as Number
|
|
var turnOnTemp = target + offset
|
|
var turnOffTemp = target - offset
|
|
if (ambient >= turnOnTemp) {
|
|
if(currMode != 3)
|
|
{
|
|
Heating_GU100_CL_C7_Mode.sendCommand(3)
|
|
}
|
|
} else if (ambient <= turnOffTemp) {
|
|
if(currMode != 2)
|
|
{
|
|
Heating_GU100_CL_C7_Mode.sendCommand(2)
|
|
}
|
|
}
|
|
end
|
|
|
|
|
|
rule "Fine tuning temperatura Uff Dario"
|
|
when
|
|
Item Heating_GU100_CL_C8_Temp changed or
|
|
Item Heating_GU100_CL_C8_Set changed
|
|
then
|
|
val offset = 0.15
|
|
val target = Heating_GU100_CL_C8_Set.state as Number
|
|
val ambient = Heating_GU100_CL_C8_Temp.state as Number
|
|
val currMode = Heating_GU100_CL_C8_Mode.state as Number
|
|
var turnOnTemp = target + offset
|
|
var turnOffTemp = target - offset
|
|
if (ambient >= turnOnTemp) {
|
|
if(currMode != 3)
|
|
{
|
|
Heating_GU100_CL_C8_Mode.sendCommand(3)
|
|
}
|
|
} else if (ambient <= turnOffTemp) {
|
|
if(currMode != 2)
|
|
{
|
|
Heating_GU100_CL_C8_Mode.sendCommand(2)
|
|
}
|
|
}
|
|
end
|
|
|
|
|
|
rule "Fine tuning temperatura Sala Riunioni"
|
|
when
|
|
Item Heating_GU100_CL_C9_Temp changed or
|
|
Item Heating_GU100_CL_C9_Set changed
|
|
then
|
|
val offset = 0.15
|
|
val target = Heating_GU100_CL_C9_Set.state as Number
|
|
val ambient = Heating_GU100_CL_C9_Temp.state as Number
|
|
val currMode = Heating_GU100_CL_C9_Mode.state as Number
|
|
var turnOnTemp = target + offset
|
|
var turnOffTemp = target - offset
|
|
if (ambient >= turnOnTemp) {
|
|
if(currMode != 3)
|
|
{
|
|
Heating_GU100_CL_C9_Mode.sendCommand(3)
|
|
}
|
|
} else if (ambient <= turnOffTemp) {
|
|
if(currMode != 2)
|
|
{
|
|
Heating_GU100_CL_C9_Mode.sendCommand(2)
|
|
}
|
|
}
|
|
end
|
|
|
|
// rule "Accensione mattutina VMC"
|
|
// when
|
|
// Time cron "0 30 8 * * ?"
|
|
// then
|
|
// SonoffServizi01_VorticeVCM.sendCommand(ON)
|
|
// SonoffServizi02_VorticeVCM.sendCommand(ON)
|
|
// end
|
|
|
|
/**********************************************************************/
|
|
|
|
|
|
/**********************************************************************
|
|
* Rules x automazione LUCERNARI
|
|
**********************************************************************/
|
|
rule "Lucernari switch Momentary x 10 sec"
|
|
when
|
|
Item SonoffLucernari_Open received command ON
|
|
then
|
|
SonoffLucernari_Close.sendCommand(OFF)
|
|
createTimer(now.plusSeconds(12), [|
|
|
SonoffLucernari_Open.sendCommand(OFF)
|
|
])
|
|
createTimer(now.plusSeconds(13), [|
|
|
SonoffLucernari_Open.sendCommand(OFF)
|
|
])
|
|
end
|
|
|
|
rule "Lucernari switch Momentary x 10 sec"
|
|
when
|
|
Item SonoffLucernari_Close received command ON
|
|
then
|
|
SonoffLucernari_Open.sendCommand(OFF)
|
|
createTimer(now.plusSeconds(12), [|
|
|
SonoffLucernari_Close.sendCommand(OFF)
|
|
])
|
|
createTimer(now.plusSeconds(13), [|
|
|
SonoffLucernari_Close.sendCommand(OFF)
|
|
])
|
|
end
|
|
|
|
/**********************************************************************/
|
|
|
|
|
|
|
|
/**********************************************************************
|
|
* Rules x automazione LUCI
|
|
**********************************************************************/
|
|
rule "Luce con switch Momentary"
|
|
when
|
|
Item SonoffLuci01_Switch1 received command ON
|
|
then
|
|
createTimer(now.plusSeconds(1), [|
|
|
SonoffLuci01_Switch1.sendCommand(OFF)
|
|
])
|
|
createTimer(now.plusSeconds(2), [|
|
|
SonoffLuci01_Switch1.sendCommand(OFF)
|
|
])
|
|
end
|
|
|
|
|
|
rule "Luce con switch Momentary"
|
|
when
|
|
Item SonoffLuci01_Switch2 received command ON
|
|
then
|
|
createTimer(now.plusSeconds(1), [|
|
|
SonoffLuci01_Switch2.sendCommand(OFF)
|
|
])
|
|
createTimer(now.plusSeconds(2), [|
|
|
SonoffLuci01_Switch2.sendCommand(OFF)
|
|
])
|
|
end
|
|
|
|
rule "Luce con switch Momentary"
|
|
when
|
|
Item SonoffLuci01_Switch3 received command ON
|
|
then
|
|
createTimer(now.plusSeconds(1), [|
|
|
SonoffLuci01_Switch3.sendCommand(OFF)
|
|
])
|
|
createTimer(now.plusSeconds(2), [|
|
|
SonoffLuci01_Switch3.sendCommand(OFF)
|
|
])
|
|
end
|
|
|
|
rule "Luce con switch Momentary"
|
|
when
|
|
Item SonoffLuci02_Switch1 received command ON
|
|
then
|
|
createTimer(now.plusSeconds(1), [|
|
|
SonoffLuci02_Switch1.sendCommand(OFF)
|
|
])
|
|
createTimer(now.plusSeconds(2), [|
|
|
SonoffLuci02_Switch1.sendCommand(OFF)
|
|
])
|
|
end
|
|
|
|
|
|
rule "Luce con switch Momentary"
|
|
when
|
|
Item SonoffLuci02_Switch2 received command ON
|
|
then
|
|
createTimer(now.plusSeconds(1), [|
|
|
SonoffLuci02_Switch2.sendCommand(OFF)
|
|
])
|
|
createTimer(now.plusSeconds(2), [|
|
|
SonoffLuci02_Switch2.sendCommand(OFF)
|
|
])
|
|
end
|
|
|
|
rule "Luce con switch Momentary"
|
|
when
|
|
Item SonoffLuci02_Switch3 received command ON
|
|
then
|
|
createTimer(now.plusSeconds(1), [|
|
|
SonoffLuci02_Switch3.sendCommand(OFF)
|
|
])
|
|
createTimer(now.plusSeconds(2), [|
|
|
SonoffLuci02_Switch3.sendCommand(OFF)
|
|
])
|
|
end
|
|
|
|
rule "Luce con switch Momentary"
|
|
when
|
|
Item SonoffLuci02_Switch4 received command ON
|
|
then
|
|
createTimer(now.plusSeconds(1), [|
|
|
SonoffLuci02_Switch4.sendCommand(OFF)
|
|
])
|
|
createTimer(now.plusSeconds(2), [|
|
|
SonoffLuci02_Switch4.sendCommand(OFF)
|
|
])
|
|
end
|
|
|
|
rule "Luce con switch Momentary"
|
|
when
|
|
Item SonoffLuci03_Switch1 received command ON
|
|
then
|
|
createTimer(now.plusSeconds(1), [|
|
|
SonoffLuci03_Switch1.sendCommand(OFF)
|
|
])
|
|
createTimer(now.plusSeconds(2), [|
|
|
SonoffLuci03_Switch1.sendCommand(OFF)
|
|
])
|
|
end
|
|
|
|
rule "Luce con switch Momentary"
|
|
when
|
|
Item SonoffLuci03_Switch2 received command ON
|
|
then
|
|
createTimer(now.plusSeconds(1), [|
|
|
SonoffLuci03_Switch2.sendCommand(OFF)
|
|
])
|
|
createTimer(now.plusSeconds(2), [|
|
|
SonoffLuci03_Switch2.sendCommand(OFF)
|
|
])
|
|
end
|
|
|
|
rule "Luce con switch Momentary"
|
|
when
|
|
Item SonoffLuci03_Switch3 received command ON
|
|
then
|
|
createTimer(now.plusSeconds(1), [|
|
|
SonoffLuci03_Switch3.sendCommand(OFF)
|
|
])
|
|
createTimer(now.plusSeconds(2), [|
|
|
SonoffLuci03_Switch3.sendCommand(OFF)
|
|
])
|
|
end
|
|
|
|
rule "Luce con switch Momentary"
|
|
when
|
|
Item SonoffLuci03_Switch4 received command ON
|
|
then
|
|
createTimer(now.plusSeconds(1), [|
|
|
SonoffLuci03_Switch4.sendCommand(OFF)
|
|
])
|
|
createTimer(now.plusSeconds(2), [|
|
|
SonoffLuci03_Switch4.sendCommand(OFF)
|
|
])
|
|
end
|
|
|
|
rule "Luce con switch Momentary"
|
|
when
|
|
Item SonoffServizi02_Switch5 received command ON
|
|
then
|
|
createTimer(now.plusSeconds(1), [|
|
|
SonoffServizi02_Switch5.sendCommand(OFF)
|
|
])
|
|
createTimer(now.plusSeconds(2), [|
|
|
SonoffServizi02_Switch5.sendCommand(OFF)
|
|
])
|
|
end
|
|
|
|
/**********************************************************************/
|
|
|
|
// rule "Test cron Riscaldamento ufficio"
|
|
// when
|
|
// Time cron "0 * 15 * JAN,FEB,NOV,DEC THU"
|
|
// then
|
|
// Heating_GU120_CL_C4_Switch.sendCommand(ON)
|
|
// end
|
|
|
|
|
|
|
|
// /**
|
|
// * This is a demo rule which simulates a real dimmer by reacting to increase/decrease commands
|
|
// * and posting an updated state on the bus
|
|
// */
|
|
// rule "Dimmed Light"
|
|
// when
|
|
// Item DimmedLight received command
|
|
// then
|
|
// if ((receivedCommand == INCREASE) || (receivedCommand == DECREASE)) {
|
|
// var Number percent = 0
|
|
// if (DimmedLight.state instanceof DecimalType) percent = DimmedLight.state as DecimalType
|
|
|
|
// if (receivedCommand == INCREASE) percent = percent + 5
|
|
// if (receivedCommand == DECREASE) percent = percent - 5
|
|
|
|
// if (percent < 0) percent = 0
|
|
// if (percent > 100) percent = 100
|
|
// postUpdate(DimmedLight, percent);
|
|
// }
|
|
// end
|
|
|
|
// rule "Timer Demo"
|
|
// when
|
|
// Item Light_GF_Corridor_Ceiling received command
|
|
// then
|
|
// if (receivedCommand == ON) {
|
|
// if (timer === null) {
|
|
// // first ON command, so create a timer to turn the light off again
|
|
// timer = createTimer(now.plusSeconds(10)) [|
|
|
// sendCommand(Light_GF_Corridor_Ceiling, OFF)
|
|
// ]
|
|
// } else {
|
|
// // subsequent ON command, so reschedule the existing timer
|
|
// timer.reschedule(now.plusSeconds(10))
|
|
// }
|
|
// } else if (receivedCommand == OFF) {
|
|
// // remove any previously scheduled timer
|
|
// if (timer !== null) {
|
|
// timer.cancel
|
|
// timer = null
|
|
// }
|
|
// }
|
|
// end
|
|
|
|
/**
|
|
* The following rules help initializing the demo items with some helpful states.
|
|
*/
|
|
// rule "Initialize light states"
|
|
// when
|
|
// System started
|
|
// then
|
|
// Lights?.members.forEach(light|
|
|
// postUpdate(light, if (Math::random > 0.7) ON else OFF)
|
|
// )
|
|
// end
|
|
|
|
// rule "Initialize heating states"
|
|
// when
|
|
// System started
|
|
// then
|
|
// Heating?.members.forEach(heating|
|
|
// postUpdate(heating, if (Math::random > 0.8) ON else OFF)
|
|
// )
|
|
// postUpdate(Temperature_Setpoint, 22)
|
|
// end
|
|
|
|
// rule "Initialize contact states"
|
|
// when
|
|
// System started
|
|
// then
|
|
// Windows?.members.forEach(window|
|
|
// postUpdate(window, if (Math::random > 0.5) OPEN else CLOSED)
|
|
// )
|
|
// end
|
|
|
|
// rule "Initialize Location"
|
|
// when
|
|
// System started
|
|
// then
|
|
// DemoLocation.postUpdate(new PointType("52.5200066,13.4049540"))
|
|
// end
|
|
|
|
// rule "Set random room temperatures"
|
|
// when
|
|
// System started or
|
|
// Time cron "0 0/5 * * * ?"
|
|
// then
|
|
// Temperature?.members.forEach(temperature|
|
|
// postUpdate(temperature, 20.0 + (25.0 - (Math::random * 50.0).intValue) / 10.0)
|
|
// )
|
|
// end
|
|
|
|
// rule "Set daily max and min temperature"
|
|
// when
|
|
// Item Weather_Temperature changed or
|
|
// Time cron "0 0 0 * * ?" or
|
|
// System started
|
|
// then
|
|
// val max = Weather_Temperature.maximumSince(now.withTimeAtStartOfDay)
|
|
// val min = Weather_Temperature.minimumSince(now.withTimeAtStartOfDay)
|
|
// if (max !== null && min !== null) {
|
|
// postUpdate(Weather_Temp_Max, max.state)
|
|
// postUpdate(Weather_Temp_Min, min.state)
|
|
// }
|
|
// end
|
|
|
|
// // Creates an item that stores the last update time of this item
|
|
// rule "Records last weather update time"
|
|
// when
|
|
// Item Weather_Temperature received update
|
|
// then
|
|
// postUpdate(Weather_LastUpdate, new DateTimeType())
|
|
// end
|
|
|
|
// rule "Set random wifi variations"
|
|
// when
|
|
// System started or
|
|
// Time cron "/20 * * * * ?"
|
|
// then
|
|
// postUpdate(Wifi_Level, (Math::random * 4.0).intValue)
|
|
// end
|
|
|
|
// rule "Set random image URLs"
|
|
// when
|
|
// Time cron "/10 * * * * ?"
|
|
// then
|
|
// val url = urlList.get(random.nextInt(urlList.length))
|
|
// val res = resList.get(random.nextInt(resList.length))
|
|
|
|
// postUpdate(ImageURL, url + "/" + res)
|
|
// end
|
|
|
|
// rule "Volume"
|
|
// when
|
|
// Item Volume received command
|
|
// then
|
|
// if (receivedCommand instanceof PercentType) {
|
|
// setMasterVolume(receivedCommand)
|
|
// } else {
|
|
// if (receivedCommand == INCREASE) increaseMasterVolume(20)
|
|
// if (receivedCommand == DECREASE) decreaseMasterVolume(20)
|
|
// }
|
|
// end
|
|
|
|
// rule "Select Radio Station"
|
|
// when
|
|
// Item Radio_Station received command
|
|
// then
|
|
// switch(receivedCommand) {
|
|
// case 0 : playStream(null)
|
|
// case 1 : playStream("http://metafiles.gl-systemhaus.de/hr/hr3_2.m3u")
|
|
// case 2 : playStream("http://mp3-live.swr3.de/swr3_m.m3u")
|
|
// }
|
|
// end
|
|
|
|
// vim: syntax=Xtend
|