How to handle sensor data that doesn't come at set times

178 views
Skip to first unread message

Greg from Oz

unread,
Mar 14, 2024, 5:18:42 PMMar 14
to weewx-user
Hi,
I have removed my fineoffset usb and replaced it with SDR but the outside fine offset station doesn't sent inside temperature, inside humidity or barometer.

I have added a BME280 sensor and can get the barometer readings every 30 seconds and that is working and graphing OK.

I have a zigbee battery powered device that I am using to get the inside temperature and inside humidity but I cannot get the graphs to show a solid line nor can I get the readings to consistently show on my web page because those readings come in a random times.

Is there any way to make the readings "stick" until a new reading is received so the graphs look right and the readings are always on the web page?

Look at the inside temperature graph on my web page to see what I mean:

Thanks

Tom Keffer

unread,
Mar 14, 2024, 5:39:12 PMMar 14
to weewx...@googlegroups.com
You may just have the option line_gap_fraction set too low.

--
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/555c8101-8f4f-45ad-8dc7-03a7b2fbb7ean%40googlegroups.com.

Greg from Oz

unread,
Mar 14, 2024, 9:54:40 PMMar 14
to weewx-user
Here is a snippet of the database:
select dateTime ,inTemp, inHumidity, pressure from archive where dateTime >= 1710459900 ;
+------------+--------+--------------------+-------------------+
| dateTime   | inTemp | inHumidity         | pressure          |
+------------+--------+--------------------+-------------------+
| 1710459900 |  23.99 | 54.019999999999996 | 968.3500000000003 |
| 1710460200 |   NULL |               NULL | 968.3142857142858 |
| 1710460500 |   NULL |               NULL | 968.3166666666667 |
| 1710460800 |   NULL |               NULL | 968.2166666666667 |
| 1710461100 |   NULL |               NULL | 968.1583333333334 |
| 1710461400 |  24.26 |              53.23 | 968.1000000000001 |
| 1710461700 |   24.5 |              53.34 | 968.0833333333335 |
| 1710462000 |   NULL |               NULL | 968.1416666666668 |
| 1710462300 |   NULL |               NULL | 968.0916666666667 |
| 1710462600 |   NULL |               NULL | 968.1285714285715 |
| 1710462900 |   NULL |               NULL |           968.225 |
| 1710463200 |  25.01 |             52.795 | 968.1666666666666 |
| 1710463500 |   NULL |               NULL | 968.1083333333335 |
| 1710463800 |  25.52 | 51.754999999999995 | 968.1357142857144 |
| 1710464100 |   NULL |               NULL | 968.1083333333332 |
| 1710464400 |   NULL |               NULL | 968.0916666666667 |
| 1710464700 |   NULL |               NULL | 968.0083333333332 |
| 1710465000 |  25.82 |              50.49 | 968.0142857142857 |
| 1710465300 |  26.03 |             50.535 | 967.9583333333334 |
| 1710465600 |   NULL |               NULL | 967.8333333333335 |
| 1710465900 |   NULL |               NULL | 967.8000000000001 |
| 1710466200 |   NULL |               NULL |            967.75 |
| 1710466500 |  26.54 |             50.095 | 967.6833333333334 |
| 1710466800 |   NULL |               NULL | 967.6916666666666 |
| 1710467100 |   NULL |               NULL | 967.6999999999999 |
| 1710467400 |   NULL |               NULL | 967.7500000000001 |
+------------+--------+--------------------+-------------------+
26 rows in set (0.000 sec)

Tom Keffer

unread,
Mar 15, 2024, 8:55:13 AMMar 15
to weewx...@googlegroups.com
You have many single data points, separated with long stretches of nulls --- no lines. That's why line_gap_fraction isn't working.

By design, WeeWX drivers don't cache data. See the guidelines for writing drivers.

However, you could write a simple service that retains the last value and uses it if a null value is seen. Perhaps up to a maximum time. But, there's nothing like that in WeeWX.

Greg from Oz

unread,
Mar 15, 2024, 5:21:37 PMMar 15
to weewx-user
Thanks Tom.

Probably not something I could do. I know nothing about python.
Maybe later when I have time to look at it again.
I will see if I can find a device that transmits in regular intervals.

Jimi Lawson

unread,
Mar 15, 2024, 7:10:57 PMMar 15
to weewx-user
What device does your station/weewx run on, couldn't you connect the bme280 to it and use the temp/humidity/pressure reading from it ? that's what I do.

Greg from Oz

unread,
Mar 15, 2024, 7:18:13 PMMar 15
to weewx-user
My bme280 only does pressure and temperature. I have it on a sonoff SV.
What bme280 are you using? Do you have a part number?
I am getting the humidity and temp from the zigbee because it is in the house and the bme280 is in the shed and it is hot in there but I can add one for the house I guess?
I will see if I can get the same BME280 as you are using.
Do you have info where you bought it?
Thanks

p q

unread,
Mar 15, 2024, 7:52:57 PMMar 15
to weewx...@googlegroups.com
I do it the dumb way. I have my sensors send data when they're ready. I have a service running on the weewx box that subscribes to the MQTT messages and writes them to a temp file. I modified the driver to read from the temp file. I check to see if the data is older than 20 minutes and ignore it if it is.

There's probably a proper way to do this, without editing driver code.



--
Peter Quinn
(415)794-2264

Jimi Lawson

unread,
Mar 15, 2024, 8:06:47 PMMar 15
to weewx-user

Greg from Oz

unread,
Mar 16, 2024, 4:38:29 AMMar 16
to weewx-user
I use home automation (openHab) and the inside humidity and inside temperature is something I am putting into the home automation so I used that to resend every 2 minutes to weew mqttsubscribe. The openHab keeps the last data it was sent. I use JSON.stringify to make it a json data pakage.

Here is the openhab code (javascript)

var TOPIC="weewx"
temperature=(items.getItem("Zigbee_temperature_bedroom_xiaomi_greg").state)
humidity=(items.getItem("Zigbee_humidity_bedroom_xiaomi_greg").state)
var PAYLOAD=(JSON.stringify({"humidity": humidity, "temperature": temperature}))

result = actions.Exec.executeCommandLine(time.Duration.ofSeconds(5), "/usr/bin/mosquitto_pub","\-h","192.168.1.164","\-t","" + TOPIC,"\-m","" + PAYLOAD);

console.log(JSON.stringify({"humidity": humidity, "temperature": temperature}))


And here is the weew.conf part.
        # The second topic to subscribe to.
        [[[weewx]]]
        #[[[zigbee2mqtt/sensor-xiaomi-greg]]]
            ignore = true    # opt out of processing fields for this topic by default - override per field
           [[[[temperature]]]]
                name = inTemp

                # True if the incoming data should not be processed into WeeWX.
                # Valid values: True, False
                # Default is False
                ignore = False

                # True if the incoming data is cumulative.
                # Valid values: True, False
                # Default is False
                contains_total = False
           [[[[humidity]]]]
                name = inHumidity

                # True if the incoming data should not be processed into WeeWX.
                # Valid values: True, False
                # Default is False
                ignore = False

And here is the data that is being sent:
{"humidity":"47.06","temperature":"23.97"}

Also thanks for the link of the bme280 device I still may get one anyway.

Hopefully now my graphs will look good again!

Thanks again for all the ideas.

bell...@gmail.com

unread,
Mar 16, 2024, 3:50:18 PMMar 16
to weewx-user
You’ve got something working, I wouldn’t change it. But for future searches/reference, MQTTSubscribeService does have limited caching support (https://github.com/bellrichm/WeeWX-MQTTSubscribe/wiki/Additional-Options#expires_after).
The primary limitation is that MQTTSubscribeService must be bound to the NEW_ARCHIVE_RECORD event if the driver is running in ‘record_generation = hardware’ mode. Some additional information on this limitation is here, https://github.com/bellrichm/WeeWX-MQTTSubscribe/issues/178.
- rich
Reply all
Reply to author
Forward
0 new messages