Sounds like a perfect job for the xtypes system. See this wiki article: *WeeWX
V4 user defined types (xtypes)*
<https://github.com/weewx/weewx/wiki/WeeWX-V4-user-defined-types>. See if
it answers your question.

If you define a derived variable using xtypes, it becomes a first-class
type and can be used in plots, or tagged expressions. If it appears in your
database schema, it will also be put in the database.

-tk

On Fri, May 22, 2020 at 7:14 AM Maarten van der Hoeven <hoeve...@gmail.com>
wrote:

> Hi group,
>
> Running weewx 4, Python 3, Mysql-database, Vantage Pro 2 with solar, UV.
>
> Within Weewx, I want to calculate a derived value from two existing values
> that's provided by my weather station. To be more specific, in the
> Netherlands, the shortage of precipitation is calculated by the amount of
> rainfall minus the amount of evapotransipration (sum of max ET-values every
> day). During the period of april till september, it;'s a drought indicator.
>
> My SQL-query to do show is, where 'tekort'  (Dutch) stands for 'shortage'.
>
> select abs(round(sum(archive_day_rain.sum)-sum(archive_day_ET.sum),0)) as
> tekort from archive_day_ET,archive_day_rain where
> from_unixtime(archive_day_rain.datetime,'%Y')=year(curdate()) and
> month(from_unixtime(archive_day_rain.datetime)) >= 4 and
> month(from_unixtime(archive_day_rain.datetime)) <= 9 and
> archive_day_rain.datetime=archive_day_ET.datetime;
>
> What I am doing right now, is running a crontab job, and start my
> PHP-script every minute to calculate the outcome of the SQL-script above
> and writes the outcome to a plan txt-file. Next step is to grab this value
> from the txt-file and show it (javascript) on my website. See
> http://www.weerinwelsum.nl, below the webcam. It says ' Doorlopend
> neerslagtekort', [amount of millimeters]. This is the value I am talking
> about.
>
> What I really want to achieve, is that I calculate this derived valu by
> WeeWX itself, and make this derived value available for everything that's
> wants to use is. For example, store this derived value in a database-field
> I am not using (for example, soilTemp4) and make this derived value
> available for whatever skin (in my case, Belchertown). In other words,
> Weewx calculates this new value and makes it available for the complete
> WeeWX-ecosystem (if you understand what I mean).
>
> Am I clear in what I want to achieve? And is this possible, and what are
> the pointers to do so?
>
> --
> 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/d48cfc39-5e17-4795-a75f-ac4c266e73b0%40googlegroups.com
> <https://groups.google.com/d/msgid/weewx-user/d48cfc39-5e17-4795-a75f-ac4c266e73b0%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/CAPq0zEAAbYg%2BVYa-3oe_j-43z3fP0Sn6h9oyaaimcydcMFLdbg%40mail.gmail.com.

Reply via email to