[SOLVED] Help creating timeslots

Hi folks,

I’m trying to reduce my power consumption at home, and I would like to manage my devices in accordance with the current energy timeslot.

In facts, I have 3 timeslots:

F1: Mon/Fri 8-19
F2: Mon/Fri 7-8 and 19-23, and Sat all day
F3: remaining (Mon/Fri 23-7 and Sun all day)

Any suggestion how to create a rule for this?

I was thinking … item Timeslot, when time is 8-18 MON/FRI, set Timeslot to F1, .and so on … but what should be the trigger?

thanks for your suggestion

Regards
Andrea

See:

I’m trying with this rule

rule "Energy Timeslot"
when
    Time cron "0 0 0/1 1/1 * ? *" or
    System started
then
   if ((now.getDayOfWeek == 1) && (LocalTime_Holiday == OFF)) {
        if (now.getHourOfDay < 7) {
            Auto_Energy_Timeslot.postUpdate(3)
        }
        else if (now.getHourOfDay < 8) {
            Auto_Energy_Timeslot.postUpdate(2)
        }
        else if (now.getHourOfDay < 19) {
            Auto_Energy_Timeslot.postUpdate(1)
        }
        else if (now.getHourOfDay < 23) {
            Auto_Energy_Timeslot.postUpdate(2)
        }
        else if (now.getHourOfDay >= 23) {
            Auto_Energy_Timeslot.postUpdate(3)
        }
    }

and so on for Tue, Wed, etc …

But Auto_Energy_Timeslot is always 3 … mmm

Do you see any visible error?

Thanks
Andrea

Try that:

rule "Energy Timeslot"
when
    Time cron "0 0 0/1 1/1 * ? *" or
    System started
then
   if ((now.getDayOfWeek == 1) && (LocalTime_Holiday == OFF)) {
        val int thisHour = now.getHourOfDay
        switch thisHour {
            case thisHour < 7: Auto_Energy_Timeslot.postUpdate(3)
            case thisHour = 7: Auto_Energy_Timeslot.postUpdate(2)
            case (thisHour > 7 && thisHour < 19): Auto_Energy_Timeslot.postUpdate(1)
            case (thisHour >= 19 && this Hour < 23): Auto_Energy_Timeslot.postUpdate(2)
            case thisHour >= 23: Auto_Energy_Timeslot.postUpdate(3)
        }
    }
end

Same … always 3. I’ve just restarted the system.

in my logs:

2018-12-31 11:11:27.052 [INFO ] [el.core.internal.ModelRepositoryImpl] - Validation issues found in configuration model 'power-consumption.rules', using it anyway:
Assignment to final variable

My fault:
case thisHour == 7: Auto_Energy_Timeslot.postUpdate(2)

Double ==

still 3 :frowning:

Found it, I think

LocalTime_Holiday.state == OFF

ooh …f… yes, it did the trick :slight_smile:

thanks

Andrea