Kalli,

I've added an approximation for sunshine time to WeeWX-WD. The algorithm 
involves calculating the elapsed time in seconds for which the WeeWX field '
radiation' is above a set threshold level and storing this time in field '
sunshine' in the WeeWX-WD database weewxwd.sdb. The default threshold level 
is 120 W/m2, but can be adjusted using the sunshine_threshold config item 
under the [Weewx-WD] stanza in weewx.conf. So in an archive record if 
radiation is above the threshold value the sunshine field will be set to 
the interval (in seconds) covered by the archive record. So if your archive 
interval is set to 300, field sunshine in that archive record would contain 
300, if radiation was below the threshold value then field sunshine will be 
0. Field sunshine is not added to loop packets, only archive records. 

You can then use field sunshine in report tags just like other WeeWX 
fields, though you will need to set the binding for each tag. For example, 
the sunshine time for today would be:

$day($data_binding='wd_binding').sunshine.sum

I have also populated the sunshine hour tags in testtags.php, so any 
sites/apps that use sunshine hours from testtags.php should now display 
data. I am not sure what FreshWDL uses, let's get WeeWX-WD working properly 
with sunshine then we can come back to FreshWDL if necessary.

Unfortunately you are going to have to upgrade to WeeWX-WD v2.1.0, adding '
sunshine' to a WeeWX-WD v1.x version was more work than I was prepared to 
do. The upgrade process is straight forward and I have detailed the steps 
below.

To upgrade WeeWX-WD v1.x to v2.1.0 (the following steps are based on you 
having a package install rather than a setup.py install, if you have a 
setup.py install let me know and I will provide appropriate instructions):

1. download the v2.1.0 extension package:

$ wget -P /var/tmp 
https://github.com/gjr80/weewx-weewx-wd/releases/download/v2.1.0/weewxwd-2.1.0.tar.gz

2. stop WeeWX and backup your WeeWX and WeeWX-WD databases:

$ sudo cp /var/lib/weewx/weewx.sdb /var/lib/weewx/weewx_backup.sdb
$ sudo cp /var/lib/weewx/weewxwd.sdb /var/lib/weewx/weewxwd_backup.sdb

3. install v2.1.0:

$ sudo wee_extension --install=/var/tmp/weewxwd-2.1.0.tar.gz

4. remove some v1.x residue that the installer cannot remove:

$ sudo rm -R /etc/weewx/skins/SteelGauges
$ sudo rm /usr/share/weewx/user/imageStackedWindRose3.py*
$ sudo rm /usr/share/weewx/user/wd_database
$ sudo rm /usr/share/weewx/user/wdAstroSearchX3.py*
$ sudo rm /usr/share/weewx/user/wdSearchX3.py*
$ sudo rm /usr/share/weewx/user/wdTaggedStats3.py*
$ sudo rm /usr/share/weewx/user/weewxwd3.py*

5. edit weewx.conf and make the following changes:

- under [StdReport] delete the [[wdSteelGauges]] stanza in full
- under [DataBindings] [[wd_binding]] change:

    schema = user.weewxwd3.schema

    to

    schema = user.wdschema.weewxwd_schema

- under [Engine] [[Services]] delete the user.weewxwd3.WdWXCalculate entry 
from process_services
- under [Engine] [[Services]] delete user.weewxwd3.WdArchive from 
archive_services

WeeWX-WD will now add a field 'sunshine' to each archive record but it will 
not be saved to database (whilst the WeeWX-WD database schema now includes 
field 'sunshine' your WeeWX-WD database will not include field 'sunshine' 
as the database was created using the old WeeWX-WD schema). To add field 
sunshine to the WeeWX-WD database: 

1. use the utility wee_database to create a new copy WeeWX-WD database with 
the new schema and populate it with data from the old WeeWX-WD database:

$ sudo wee_database /etc/weewx/weewx.conf --reconfigure --binding=wd_binding

2. you will now have a new WeeWX-WD database named weewxwd.sdb_new that 
includes field sunshine, you now need to swap your old WeeWX-WD database 
for this new database:

$ sudo mv /var/lib/weewx/weewxwd.sdb /var/lib/weewx/weewxwd_orig.sdb
$ sudo mv /var/lib/weewx/weewxwd.sdb_new /var/lib/weewx/weewxwd.sdb

3. the daily summaries in the new database should be rebuilt on the next 
WeeWX startup but let's do it manually to make sure:

$ sudo wee_database /etc/weewx/weewx.conf --binding=wd_binding 
--rebuild-daily

You should now be able to restart WeeWX and WeeWX-WD will populate field 
sunshine in the WeeWX-WD database and the sunshine hours fields in 
testtags.php should also be populated.

Gary
On Monday, 2 November 2020 at 08:26:42 UTC+10 gjr80 wrote:

> Hi Kalli,
>
> Have written the code but just sorting out a couple of unrelated issues 
> that are causing problems under WeeWX v3.8.0. Won't be long.
>
> Gary
>
> On Sunday, 1 November 2020 at 23:26:07 UTC+10 Kalli wrote:
>
>> Hello Gir80
>> I'm curious what you're doing great again.
>>
>> cu.Kalli
>>
>>
>>
>> Am Dienstag, 27. Oktober 2020 22:39:17 UTC+1 schrieb gjr80:
>>>
>>> Thanks Kalli, I will put something together and email you.
>>>
>>> Gary
>>>
>>> On Wednesday, 28 October 2020 at 01:52:30 UTC+10 Kalli wrote:
>>>
>>>> Gir80 I have the weewx 3.8 weewx wd v1.3 
>>>>
>>>> tke...@gmail.com schrieb am Dienstag, 27. Oktober 2020 um 13:40:39 
>>>> UTC+1:
>>>>
>>>>> Never mind!
>>>>>
>>>>> On Tue, Oct 27, 2020 at 5:39 AM gjr80 <gjrod...@gmail.com> wrote:
>>>>>
>>>>>> Tom,
>>>>>>
>>>>>> I suspect that in this case FreshWDL is displaying sunshine hours as 
>>>>>> measured by a sunshine recorder 
>>>>>> <https://en.wikipedia.org/wiki/Sunshine_recorder>. Some PWS software 
>>>>>> approximates sunshine hours by calculating the cumulative time for a day 
>>>>>> where the solar irradiance is above a given level. From memory the 
>>>>>> measurement of sunshine hours has come up a couple of times here or in 
>>>>>> weewx-development.
>>>>>>
>>>>>> Gary
>>>>>> On Tuesday, 27 October 2020 at 22:25:34 UTC+10 tke...@gmail.com 
>>>>>> wrote:
>>>>>>
>>>>>>> The Seasons skin has something you can use. Look in the file 
>>>>>>> celestial.inc. 
>>>>>>>
>>>>>>> If you just want amount of daylight, try something like (NOT TESTED):
>>>>>>>
>>>>>>> #set $sunrise_ts = $almanac.sun.rise.raw
>>>>>>> #set $sunset_ts = $almanac.sun.set.raw
>>>>>>> #if $sunrise_ts and $sunset_ts
>>>>>>>
>>>>>>>     #set $today_daylight = $sunset_ts -  $sunrise_ts
>>>>>>>     #set $seconds = $today_daylight
>>>>>>>     #set $hours = $seconds //3600
>>>>>>>     #set $seconds %= 3600
>>>>>>>     #set $minutes = $seconds//60
>>>>>>>     #set $seconds %= 60
>>>>>>>     #set $daylight_str = "%d hours, %d minutes, %d seconds" % 
>>>>>>> ($hours, $minutes, $seconds)
>>>>>>>
>>>>>>>     <p>Total daylight: $daylight_str</p>
>>>>>>>
>>>>>>> #end if
>>>>>>>
>>>>>>> -tk
>>>>>>>
>>>>>>> On Mon, Oct 26, 2020 at 7:55 PM gjr80 <gjrod...@gmail.com> wrote:
>>>>>>>
>>>>>>>> Hallo Kalli,
>>>>>>>>
>>>>>>>> The short answer is at the moment sunshine hours is not provided by 
>>>>>>>> WeeWX or WeeWX-WD. Looking at the WeeWX-WD code it appears to be 
>>>>>>>> something 
>>>>>>>> I started working on but never fully implemented. Can you let me know 
>>>>>>>> hat 
>>>>>>>> version of WeeWX and WeeWX-WD you are running. It should be a simple 
>>>>>>>> function to implement.
>>>>>>>>
>>>>>>>> Gary
>>>>>>>>
>>>>>>>> On Tuesday, 27 October 2020 at 03:16:23 UTC+10 Kalli wrote:
>>>>>>>>
>>>>>>>>>
>>>>>>>>> Hello i have weewx-wd. in FreshWDL the sun is displayed. 
>>>>>>>>> unfortunately i can't find any settings for it at weewx. Can anybody 
>>>>>>>>> help 
>>>>>>>>> me further. 
>>>>>>>>
>>>>>>>> -- 
>>>>>>>> You received this message because you are subscribed to the Google 
>>>>>>>> Groups "weewx-user" group.
>>>>>>>> To unsubscribe from this group and stop receiving emails from it, 
>>>>>>>> send an email to weewx-user+...@googlegroups.com.
>>>>>>>> To view this discussion on the web visit 
>>>>>>>> https://groups.google.com/d/msgid/weewx-user/884f712b-74c8-4bd4-8655-74610e4f94dcn%40googlegroups.com
>>>>>>>>  
>>>>>>>> <https://groups.google.com/d/msgid/weewx-user/884f712b-74c8-4bd4-8655-74610e4f94dcn%40googlegroups.com?utm_medium=email&utm_source=footer>
>>>>>>>> .
>>>>>>>>
>>>>>>> -- 
>>>>>> You received this message because you are subscribed to the Google 
>>>>>> Groups "weewx-user" group.
>>>>>> To unsubscribe from this group and stop receiving emails from it, 
>>>>>> send an email to weewx-user+...@googlegroups.com.
>>>>>>
>>>>> To view this discussion on the web visit 
>>>>>> https://groups.google.com/d/msgid/weewx-user/3ad7fb34-745e-40bd-8e65-454da4c0c701n%40googlegroups.com
>>>>>>  
>>>>>> <https://groups.google.com/d/msgid/weewx-user/3ad7fb34-745e-40bd-8e65-454da4c0c701n%40googlegroups.com?utm_medium=email&utm_source=footer>
>>>>>> .
>>>>>>
>>>>>

-- 
You received this message because you are subscribed to the Google Groups 
"weewx-user" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to weewx-user+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/weewx-user/28ed7084-b28f-4011-9129-b413ebe19bd9n%40googlegroups.com.

Reply via email to