Balboa Binding

@binderth here’s my 3 rules
the first one is triggered every time the solar pv being generated change and also how much load the house is drawing changes. if there is more than 3kw of power being sent from the house to the grid it turns the hot water cylinder on and if there is more than 5kw of power being generated then it turns the spa temp up to 40c. when the house is pulling more than 1kw from the grid it turns the hot water cylinder off and lowers the temp of the spa to 30c

rule "Auto Solar Power Usage"

when
	Item Inverter_Generation_Combined changed or
	Item Inverter_1_Grid changed
	then
	createTimer(now.plusSeconds(2), [ |
		if		(Inverter_1_Grid.state < -3000 && Hot_water_Element_2.state !== OFF)

				{
					Hot_water_Element_2.sendCommand(OFF)
					Hot_water_Element_1.sendCommand(OFF)
				}
		if		(Inverter_1_Grid.state < -5000 && Spa_Target_Temp.state !== "40")
				{
				Spa_Target_Temp.sendCommand(40)
				}
		if		(Inverter_1_Grid.state > 1000)
				{
				Hot_water_Element_2.sendCommand(ON)
				Hot_water_Element_1.sendCommand(ON)
				}
		if		(Inverter_1_Grid.state > 1000 && Force_Spa_Heat.state !== ON && Spa_Target_Temp.state !== "33")
				{
				Spa_Target_Temp.sendCommand(30.0)
				}
    ])   
end

my next rule openhab monitors the in built spa lights and when they are switched on the spa controller touchscreen twice in 10 seconds it turns all the lights off inside the house, sets the backyard lights brightness and colour and turns the outdoor speakers to Spotify and sets the volume

rule "Spa Lights turn on and off 3 times within 10 seconds then turn all house lights Off"

when
	Item Spa_Lights changed
then
        SpaLightsCounter = SpaLightsCounter +1
	Thread::sleep(100)
	if	( SpaLightsCounter == 2 ) {
		 GHouseLights.sendCommand(OFF)
		}
	if	( SpaLightsCounter == 2 ) {
		 HueBackYardSpotColour.sendCommand("0,100,100")
		 GSpaLights.sendCommand("0,100,30")
		 HueBackYardBollardColour.sendCommand("287,100,100")
		MusicCast_Power.sendCommand(ON)
		MusicCast_Backyard_Power.sendCommand(ON)
		Thread::sleep(300)
		MusicCast_Input.sendCommand("spotify")
		sendCommand(MusicCast_Backyard_Server, "192.168.178.149***main")
		Thread::sleep(300)
		MusicCast_Player.sendCommand("PLAY")
		Thread::sleep(300)
		sendCommand(MusicCast_Backyard_Volume, 40)
		sendCommand(MusicCast_Volume, 0)
		MusicCast_Player.sendCommand("PLAY")
		}
		createTimer(now.plusSeconds(10), [|	        
	        SpaLightsCounter = SpaLightsCounter -1
        		])

and my last rule, if there is music playing outside and one of the 3 jet pumps turn on the music volume will be increased so that the apparent volume is the same and when all of the jet pumps have been turned off it will reduce the volume again.

rule "Spa Volume while pumps are on and off"
when
	Item Spa_Pump_1 changed or
	Item Spa_Pump_2 changed or
	Item Spa_Pump_3 changed
then
		Thread::sleep(100)
if		(Spa_Pump_1.state == OFF && Spa_Pump_2.state == OFF && Spa_Pump_3.state == OFF && MusicCast_Backyard_Power.state == ON && SpaVolumeCounter == 1)
		{
			logInfo("Spa Volume while pumps are on and off", "Pumps turned off so lowering the volume")
        	VSpaVolume = MusicCast_Backyard_Volume_ABS.state as Number - 15
		    SpaVolumeCounter = 0
			sendCommand(MusicCast_Backyard_Volume_ABS, VSpaVolume)
		}
if		(Spa_Pump_1.state == ON && Spa_Pump_2.state == OFF && Spa_Pump_3.state == OFF && MusicCast_Backyard_Power.state == ON && SpaVolumeCounter == 0)
		{
			logInfo("Spa Volume while pumps are on and off", "Pump/s turned on so increasing the volume")
        	VSpaVolume = MusicCast_Backyard_Volume_ABS.state as Number + 15
		    SpaVolumeCounter = 1
			sendCommand(MusicCast_Backyard_Volume_ABS, VSpaVolume)
		}
if		(Spa_Pump_1.state == OFF && Spa_Pump_2.state == ON && Spa_Pump_3.state == OFF && MusicCast_Backyard_Power.state == ON && SpaVolumeCounter == 0)
		{
			logInfo("Spa Volume while pumps are on and off", "Pump/s turned on so increasing the volume")
        	VSpaVolume = MusicCast_Backyard_Volume_ABS.state as Number + 15
		    SpaVolumeCounter = 1
			sendCommand(MusicCast_Backyard_Volume_ABS, VSpaVolume)
		}
if		(Spa_Pump_1.state == OFF && Spa_Pump_2.state == OFF && Spa_Pump_3.state == ON && MusicCast_Backyard_Power.state == ON && SpaVolumeCounter == 0)
		{
			logInfo("Spa Volume while pumps are on and off", "Pump/s turned on so increasing the volume")
        	VSpaVolume = MusicCast_Backyard_Volume_ABS.state as Number + 15
		    SpaVolumeCounter = 1
			sendCommand(MusicCast_Backyard_Volume_ABS, VSpaVolume)
		}
end

so my issue where the Balboa thing keeps loosing a connection/freazing is a right pain because then the rules stop working.