This page last changed on Nov 26, 2013 by bourrin.

Hi,

I am a newbe with openremote.

I use a Synology with AEON Stick to drive roller shutters.

I have build a rule with a timer to open and close, but I would use real sunrise time.

I have found a xml provider who do this : http://www.earthtools.org/sun/45.758682/5.014803/26/11/99/0

Can someone tell me how I can improve it in a rule ?

Sorry, for my poor english

Use the DateTime protocol http://www.openremote.org/display/docs/OpenRemote+2.0+How+To+-+DateTime+Protocol
Then you can use isDay sensor to drive your roller shutters.

Posted by aktur at Nov 26, 2013 13:23

I have here Sunscreen docking an example of controlling Sunshades taking into account day/night, rain, wind gusts. A rule for lowering the sunshades on high radiation, high inside temperature, day/night is being tested at the moment.

Posted by pz1 at Nov 26, 2013 14:03

If I have understand with this two rules and a sensor created as described in the tuto

rule "Store off at sunset"
when
CustomState( source=="Sensor isDay", value=="false")
then
execute.command("fermeture volet cuisine -OFF-");
end

rule "Store on at sunrise"
when
CustomState( source=="Sensor isDay", value=="true")
then
execute.command("ouverture volet cuisine -ON-");
end

My roller will open and close when the value of isDay change ?

Posted by bourrin at Nov 26, 2013 14:27

When I try to deploy my rules I have this error : ERROR 2013-11-26 15:32:00,097 : Rule definition 'modeler_rules.drl' could not be deployed. See errors below.

ERROR [Controller Definition File Watcher for Default Deployer]: Rule definition 'modeler_rules.drl' could not be deployed. See errors below.
ERROR 2013-11-26 15:32:00,098 : Unable to resolve ObjectType 'CustomState'
ERROR [Controller Definition File Watcher for Default Deployer]: Unable to resolve ObjectType 'CustomState'
ERROR 2013-11-26 15:32:00,098 : Unable to resolve ObjectType 'CustomState'
ERROR [Controller Definition File Watcher for Default Deployer]: Unable to resolve ObjectType 'CustomState'
Unable to resolve ObjectType 'CustomState' : [Rule name='Store off at sunset']

Unable to resolve ObjectType 'CustomState' : [Rule name='Store on at sunrise']

ERROR 2013-11-26 15:32:00,109 : There was an error parsing the rule definition 'modeler_rules.drl' : Could not parse knowledge.
java.lang.IllegalArgumentException: Could not parse knowledge.
        at org.drools.builder.impl.KnowledgeBuilderImpl.newKnowledgeBase(KnowledgeBuilderImpl.java:58)
        at org.openremote.controller.statuscache.rules.RuleEngine.getValidKnowledgePackages(RuleEngine.java:532)
        at org.openremote.controller.statuscache.rules.RuleEngine.start(RuleEngine.java:253)
        at org.openremote.controller.statuscache.EventProcessorChain.start(EventProcessorChain.java:112)
        at org.openremote.controller.statuscache.StatusCache.start(StatusCache.java:120)
        at org.openremote.controller.deployer.Version20ModelBuilder.buildSensorModel(Version20ModelBuilder.java:659)
        at org.openremote.controller.deployer.Version20ModelBuilder.build(Version20ModelBuilder.java:557)
        at org.openremote.controller.deployer.AbstractModelBuilder.buildModel(AbstractModelBuilder.java:154)
        at org.openremote.controller.service.Deployer.startup(Deployer.java:858)
        at org.openremote.controller.service.Deployer.softRestart(Deployer.java:440)
        at org.openremote.controller.service.Deployer$ControllerDefinitionWatch.run(Deployer.java:1324)
        at java.lang.Thread.run(Thread.java:662)
ERROR [Controller Definition File Watcher for Default Deployer]: There was an error parsing the rule definition 'modeler_rules.drl' : Could not parse knowledge.
java.lang.IllegalArgumentException: Could not parse knowledge.
        at org.drools.builder.impl.KnowledgeBuilderImpl.newKnowledgeBase(KnowledgeBuilderImpl.java:58)
        at org.openremote.controller.statuscache.rules.RuleEngine.getValidKnowledgePackages(RuleEngine.java:532)
        at org.openremote.controller.statuscache.rules.RuleEngine.start(RuleEngine.java:253)
        at org.openremote.controller.statuscache.EventProcessorChain.start(EventProcessorChain.java:112)
        at org.openremote.controller.statuscache.StatusCache.start(StatusCache.java:120)
        at org.openremote.controller.deployer.Version20ModelBuilder.buildSensorModel(Version20ModelBuilder.java:659)
        at org.openremote.controller.deployer.Version20ModelBuilder.build(Version20ModelBuilder.java:557)
        at org.openremote.controller.deployer.AbstractModelBuilder.buildModel(AbstractModelBuilder.java:154)
        at org.openremote.controller.service.Deployer.startup(Deployer.java:858)
        at org.openremote.controller.service.Deployer.softRestart(Deployer.java:440)
        at org.openremote.controller.service.Deployer$ControllerDefinitionWatch.run(Deployer.java:1324)
        at java.lang.Thread.run(Thread.java:662)
INFO 2013-11-26 15:32:00,123 : Initialized event processor : Drools Rule Engine
INFO 2013-11-26 15:32:00,157 : Initialized event processor : RRD4J Data Logger
INFO 2013-11-26 15:32:00,158 : Initialized event processor : EmonCMS Data Logger
INFO 2013-11-26 15:32:00,197 : Registered sensor : Switch Sensor (Name = 'switch volet cuisine', ID = '39')
INFO 2013-11-26 15:32:00,699 : Registered sensor : Sensor (Name = 'Sensor isDay', ID = '43', State Mappings: {})
INFO 2013-11-26 15:32:00,705 : Startup complete.

Here are my rules :

package org.openremote.controller.model.event

global org.openremote.controller.statuscache.CommandFacade execute;
global org.openremote.controller.statuscache.SwitchFacade switches;
import org.openremote.controller.protocol.*;

rule "Store off at sunset"
when 
  CustomState( source=="Sensor isDay", value=="false")
then
  execute.command("fermeture volet cuisine -OFF-"); 
end

rule "Store on at sunrise"
when
  CustomState( source=="Sensor isDay", value=="true")
then
  execute.command("ouverture volet cuisine -ON-"); 
end

Can you help me ?

Posted by bourrin at Nov 26, 2013 14:35

I resync one time the controller and I have no more error.

Now I'm waiting for the night to see if it works...

Posted by bourrin at Nov 26, 2013 14:46

Yes, one or two resync's appear to be a good remedy. I run OR on a Synology NAS. Sometimes a restart of the NAS does help.

Posted by pz1 at Nov 26, 2013 14:57

Good news, it works but it is a little too early.

How can do to close 30 minutes after sunset and open 30 minutes before sunrise ?

Posted by bourrin at Nov 26, 2013 16:08

Probably you would need the civil sunset time, but it is not available in the current controller version. You can delay sunset by using minutesUntilSunset and execute the command when this number is 1410 (so in fact about 30 minutes after sunset).

Posted by aktur at Nov 26, 2013 16:24

I have done a rule with a new sensor datetime with the function minutesUntilSunset

CustomState( source=="Sensor Sunset", value=="1385")

But it does not work.

Posted by bourrin at Nov 26, 2013 16:46

I have done a rule with a new sensor datetime with the function minutesUntilSunset

CustomState( source=="Sensor Sunset", value=="1385")

But it does not work.

Posted by bourrin at Nov 26, 2013 16:46

In fact, it work, I just forget to save in the designer before synchronise to controller.

I am dummy ...

Posted by bourrin at Nov 26, 2013 17:42

My friend has a teenage son who is into home automation, and while discussing my OpenRemote setup with him, he came up with a brilliant solution for adjusting sunrise and sunset: simply adjust the longitude setting eastward to move the desired event earlier, and vice versa. The earth rotates at 15 degrees/hour, so for example, to close your shades 30 minutes later add 7.5 to your longitude entry.

Posted by russ at Aug 02, 2014 13:51

Yes, this would add absolute time, just like examples above. However, since the real point is rather the position of the sun below horizon (which defines how dark it is), the ultimate solution would be to add different types of sunsets as they are defined already in the library. The only problem is the lack of user interface to call these.

Posted by aktur at Aug 02, 2014 21:01

I have faced the same problem and I am going to change DateTimeCommand a little bit. In the simple version I will just switch to civil sunset/sunrise. The more flexible way will be to specify type of sunset/sunrise after semicolon. This is the easiest solution to not change the designer. So for example you could specify following commands in DateTimeCommand UI:

  • "isDay",
  • "isDay;CIVIL",
  • "isDay;-5" - this is an arbitrary angle (for example CIVIL is -6, OFFICIAL is -0.8333).

Actually I did already the simple version, but it is not yet tested. I hope to test this today/tomorrow.

Posted by druciak at Aug 04, 2014 13:57

I don't think this is a good idea. By changing your location you'll "shift" only the moment of sunset and sunrise. So you'll have later sunset, but also later sunrise. We most people need is - for example - later sunset, sooner sunrise. At least this is what I need.

Posted by druciak at Aug 04, 2014 14:00

I created two commands, "isNight" and "isDay" which calculate the respective events shifted in the desired direction via longitude adjustment, then used these to trigger the desired rules.

Posted by russ at Aug 08, 2014 16:59
Document generated by Confluence on Jun 05, 2016 09:39