• 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
[SOLVED] - How to switch a device 15 minutes after sunset with newest nightly
#1
Question 
I have upgraded my Pi - unfortunately it also installs the latest nightly version of pilight.
With the installed older version my rules have worked like a charm. Now - pilight won't start.

Code:
pilight-daemon: ERROR: config device #6 "sunriseset", protocol names are reserved words
pilight-daemon: ERROR: config device #7 "datetime", protocol names are reserved words
pilight-daemon: ERROR: DATE_FORMAT requires at least three parameters when passing a datetime string e.g. DATE_FORMAT(01-01-2015, 175-Bad address-%Y, %Y-Bad address-0)
pilight-daemon: INFO: rule #1 was parsed until: ... (sunriseset.sunset == DATE_FORMAT(datetime, %H.%M)) AND tvbacklight.state IS off THEN switch DEVICE tvbacklight TO on AFTER 15 MINUTE
pilight-daemon: INFO: rule #1 TV_Backlight_AutoON was parsed in 0.000583 seconds

I replaced the old device-names by the suggested ones in the wiki, so that the first two error-lines have gone.

But i don't have the time yet to study all threads to search for the solution to get my rule work again with
the new nightly.

Could somebody (more experienced in this topic) help me? The goal is to switch my tvbacklight to on 15 minutes after sunset :-)

Code:
"devices": {
        "tvbacklight": {
            "protocol": [ "intertechno_old" ],
            "id": [{
                "id": 12,
                "unit": 4
            }],
            "state": "off"
        },
        "sonnenaufuntergang": {
            "protocol": [ "sunriseset" ],
            "id": [{
                "longitude": 8.550002500000005,
                "latitude": 47.367347
            }],
            "sunrise": 5.34,
            "sunset": 21.27,
            "sun": "rise"
        },
        "zeitunddatum": {
            "protocol": [ "datetime" ],
            "id": [{
                "longitude": 8.550002500000005,
                "latitude": 47.367347
            }],
            "year": 2015,
            "month": 7,
            "day": 2,
            "hour": 20,
            "minute": 45,
            "second": 18,
            "weekday": 5,
            "dst": 1
        },
        "outside": {
            "protocol": [ "openweathermap" ],
            "id": [{
                "country": "ch",
                "location": "Waedenswil"
            }],
            "humidity": 68.00,
            "temperature": 21.48,
            "sunrise": 5.33,
            "sunset": 21.25,
            "sun": "set",
            "update": 1
        },

"rules": {
        "TV_Backlight_AutoON": {
            "rule": "IF (sunriseset.sunset == DATE_FORMAT(datetime, %H.%M)) AND tvbacklight.state IS off THEN switch DEVICE tvbacklight TO on AFTER 15 MINUTE",
            "active": 1
    },

"gui": {
        "tvbacklight": {
            "name": "TV Hintergrundbeleuchtung",
            "group": [ "Schlafzimmer #9" ],
            "media": [ "all" ]
        },
        "zeitunddatum": {
            "name": "Zeit & Datum",
            "group": [ "Info" ],
            "format": "HH:mm:ss   DD-MM-YYYY"
        },
        "outside": {
            "name": "Temperatur",
            "group": [ "Info" ],
            "media": [ "all" ]
        },

"settings": {
        "log-level": 4,
        "pid-file": "/var/run/pilight.pid",
        "log-file": "/var/log/pilight.log",
        "webserver-enable": 1,
        "webserver-root": "/usr/local/share/pilight/",
        "webserver-http-port": 5001,
        "webserver-cache": 1,
        "ntp-servers": [ "0.ch.pool.ntp.org", "1.ch.pool.ntp.org" ]
    },

I really appreciate your help

EDIT: I changed the rule in this way:
Code:
    "rules": {
        "TV_Backlight_AutoON": {
            "rule": "IF sunriseset.sun IS set AND tvbacklight.state IS off THEN switch DEVICE tvbacklight TO on AFTER 15 MINUTE",
            "active": 1
Maybe this will be a solution - i have to wait until 15 minutes after sunriseset is reached...

well done - the device has switched to on around 21:20 oclock
 
Reply
#2
Hi Seebueb,
you have to edit your actual device name in the rule:
"TV_Backlight_AutoON": {
"rule": "IF (sunriseset.sunset == DATE_FORMAT(datetime, %H.%M)) AND tvbacklight.state IS off THEN switch DEVICE tvbacklight TO on AFTER 15 MINUTE",
"active": 1
-->
"TV_Backlight_AutoON": {
"rule": "IF (sunriseset.sunset == DATE_FORMAT(zeitunddatum, %H.%M)) AND tvbacklight.state IS off THEN switch DEVICE tvbacklight TO on AFTER 15 MINUTE",
"active": 1
Wrong variable names will not be written into the error log :-(
Regards,
Guido
 
Reply
#3
Please use code tags.
 
Reply
#4
@ gstrotmann
What a shame for me! Just now i have changed my old rule to that what you suggested.
No problem to start pilight. I hope it would work like a charm again.
Guido - you are the best. Thank you very much for your help.

[EDIT]
======================================================
For those who want to copy the whole rule (or in part) - there is a second bug on it. Correct is to change the second device id also - otherwise you wont't get an error in log, but the rule doesn't work.


Quote:Nightly

Starting with nightly 7.0 commit 6becc0d, protocol names are no more accepted as device id. The example on this page is no longer valid because it uses a protocol name as id (sunriseset). Therefore the device must be renamed (i.e. sunrisesunset, sonnenaufuntergang etc.) using only alphanumeric characters, symbols are not allowed. For users of previous versions it's recommended to write the new configuration files in this way, to be already compatible with the future versions of pilight.


"rules": {
"TV_Backlight_AutoON": {
"rule": "IF (sunriseset.sunset == DATE_FORMAT(zeitunddatum, %H.%M)) AND tvbacklight.state IS off THEN switch DEVICE tvbacklight TO on AFTER 15 MINUTE",
"active": 1
},

--> change to

"rules": {
"TV_Backlight_AutoON": {
"rule": "IF (sonnenaufuntergang.sunset == DATE_FORMAT(zeitunddatum, %H.%M)) AND tvbacklight.state IS off THEN switch DEVICE tvbacklight TO on AFTER 15 MINUTE",
"active": 1
},
======================================================

PS: @curlymo - what is the meaning for "use code tags"? I do not really understand - respectively i didn't find the option to do in this way.
 
Reply
#5
You used code tags so you clearly know what they are Smile
 
Reply
#6
@curlymo
I mistakenly assumed you meant to use code tags in my thread description or something like that.
If your note pointet out to use code tags in Guidos answering-post, then i understand what you mean.Wink
Greetings and thank you for such a good work like pilight. It's very useful for me and i do not want to miss it!Smile
 
Reply
#7
I don't know that "AFTER 15 MINUTE" is a function of the rules.
I have a similar rule and I used this code.

IF outside.sunset + 0.15 == (date.hour + (date.minute / 100)) THEN switch DEVICE lamp TO on.
 
Reply
#8
Have you checked the wiki to see if you're right?
http://wiki.pilight.org/doku.php/example...ased_rules
 
Reply
#9
Ok now I know it Big Grin

But my rule works also Cool
 
Reply
  


Possibly Related Threads...
Thread Author Replies Views Last Post
  [solved] sunset rule doesn't work fleisch 5 1,498 08-29-2020, 05:23 AM
Last Post: CharlesRhymn
  [Solved] On and Off for one device in one rule Oliver 3 1,056 10-28-2019, 06:55 PM
Last Post: Oliver
  Sunset state check parse error dennisvo 6 1,292 09-27-2019, 08:34 PM
Last Post: curlymo
  skipping overridden action switch do1eh 2 1,224 01-19-2019, 05:25 PM
Last Post: do1eh
  Can't switch Relay device by rules: Error switch.lua:77 wobbi 6 2,072 07-31-2018, 06:25 AM
Last Post: curlymo
  Rule with&without device. One working not the other... Tamadite 9 2,622 07-24-2018, 08:55 AM
Last Post: curlymo
  Send on command when switch is already "on" joshovki 1 979 01-28-2018, 11:27 PM
Last Post: curlymo
  Rule Sunset works, Sunrise not apartmedia 1 1,690 12-05-2017, 07:09 PM
Last Post: apartmedia
  Always trigger event on any device state Phil 8 3,738 03-22-2017, 07:30 PM
Last Post: Phil
  Problem with a Rule for a One Button Switch martin-dj 1 1,803 03-06-2017, 12:01 PM
Last Post: pilino1234

Forum Jump:


Browsing: 1 Guest(s)