How to set up a controlled garage door?

True. So the sitemap SHOULD NOT display the explicitly defined icons? :confused: The only difference in your workaround is that they aren’t the built in ones. Why would that be the expected behavior?

Read: “Be careful and pay attention in rules/scripts.” Got it.

They have clearly changed how dynamic icons work in OH 2. For example, in Basic UI they now support gradual icons like a battery meter for Number Items.

As part of this change is now a new requirement that there must be a default version of an icon (i.e. one that does not include the “-state” part of the icon).

It is perfectly reasonable that these changes result in a sitemap from no longer being able to explicitly use the icon for a specific state.

My work around is to make a copy of the icons without the state part of the name.

This behavior could be by design, it could be an unfortunate limitation imposed to support the battery meter like icons, or it may be a regression that no one thought to test for.

I was in OH 1.x for about a week and never got this far. But much of the documentation still refers to 1.x stuff that may or may not be in 2 or at least the same in 2. (OK, or at least that documentation is easier to come across. I’d really like to help with documentation but I’ve got to get the supporting systems up and running on W10.)

I can’t imagine that this wouldn’t be supported (although I CAN see how it would be low on the list). I mean, if you can show the state of the object AND control it, all within one sitemap line, why wouldn’t you? “The door is closed, do you want to open it?” I would bet that it’s a regression, only because it works like a charm in IE with the Basic UI. But I could be wrong and so I wouldn’t bet more than a Starbucks.

Thanks for all the help (and inspiration) with this! Now I’ve got to concentrate on the Arduino side of things (ESP8266 Wifi, CC3000 was a bust).

1 Like

Hi

I know this is an old thread but it somehow fits to my topic.

I have a garage door which works with two switches (KNX) . One for open, one for close.
Then I have two reed sensors, one for fully open, one for fully close.

Is it possible, to have a switch in habpanel, which only shows the actual possible direction:
Reed Closed = 1 --> switch is Red and label is open {knx=5/1/1}
Reed Open = 1 --> switch is Green and label is close {knx=5/1/2}

If that is not possible, how can I show the status for the door. The usual contact item is not the right thing becaus i have three possible stati,
OPEN, CLOSE, something between.
With the usual contact item I can only handle one reed sennsor, but not CLOSE doesn´t mean fully open.

I hope some of you guys can help me with that issue.

THX

Yes
You need to create another item

String GarageDoorStatus
Rule "Garage door direction"
when
    ReedClosed changed to OPEN or //Door opening
    ReedOpen changed to OPEN //Door closing
then
    var doorStatus = ""
    if (triggeringItem.name.toString = "ReedClosed") doorStatus = "OPENING"
    if (triggeringItem.name.toString = "ReedOPEN") doorStatus = "CLOSING"
end

Rule "Garage door direction"
when
    ReedClosed changed to CLOSED or //Door closed
    ReedOpen changed to CLOSED //Door open
then
    var doorStatus = ""
    if (triggeringItem.name.toString = "ReedClosed") doorStatus = "CLOSED"
    if (triggeringItem.name.toString = "ReedOPEN") doorStatus = "OPEN"
end

Hello Vincent

Thx for your reply and help. I tried it today but got a lot of errors.
I creadet one new String Item “Status_Garagentor” and copied your rule. Now this looks like this

rule "Garage door direction"
when
    Status_Garagentor_close changed to OPEN or //Door opening
    Status_Garagentor_open changed to OPEN //Door closing
then
    var Status_Garagentor = ""
    if (triggeringItem.name.toString = "Status_Garagentor_close") Status_Garagentor = "OPENING"
    if (triggeringItem.name.toString = "Status_Garagentor_open") Status_Garagentor = "CLOSING"
end

rule "Garage door direction"
when
    Status_Garagentor_close changed to CLOSED or //Door closed
    Status_Garagentor_open changed to CLOSED //Door open
then
    var Status_Garagentor = ""
    if (triggeringItem.name.toString = "Status_Garagentor_close") Status_Garagentor = "CLOSED"
    if (triggeringItem.name.toString = "Status_Garagentor_open") Status_Garagentor = "OPEN"
end

I don´t know what I missed.
THX

You can’t use an item name as a variable
The comparison for equal is == not =

rule "Garage door direction"
when
    Status_Garagentor_close changed to OPEN or //Door opening
    Status_Garagentor_open changed to OPEN //Door closing
then
    if (triggeringItem.name.toString == "Status_Garagentor_close") Status_Garagentor.postUpdate("OPENING")
    if (triggeringItem.name.toString == "Status_Garagentor_open") Status_Garagentor.postUpdate("CLOSING")
end

rule "Garage door direction"
when
    Status_Garagentor_close changed to CLOSED or //Door closed
    Status_Garagentor_open changed to CLOSED //Door open
then
    if (triggeringItem.name.toString == "Status_Garagentor_close") Status_Garagentor.postUpdate("CLOSED")
    if (triggeringItem.name.toString == "Status_Garagentor_open") Status_Garagentor.postUpdate("OPEN")
end

Thank you for your fast respond.

I copied the code but got the following errors:
no viable alternative at input ‘Status_Garagentor_close’
no viable alternative at input ‘Status_Garagentor_open’
no viable alternative at input ‘Status_Garagentor_close’
no viable alternative at input ‘Status_Garagentor_open’
The method or field triggeringItem is undefined



Maybe you can give me another hint.

THX
Daniel

What version of openhab are you running?

OPenhab 2.3 on RPi3 with openhabian

My bad, the two rules have the same name!!

rule "Garage door direction1"
when
    Status_Garagentor_close changed to OPEN or //Door opening
    Status_Garagentor_open changed to OPEN //Door closing
then
    if (triggeringItem.name.toString == "Status_Garagentor_close") Status_Garagentor.postUpdate("OPENING")
    if (triggeringItem.name.toString == "Status_Garagentor_open") Status_Garagentor.postUpdate("CLOSING")
end

rule "Garage door direction2"
when
    Status_Garagentor_close changed to CLOSED or //Door closed
    Status_Garagentor_open changed to CLOSED //Door open
then
    if (triggeringItem.name.toString == "Status_Garagentor_close") Status_Garagentor.postUpdate("CLOSED")
    if (triggeringItem.name.toString == "Status_Garagentor_open") Status_Garagentor.postUpdate("OPEN")
end

Just to show a way of doing this

My items

Switch GarageDoorSwitch		 [ "Switchable" ] 									{ mqtt=">[broker:cmnd/GarageDoorSonoff/POWER:command:*:default]" }
Rollershutter GarageDoor		 
String GarageDoorState 			          	
Switch GarageDoorClosed															{ mqtt="<[broker:cmnd/GarageDoorSensors/POWER1:state:default]" }
Switch GarageDoorOpened															{ mqtt="<[broker:cmnd/GarageDoorSensors/POWER2:state:default]" }
Number Garage_RSSI 	"Garage: RSSI [%d %%]"  									{ mqtt="<[broker:tele/GarageDoorSonoff/STATE:state:JSONPATH($.Wifi.RSSI)]" }
String Garage_IP 	"Get Info"  												{ mqtt=">[broker:cmnd/GarageDoorSonoff/IPAddress1:command:*:*]" }
String Garage_IP_String "Info [%s]"	 											{ mqtt="<[broker:stat/GarageDoorSonoff/RESULT:state:default]" }
Switch GarageDoorAuto "Garage Door auto close 9PM-5AM" 
Switch GarageDoorStateUpdate 													{ mqtt=">[broker:cmnd/GarageDoorSonoff/STATUS:command:*:10]" } //hidden button to get update of garage door status. Runs every minute
String GarageDoorStateString													{ mqtt="<[broker:tele/GarageDoorSonoff/SENSOR:state:default]" } //hidden string to be updated depending on status 

sitemap

Text label="Garage" icon="garage"
	{
		Frame label="Control"
		{
		
		Switch item=GarageDoor label="Garage Door" icon="garagedoor"
		}
		
		Frame label="Status"
		{
		Text item=GarageDoorState label="[%s]" icon="garagedoor" valuecolor=[GarageDoorState=="Closed"="green",GarageDoorState=="Open"="red",GarageDoorState=="Ajar"="orange"] 
		}
		Text label="Settings" icon="settings"
		{
		Switch item=GarageDoorAuto icon="time"
		}
	}

rules

var Timer garageDoorTimer 
var Timer garageDoorOpenTimer

//*************************************************************************** Garage Door Rules Below********************************************************************


rule "Garage Door Open"
when
	Item GarageDoor received command UP
then

if (garageDoorTimer !== null)
	{
	garageDoorTimer.cancel
	garageDoorTimer = null
	}
	
	if (GarageDoorOpened.state != ON)
		{
		
		GarageDoorSwitch.sendCommand(ON)
			garageDoorTimer = createTimer(now.plusSeconds(25)) [|
			if (GarageDoorOpened.state != ON && GarageDoorClosed.state == ON)
				{
				GarageDoorSwitch.sendCommand(ON)
			    }
			]
		}
end
//********************************************************************



rule "Garage Door Close"
when
	Item GarageDoor received command DOWN
then

if (garageDoorOpenTimer !== null)
	{
	garageDoorOpenTimer.cancel
	garageDoorOpenTimer = null
	}
	
if (garageDoorTimer !== null)
	{
	garageDoorTimer.cancel
	garageDoorTimer = null
	}

	
	if (GarageDoorClosed.state != ON)
		{
			
			
		GarageDoorSwitch.sendCommand(ON)
			garageDoorTimer = createTimer(now.plusSeconds(25)) [|
			if (GarageDoorClosed.state != ON && GarageDoorOpened.state == ON)
				{
				GarageDoorSwitch.sendCommand(ON)
			    }
			]
		}
end
//********************************************************************




rule "Garage Door Stop"
when
	Item GarageDoor received command STOP
then

if (garageDoorTimer !== null)
	{
	garageDoorTimer.cancel
	garageDoorTimer = null
	}

	if (GarageDoorClosed.state != ON && GarageDoorOpened.state != ON)
		{
		GarageDoorSwitch.sendCommand(ON)
		}
		
end
//********************************************************************




rule "Garage Door State"
when 
	Item GarageDoorClosed received update	or
	Item GarageDoorOpened received update
then
Thread.sleep(500)
	if (GarageDoorClosed.state == ON && GarageDoorOpened.state == OFF)
		{
		GarageDoor.postUpdate(DOWN)
		GarageDoorState.postUpdate("Closed")
		if (garageDoorOpenTimer !== null)
	        	{
      			garageDoorOpenTimer.cancel
        		garageDoorOpenTimer = null
        		}

		}
	if (GarageDoorOpened.state == ON && GarageDoorClosed.state == OFF)
		{
		GarageDoor.postUpdate(UP)
		GarageDoorState.postUpdate("Open")
		}
	if (GarageDoorClosed.state == OFF && GarageDoorOpened.state == OFF)
		{
		GarageDoor.postUpdate(50)
		GarageDoorState.postUpdate("Ajar")
		}
		
end
//********************************************************************




rule "Garage Door Button Timer"
when
	Item GarageDoorSwitch received command ON
then
	createTimer(now.plusSeconds(1)) [|
	GarageDoorSwitch.sendCommand(OFF)
	]
end


//********************************************************************
	
rule "Garage Door Auto Close"
when 
	Time cron "0 0/6 21-5 1/1 * ? *"
then



if (GarageDoorAuto.state == ON)
	{
	if (GarageDoorClosed.state != ON)
		{
		sendBroadcastNotification("Garage door will shut in 5 minutes")
		garageDoorOpenTimer=createTimer(now.plusMinutes(5)) [|
		sendBroadcastNotification("Garage door has closed automatically")
		GarageDoor.sendCommand(DOWN)
		]
		}
	}
end


//********************************************************************
	
rule "Garage Door Auto Close Switch "
when 
	Item GarageDoorAuto received command OFF
then
	if (garageDoorOpenTimer !== null)
	{
	garageDoorOpenTimer.cancel
	garageDoorOpenTimer = null
	}
end



//********************************************************************




rule "Garage Door Opening"
when 
	Item GarageDoorClosed changed from ON to OFF
then
	sendBroadcastNotification("Garage Door has opened!")
end

//********************************************************************

rule "Garage Door Closing"
when 
	Item GarageDoorOpened changed from ON to OFF
then
Thread::sleep(500)
	if (GarageDoorOpened.state != ON)
	{
	sendBroadcastNotification("Garage Door is Closing!")
	}	
end

Basically. I have a switch which literally sends the MQTT command,

I use a ruller shutter item to have UP X DOWN as commands.
I then run rules to check if the garage is down, and i press down, nothing happens, If the garage is up and i press up, nothing happens. And the X button only works if the garage is neither opened of closed.

I also have 2 reed switches, one for open, one for close.

I have another rule. which when i press either up or down, it sends the command to activate the garage. if after 25 seconds, it hasn’t activated the reed switch i wanted, (either opened or closed depending what i pressed), it will press the garage button one time. If for instance, there is something blocking the door from moving, it wont run the rule again, as I pressed the garage button, not pressed up/down again.

I also have timers, and auto closing after certain times. as you can see in my rules

2 Likes

Nice one, did not think about that. Will implement this too, thx. :+1:

Hi Vincent

this doesn´t solve the problems, ist still:
no viable alternative at inpot…
and
the method or field triggeritem is undifined.

Christopher thank you for your very welcome input.
I will need some time to see how I can implement your rules as I use two KNX contacts to open and close the carage door and to reed an a KNX sensor to read the status.

Furthermore I´m not sure how these rules handle Inputs from remote, or in my case from usual KNX switches.

THX
Daniel

@Daniel_OH
Can you publish your items and rules, please
Please use the code fences

Items

Switch Garagentor_open           "Garagentor"                                    (gAussen)       [ "Switchable" ]                {knx="5/1/2+<10/3/2"}
Switch Garagentor_close           "Garagentor"                                    (gAussen)       [ "Switchable" ]                {knx="5/1/1+<10/3/1"}
Switch Haustuere           "Haustüre"                                       (gAussen)       [ "Switchable" ]                {knx="5/1/0"}
Contact Status_Garagentor_open       "Garantor offen "                <Garagedoor>         (gAussen)       [ "Switchable" ]                 {knx="4/3/1"}
Contact Status_Garagentor_close       "Garantor geschlossen "       <Garagedoor>                 (gAussen)       [ "Switchable" ]                 {knx="4/3/2"}
String Status_Garagentor    "Status Garagentor"

Rule

rule "Garage door direction1"
when
    Status_Garagentor_close changed to OPEN or //Door opening
    Status_Garagentor_open changed to OPEN //Door closing
then
    if (triggeringItem.name.toString == "Status_Garagentor_close") Status_Garagentor.postUpdate("OPENING")
    if (triggeringItem.name.toString == "Status_Garagentor_open") Status_Garagentor.postUpdate("CLOSING")
end

rule "Garage door direction2"
when
    Status_Garagentor_close changed to CLOSED or //Door closed
    Status_Garagentor_open changed to CLOSED //Door open
then
    if (triggeringItem.name.toString == "Status_Garagentor_close") Status_Garagentor.postUpdate("CLOSED")
    if (triggeringItem.name.toString == "Status_Garagentor_open") Status_Garagentor.postUpdate("OPEN")
end

THX

rule "Garage door opening"
when
    Status_Garagentor_close changed to OPEN //Door opening
then
    Status_Garagentor.postUpdate("OPENING")
end

rule "Garage door closing"
when
    Status_Garagentor_open changed to OPEN //Door closing
then
    Status_Garagentor.postUpdate("CLOSING")
end

rule "Garage door closed"
when
    Status_Garagentor_close changed to CLOSED //Door closed
then
    Status_Garagentor.postUpdate("CLOSED")
end

rule "Garage door open"
when
    Status_Garagentor_open changed to CLOSED //Door open
then
    Status_Garagentor.postUpdate("OPEN")
end

Sorry fore the late respond, was on holydays.

I´m really sorry but I dont get it. Its still the same

no viable alternative at input ‘Status_Garagentor_close’ (3,5)
no viable alternative at input ‘Status_Garagentor_open’ (10,5)
no viable alternative at input ‘Status_Garagentor_close’ (17,5)
no viable alternative at input ‘Status_Garagentor_open’ (24,5)

Found the problem

Just had to add Item before “Status_Garagentor”

Thank you very much. You helped me a lot Vincent

I can’t believe I missed that!!