Days of the week

Hello

I just wanted to check I’m not missing something. I want to do different automation at weekends. There’s no way for RulesAPI to know either weekday or day of week, is there?

I can make a virtual switch or change the location mode in the app, but I just wanted to check there’s no way to run an action only on a Sunday, say?

Hi @robcmorgan
You can use routines with the previous condition of time, at any time and choosing the days of the week that you need.

If you want to use the rules API, I don’t know, but you could make a routine to activate a virtual device on weekends and use the API rules with this device

2 Likes

Are you writing JSON directly and publishing via Rules API or are you creating routines in the mobile app? As Marianom mentioned, you can add days under the Time option on the IF side of Routines. And Routines calls the Rules API in the background, so I assume you can do it via raw JSON too.

2 Likes

There should be, as Routines can do it and they use the Rules API. However they have access to some bits and bobs that aren’t available to the public. Let’s see …

Yes, it looks like you use something like:

"date": {
    "daysOfWeek": [ "Sun" ]
}

So three letter abbreviations for the days of the week in an array.

2 Likes

Hi, thanks everyone. Yes, I’m just getting started writing JSON in the Rules API.

I’ve made a virtual switch that activates at weekends and gone from there. It’s not difficult, but I had that feeling I was doing everything the wrong way.

Ah, that looks the sort of thing I was expecting, yes, thanks.

Was there any way I should have been able to find that out?

Well it is in the API reference, though that can be as clear as mud.

API | SmartThings Developers

1 Like

Oh I see. I hadn’t understood how to click around in that document, or that the search doesn’t work until you do.

So now I’ve learned something.

Could you let me know how you managed that? I am trying to write a rule to manage daylight time and “daysOfweek” is tripping me up.

Thank you.

And the answer is…

            "equals":{
               "left":{
                  "date":{
                     "daysOfWeek":[
                        "Sun"
                     ]
                  }
             },
               "right":{
                   "date": {
                       "reference": "Today"
                   }
               }
            },

Hi, you were ahead of me. Here’s mine that’s working now (as YAML)

actions:
  - every:
      specific:
        daysOfWeek: [Sat,Sun]
        reference: Midnight
        offset:
          value:
            integer: 33
          unit: Minute
      actions:
      - command:        

Thanks