Im trying to create a simple sunrise / sunset rule to turn on/off garage lights. After hours of looking at examples, I came up with the basic rule(s) pasted below. The only issue, is it doesnt work. Also, is there a way to test this script without waiting for sunrise / sunset?
Here’s a simple ASTRO based sunrise/sunset rule I use…
Please notice the cAsE of your ON/off commands…they should both be UPPER CASE.
rule "turn landscape lighting off"
when
Channel 'astro:sun:home:rise#event' triggered START
then
FntLandscapeLights.sendCommand(OFF)
BckLandscapeLights.sendCommand(OFF)
end
rule "turn landscape lighting on"
when
Channel 'astro:sun:home:set#event' triggered START
then
FntLandscapeLights.sendCommand(ON)
BckLandscapeLights.sendCommand(ON)
end
As others have pointed out as well you need to place the end statement after each rule.
This might work. I setup the files, changed the “geolocation” and added my lights. I also added a night switch to my sitemap. I all works manually, waiting on night time…
Please be aware that you used smart quotes (but maybe this was only in the posting, as Discourse changes quotes to smart quotes if the text is not set in code fences. Please use
```
'Your Code' goes here with "Quotes"
```
to post Code.
Without Code fences this will be changed, even if later changing the text to Code:
‘Your Code’ goes here with “Smart Quotes”
As the quotes look nearly the same in standard font, this is a common error. So please ensure you didn’t use smart quotes at all as openHAB does not work correctly with smart quotes.
2017-12-11 17:20:00.082 [ItemStateChangedEvent ] - NightState changed from OFF to ON
2017-12-11 17:20:00.091 [ItemCommandEvent ] - Item ‘Outside_garage_lights’ received command ON
2017-12-11 17:20:00.149 [ItemStateChangedEvent ] - Outside_garage_lights changed from OFF to ON
2017-12-11 17:20:00.159 [ItemStateChangedEvent ] - ZWaveSerialController_FramesAcknowledged changed from 29 to 30
2017-12-11 17:20:00.160 [ItemStateChangedEvent ] - ZWaveSerialController_StartFrames changed from 44 to 45
2017-12-11 17:20:00.164 [ItemStateChangedEvent ] - ZWaveSerialController_StartFrames changed from 45 to 46
2017-12-11 17:20:01.930 [ItemCommandEvent ] - Item ‘Milk_Glass_lamp’ received command ON
2017-12-11 17:20:01.935 [ItemStateChangedEvent ] - Milk_Glass_lamp changed from UNDEF to 100