Rules / Variables based on Date or Calendar

I’m brand new to SharpTools but am working on redoing everything I had in WebCoRE as Samsung is killing off Groovy.
I have a piston that sets 3 of my light posts outside to various colors depending on the date range (near Christmas they’re red/green/blue, Near Easter, they’re pastel colors, etc). I’m trying to figure out how to replicate that in SharpTools, but I can’t see a way to use either a date range or a calendar entry.
Is it possible?

1 Like

Hi

I would like to create two variables, one that equals the day of the week Monday, Tuesday, etc.

and the second one would be in the format 01.01.2022

how can i do that, i haven’t found any automation that could put just these values into variables

hello

Still a nooby question, is there some system variable available?
Like, now, date, month, to have the current date, the current month, the current dateTime ?

To be able to make some condition based on those context variable

Thanks!

Hi

I asked about it too

I managed to deal with the variables that indicate the days of the week, Monday, Tuesday, etc.

I created a Rule triggered by opening a webhook link with a variable, CRON from the hosting server opens a similar link every day, but ending on Monday, Tuesday, etc.

and what is in the link is entered as the value of the variable.

But I will not write the calendar for the whole year like this: D

Damn that seem pretty complicated haha

For the moment a piston I’m trying to convert only need to compare a date variable with sysdate

Pretty basic stuff

1 Like

Day, time and date variables are a good thing
Plus weather variables, current weather, expected rain, temperature and humidity

It would be perfect

Hi there! I hope you don’t mind that I’ve merged these three topics together. While there are some minor differences between them, it sounds like the overall need is for better control over dates/times – either directly through conditions or potentially through a proposed ‘Date/Time’ type of variable.

Would you see this as a potential addition in the ‘Time’ trigger section? Currently, you can use the Time trigger and either trigger every day or adjust it to only trigger certain days of the week.

Perhaps in addition to the ‘daily’ and ‘weekly’ option, there could be some other choice for broader date ranges. Similarly, there’s an IF Condition for Day / Time and perhaps a date range option could be added there as well.

1 Like

Do you have an example use-cases you could share? We could certainly create variables for current date / month / timestamp, but we’ve held off on it as there hadn’t been any requests for it so far and the use cases weren’t particularly clear.

If you’re just looking to trigger a rule based on different days of the week, you can do this with the Time Trigger. See the screenshots two posts up – you can tap the ‘Everyday’ in my screenshot which brings up the Repeat Options. From here, you can select ‘weekly’ and choose which days of the week you want to trigger things on.

Do you have any weather devices attached to your SmartThings account? If so, do they not include the data you’re looking for?

@josh - variables are so much better that you can use them in notifications, eg “Hi, It’s Monday, September 20, moderate cloudiness”

Do you have any weather devices attached to your SmartThings account? If so, do they not include the data you’re looking for?

I have an outside temperature sensor, but it doesn’t show the weather. The easiest way would be to extract data from the integration with https://openweathermap.org/ and on their basis set constant variables, such as the current weather forecast, humidity, temperature, etc.

Thanks. I suspected there was more than just the ‘variable’ part of things. It sounds like some controls around formatting the dates would be important in that case too. :slight_smile:

Can you share some examples of how you format these date/timestamp variables today? It seems like it could be something that would feel overwhelming to a new user… but perhaps it’s just more of an ‘advanced’ feature and naturally requires a bit more configuration if you want to customize the format.

Currently in Homey Bridge I have one date format and I accept it as it is DD.MM.YYYY you can define 2 or 3 formats permanently in the settings or for very demanding users make 3 variables
current day (e.g. 20), current month digitally or in words (08) and current year 2022 and you can write in the notification

E.g. “Hey, it’s {day}. {Month}. {Year}, current weather: it’s raining”

Similarly, with the time we are from different parts of the world, some use 24 hours, others AM / PM

You can do this with the HTTP Action in SharpTools today. I agree that it makes for a good feature request as a native integration though to simplify this process for people who don’t have weather devices attached to their SmartThings. :smiley:

Let’s take the Open Weather /weather endpoint which provides the current weather. The URL is in the format:

https://api.openweathermap.org/data/2.5/weather?lat=-33&lon=96&appid={{ApiKey}}

And the response is in the format:

{
   "coord":{
      "lon":96,
      "lat":-33
   },
   "weather":[
      {
         "id":500,
         "main":"Rain",
         "description":"light rain",
         "icon":"10n"
      }
   ],
   "base":"stations",
   "main":{
      "temp":286.4,
      "feels_like":286.08,
      "temp_min":286.4,
      "temp_max":286.4,
      "pressure":1032,
      "humidity":88,
      "sea_level":1032,
      "grnd_level":1032
   },
   "visibility":10000,
   "wind":{
      "speed":6.89,
      "deg":143,
      "gust":7.83
   },
   "rain":{
      "1h":0.19
   },
   "clouds":{
      "all":97
   },
   "dt":1661023588,
   "sys":{
      "sunrise":1661040462,
      "sunset":1661080271
   },
   "timezone":21600,
   "id":0,
   "name":"",
   "cod":200
}

So if we wanted to get the main weather report, we would be looking for the weather.0.main element in the response. So we can make the HTTP call and then get the response data using Context Variables (Response > HTTP > Data) and use the object property notation to grab that nested property for use in our notification:

Thanks for the feedback. In our Super Tiles, since they are running in the browser, we can infer your ‘locale’ and use that to display things in the timezone and format your computer / tablet prefers.

For Rules, we typically associate things with ‘locations’ since some people have multiple locations attached to their account – for example, their main home and a vacation home. We use that for determining the appropriate localized time for triggering rules. I suspect we could either add user-level or location-level formatting options. Originally I was thinking you might want a rule action like Format Date where you could customize the date for that particular notification just to pull out the parts you are interested in (similar to our Super Tile date/time format options).

I love your advice right away in a few hours :slight_smile: Divine!

Yes, but how do I pair it with variables? I would like to use them in notifications?

My apologies for not being clear – I was just trying to better understand the use-cases. We don’t have it available as Rule Variables today, but if we eventually build it I want to make sure I understand how people use it so we can make the right design. :smiley:

Thanks! :slight_smile:

Sorry, my English is terrible.

Generally, it is about notifications in which you can use the date, sometimes in simple such as hello is a day, and sometimes in emergency such as “At 12:00 on August 20, 2022, a movement in the garage has been detected”

The weather works perfectly, I take the data I need from the API, you are great!

1 Like

I was able to download weather.0.description from the data, but I would like to download the temperature data in the same query and how it adds main.0. temp is unfortunately nothing changes in variables, can you tell me what am i doing wrong?

Ok, I did it, I don’t know why you put “0” there, what does it mean, what does it mean?


Sorry, I call myself variables in Polish, I think you might guess what’s going on: D