diff --git a/bin/weewx/tags.py b/bin/weewx/tags.py
index 09940555..ffdef96c 100644
--- a/bin/weewx/tags.py
+++ b/bin/weewx/tags.py
@@ -440,7 +440,10 @@ class TrendObj(object):
# F_to_C(68F - 50F). We want the former, not the latter.
now_vtc = self.converter.convert(now_vt)
then_vtc = self.converter.convert(then_vt)
- trend = now_vtc - then_vtc
+ if now_vtc.value is None or then_vtc.value is None:
+ trend = ValueTuple(None, now_vtc.unit, now_vtc.group)
+ else:
+ trend = now_vtc - then_vtc
# Return the results as a ValueHelper. Use the formatting and labeling
# options from the current time record. The user can always override
diff --git a/bin/weewx/test/expected/index.html b/bin/weewx/test/expected/index.html
index a331e8b1..9690ceb2 100644
--- a/bin/weewx/test/expected/index.html
+++ b/bin/weewx/test/expected/index.html
@@ -91,6 +91,10 @@
Outside Temperature trend with explicit time_delta (3600 seconds) |
4.4°F |
+
+ | Outside Temperature trend where previous value is known to be None (9000 seconds) |
+ N/A |
+
| Trend with nonsense type |
?'foobar'? |
diff --git a/bin/weewx/test/expected/metric/index.html b/bin/weewx/test/expected/metric/index.html
index 314cfd62..647574f5 100644
--- a/bin/weewx/test/expected/metric/index.html
+++ b/bin/weewx/test/expected/metric/index.html
@@ -91,6 +91,10 @@
Outside Temperature trend with explicit time_delta (3600 seconds) |
2.4°C |
+
+ | Outside Temperature trend where previous value is known to be None (9000 seconds) |
+ N/A |
+
| Trend with nonsense type |
?'foobar'? |
diff --git a/bin/weewx/test/test_skins/StandardTest/index.html.tmpl b/bin/weewx/test/test_skins/StandardTest/index.html.tmpl
index 081d7e86..45e7b198 100644
--- a/bin/weewx/test/test_skins/StandardTest/index.html.tmpl
+++ b/bin/weewx/test/test_skins/StandardTest/index.html.tmpl
@@ -98,6 +98,11 @@
Outside Temperature trend with explicit time_delta (3600 seconds) |
$trend($time_delta=3600).outTemp |
+
+ ## This test uses a previous value known to be None:
+ | Outside Temperature trend where previous value is known to be None (9000 seconds) |
+ $trend($time_delta=9000).outTemp |
+
| Trend with nonsense type |
$trend.foobar |