Author Topic: Event criteria for daytime or nighttime  (Read 5088 times)

jeangot

  • Guru
  • ****
  • Posts: 233
    • View Profile
Event criteria for daytime or nighttime
« on: November 11, 2008, 07:37:07 am »
Hello,

to work with lights and motion detectors outside my home, I am trying to setup Events where part of the criteria is based in whether it's night or not.
I can't use the preconfigured "Sunset" or "Sunrise" events since it involves additional criterias.

Some threads seem to recommend using "Time Of Day = Night" or "Time of Day = Daytime", but neither of these seem to work, whether I write them with a capital letter or not.

Does anyone have a definite answer as to whether thsi is supported or not, or am I stuck working with fixed times instead of a Sunset time which fluctuates around 3 or 4 hours throughout the year.

Thanks.

Jean



jondecker76

  • Alumni
  • wants to work for LinuxMCE
  • *
  • Posts: 763
    • View Profile
Re: Event criteria for daytime or nighttime
« Reply #1 on: November 11, 2008, 07:44:28 am »
I use 2 conditional times to narrow time slots down. For example, to make things happen only at night, I do the following criteria:
if Time Of Day > 21:00 OR
if Time Of Day < 08:00

(translation: if the time is between 21:00 and 08:00)
then do my commands


Looking at the source briefly, src/Event_Plugin/Criteria_EvaluateExpression.cpp EvaluateTimeOfDay() seems to indicate NIGHT and DAY keywords are supported. Following the source further to General Info plugin at src/General_Info_Plugin/General_Info_Plugin.cpp, you can see it implemented as command 371. Not saying that it works as it should, but everything points to it being implemented.

« Last Edit: November 11, 2008, 09:09:07 am by jondecker76 »

jeangot

  • Guru
  • ****
  • Posts: 233
    • View Profile
Re: Event criteria for daytime or nighttime
« Reply #2 on: November 11, 2008, 05:05:00 pm »
Jon,

Thanks. I saw this command 371 also but I'm not sure how that helps me: do you know if/how the result of a command can be used in a criteria?

Jean

jondecker76

  • Alumni
  • wants to work for LinuxMCE
  • *
  • Posts: 763
    • View Profile
Re: Event criteria for daytime or nighttime
« Reply #3 on: November 11, 2008, 06:38:28 pm »
I haven't tried it, but it looks like it should be as simple as:

What time of day? = DAY

or

What time of day? = NIGHT

also, case shouldn't matter as the expression is converted to caps in code
« Last Edit: November 11, 2008, 07:26:43 pm by jondecker76 »

jeangot

  • Guru
  • ****
  • Posts: 233
    • View Profile
Re: Event criteria for daytime or nighttime
« Reply #4 on: November 12, 2008, 07:20:59 am »
Jon,

that was the first thing I tried, that's also what some posts in these forums seemed to indicate (although there was never a definite answer as to whether it worked).
I just tried it again, with plenty of reloads to make sure that my settings are taking effect, and neither DAY nor NIGHT have any effect.
As far as I understand the command  CMD_Is_Daytime (#371) that you're referring to is just that, a command. Meaning that I can probably run it in the list of commands, and it will return 1 or 0, but I don't know how to use this value (1 or 0 returned by  CMD_Is_Daytime) as a criteria?

Jean

bulek

  • Administrator
  • wants to work for LinuxMCE
  • *****
  • Posts: 909
  • Living with LMCE
    • View Profile
Re: Event criteria for daytime or nighttime
« Reply #5 on: November 12, 2008, 10:35:47 am »
Jon,

that was the first thing I tried, that's also what some posts in these forums seemed to indicate (although there was never a definite answer as to whether it worked).
I just tried it again, with plenty of reloads to make sure that my settings are taking effect, and neither DAY nor NIGHT have any effect.
As far as I understand the command  CMD_Is_Daytime (#371) that you're referring to is just that, a command. Meaning that I can probably run it in the list of commands, and it will return 1 or 0, but I don't know how to use this value (1 or 0 returned by  CMD_Is_Daytime) as a criteria?

Jean

Hi,

sorry for being of no help, but would like to express interest in this matters - I guess such solutions will be of great help for other users... Please post to Wiki, when ready...

Maybe for a start, we could write some Ruby skeleton for event handler in Ruby - so we can try out various things, post everything usefull to Wiki and I guess we will progress faster with solutions to our event/scenario/device handling problems....

What do you think about this?

Is DDamron around, to help us going with evet handler Ruby skeleton code ?



regards,
bulek.
« Last Edit: November 12, 2008, 10:38:25 am by bulek »
Thanks in advance,

regards,

Bulek.

jondecker76

  • Alumni
  • wants to work for LinuxMCE
  • *
  • Posts: 763
    • View Profile
Re: Event criteria for daytime or nighttime
« Reply #6 on: November 12, 2008, 03:11:18 pm »

From studying
Criteria_EvaluateExpression.cpp
more, I can't see why it doesn't work. All it does is send the #371 command to the GeneralInfo plugin, which calls a function in the Event plugin. In the end it evaluates to true of false as far as the expression evaluation is concerned.

I'll look in into it more as I get rolling over here. I'd also like to support SUNRISE and SUNSET keywords directly as a time so that it can be used in more advanced criteria.

Now, as far as using the 371 command directly in criteria, that won't work.

Try to get on IRC today - we can discuss it a bit. I'd really like to fix this.

colinjones

  • Alumni
  • LinuxMCE God
  • *
  • Posts: 3003
    • View Profile
Re: Event criteria for daytime or nighttime
« Reply #7 on: November 12, 2008, 08:15:03 pm »
As has been mentioned before, it would be nice if you could create new/additional events along the lines of SUNRISE-20mins or SUNSET+1hr so that you could hook into the calculation that works out sunrise/set for your location but trigger the events early or late based on requirements (eg, often a particular house will be too dark long before actual sunset!) Or even allow reconfiguration of the actual base SUNRISE/SET events to apply on offset.. just a thought...

jondecker76

  • Alumni
  • wants to work for LinuxMCE
  • *
  • Posts: 763
    • View Profile
Re: Event criteria for daytime or nighttime
« Reply #8 on: November 12, 2008, 08:23:39 pm »
excellent recomendation - I'll put that on my list.

The good thing is, that criteria evaluation already has a preprocessing function (where the Day and Night keywords are handled), so adding support for + xx:yy times shouldn't be all too hard

Of course, you can already do this by making your first command a delay (for positive differentials anyways)

colinjones

  • Alumni
  • LinuxMCE God
  • *
  • Posts: 3003
    • View Profile
Re: Event criteria for daytime or nighttime
« Reply #9 on: November 12, 2008, 08:30:07 pm »
I've seen that suggestion before, however as you point out it can only work for delays and my main concern is to bring forward sunrise to turn on a light before it gets too dark!

Actually, fading in a light from an earlier time would be nice, too!

jeangot

  • Guru
  • ****
  • Posts: 233
    • View Profile
Re: Event criteria for daytime or nighttime
« Reply #10 on: November 12, 2008, 10:27:01 pm »
Jon,

not sure if I can make it to IRC this week, as I have to prepare things for my trip. If not, I could only do it in the first week of December. What timezone are you in? I am in PST (USA West Coast).

Is there any way to enable additional debug information for DCERouter.log, maybe something that would tell us how it's evaluating these expressions, and where it's not following the procedure that you describe?

Jean

jondecker76

  • Alumni
  • wants to work for LinuxMCE
  • *
  • Posts: 763
    • View Profile
Re: Event criteria for daytime or nighttime
« Reply #11 on: November 12, 2008, 10:52:16 pm »
I'm going to add some logwrapper commands around the evaluation on my local copy and see whats going on

I'm EST timezone (in Ohio)

freymann

  • Douchebag
  • Guru
  • *
  • Posts: 380
    • View Profile
Re: Event criteria for daytime or nighttime
« Reply #12 on: November 13, 2008, 03:31:38 am »
I'm EST timezone (in Ohio)

 I'm ET too (Ontario, Canada) and I have some X10 stuff here and the CM11A controller.

 If I can help test/report anything let me know.

 I have:

dimmable lamp modules (LM465, WS12A)
2-way transceiver module (RR501)
on/off lamp modules (LM15A)
appliance modules (AM466)
keychain remotes (KR22A)
and just ordered today, 3 x eagleEye Motion Sensors (MS14A) for use on the front/rear doors, and basement furnace room.