Unfortunately, there's no simple way to make the tag machinery available
outside the StdReport context --- for one thing, there is no skin
configuration (skin.conf) available. It would probably be easier just to do
the conversions yourself. Something like this (NOT TESTED):
def do_alarm(self, rec):
"""Send an email out"""
# Get the time and convert to a string:
t_str = timestamp_to_string(rec['dateTime'])
# Log the alarm
syslog.syslog(syslog.LOG_INFO, 'alarm: Alarm expression "%s"
evaluated True at %s' % (self.expression, t_str))
# Create a Metric ValueHelper for the temperature
t_vt = weewx.units.as_value_tuple(rec, 'outTemp')
t_vh = weewx.units.ValueHelper(t_vt,
converter=weewx.units.MetricWXUnits)
# Build the final message:
msg_text = "At %s, the temperature is %s" % (t_str, t_vh)
# Convert to MIME:
msg = MIMEText(msg_text)
... (as before)
Hopefully, this gets you started
-tk
On Mon, Apr 29, 2019 at 12:14 AM Graham Eddy <[email protected]> wrote:
> in the example alarm.py, it prints the test expression verbatim inside the
> email.
> how do i get it to use the skin to get converted value and units to put in
> the email?
> note that this is outside the Cheetah conversion context of StdReport etc.
> cheers
>