There is no thing, these are rules:
var lastAlert = now.minusMinutes(5) // set to five minutes ago so the Rule can run when OH first starts
var Number LoadingFor = 0
var Number NotLoadingFor = 0
var Number SwitchOffTries = 0
var Number SwitchOnTries = 0
rule “HeatUpManually”
when
Item BALBOA_MANUAL changed to ON or
Item Persistent_BALBOA_OPERATIONMODE received command or
Item Persistent_HOTTUB_MANUAL_TEMP changed
then
if (Persistent_BALBOA_OPERATIONMODE.state == ‘MANUAL’)
{
return;
}
logInfo("-18-balboa.R3", "Manual Heating On Received: " + Persistent_BALBOA_OPERATIONMODE.state)
if ((Persistent_BALBOA_OPERATIONMODE.state == “AUTO”) && (Persistent_BALBOA_OPERATIONMODE.state == “ON”))
{
logInfo("-18-balboa.R3", "Manual Heating On Received")
if (BALBOA_TEMP_RANGE.state == "Low")
{
executeCommandLine("/usr/bin/python3 /etc/openhab2/scripts/balboa.py temprange")
}
if (BALBOA_SET_TEMP.state < 38.5)
{
executeCommandLine("/usr/bin/python3 /etc/openhab2/scripts/balboa.py settemp " + Persistent_HOTTUB_MANUAL_TEMP.state)
}
}
end
rule “SwitchOffTubOverNight”
when
//Every weekday at 14:00 hours
Time cron “0 0 22 ? * * *” or
Item Persistent_BALBOA_OPERATIONMODE changed
then
if((Persistent_BALBOA_OPERATIONMODE.state == ‘AUTO’) || (Persistent_BALBOA_OPERATIONMODE.state == ‘OFF’) || (Persistent_BALBOA_OPERATIONMODE.state == ‘MANUAL’))
{
if (BALBOA_MANUAL.state == ON)
{
BALBOA_MANUAL.postUpdate(OFF)
}
}
if((Persistent_BALBOA_OPERATIONMODE.state == ‘AUTO’) || (Persistent_BALBOA_OPERATIONMODE.state == ‘OFF’)) {
executeCommandLine("/usr/bin/python3 /etc/openhab2/scripts/balboa.py settemp 30");
}
else
{
executeCommandLine("/usr/bin/python3 /etc/openhab2/scripts/balboa.py settemp " + (Persistent_HOTTUB_MANUAL_TEMP.state));
}
end
rule “HeatUpWhenEnoughPower”
when
//Every weekday at 14:00 hours
Time cron “*/30 * 09-15 ? * * *”
//Item KebaPower changed or
//Item PV_Meter changed
then
if ((Persistent_BALBOA_OPERATIONMODE.state == ‘AUTO’) || (Persistent_BALBOA_OPERATIONMODE.state == ‘ON’) || (Persistent_BALBOA_OPERATIONMODE.state == ‘MANUAL’))
{
var Number Available = -(PV_Meter.state as DecimalType)
logInfo("-18-balboa.R3", "Available: " + Available.toString() )
if (((Available > 2000) && (KebaPlugLocked.state == OFF)) || (Available > 3000))
{
SwitchOnTries += 1;
SwitchOffTries = 0;
logInfo("-18-balboa.R3", "SwitchOn: " + SwitchOnTries);
}
if (((Available < -1500) && (KebaPlugLocked.state == OFF)) || (Available < -1000))
{
if (BALBOA_MANUAL.state == ON) // No need to care if ON anyway
{
executeCommandLine("/usr/bin/python3 /etc/openhab2/scripts/balboa.py settemp " + (Persistent_HOTTUB_MANUAL_TEMP.state));
logInfo("-18-balboa.R3", "SetTemp: " + (Persistent_HOTTUB_MANUAL_TEMP.state))
}
else
{
SwitchOffTries += 1;
SwitchOnTries = 0;
logInfo("-18-balboa.R3", "SwitchOff: " + SwitchOffTries);
}
}
if (SwitchOnTries >= 5) {
if (BALBOA_SET_TEMP.state < 40)
{
executeCommandLine("/usr/bin/python3 /etc/openhab2/scripts/balboa.py settemp 40")
logInfo("-18-balboa.R3", "HeatUp: 40")
}
}
if (SwitchOffTries >= 5) {
if (BALBOA_MANUAL.state == ON) // No need to care if ON anyway
{
if (BALBOA_SET_TEMP.state > 38)
{
executeCommandLine("/usr/bin/python3 /etc/openhab2/scripts/balboa.py settemp 38");
logInfo("-18-balboa.R3", "SetTemp: 38")
}
}
else
{
if (Persistent_BALBOA_OPERATIONMODE.state == 'MANUAL')
{
if (BALBOA_SET_TEMP.state > (Persistent_HOTTUB_MANUAL_TEMP.state)) {
executeCommandLine("/usr/bin/python3 /etc/openhab2/scripts/balboa.py settemp " + (Persistent_HOTTUB_MANUAL_TEMP.state));
logInfo("-18-balboa.R3", "SetTemp: " + (Persistent_HOTTUB_MANUAL_TEMP.state));
}
}
else
{
if (BALBOA_SET_TEMP.state > 30) {
executeCommandLine("/usr/bin/python3 /etc/openhab2/scripts/balboa.py settemp 30");
logInfo("-18-balboa.R3", "SetTemp: 30")
}
}
}
}
}
// update item to switch on light here
end
rule “NormalizeTemperature”
when
//Every weekday at 14:00 hours
Time cron “0 10 15-17 ? * * *”
//Item KebaPower changed or
//Item PV_Meter changed
then
if (Persistent_BALBOA_OPERATIONMODE.state == ‘MANUAL’)
return;
if ((Persistent_BALBOA_OPERATIONMODE.state == ‘AUTO’) || (Persistent_BALBOA_OPERATIONMODE.state == ‘ON’))
{
if (BALBOA_SET_TEMP.state > 38)
{
executeCommandLine("/usr/bin/python3 /etc/openhab2/scripts/balboa.py settemp 37.5")
logInfo("-18-balboa.R3", "HeatUp: 37.5")
}
}
// update item to switch on light here
end
rule “Hot Tub: Parsing (SPARaw) JSON output to individual Items”
when
Item SPARaw changed
then
{
logInfo("-18-balboa.R2", “### Hot Tub: Parsing (SPARaw) JSON output to individual Items ###”)
val String json = (SPARaw.state as StringType).toString
gHotTub_Parse_json.members.forEach [ value |
var String name = value.name.replace('BALBOA_','$.')
var String type = value.type
if (type == "Switch")
{
var String newValue = transform("JSONPATH", name, json).replaceAll('"','')
if (newValue != "Off")
{
value.postUpdate(ON)
}
else
{
value.postUpdate(OFF)
//value.postUpdate(transform("JSONPATH", name, json).replaceAll('"',''))
}
}
else
{
value.postUpdate(transform("JSONPATH", name, json).replaceAll('"',''))
}
//logInfo("-18-balboa.R3", " " )
]
SPARaw_LastChanged.postUpdate( new DateTimeType() )
}
end
rule ToggleLights
when
Item BALBOA_LIGHTS received command
then
executeCommandLine("/usr/bin/python3 /etc/openhab2/scripts/balboa.py lights")
end
rule TogglePump1
when
Item BALBOA_PUMP1 received command
then
executeCommandLine("/usr/bin/python3 /etc/openhab2/scripts/balboa.py pump1")
end
rule TogglePump2
when
Item BALBOA_PUMP2 received command
then
executeCommandLine("/usr/bin/python3 /etc/openhab2/scripts/balboa.py pump2")
end
rule TogglePump3
when
Item BALBOA_PUMP3 received command
then
executeCommandLine("/usr/bin/python3 /etc/openhab2/scripts/balboa.py pump3")
end
rule SetTargetTemp
when
Item BALBOA_SET_TEMP received command
then
var String commandline = "/usr/bin/python3 /etc/openhab2/scripts/balboa.py settemp " + (BALBOA_SET_TEMP.state)
executeCommandLine(commandline)
logInfo("-18-balboa.R3", "Set target temp: " + commandline)
end
rule ToggleTempRange
when
Item BALBOA_TEMP_RANGE received command
then
executeCommandLine("/usr/bin/python3 /etc/openhab2/scripts/balboa.py temprange")
end
rule ToggleHeatingMode
when
Item BALBOA_HEATING_MODE received command
then
executeCommandLine("/usr/bin/python3 /etc/openhab2/scripts/balboa.py heatingmode")
end