Help, I'm ready to give up

I don’t understand the question. You can use a script to clear it out on every restart but be aware that all the bindings will reinstall so startup might take a lot longer. You need to define your addons in addons.cfg as well.

Thanks, that answers my question. I just was not sure, what side effects deleting the cache might have. I do not mind, when starting takes longer. My openHAB 1 Installation is nearly never restarted, so that does not matter.

The designer is unfortunately no help for OH2. Not even the ESH and OH methods (logDebug, postUpdate, …) are available and one can’t integrate any actions (sendTelegram, …). For example my security.rules has 55 lines of source code without blank lines. 33 of these are marked as defective.

Which version are you using? You should be using Eclipse SmartHome Designer version 0.8 at this point. When you go to the official download page: https://github.com/eclipse/smarthome/blob/master/docs/documentation/community/downloads.md#designer-builds

that is the version made available.

Version 0.9 which was there for awhile has an issue that pretty much breaks its ability to recognize pretty much everything.

openHAB Designer only works with 1.8.

It is true that and separately installed actions are not recognized yet even with the 0.8 version. But that should only amount to a handful of lines marked as errors and in these cases it will be obvious that it is not a real problem.

Because OH’s errors are not all that helpful in identifying syntax errors having the ability to have something syntax check Rules (and sitemaps and items) for you will save tons of time.

The issue to fix what broke 0.9 is actively being worked and long term there is work to create a web based replacement for Designer.

1 Like

gnarf I tried the 0.9 version several times, because of:

I never noticed that warning. Until the major issue gets fixed that line should be removed.

Hey, sooooo

  1. that line is my doing :see_no_evil: sorry guys
  2. hopefully the problem will be solved in the next few days https://github.com/eclipse/smarthome/issues/2190

How can I see what version I am running?
Does it do auto-completion? (How to invoke?)
It errors on assigning a PointType to a PointType value.

Also from your rules it underlines everything, yet it works.
It says multiple markers it can’t resolve.

Now I remember why I quit using it… it is not of any use. :frowning:

  1. I’m not sure. If you have any doubts download from the link above.

  2. Yes, ctrl-space

  3. And 4. Sounds like you are not running 0.8. when running 0.8 the only false negatives will be calls to add-on actions.

There was a couple day period when 0.9 was the current download at that site.

If it were useless I would not advocate it’s use.

Thanks – as always…

found in my change log distribution-1.8.3-designer-win.zip
just downloaded eclipsesmarthome-incubation-0.8.0-designer-win64.zip
started it… and…

… looks (evidence) whatever I touch in this OH context never works from the start.

No idea what to do with this.

Any help appreciated…

I may have misremembered. You are running 1.8? In that case I told you wrong and you need openHAB Designer. But I’m pretty sure that isn’t being maintained any longer. I’m not even sure where to download it any longer. I’m sure it’s on bintray or cloudbees. I’m on my phone so can’t really search at the moment.

No worries… a reason to get rid of it for good! :slight_smile:

Could someone take a look at this rule to turn on/off a light based on a motion sensor? BA_HUE_Motion is of course the hue motion sensor and bathroom_light is the hue light. The rule is working all EXCEPT keeping the light as long as motion is detected. I’ve searched around the site and found several ways to do this and tried them but couldn’t get them to work. This is what I’ve pieced together myself. If you have some other .rule code that works I’m game to switch to that. Note that I am checking if the time is between 6am and 11pm if it is then the bathroom_light is 100% if not then it’s 15%.

rule "BALightOn"
    when   
            Item BA_HUE_Motion changed       
    then   
logInfo('BA_HUE_Motion', 'Motion detected in Bathroom')
logInfo('bathroom_light', 'Turning Bathroom Light ON')
var DateTime t11p = new DateTime(now.getYear(), now.getMonthOfYear(), now.getDayOfMonth(), 23, 00, 0)
var DateTime t6a = new DateTime(now.getYear(), now.getMonthOfYear(), now.getDayOfMonth(), 6, 00, 0)

	if(BA_HUE_Motion.state==ON) {    
		if(now.isBefore(t11p) && (now.isAfter(t6a)) )	{
               	bathroom_light.sendCommand(100)
               	if(timer!=null){
        			timer.cancel
        			timer = null
        		}
     	} else {
                bathroom_light.sendCommand(15)
                if(timer!=null){
        			timer.cancel
        			timer = null
        		}
		}
	} else {
        	if(BA_HUE_Motion.state==OFF){
        		timer = createTimer(now.plusMinutes(3)) [|
        			bathroom_light.sendCommand(0)
        			logInfo('BA_HUE_Motion', 'No Motion in Bathroom for 3 minutes')
        			logInfo('bathroom_light', 'Turning Bathroom Light OFF')   			
        		]
        	} 
	}
end

After 133 postings to this thread, something like this probably should be posted into its own thread so it can be found by other readers of the forum easier. Answers to questions like these are particularly helpful.

Question: How does the motion sensor behave? By this I mean does it send an ON when motion is triggered and then send an off after a certain amount of time, just sends ON when motion is detected with no OFF, send ON immediately followed by OFF?

This is important because how the motion sensor behaves will greatly impact how the rule you want need to be written.

Let’s assume that the motion sensor either only sends ON commands or stays ON for a shorter or longer period of time than we want the light to stay on. This should cover most of the motion sensor behaviors listed above.

NOTE: I’ve made a number of other simplifications to your code below. Ask if you have any questions.

var Timer timer = null

rule "BALightOn"
when
    Item BA_HUE_Motion received command ON // only trigger when motion is detected, we don't care when the motion sensor goes OFF
then
    logInfo("BALightOn", "Motion detected in Bathroom")

    val t6a = now.withTimeAtStartOfDay.plusHours(6) // better way to get to something to compare to now
    val t11p = now.withTimeAtStartOfDay.plusHours(23) // better way to get to something to compare to now

    // Calculate brightness as a separate step to make the logic simpler
    var brightness = 15
    if(now.isBefore(t11p) && now.isAfter(t6a) brightness = 100

    logInfo("BALightOn", "Turning bathroom light to " + brightness)
    bathroom_light.sendCommand(brightness)

    // create a timer to turn off the light if one doesn't already exist
    if(timer == null){ 
        timer.createTimer(now.plusMinutes(3), [|
            logInfo("BALightOn", "Turning bathroom light off") // if you log the ON you should log the OFF
            bathroom_light.sendCommand(OFF)
            timer = null
        ]
    }
    // if there is a timer, reschedule it for another 3 minutes
    else {
        timer.reschedule(now.plusMinutes(3))
    }
end

However, this rule can be made even simpler using the Expire binding.

Item

bathroom_light "label" { hue="...", expire="3m,command=0" }

Rule

rule "BALightOn"
when
    Item BA_HUE_Motion received command ON // only trigger when motion is detected, we don't care when the motion sensor goes OFF
then
    logInfo("BALightOn", "Motion detected in Bathroom")

    val t6a = now.withTimeAtStartOfDay.plusHours(6)
    val t11p = now.withTimeAtStartOfDay.plusHours(23)

    var brightness = 15
    if(now.isBefore(t11p) && now.isAfter(t6a) brightness = 100

    logInfo("BALightOn", "Turning bathroom light to " + brightness)  
    bathroom_light.sendCommand(brightness)
end

The expire binding config above will wait for three minutes after the Item is set to something and then sendCommand(0) to the light after the last update to the Light is received. The rule will sendCommand the brightness every time the motion sensor is triggered, rescheduling the expire binding.

The Rule above this does the exact same thing using Timers.

See also:

  • Motion Sensor Timer for a more detailed explanation of the code above.
  • Time of Day for a better way to manage time periods in your home automation so you don’t end up with checks to see if it is between certain time periods scattered all over your rules.
1 Like

The Hue motion sensor appears to send both ON and OFF commands. The best I can tell, as long as it detects motion it stays on. Once it stops detecting motion it sends an OFF command a few seconds after no motion is detected. For my purposes, I just want the rule to react on the ON to turn on the light and then X amount of time after the OFF motion detection turn the light off. But if it detects motion after turning OFF and turns back ON then the timer should cancel so the light stays on.

It all boils down to how long the motion sensor stays ON. If it stays on for longer than 3 minutes without sending more ON commands then we have a problem. If it is shorter than 3 minutes what I have above will work.

No, the timer should be rescheduled so the lights turn off 3 minutes after the last motion was seen. If you cancel the timer then the lights will never go off.

The hue website says there is a 30 second delay after no motion is detected before the off command is sent. So your code should work. I’ll test it and see.

There was some mismatched () in your code I fixed to get it to turn the light on. It never turns the light off though. Also, for some reason the rule would not react to received command…have to use changed from OFF to ON

var Timer timer = null

rule "BALightOn"
when
    Item BA_HUE_Motion changed from OFF to ON // only trigger when motion is detected, we don't care when the motion sensor goes OFF
then
    logInfo("BALightOn", "Motion detected in Bathroom")
	//say("Motion detected in Bathroom")
    val t6a = now.withTimeAtStartOfDay.plusHours(6) // better way to get to something to compare to now
    val t11p = now.withTimeAtStartOfDay.plusHours(23) // better way to get to something to compare to now

    // Calculate brightness as a separate step to make the logic simpler
    var brightness = 15
    if(now.isBefore(t11p) && now.isAfter(t6a)) brightness = 100
    
    logInfo("BALightOn", "Turning bathroom light to " + brightness)
    bathroom_light.sendCommand(brightness)

    // create a timer to turn off the light if one doesn't already exist
    if(timer == null){ 
        timer.createTimer(now.plusMinutes(1), [|
            logInfo("BALightOn", "Turning bathroom light off")
            say("Turning Bathroom light off"
            bathroom_light.sendCommand(OFF)
            timer = null
        ])
    }
    // if there is a timer, reschedule it for another 3 minutes
    else {
        timer.reschedule(now.plusMinutes(1))
    }
end

Seems likely. I typed it on my phone. I recommend using Designer to find and fix the sorts of errors.

The motion sensor may just post updates instead of commands. Use received update ON instead.

Look in the logs when the file loads for parse errors. Content everything out but the log statements to verify the rule triggers

I am using Designer but in rules almost every line gives an error.