Sunrise-Sunset and Calendar functions for edge

@TAustin could you please help @Mariano_Colmenarejo create virtual device?

hello @milandjurovic71

the calculation module that I found on the internet, does all the calculations with the table format of the UTC time that lua sends.

In calculation of the data for the new day does it at 0 hours UTC and the calculations of the difference of local time with sunrise and sunset would not be correct until they are 0 hours UTC.

I made some corrections for the calculation of the offsets with the local time and I must have done it wrong

I tried it for positive local hours, in my case +2.

For the negatives it seems that I made the corrections wrong.

i will correct it

1 Like


Try now with this version.

│ Name        │ Zigbee Sunrise and Sunset Mc         │
│ Version     │ 2022-06-09T11:21:37.349590437        │

I have simulated your Lat, Long and local time and it works fine.

It only remains to check if the calculation of the offsets works well when the local time is greater than 7:00 p.m. (0h UTC - your local offset time) and less than 0:00 a.m.

The Sunrise Offset is the time in minutes remaining, if negative, for sunrise or the time that has elapsed, if positive, since sunrise.

Same for the Sunset Offset.

Offset times are the time that can be used in automations to activate or deactivate x time in minutes before or after Sunrise or Sunset

1 Like

Looking good.

Only thing that i would suggest is to use absolute number in time, and if possible to change wording for negative numbers to say “from”, and for positive to say “to”

Time “to/from” Local Sunset
Time “to/from” Local Sunrise

It would look cleaner

Doing this is equivalent to having to use 4 capabilities instead of 2.

I have used the same concept that smart lighting has used for years:
(-) for before…
(+) for after…

In any case this would only be useful for times greater than 60 minutes before and after sunrise and sunset, when smart lighting disappears.

Sunset and sunrise are local in the app routines and if smartthings increase the time before and after to more than 60 minutes, it would no longer have any added value


New name and version of the driver Zigbee Sunrise and Sunset Mc (Zigbee Calendar Mc)

  • To give it some utility more than a calculation of susrise and sunset with offsets, I have added Calendar functions to this driver, since from time to time someone needs to use it to automate irrigation or other things, that they need to use IFTT for example:
  • Added Capabilities of Date one and two:
    • They allow to make automations for period between dates
    • In order to make equal, greater or lesser comparisons, the chosen format must be an integer number.
    • The format to build a representative and comparable number of a date will be YYYYMMDD, that is, for today 2022, June, 10 it would be: 20220610
    • I didn’t find another way to enter usable data formant of date,
  • Capability Hour of the day: In this way it can be combined with sunrise and sunset to perform periods of sunrise or sunset and a fixed hour or less or greater than one hour.
  • Capability Day of the month: In this way you can make automations for a specific day of each month
  • Capability of the Month of the year: in this way automations can be made for a specific month of the year
  • Capability for Year: In case you need to do automation for a specific year
  • Capability to select Odd or Even days of the month: Automations can be made only for select odd or even days of each month.
  • All this can be combined with standard time preconditions such as day of the week or hour interval

I have installed in a plug that has a bad relay and I use it only as a repeater.
Can be used on any zigbee device that has no use.

If a battery device is used, no matter if the battery is depleted or removed, it will remain online indefinitely as a virtual device. Only the physical device will be needed to be able to uninstall the driver from your hub.

Automation Conditions:

Driver version:

│ Name        │ Zigbee Calendar Mc                   │
│ Version     │ 2022-06-10T11:43:41.621583325        │

If anyone finds something wrong or could be improved, please let me know.


Maybe Samsung should just hire Mariano?
Because the internal dev team is seriously lagging behind.



@Mariano_Colmenarejo is a valuable Community member and he’s been developing awesome custom functionality using all the tools provided to developers (eg. custom capabilities) which is their purpose.

There are a lot of different use cases, and we report the feature requests that you all share with us. This way, the team is able to analyze those needs and implement them if necessary.

If you consider there’s a capability that could help everyone, we can create a request for it to be developed as a stock capability.

1 Like

Hi Nayely,
Since you say it would be useful to have a Calendar function for automations, added to the time or separately.

I have also missed a presentation for date/time type data entry, as exists in the groovy smartApps


@Mariano_Colmenarejo I don’t see this new driver yet

Edit: Disregard, Found it

@Mariano_Colmenarejo this looks great. Only function that I am missing from IFTTT’s Date and Time is Every Day of the Week, where you can select for example every Monday, etc. I think that is also available in Lua.
Great work.
Now I don’t need to depend on IFTTT, as everything is done in house

This is what I was using to reset your Energy Consumption each 1st of the month

1 Like

As they are independent capabilities you can use the day of the month and the stock time or the custom hour to do it.

I’m glad it’s helpful

1 Like

Any chance you can add week days?

Yuo can use the stock week days functions as precondition with all others conditions

I had it done, but I saw that the stock function worked better

1 Like

You are right.

Ok, so, your request is to have better options to define automation using time as a condition.
Taking your driver into consideration, I can list the following:

  • Greater offset for Sunrise and Sunset conditions. That’s already a request (see this post)
  • Select a range of dates or a specific day, month and year for the automation.
    • As part of this, there should be an option to define the specific hour of the day
  • Option to define different intervals, like every two days, even or odd days
  • Be able to select a specific day of the month

Please, let me know other time conditions you’d like to see in automation.


That’s right.

For the time, the function stock specific hour, period… works fine

Being able to choose a specific day of the month is also requested by some users.

There are also users who need to select even or odd days for irrigation, for example


New version of the driver as a virtual device. Virtual Calendar Mc.

I thought it was more difficult to make a virtual device and by modifying the Hello Word stock example it was very easy to adapt the zigbee driver to a new virtual LAN device.

Thank you Smartthings Team for your good work on the LUA libraries, you have made it much easier to do new things with Edge. We criticize you when things don’t work and it’s fair to recognize you when you do it right!

  • Install the Virtual Calendar Mc driver in your Hub
  • In the App search nearby.
  • In preferences:
    • Enter the offset of your local time with UTC time
    • Enter the coordinates, latitude and longitude of your location, rounded to 1 decimal. You can get it from Google Maps

Driver version:

│ Name        │ Virtual Calendar Mc                  │
│ Package Key │ virtual-calendar                     │
│ Version     │ 2022-06-11T10:49:35.050606762        │

@Mariano_Colmenarejo @nayelyz is there a way for Mariano to add Time icon to this driver?
Time icon can be found in Routines under IF (conditions)


For now, Do you like this wine fridge icon highlighted in blue? and you could change it for one of these marked in green

UPDATE: this version has the icons

│ Name        │ Virtual Calendar Mc                  │
│ Version     │ 2022-06-11T13:32:39.681492727        │
1 Like