I am not sure that I understood what I am expected to post. The units and 
unit group definition file I created is this:

bell...@gmail.com schrieb am Montag, 25. Januar 2021 um 01:09:55 UTC+1:

> Karen, 
> If you pst what you have done, I’d be willing to look at updating 
> MQTTSubscribe to have a configuration option. If we get something working, 
> perhaps a pull request to WeeWX might result.
> rich
>
> On Sunday, 24 January 2021 at 05:57:47 UTC-5 kk44...@gmail.com wrote:
>
>> @Rich: Yes, I was afraid that that is the only way to do it. So I guess, 
>> I will do it the same way
>>
>> @Weatherl: Oh, I did not install devices of my own. Instead I got 
>> permission to read the readings of the official level and flow meters from 
>> the government. They provide an API in the Internet here. If you register 
>> with them you can get the data live.
>>
>> bell...@gmail.com schrieb am Samstag, 23. Januar 2021 um 22:48:32 UTC+1:
>>
>>> I'll be interested in hearing if there is a better way, but here is what 
>>> I did to add a new observation.
>>> 1. Wrote this service.
>>>
>>> import weewx
>>>
>>> import weewx.units
>>> weewx.units.obs_group_dict['honeywell01'] = 'group_temperature'
>>> weewx.units.obs_group_dict['honeywell02'] = 'group_temperature'
>>> weewx.units.obs_group_dict['honeywell03'] = 'group_temperature'
>>>
>>> class Noop(weewx.engine.StdService):
>>>     pass
>>>
>>> 2. Updated weewx.conf
>>>         prep_services = weewx.engine.StdTimeSynch , user.bellrichm.Noop
>>>
>>> rich
>>>
>>> On Saturday, 23 January 2021 at 16:18:28 UTC-5 kk44...@gmail.com wrote:
>>>
>>>> I installed MQTTSubscribe service. In this case it provides data about 
>>>> water level (unit cm) and water flow (unit cubic meter per second) of the 
>>>> near river.
>>>>
>>>> As those units and unit group are not included in the standard weewx I 
>>>> have to assign them elsewhere.
>>>>
>>>> Because I use the MQTTSubscribe service, there is no need to write an 
>>>> extension. On the other hand, no extension file means no place to put the 
>>>> assignment of the additional units and unit groups.
>>>>
>>>> Could I declare those units and unit groups somewhere in weewx.conf?
>>>>
>>>> Is there any other possibility?
>>>>
>>>

-- 
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/314e2573-22bb-4798-9990-f0b039f9f1bfn%40googlegroups.com.
# water level and water flow units and unit groups

import weewx.units
import weeutil.weeutil 

# add groups for water level and water flow
weewx.units.USUnits.extend(
  {'group_flow':'cubic_foot_per_second',
   'group_level':'foot'})

# add groups for water level and water flow
weewx.units.MetricUnits.extend(
  {'group_flow':'cubic_meter_per_second',
   'group_level':'cm'})
   
# add groups for water level and water flow
weewx.units.MetricWXUnits.extend(
  {'group_flow':'cubic_meter_per_second',
   'group_level':'cm'})

# default format for flow units   
weewx.units.default_unit_format_dict['cubic_meter_per_second']='%.1f'
weewx.units.default_unit_format_dict['cubic_foot_per_second']='%.0f'
  
# default unit label for flow units
weewx.units.default_unit_label_dict['cubic_meter_per_second']=u" m³/s"
weewx.units.default_unit_label_dict['cubic_foot_per_second']=u" ft³/s"

# Note: default format and unit labels for water level units are
# already defined within weewx.units. No need to do it here.

# add conversion functions between cm and foot for water level
weewx.units.conversionDict['cm']['foot']= lambda x : x / 30.48
weewx.units.conversionDict['foot']['cm']= lambda x : x * 30.48

# add conversion functions for flow units
if 'cubic_meter_per_second' not in weewx.units.conversionDict:
    weewx.units.conversionDict['cubic_meter_per_second']={'cubic_foot_per_second': lambda x : x * 35.3147 }
else:
    weewx.units.conversionDict['cubic_meter_per_second']['cubic_foot_per_second']= lambda x : x * 35.3147 
if 'cubic_foot_per_second' not in weewx.units.conversionDict:
    weewx.units.conversionDict['cubic_foot_per_second']={'cubic_meter_per_second': lambda x : x / 35.3147 }
else:
    weewx.units.conversionDict['cubic_foot_per_second']['cubic_meter_per_second']= lambda x : x / 35.3147 

# water level and flow measurements
weewx.units.obs_group_dict.extend(
  {'Q566055v':'group_flow',
   'W566055v':'group_level',
   'W566055a':'group_count',
   'Q567470v':'group_flow',
   'W567470v':'group_level',
   'W567470a':'group_count'})


class Noop(weewx.engine.StdService):
  pass
  

Reply via email to