Hi, There are a few ways you could do this but the simplest way for a one-off requirement is a little in-line python code in the template. Put something like the following (untested) in your template:
#set $battery_state = $current.extraTempBatteryStatus12.raw #set $battery_message = "N/A" #if $battery_state == 0 #set $battery_message = "OK" #elif $battery_state == 1 #set $battery_message = "Low Batt" #end if Then use $battery_message wherever you want the battery state message to appear. The code could go in index.html.tmpl or in the .inc, up to you, as long as it is executed before you try to use the $battery_message tag. Gary On Tuesday, 7 May 2019 09:16:22 UTC+10, Ken Booth wrote: > > When the Acurite SmartHub sends raw data to weewx, the battery status is > reported as "normal" or "low" and this is converted to 0 or 1 respectively. > > weewx[24667]: interceptor: MainThread: raw data: > dateutc=now&action=updateraw&realtime=1&id=24C86E090EC1&mt=tower&sensor=00004036&humidity=34&tempf=76.4&baromin=30.31&battery=normal&rssi=4 > weewx[24667]: interceptor: MainThread: raw packet: > {'bridge_id.00004036.24C86E090EC1': '24C86E090EC1', > 'sensor_type.00004036.24C86E090EC1': 'tower', > 'battery.00004036.24C86E090EC1': 0, > ... > weewx[24667]: interceptor: MainThread: raw data: > dateutc=now&action=updateraw&realtime=1&id=24C86E090A48&mt=tower&sensor=00005422&humidity=34&tempf=71.4&baromin=29.83&battery=low&rssi=3 > weewx[24667]: interceptor: MainThread: raw packet: > {'rssi.00005422.24C86E090A48': 75.0, 'battery.00005422.24C86E090A48': 1, > ... > > I've defined the battery status as a count, rather than a percentage in > /usr/share/weewx/user/extensions.py > weewx.units.obs_group_dict['extraTempBatteryStatus12'] = 'group_count' > > But when I put into the skin in /etc/weewx/skins/Seasons/current.inc > <td class="data">$current.extraTempBatteryStatus12</td> > the resulting table is displayed as 0% for normal and 1% for low > > At the moment I have changed /etc/weewx/skins/Seasons/current.inc to > <td class="data">$current.extraTempBatteryStatus12.raw</td> > so I get 0.0 for a good battery and 1.0 for a low battery. > > What syntax do I use in current.inc to display the string "OK" for 0 or > "Low Batt" for 1 ? > -- 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/7ffd9919-d550-409b-b47d-6980943f7914%40googlegroups.com. For more options, visit https://groups.google.com/d/optout.