Created new thread about this topic
I found another code that directly calculates sunset and sunrise.
I had to modify it a bit, but it works as a driver module
I will continue creating the capabilities to see what happens.
It would be nice if this was implemented on a virtual device so you don’t have to use a real device to run it.
In this of creating virtual devices I have no experience
2022-05-25T15:08:21.306571599+00:00 PRINT Zigbee Thing Sun <<< Sunrise: 06:50:00 Sunset: 21:33:00 Day Duration: 14 Hrs 43.0 Min >>> 2022-05-25T15:08:21.313002932+00:00 PRINT Zigbee Thing Sun <<< Sunrise: 06:50:00 Sunset: 21:33:00 Day Duration: 14 Hrs 43.0 Min >>>
I made the capabilities and preferences of offset local time, latitude and longitude
I will make the offset to sunrise and sunset references
I have made this driver that locally calculates sunrise, sunset, day length, offset from the current time to sunrise and sunset, which allows automation with up to +/- 600 minutes of sunrise or sunset
The offset time is calculated every 1 minute
I have tried an automation and it works, now I have not been able to test with a negative offset since the latest version of the app does not let me enter negative values
I will keep testing and adjusting
If anyone wants to try it, it’s on my shared channel.
┌─────────────┬──────────────────────────────────────┐ │ Name │ Zigbee Sunrise and Sunset Mc │ │ Version │ 2022-05-25T20:20:17.093509387 │ └─────────────┴──────────────────────────────────────┘
You just have to:
- install it on the hub
- do a driver change on any zigbee device you are using with an edge driver
- That device will not lose anything that it has configured
- You can go back to your original driver without losing anything
- You can use a plug or sensor that you are not using on something important
Is the copy/paste trick not working anymore? (Copy this
- and paste it first then enter the number. Or copy
-30 or whatever value you need…)
Otherwise, I thought this bug has been fixed ages ago.
@orangebucket, will you give it a try? This might solve all your problem with the built in way, and will give a longer offset than the default 60 minutes.
Yes, this worked perfectly until today I updated the version of the android app
The ideal for this would be to implement the code in a virtual edge device.
I have never created one, maybe @TAustin could do it when he will is less involved with the cameras
@orangebucket, considering when was last time this negative value misery, it should be considered as well, that someone removed all the fixes what has been implemented in the app during the years and caused a bunch of regressions… (including your original problem)
Indeed, back in 2020!
The 60 minute offset is just the app bods making it up again, though I guess it might have been based on a real limitation before the Rules API took over. I have three trivial Routines, and that is three too many. Same with Scenes. Unless and until they can be managed outside the app they can’t be taken seriously.
My problem is that if the Rules API doesn’t work then there isn’t much fun left in SmartThings at all. Edge drivers have no appeal for me. Maybe if they were only used for LAN stuff I’d get it, but I see one solution where two were needed, and nothing is going to make Lua attractive.
I’ve only just twigged that there is an update to the app. I believe the OED are planning to amend their entry for
FFS to say ‘See SmartThings app’.
I have modified the driver so that it calculates the sunrise and sunset offsets correctly when the day changes in the user’s location, since the sunsrise and sunset calculation code is performed with UTC time.
I hope it works fine both in local time with positive and negative UTC offsets
I have removed the visibility of the offset sunrise and susnset events so that the app history is not shown every minute
┌─────────────┬──────────────────────────────────────┐ │ Name │ Zigbee Sunrise and Sunset Mc │ │ Version │ 2022-05-26T10:13:13.405145088 │ └─────────────┴──────────────────────────────────────┘
Something is wrong with day length. This is actually Night length.
Edit: I have actually calculated night and day time
What is “Sunset Offset to Local time”? Is this Time to Sunset?
What is “Sunrise Offset to Local time”? Is this Time to Sunrise?
Also this timers are changing in opposite direction from what I have expected.
Anyway sunrise and sunset times are correct
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
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
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.
┌─────────────┬──────────────────────────────────────┐ │ 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.