Jalousie (venetian blinds) control even without positioning information

Tags: #<Tag:0x00007f616fc98128> #<Tag:0x00007f616fc98060> #<Tag:0x00007f616fceff40>

Hi community

This is an approach to control jalousie (venetian blinds, Verbundraffstoren, Lamellenstoren) when your controller can not read the position of the jalousie and its slats. This is unfortunately the case with my KNX controller I have in place.

Requirements:

  • I use my jalousie mostly covering the whole window (jalousie entirely down). But I need to adjust the position of the slats in order to control the brightness in the room.
  • I want to control them manually but need also to have the basis for a complete automated shading of the house according the sun position and intensity (LUX).
  • Manual individual jalousie control (Up/Down/Stop)

Approach:
For every jalousie I defined 3 items:

  1. The rollershutter item for manual individual jalousie control (out of the box)
  2. Shading (Beschattung) switch. If this is set to ON then the jalousie gets down entirely and the slats will be adjusted according to
  3. the Dimmer. The dimmer controls the brightness in the room. Eg. 50% means the slats are in a 45° position.

Solution
For every jalousie 3 items are defined:

Rollershutter J_Wohnen_5                "Süd [%d %%]"               <blinds>        (Wohnen)        {channel="knx:device:bridge:generic:J_Wohnen_5"}
Switch JS_Wohnen_5                      "Süd Beschattung [%s]"      <blinds>        (Wohnen,gShade) //JS=Jalousie Shading
Dimmer JD_Wohnen_5                      "Süd Dimmen [%d %%]"        <light>         (Wohnen,gJDimm) //JD=Jalousie Dimming

They always start with J_, JS_ and JD_

In the rules the following variables are defined:

//Variables/////////////////////////////////////
var vJalousieDownTimeNeed = 62000   //Max Time needed for every jalousie to go completly down ideal 62'000ms
var vSlats90 = 2000     //Max time [ms] needed for slats going from  horizontal (0°) to vertical (90°) Ideal=2000ms
var vSlats0  = 1600	  //Max time [ms] needed for slats going from  vertical (90°) to horizontal (0°) from the time the strings are tightened Ideal=1600ms 
var vSlatStringsTighten = 1000	// Time from slats are vertical until the strings are tightended and slats start to move Ideal=1000ms
////////////////////////////////////////////////

As there are no position information available the control is entirely time based. These variables define the different times. Their values need to be experimental adjusted to your configuration.

The following rules implement the logic:

// Activates the shading of a Jalousie when a corresponding shading switch is set to ON
rule "gShade Activate Shading"
when 
  Member of gShade changed from OFF to ON					//When any shading switch changed to ON
  then
   	var String vShadeSwitchName = triggeringItem.name		//Name of Beschattungs Switch, witch triggered the event - Beschattungs Switch Names Start with "JB_"= JalousieBeschattung
	if (!vShadeSwitchName.startsWith("JS_")) {				//Check if triggering item is name is in correct format and therefore the correct function can be assumed
		logError("org.openhab", "Event triggerItem " + vShadeSwitchName + " does not start with 'JS_', therefore the corresponding items can not be found - rule terminated")
		return
		}	
	var String vShadeDimmerName = vShadeSwitchName.replaceFirst("JS_","JD_")     //Name of the corresponding jalousie slats dimmer - These names start with "JD_" = Jalousie dimming
	var vShadeDimmerItem = ScriptServiceUtil.getItemRegistry.getItem(vShadeDimmerName)
	
	var String vShadeName = vShadeSwitchName.replaceFirst("JS_","J_") 			//Name of the corresponding jalousie - These names start with "J_" = Jalousie
	var vShadeItem = ScriptServiceUtil.getItemRegistry.getItem(vShadeName)
	
	vShadeItem.sendCommand(DOWN)
	var myDownTimer = createTimer(now.plusMillis(vJalousieDownTimeNeed), [ |	vShadeItem.sendCommand(UP)  ])

	var float vShadeDimValue = (vShadeDimmerItem.state as Number).floatValue
	if (!(vShadeDimValue>=0.0 && vShadeDimValue<=100.0)) 
	    {logError("org.openhab", "Shade dimmer item "+ vShadeDimmerItem + "value is not between 0..100. Therefore using for calculation = 50")
		 vShadeDimValue=50
		}
	var vSlatsTime = (vSlats0 * (vShadeDimValue / 100f)).intValue
	var mySlatsTimer = createTimer(now.plusMillis(vJalousieDownTimeNeed+vSlatStringsTighten+vSlatsTime), [ |	
					vShadeItem.sendCommand(STOP)
					vShadeItem.postUpdate(100)
			        ])
end
////////////////////////////////////////////////////////////////////////////////////////////////



//DeActivates the shading of a Jalousie when a corresponding shading switch is set to OFF//////////
rule "gShade Deactivate Shading"
when 
  Member of gShade changed from ON to OFF				//When any shading switch changed to OFF
  then
   	var String vShadeSwitchName = triggeringItem.name		//Name of Beschattungs Switch, witch triggered the event - Beschattungs Switch Names Start with "JB_"= JalousieBeschattung
	if (!vShadeSwitchName.startsWith("JS_")) {				//Check if triggering item is name is in correct format and therefore the correct function can be assumed
		logError("org.openhab", "Event triggerItem " + vShadeSwitchName + " does not start with 'JS_', therefore the corresponding items can not be found - rule terminated")
		return
		}	
	
	var String vShadeName = vShadeSwitchName.replaceFirst("JS_","J_") 			//Name of the corresponding jalousie - These names start with "J_" = Jalousie
	var vShadeItem = ScriptServiceUtil.getItemRegistry.getItem(vShadeName)
	vShadeItem.sendCommand(UP)

end
////////////////////////////////////////////////////////////////////////////////////////////////


//Jalousie dimming - Adjusts the slats of a jalousie when a corresponding  jalousie dimmer is changed
rule "Adjust slats when jalousie dimmer changed"
when 
  Member of gJDimm changed				//When any Jalousie dimmer changed
then
	var vShadeDimmerItem = triggeringItem
	var vShadeDimmerName  = vShadeDimmerItem.name
	if (!vShadeDimmerName.startsWith("JD_")) {				//Check if triggering item is name is in correct format and therefore the correct function can be assumed
		logError("org.openhab", "Event triggerItem " + vShadeDimmerName + " does not start with 'JD_', therefore the corresponding items can not be found - rule terminated")
		return
		}	

	var String vShadeName = vShadeDimmerName.replaceFirst("JD_","J_") 			//Name of the corresponding jalousie - These names start with "J_" = Jalousie
	var vShadeItem = ScriptServiceUtil.getItemRegistry.getItem(vShadeName)

	var float vShadeDimValue = (vShadeDimmerItem.state as Number).floatValue
	if (!(vShadeDimValue>=0.0 && vShadeDimValue<=100.0)) 
	    {logError("org.openhab", "Shade dimmer item "+ vShadeDimmerItem + "value is not between 0..100. Therefore using for calculation = 50")
		 vShadeDimValue=50
		}
	var vSlatsTime = (vSlats0 * (vShadeDimValue / 100f)).intValue

	vShadeItem.sendCommand(DOWN)
	var myDownTimer = createTimer(now.plusMillis(vSlats90), [ | vShadeItem.sendCommand(UP)     ])
	var mySlatsTimer = createTimer(now.plusMillis(vSlats90+vSlatStringsTighten+vSlatsTime), [ |	
			vShadeItem.sendCommand(STOP)
			vShadeItem.postUpdate(100)
	        ])
end
////////////////////////////////////////////////////////////////////////////////////////////////

For every jalousie the corresponding rollershutter (J_), Shading switch (JS_) and Dimmer (JD_) item are automatically found.

If anyone is interested about the additional rules for an automated shading control based on this and the sun position let me know.

Cheers Thomas

2 Likes

Thanks for posting! I’ve moved the post to the proper category.