• 10 dec 2017: forum version update. In case of issues use this topic.
  • 30 nov 2017: pilight moved servers. In case of issues use this topic.
Hello There, Guest! Login Register


Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Sunriseset problem switches on at 0:00
#1
Hello community,

I have the following problem with my rule.

I use the standard rule to switch on a light at sunset.

"IF sunriseset.sun IS set THEN ..." There is no AND in my rule.

In a different rule I turn of the lamp at 23:00. That are all rules.

At 0:00 the lamp switches on again and I don't know why. I only have these two rules.

I'll post the config later. Maybe somebody has the same problem and already knows the problem.

Thank you very much.
-Daniel
 
Reply
#2
The state of sunriseset.sun is "set" from sunset until sunrise. During that period the rule will trigger if the state of the lamp changes to off. So if you switch it off, the rule will switch it on again.

If you only want the lamp to switch on at sunset, you can use:

Code:
IF (sun.sunset == DATE_FORMAT(dt, %H.%M)) THEN

Replacing "dt" with the name of your datetime device.
 
Reply
#3
(03-29-2016, 11:14 AM)Niek Wrote: The state of sunriseset.sun is "set" from sunset until sunrise. During that period the rule will trigger if the state of the lamp changes to off. So if you switch it off, the rule will switch it on again.

If you only want the lamp to switch on at sunset, you can use:

Code:
IF (sun.sunset == DATE_FORMAT(dt, %H.%M)) THEN

Replacing "dt" with the name of your datetime device.

Thanks Niek, I'll try it today and let you know if it works. Wink
 
Reply
#4
Just noticed that your sunriseset device is called "sunriseset", so the rule should look like:
Code:
IF (sunriseset.sunset == DATE_FORMAT(dt, %H.%M)) THEN ....

With "dt" replaced by the name of your datetime device.
 
Reply
#5
(03-29-2016, 01:40 PM)Niek Wrote: Just noticed that your sunriseset device is called "sunriseset", so the rule should look like:
Code:
IF (sunriseset.sunset == DATE_FORMAT(dt, %H.%M)) THEN ....

With "dt" replaced by the name of your datetime device.

Hi Niek, I tried your solution yesterday but I got still the same mistake. Lamp switches on at 0:00 again.

Now I've copied my config. That's what I setup for me.

Code:
"devices": {
        "outside": {
        "protocol": [ "openweathermap" ],
        "id": [{
            "country": "de",
            "location": "xxx"
        }],
        "humidity": 94.00,
        "temperature": 0.21,
        "sunrise": 8.29,
        "sunset": 17.05,
        "sun": "set",
        "update": 0
        },
        "sonne": {
        "protocol": [ "sunriseset" ],
        "id": [{
            "longitude": xxxxx,
            "latitude": xxxxx
        }],
        "sunrise": 8.16,
        "sunset": 16.52,
        "sun": "set"
        },
        "datetime": {
            "protocol": [ "datetime" ],
            "id": [{
                "longitude": xxxxx,
                "latitude": xxxxx
            }],
            "year": 2016,
            "month": 2,
            "day": 13,
            "hour": 17,
            "minute": 1,
            "second": 9,
            "dst": 0,
            "weekday": 7
        },
                "Flurlampe": {
            "protocol": [ "kaku_switch" ],
            "id": [{
                "id": 13104778,
                "unit": 5
            }],
            "state": "on"
        }
...

"rules": {
        "Flurlampe_an": {
            "rule": "IF (sonne.sunset == DATE_FORMAT(datetime, %H.%M)) THEN switch DEVICE Flurlampe TO on",
            "active": 1
        },
        "Flurlampe_aus": {
            "rule": "IF datetime.hour == 23 AND datetime.minute == 00 AND datetime.second == 0 THEN switch DEVICE Flurlampe TO off",
            "active": 1
        }
    },
 
Reply
#6
This would mean that "sonne.sunset" is zeroUnsure

Does the rule also switch to on at sunset?
Are these two rules the only ones in your config?
Can you zip and post your full config (without passwors and such!)?
 
Reply
#7
(03-30-2016, 09:47 AM)Niek Wrote: This would mean that "sonne.sunset" is zeroUnsure

Does the rule also switch to on at sunset?
Are these two rules the only ones in your config?
Can you zip and post your full config (without passwors and such!)?

I'll make some changes and post it tomorrow. I try to use the sunset state from openweathermap and I delete the complete "sonne".

Btw that are the only two rules.
 
Reply
#8
I'll anser to this post, because I came across the same problem as the OP.
The device sunrise is correctly defined as the sunriseset protocol, and the rule states
Code:
"Sonnenuntergang": {
        "rule": "IF sunrise.sun IS set THEN (...),
        "active": 1
},


This rule is executed twice a day, as one can see in the log file (1 hour from UTC):

Code:
[Dec 22 15:34:00:243856] pilight-daemon: INFO: executed rule: Sonnenuntergang
(...)
[Dec 22 23:00:00:872979] pilight-daemon: INFO: executed rule: Sonnenuntergang


The manual states:
Quote:The sunriseset will send three messages:
  • When the sunset time has been arrived.
  • When the sunrise time has been arrived.
  • After midnight so all values can be updated for a new day.

So what happens at midnight is that sunriseset sends a message, the sun has indeet set, so my rule fires. I don't think that this is the required behaviour, otherwise the usage of this rule as an example on the manual page wouldn't make sense.

Until correction of the behaviour, the correct solution to fire a rule on sunset would be
Code:
"SonnenuntergangSW1": {
        "rule": "IF DATE_FORMAT(CurrentDateTime, %H.%M) == sunrise.sunset THEN (...),
        "active": 1
},

Is this correct? However, this rule will fire 60 times, so better add AND datetime.second == 0 to the rule?
 
Reply
#9
1. Indeed add the seconds check.
2. Don't rely on the sunriseset state, but rather on the time.
3. The three notifications are correct. The midnight notification is meant so you know the sunriseset times have changed.
 
Reply
#10
In this case, you should consider to remove the example from the manual Wink
 
Reply
  


Possibly Related Threads...
Thread Author Replies Views Last Post
  Problem FOR Alex 5 954 05-18-2018, 01:21 PM
Last Post: curlymo
  Problem with executing bash script via rule/program dYna 1 929 02-15-2018, 09:06 PM
Last Post: dYna
  Problem with a Rule for a One Button Switch martin-dj 1 1,263 03-06-2017, 12:01 PM
Last Post: pilino1234
  sunriseset rule question Michel 2 1,431 07-09-2016, 06:30 PM
Last Post: Michel
Lightbulb Whats wrong with my "sunriseset.sun" rule Seebueb 2 1,991 10-15-2015, 08:45 PM
Last Post: Seebueb
  Problem: understanding rule ktams 6 3,143 09-07-2015, 10:37 AM
Last Post: ktams
  Problem switching device off after 20 minutes jurkla 3 1,768 08-28-2015, 08:54 AM
Last Post: jurkla

Forum Jump:


Browsing: 1 Guest(s)