In the general case, including keys in the loop packet for non-existent data is 
not a good idea.  This would break existing code (e.g., JavaScript code I use 
in my skins).

You could easily fork the extension and add in what you need.  At line 736, 
right before write_packet_to_file is called, simply check for the keys you need 
to exist, and add them if they are not there. The following should work.  Just 
replace the keys I’ve listed with the ones you need in the packet.

must_have_keys = [ 'current.outTemp', 'current.outHumidity' ]
    for must_have_key in must_have_keys:
        if must_have_key not in loopdata_pkt:
            loopdata_pkt[must_have_key] = None

If you don’t want to hard code the keys, you’ll have a bigger task; but you 
could just copy the code used to process the ‘fields’ entry in the LoopData 
section of weewx.conf.

Cheers,
John

> On Nov 24, 2020, at 8:54 PM, geoffs...@gmail.com <geoffshar...@gmail.com> 
> wrote:
> 
> Hi John,
> 
> This is a great extension. I'm wondering if there is a way to be able to 
> include sending data that is null  or none for a particular key? I'm using a 
> davis vantage pro2, weewx 4.2. I'd like to use this to make a JSON output 
> that can be ingested into a home automation system. So far it works great as 
> long as the data is available to be sent, but I have not figured out how to 
> send a key with a Null or none value. It looks like a key with a null or none 
> value gets cleaved off the JSON output. If a battery dies on a sensor and it 
> just disappears from the JSON output, that is much harder for the HA system 
> to handle than a null, none or zero value. 
> 
>> On Monday, November 16, 2020 at 2:57:13 PM UTC-8 jo...@johnkline.com wrote:
>> A fix is released (v2.7.2).  There is no hurry to install the new release; 
>> but once you’ve installed it, you can remove the field I asked you to add to 
>> weewx.conf.
>> 
>>> On Nov 16, 2020, at 9:04 AM, Geni <eugen.a...@gmail.com> wrote:
>>> 
>>> Ok, works
>> 
>>> 
>>> Thank you
>>> 
>>> jo...@johnkline.com schrieb am Montag, 16. November 2020 um 16:05:21 UTC+1:
>>>> I can duplicate this problem and will issue a fix.
>>>> 
>>>> In the meantime, you can add:
>>>> rainyear.outTemp.max
>>>> to the fields clause in the LoopData section of weewx.conf?
>>>> 
>>>> That will stop this problem.  If you get similar errors for other periods 
>>>> where you have no fields listed, you’ll have to temporarily add a field 
>>>> for those periods also.
>>>> 
>>>> I should have a fix shortly.  I don’t know that this is related to WeeWX 
>>>> 4.2, not that that really matters. 
>>>> 
>>>>>> On Nov 16, 2020, at 2:45 AM, Geni <eugen.a...@gmail.com> wrote:
>>>>>> 
>>>>> 
>>>> 
>>>>> 
>>>>> Hi john
>>>>> since weewx 4.2.0 the loop-data.txt is no longer generated?
>>>>> regards Geni
>>>>> 
>>>>> 
>>>> 
>>>>> -- 
>>>>> 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/3f89791f-c06b-43d1-beac-0afa58df59d6n%40googlegroups.com.
>>>>> <syslog.txt>
>>> 
>>> -- 
>>> 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/0f6cb227-1cdd-4fbb-9cf9-6f4c59521262n%40googlegroups.com.
> 
> -- 
> 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/0611c189-0c9f-4ab6-b6be-4d797e80bb96n%40googlegroups.com.

-- 
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/6488424C-22DE-4632-8959-7B2954E470E3%40johnkline.com.

Reply via email to