Hello Tom!

Thank you for your hint.

This means that data_type is evaluated as SQL within the field list.

In sqlite, of course, you can use the IIF you suggested

In general, this is also possible in SQL with the following example:

data_type = "CASE WHEN outTemp < 48.0 THEN 32.0 ELSE null END"

But a corresponding if was also built into mysql:

https://www.w3schools.com/sql/func_mysql_if.asp

Thank you for the great software weewx and your support
tke...@gmail.com schrieb am Dienstag, 15. März 2022 um 22:46:36 UTC+1:

> Update on this issue.
>
> First: I was wrong. The problem is not that weewx is attempting to 
> evaluate the constant as an xtype. The problem is in how we autoconfigure 
> which plots to create. The templates test to see whether there is any data 
> in a plot before deciding whether to generate it. 
>
> There is a workaround, which involves abandoning the test. In the file 
> telemetry.html.tmpl you'll find a stretch that looks something like this:
>
>     #for obs in $getobs($plot_name)
>       #if $getVar('year.%s.has_data' % $obs)
>         #set $show_plot = 1
>       #end if
>     #end for
>
> Comment out the highlighted lines by using double hash marks, so it 
> becomes:
>
>     #for obs in $getobs($plot_name)
>       ##if $getVar('year.%s.has_data' % $obs)
>         #set $show_plot = 1
>       ##end if
>     #end for
>
> Now if you use an [ImageGenerator] spec such as the below, it will work:
>
>         [[[dayvolt]]]
>             yscale = 3.6, 4.2, 0.1
>             [[[[consBatteryVoltage]]]]
>                 label = Transmitter battery
>                 color = 0xb48242    # blue
>             [[[[voltMin]]]]
>                 data_type = 3.7
>
>                 label = ' '
>                 color = orange
>                 width = 1
>
> To user "plinepa": 
>
> You can do what you want by using the SQLite function "IIF() 
> <https://www.sqlite.org/lang_corefunc.html#iif>". Unfortunately, it is 
> available only in SQLite 3.32 and later, which came out about 2 years ago. 
> It's still pretty rare, but you might get lucky. In that case, assuming 
> your database is in US Customary units, you could do something like this:
>
> [[[dayoutTemp]]]
>     [[[[outTemp]]]]
>     [[[[freezing]]]]
>         data_type = "IIF(outTemp<48.0, 32.0, null)"
>         label = ' '
>
> This produces a plot that looks like:
>
> [image: image.png]
>
> -tk
>
> On Tue, Mar 8, 2022 at 10:42 PM 'pli...@googlemail.com' via weewx-user <
> weewx...@googlegroups.com> wrote:
>
>> I am a beginnger and use the Seasons skin, I forgot to write that
>>
>> pli...@googlemail.com schrieb am Mittwoch, 9. März 2022 um 07:39:40 
>> UTC+1:
>>
>>> I'll join this thread for a moment. 
>>>
>>> I also had the question of how to draw an additional line into a plot. 
>>>
>>> So far I haven't been able to find anything about it in the 
>>> instructions. But since the topic is being discussed here... 
>>>
>>> In my case, I want an additional line at 0°C on the temperature plots. 
>>> This would make it very easy to see if the temperatures have gone below 
>>> zero. 
>>>
>>> But I only want this line at minimum temperatures below 0°C. 
>>> Is there any way I can link this to a condition? 
>>>
>>> tke...@gmail.com schrieb am Mittwoch, 9. März 2022 um 01:05:57 UTC+1:
>>>
>>>> I was able to reproduce your error.
>>>>
>>>> It did work with v3.7. It appears that in my zeal to allow xtypes to be 
>>>> used in arbitrary plots, I broke something.
>>>>
>>>> I've opened issue #761 <https://github.com/weewx/weewx/issues/761> to 
>>>> track.
>>>>
>>>> -tk
>>>>
>>>> On Tue, Mar 8, 2022 at 3:35 PM ianpre...@gmail.com <ianpre...@gmail.com> 
>>>> wrote:
>>>>
>>>>> Thanks
>>>>> I won't pretend that I understood ........but it may help others.
>>>>> It did give me a clue as to how to move forward a bit .....I think
>>>>> I tried this .......and it worked ......an orange line at 4v .......1 
>>>>> step forward
>>>>> and telemetry display updates.
>>>>>         [[[dayvolt]]]
>>>>>             yscale = 3.6, 4.2, 0.1
>>>>>             [[[[consBatteryVoltage]]]]
>>>>>                 label = Transmitter battery
>>>>>                 color = 0xb48242    # blue
>>>>> #                color = 0x4242b4    # red
>>>>>
>>>>> # place limit line on graph
>>>>>             [[[[voltMin]]]]
>>>>>                 data_type = consBatteryVoltage - consBatteryVoltage + 4
>>>>>                 label = ' '
>>>>>                 color = orange
>>>>>                 width = 1
>>>>>
>>>>> but I want the limit at 3.7v ........so using the above
>>>>>         [[[dayvolt]]]
>>>>>             yscale = 3.6, 4.2, 0.1
>>>>>             [[[[consBatteryVoltage]]]]
>>>>>                 label = Transmitter battery
>>>>>                 color = 0xb48242    # blue
>>>>> #                color = 0x4242b4    # red
>>>>>
>>>>> # place limit line on graph
>>>>>             [[[[voltMin]]]]
>>>>>                 data_type = consBatteryVoltage - consBatteryVoltage + 
>>>>> 3.7
>>>>>                 label = ' '
>>>>>                 color = orange
>>>>>                 width = 1
>>>>> fail ....errors in the log .......places the orange line, but 
>>>>> telemetry page is now frozen
>>>>> Mar  9 08:56:06 weatherstn weewx[14006] DEBUG weewx.reportengine: 
>>>>> Found configuration file /etc/weewx/skins/Seasons/skin.conf for report 
>>>>> 'SeasonsReport'
>>>>> Mar  9 08:56:06 weatherstn weewx[14006] DEBUG user.MQTTSubscribe: 
>>>>> (Driver) data-> final loop packet is tele/weather-stn-sensor/STATE 
>>>>> 2022-03-09 08:56:04 AEST (1646780164): 'batteryStatus1': '0.0', 
>>>>> 'consBatteryVoltage': '4.086810112', 'dateTime': '1646780164.264368', 
>>>>> 'extraTemp1': '33.0', 'signal1': '1515', 'signal2': '-34.0', 
>>>>> 'supplyVoltage': '12.13632011', 'txBatteryStatus': '0.0', 'usUnits': '17'
>>>>> Mar  9 08:56:06 weatherstn weewx[14006] DEBUG weewx.cheetahgenerator: 
>>>>> Using search list ['weewx.cheetahgenerator.Almanac', 
>>>>> 'weewx.cheetahgenerator.Current', 
>>>>> 'weewx.cheetahgenerator.DisplayOptions', 
>>>>> 'weewx.cheetahgenerator.Extras', 'weewx.cheetahgenerator.Gettext', 
>>>>> 'weewx.cheetahgenerator.JSONHelpers', 'weewx.cheetahgenerator.PlotInfo', 
>>>>> 'weewx.cheetahgenerator.SkinInfo', 'weewx.cheetahgenerator.Station', 
>>>>> 'weewx.cheetahgenerator.Stats', 'weewx.cheetahgenerator.UnitInfo']
>>>>> Mar  9 08:56:06 weatherstn weewx[14006] DEBUG weewx.manager: Daily 
>>>>> summary version is 4.0
>>>>> Mar  9 08:56:06 weatherstn weewx[14006] ERROR weewx.cheetahgenerator: 
>>>>> Evaluation of template /etc/weewx/skins/Seasons/telemetry.html.tmpl 
>>>>> failed.
>>>>> Mar  9 08:56:06 weatherstn weewx[14006] ERROR weewx.cheetahgenerator: 
>>>>> **** Ignoring template /etc/weewx/skins/Seasons/telemetry.html.tmpl
>>>>> Mar  9 08:56:06 weatherstn weewx[14006] ERROR weewx.cheetahgenerator: 
>>>>> **** Reason: cannot find 'has_data' while searching for 
>>>>> 'year.consBatteryVoltage - consBatteryVoltage + 3.7.has_data'
>>>>> Mar  9 08:56:06 weatherstn weewx[14006] ERROR weewx.cheetahgenerator: 
>>>>> **** To debug, try inserting '#errorCatcher Echo' at top of template
>>>>> Mar  9 08:56:06 weatherstn weewx[14006] INFO weewx.cheetahgenerator: 
>>>>> Generated 7 files for report SeasonsReport in 0.29 seconds
>>>>> Mar  9 08:56:06 weatherstn weewx[14006] DEBUG weewx.manager: Daily 
>>>>> summary version is 4.0
>>>>> Mar  9 08:56:06 weatherstn weewx[14006] INFO weewx.imagegenerator: 
>>>>> Generated 19 images for report SeasonsReport in 0.23 seconds
>>>>> Mar  9 08:56:06 weatherstn weewx[14006] INFO weewx.reportengine: 
>>>>> Copied 0 files to /var/www/html/weewx
>>>>> Mar  9 08:56:06 weatherstn weewx[14006] DEBUG weewx.reportengine: 
>>>>> Report 'SmartphoneReport' not enabled. Skipping.
>>>>> Mar  9 08:56:06 weatherstn weewx[14006] DEBUG weewx.reportengine: 
>>>>> Report 'MobileReport' not enabled. Skipping.
>>>>> Mar  9 08:56:06 weatherstn weewx[14006] DEBUG weewx.reportengine: 
>>>>> Report 'StandardReport' not enabled. Skipping.
>>>>> Mar  9 08:56:06 weatherstn weewx[14006] DEBUG weewx.reportengine: 
>>>>> Report 'FTP' not enabled. Skipping.
>>>>> Mar  9 08:56:06 weatherstn weewx[14006] DEBUG weewx.reportengine: 
>>>>> Report 'RSYNC' not enabled. Skipping.
>>>>>
>>>>> I take it that it doesn't like 3.7 ..........I don't understand 
>>>>> why.........
>>>>> the windspeed example is so easy and simple and works using a number 
>>>>> with a decimal point and no equation
>>>>> should I place the number in quotes ? ...........is there a workaround 
>>>>> ?  ............or this will never fly ?
>>>>> thanks again
>>>>>
>>>>>
>>>>> On Tuesday, 8 March 2022 at 22:56:57 UTC+10 tke...@gmail.com wrote:
>>>>>
>>>>>> You're right: it's not mentioned in the Customizing Guide, and it 
>>>>>> really should be. 
>>>>>>
>>>>>> I've modified the guide to include a section about the topic. 
>>>>>> Hopefully it will help. *Including arbitrary expressions 
>>>>>> <https://weewx.com/docs/customizing.htm#arbitrary_expressions_in_plot>*
>>>>>>
>>>>>>
>>>>>> On Mon, Mar 7, 2022 at 10:01 PM Ian Prescott <ianpre...@gmail.com> 
>>>>>> wrote:
>>>>>>
>>>>>>> Hi 
>>>>>>> Could somebody show me how to correctly display a limit / constant 
>>>>>>> value on a plot
>>>>>>> some time ago I alerted to a post about how to show a constant value 
>>>>>>> in a plot.
>>>>>>> I have searched but I haven't found the right words to find that 
>>>>>>> post again
>>>>>>> but I copied it and use it in my skin.conf
>>>>>>>         [[[daywind]]]
>>>>>>> #            [[[[windSpeed]]]]
>>>>>>> #            [[[[windGust]]]]
>>>>>>>
>>>>>>> # place limit line on graph
>>>>>>>             [[[[windMax]]]]
>>>>>>> #                data_type = function              | this 
>>>>>>> #                label = ' '                                 | does
>>>>>>> #                function_definition = 10.5       | not 
>>>>>>> #                function_type = windSpeed   | work
>>>>>>> #                color = red
>>>>>>>
>>>>>>>                 data_type = 10.5
>>>>>>>                 label = ' '
>>>>>>>                 color = orange
>>>>>>>                 width = 1
>>>>>>>             [[[[windSpeed]]]]
>>>>>>>                 color = 0xb48242
>>>>>>>             [[[[windGust]]]]
>>>>>>>                 color = 0x4242b4
>>>>>>> I think it is a useful feature for me and it displays an orange line 
>>>>>>> at 10.5
>>>>>>> BTW the red line does not show on the plot and no errors appear in 
>>>>>>> the log (debug=1)
>>>>>>> see here at   oxleyweather.ddnsfree.com
>>>>>>>
>>>>>>> Now I would like to display a constant value in another plot.
>>>>>>> like this
>>>>>>>         [[[dayvolt]]]
>>>>>>>             yscale = 3.6, 4.2, 0.1
>>>>>>>             [[[[consBatteryVoltage]]]]
>>>>>>>                 label = Transmitter battery
>>>>>>>                 color = 0xb48242    # blue
>>>>>>> #                color = 0x4242b4    # red
>>>>>>> # place limit line on graph
>>>>>>>             [[[[voltMin]]]]
>>>>>>>                 data_type = function
>>>>>>>                 label = ' '
>>>>>>>                 function_definition = 3.7
>>>>>>>                 function_type = consBatteryVoltage
>>>>>>>                 color = red
>>>>>>> #                width = 1
>>>>>>> But this doesn't show a red line, and there are no complaints in the 
>>>>>>> log.
>>>>>>>
>>>>>>> However if I use the wind example I get errors in the log .........
>>>>>>> but not for the wind example ........only about the voltage limit
>>>>>>> The Customization Guide under ImageGenerator doesn't give any details
>>>>>>> Thanks
>>>>>>>
>>>>>>> Mar  8 15:46:17 weatherstn weewx[14006] INFO weewx.manager: Added 
>>>>>>> record 2022-03-08 15:45:00 AEST (1646718300) to database 'weewx.sdb'
>>>>>>> Mar  8 15:46:17 weatherstn weewx[14006] INFO weewx.manager: Added 
>>>>>>> record 2022-03-08 15:45:00 AEST (1646718300) to daily summary in 
>>>>>>> 'weewx.sdb'
>>>>>>> Mar  8 15:46:17 weatherstn weewx[14006] DEBUG weewx.reportengine: 
>>>>>>> Running reports for latest time in the database.
>>>>>>> Mar  8 15:46:17 weatherstn weewx[14006] DEBUG weewx.reportengine: 
>>>>>>> Running report 'SeasonsReport'
>>>>>>> Mar  8 15:46:17 weatherstn weewx[14006] DEBUG weewx.restx: 
>>>>>>> StationRegistry: wait interval (91800 < 604800) has not passed for 
>>>>>>> record 
>>>>>>> 2022-03-08 15:45:00 AEST (1646718300)
>>>>>>> Mar  8 15:46:17 weatherstn weewx[14006] DEBUG weewx.reportengine: 
>>>>>>> Found configuration file /etc/weewx/skins/Seasons/skin.conf for report 
>>>>>>> 'SeasonsReport'
>>>>>>> Mar  8 15:46:17 weatherstn weewx[14006] DEBUG 
>>>>>>> weewx.cheetahgenerator: Using search list 
>>>>>>> ['weewx.cheetahgenerator.Almanac', 'weewx.cheetahgenerator.Current', 
>>>>>>> 'weewx.cheetahgenerator.DisplayOptions', 
>>>>>>> 'weewx.cheetahgenerator.Extras', 
>>>>>>> 'weewx.cheetahgenerator.Gettext', 'weewx.cheetahgenerator.JSONHelpers', 
>>>>>>> 'weewx.cheetahgenerator.PlotInfo', 'weewx.cheetahgenerator.SkinInfo', 
>>>>>>> 'weewx.cheetahgenerator.Station', 'weewx.cheetahgenerator.Stats', 
>>>>>>> 'weewx.cheetahgenerator.UnitInfo']
>>>>>>> Mar  8 15:46:17 weatherstn weewx[14006] DEBUG weewx.manager: Daily 
>>>>>>> summary version is 4.0
>>>>>>> Mar  8 15:46:17 weatherstn weewx[14006] ERROR 
>>>>>>> weewx.cheetahgenerator: Evaluation of template 
>>>>>>> /etc/weewx/skins/Seasons/telemetry.html.tmpl failed.
>>>>>>> Mar  8 15:46:17 weatherstn weewx[14006] ERROR 
>>>>>>> weewx.cheetahgenerator: **** Ignoring template 
>>>>>>> /etc/weewx/skins/Seasons/telemetry.html.tmpl
>>>>>>> Mar  8 15:46:17 weatherstn weewx[14006] ERROR 
>>>>>>> weewx.cheetahgenerator: **** Reason: cannot find 'has_data' while 
>>>>>>> searching 
>>>>>>> for 'year.3.7.has_data'
>>>>>>> Mar  8 15:46:17 weatherstn weewx[14006] ERROR 
>>>>>>> weewx.cheetahgenerator: **** To debug, try inserting '#errorCatcher 
>>>>>>> Echo' 
>>>>>>> at top of template
>>>>>>> Mar  8 15:46:17 weatherstn weewx[14006] INFO weewx.cheetahgenerator: 
>>>>>>> Generated 7 files for report SeasonsReport in 0.29 seconds
>>>>>>> Mar  8 15:46:17 weatherstn weewx[14006] DEBUG weewx.manager: Daily 
>>>>>>> summary version is 4.0
>>>>>>> Mar  8 15:46:17 weatherstn weewx[14006] INFO weewx.imagegenerator: 
>>>>>>> Generated 19 images for report SeasonsReport in 0.23 seconds
>>>>>>> Mar  8 15:46:17 weatherstn weewx[14006] INFO weewx.reportengine: 
>>>>>>> Copied 0 files to /var/www/html/weewx
>>>>>>> Mar  8 15:46:17 weatherstn weewx[14006] DEBUG weewx.reportengine: 
>>>>>>> Report 'SmartphoneReport' not enabled. Skipping.
>>>>>>> Mar  8 15:46:17 weatherstn weewx[14006] DEBUG weewx.reportengine: 
>>>>>>> Report 'MobileReport' not enabled. Skipping.
>>>>>>> Mar  8 15:46:17 weatherstn weewx[14006] DEBUG weewx.reportengine: 
>>>>>>> Report 'StandardReport' not enabled. Skipping.
>>>>>>> Mar  8 15:46:17 weatherstn weewx[14006] DEBUG weewx.reportengine: 
>>>>>>> Report 'FTP' not enabled. Skipping.
>>>>>>> Mar  8 15:46:17 weatherstn weewx[14006] DEBUG weewx.reportengine: 
>>>>>>> Report 'RSYNC' not enabled. Skipping.
>>>>>>>
>>>>>>> -- 
>>>>>>> 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/CAN84nRuRrvwvW5zhONY4n%2B%2BydT74zUiuE%3DP6h9Ej3tdMXpeLRg%40mail.gmail.com
>>>>>>>  
>>>>>>> <https://groups.google.com/d/msgid/weewx-user/CAN84nRuRrvwvW5zhONY4n%2B%2BydT74zUiuE%3DP6h9Ej3tdMXpeLRg%40mail.gmail.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/66f61c5e-0f30-4edd-be61-85e468f968a8n%40googlegroups.com
>>>>>  
>>>>> <https://groups.google.com/d/msgid/weewx-user/66f61c5e-0f30-4edd-be61-85e468f968a8n%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/c178a455-ae0c-4a41-a757-ed46c2ed6f6dn%40googlegroups.com
>>  
>> <https://groups.google.com/d/msgid/weewx-user/c178a455-ae0c-4a41-a757-ed46c2ed6f6dn%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/c6ce250c-5701-4c2c-88bb-39a14f89f324n%40googlegroups.com.

Reply via email to