I'm still a little hazy on what the issue is. What do you mean by "the
values don't match"? Which values? And I don't know where your website is.

​The wxMesh driver (at least as posted here
<https://github.com/morrowwm/weewxMQTT/blob/master/bin/user/wxMesh.py>)
expects weewx.METRIC units, that is, rain (and hail) should be in
centimeters, not millimeters.​ You can't just simply change to
weewx.METRICWX in your copy, because then the other units will be wrong.

Run weewx from the command line and watch what it prints. Tip the bucket
and see what value gets printed. Is it what you expected?

-tk

On Sun, Dec 3, 2017 at 9:16 AM, 'Christian Peters' via weewx-user <
[email protected]> wrote:

> Tom,
>
> I use the wxMesh driver but I think your demo code is imlemented in that
> way you posted:
>
> #!/usr/bin/python
> #
> # weewx driver that reads data from MQTT subscription
> #
> # This program is free software: you can redistribute it and/or modify it
> under
> # the terms of the GNU General Public License as published by the Free
> Software
> # Foundation, either version 3 of the License, or any later version.
> #
> # This program is distributed in the hope that it will be useful, but
> WITHOUT
> # ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
> FITNESS
> # FOR A PARTICULAR PURPOSE.
> #
> # See http://www.gnu.org/licenses/
>
> #
> # The units must be weewx.US:
> # degree_F, inHg, inch, inch_per_hour, mile_per_hour
> #
> # To use this driver, put this file in the weewx user directory, then make
> # the following changes to weewx.conf:
> #
> # [Station]
> # station_type = wxMesh
> # [wxMesh]
> # host = localhost # MQTT broker hostname
> # topic = weather # topic
> # driver = user.wxMesh
> #
> # If the variables in the file have names different from those in weewx,
> then
> # create a mapping such as this:
> #
> # [wxMesh]
> # ...
> # [[label_map]]
> # temp = outTemp
> # humi = outHumidity
> # in_temp = inTemp
> # in_humid = inHumidity
>
> from __future__ import with_statement
> import syslog
> import time
> import paho.mqtt.client as mqtt
> import weewx.drivers
>
> DRIVER_VERSION = "0.1"
>
> def logmsg(dst, msg):
> syslog.syslog(dst, 'wxMesh: %s' % msg)
>
> def logdbg(msg):
> logmsg(syslog.LOG_DEBUG, msg)
>
> def loginf(msg):
> logmsg(syslog.LOG_INFO, msg)
>
> def logerr(msg):
> logmsg(syslog.LOG_ERR, msg)
>
> def _get_as_float(d, s):
> v = None
> if s in d:
> try:
> v = float(d[s])
> except ValueError, e:
> logerr("cannot read value for '%s': %s" % (s, e))
> return v
>
> def loader(config_dict, engine):
> return wxMesh(**config_dict['wxMesh'])
>
> class wxMesh(weewx.drivers.AbstractDevice):
> """weewx driver that reads data from a file"""
>
> def __init__(self, **stn_dict):
> # where to find the data file
> self.host = stn_dict.get('host', 'localhost')
> self.topic = stn_dict.get('topic', 'weather')
> # how often to poll the weather data file, seconds
> self.poll_interval = float(stn_dict.get('poll_interval', 5.0))
> # mapping from variable names to weewx names
> self.label_map = stn_dict.get('label_map', {})
>
> loginf("host is %s" % self.host)
> loginf("topic is %s" % self.topic)
> loginf("polling interval is %s" % self.poll_interval)
> loginf('label map is %s' % self.label_map)
>
> self.payload = "Empty"
> #self.payloadList = [payload]
> self.client = mqtt.Client(client_id="XXX", protocol=mqtt.MQTTv31)
>
> #self.client.on_connect = self.on_connect
> self.client.on_message = self.on_message
>
> self.client.username_pw_set("XXX", "XXX")
> self.client.connect(self.host, 1883, 60)
> self.client.subscribe(self.topic, qos=1)
>
> # The callback for when a PUBLISH message is received from the server.
> def on_message(self, client, userdata, msg):
> self.payload = str(msg.payload)
> logdbg("Got message %s" % str(msg.payload))
>
> def genLoopPackets(self):
> while True:
> self.client.loop()
> # read whatever values we can get from the MQTT broker
> logdbg("Working on payload : %s" % self.payload)
> if self.payload != "Empty" :
> data = {}
> row = self.payload.split(",");
> for datum in row:
> (key,value) = datum.split(":")
> data[key] = value
> if( key=="TIME" and data[key] == "0"):
> data[key] = str(int(time.time()))
> logdbg("key: "+key+" value: "+data[key])
>
> *# map the data into a weewx loop packet*
> * _packet = {'usUnits': weewx.METRICWX}*
> *for vname in data:*
> * _packet[self.label_map.get(vname, vname)] = _get_as_float(data, vname)*
>
> *yield _packet*
> self.payload = "Empty"
>
> logdbg("Sleeping for %d" % self.poll_interval)
> time.sleep(self.poll_interval)
> self.client.disconnect()
> @property
> def hardware_name(self):
> return "wxMesh"
>
> I got 0.1mm on Payload hail...but If I look at the values they doesn't
> match (printed on my website).
> If I change to 'US' units then my Celsius values mapped wrong so I think
> in general changing to METRICWX in the wxMesh driver works.
>
> I think I have to look in the database what hail values were written if I
> simulate a 0.1mm rain event (at the moment one switch to press...just
> before wirering to the bucket in the garden)....
>
> Thanks for you help.
>
> Regards,
>
> Christian
>
> Am Sonntag, 3. Dezember 2017 14:50:27 UTC+1 schrieb Tom Keffer:
>>
>> You're being a little vague on the details. What results are you getting?
>> And, what do you mean by "send 0.1 (mm)?" Do you mean in the loop packets?
>> If so, your genLoopPackets() function should look something like this
>> (NOT TESTED):
>>
>> def genLoopPackets():
>>   data = {'dateTime': time.time(), 'usUnits': weewx.METRIC}
>>   data['outTemp'] = (something)
>>   ...
>>   data['hail'] = 0.1    # NB: This would be 0.1 cm, or 1mm
>>
>>   yield data
>>
>> There are a two other assumptions as well:
>>
>>    1. You have not implemented genArchiveRecords() and are, therefore,
>>    depending on software record generation to turn your loop packets into
>>    archive records.
>>    2. The observation type 'hail' is in your schema. This is the normal
>>    situation with the default "wview" schema, so I'm assuming you have not
>>    changed it.
>>
>>
>> -tk
>>
>>
>>
>> On Sun, Dec 3, 2017 at 6:56 AM, 'Christian Peters' via weewx-user <
>> [email protected]> wrote:
>>
>>> Tom,
>>>
>>> that seems not to solve my problem. I send 0.1 (mm) but didn't get that
>>> into weewx.
>>> As I already have a rain bucket with the VPII I used 'hail' and 'hail
>>> rate". Could these be a problem or can't I use it for a second rain bucket
>>> (same computation as rain?).
>>>
>>> Regard,
>>>
>>> Chrstian
>>>
>>> Am Sonntag, 26. November 2017 15:09:33 UTC+1 schrieb Tom Keffer:
>>>>
>>>> That could be it. weewx.METRIC has rainfall in cm, weewx.METRICWX in
>>>> mm. See the Units <http://weewx.com/docs/customizing.htm#units>
>>>> appendix in the Customizing Guide.
>>>>
>>>> -tk
>>>>
>>>> On Sun, Nov 26, 2017 at 8:02 AM, 'Christian Peters' via weewx-user <
>>>> [email protected]> wrote:
>>>>
>>>>> Tom,
>>>>>
>>>>> thank you for that hint. So emitting in mm was the right change.
>>>>> I just wonder why my temp values are ok but my rain data isn't!?
>>>>> Just found that on the wxMesh driver:
>>>>>
>>>>> # map the data into a weewx loop packet
>>>>> _packet = {'usUnits': weewx.METRIC}
>>>>>
>>>>> So I think I have to switch to METRICWX.
>>>>>
>>>>> Regards,
>>>>>
>>>>> Christian
>>>>>
>>>>>
>>>>>
>>>>> --
>>>>> 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 [email protected].
>>>>> For more options, visit https://groups.google.com/d/optout.
>>>>>
>>>>
>>>> --
>>> 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 [email protected].
>>> For more options, visit https://groups.google.com/d/optout.
>>>
>>
>> --
> 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 [email protected].
> For more options, visit https://groups.google.com/d/optout.
>

-- 
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 [email protected].
For more options, visit https://groups.google.com/d/optout.

Reply via email to