diff --git a/bin/user/weatherlink_live/__init__.py b/bin/user/weatherlink_live/__init__.py
index af28bf5..2c3b2ca 100644
--- a/bin/user/weatherlink_live/__init__.py
+++ b/bin/user/weatherlink_live/__init__.py
@@ -34,7 +34,7 @@
from weewx.engine import InitializationError
DRIVER_NAME = "WeatherLinkLive"
-DRIVER_VERSION = "1.0.8"
+DRIVER_VERSION = "1.0.9"
log = logging.getLogger(__name__)
@@ -258,7 +258,7 @@ def default_stanza(self):
# Mapping of transmitter ids to WeeWX records
# Default for Vantage Pro2
- mapping = th:1, th_indoor, baro, rain:1, wind:1, thw:1:appTemp, windchill:1, battery
+ mapping = th:1, th_indoor, baro, rain:1, wind:1, thw:1:appTemp, windchill:1, battery:1:outTemp:rain:wind
"""
def modify_config(self, config_dict):
diff --git a/bin/user/weatherlink_live/configuration.py b/bin/user/weatherlink_live/configuration.py
index d7efb7f..111e407 100644
--- a/bin/user/weatherlink_live/configuration.py
+++ b/bin/user/weatherlink_live/configuration.py
@@ -111,7 +111,12 @@ def __repr__(self):
def create_mappers(self) -> List[AbstractMapping]:
used_record_keys = []
- return [self._create_mapper(source_opts, used_record_keys) for source_opts in self.mappings]
+ mappers = []
+ for source_opts in self.mappings:
+ mapper = self._create_mapper(source_opts, used_record_keys)
+ mappers.append(mapper)
+ used_record_keys.extend(mapper.targets.values())
+ return mappers
def _create_mapper(self, source_opts: List[str], used_map_targets: List[str]) -> AbstractMapping:
type = source_opts[0]
diff --git a/bin/user/weatherlink_live/mappers.py b/bin/user/weatherlink_live/mappers.py
index c1b061c..83b3c3a 100644
--- a/bin/user/weatherlink_live/mappers.py
+++ b/bin/user/weatherlink_live/mappers.py
@@ -457,12 +457,23 @@ def _do_mapping(self, packet: DavisConditionsPacket, record: dict):
class BatteryStatusMapping(AbstractMapping):
def __init__(self, mapping_opts: list, used_map_targets: list, log_success: bool = False, log_error: bool = True):
- super().__init__({}, mapping_opts, used_map_targets, log_success, log_error)
+ super().__init__({
+ 'battery': targets.BATTERY_STATUS
+ }, mapping_opts, used_map_targets, log_success, log_error)
+
+ self.tx_id = self._parse_option_int(mapping_opts, 0)
+
+ further_opts = mapping_opts[1:]
+ try:
+ self.further_targets = [targets.BATTERY_STATUS_NAMED[key] for key in further_opts]
+ except KeyError as e:
+ raise KeyError("Invalid battery remap target") from e
def _do_mapping(self, packet: DavisConditionsPacket, record: dict):
- for tx in targets.BATTERY_STATUS.keys():
- try:
- self._set_record_entry(record, targets.BATTERY_STATUS[tx],
- packet.get_observation(KEY_BATTERY_FLAG, tx=tx))
- except NotInPacket:
- pass # Continue with other transmitters
+ battery_num = self.targets['battery']
+
+ self._set_record_entry(record, battery_num,
+ packet.get_observation(KEY_BATTERY_FLAG, tx=self.tx_id))
+ for target in self.further_targets:
+ self._set_record_entry(record, target,
+ packet.get_observation(KEY_BATTERY_FLAG, tx=self.tx_id))
diff --git a/bin/user/weatherlink_live/static/targets.py b/bin/user/weatherlink_live/static/targets.py
index 22e25f0..55724a3 100644
--- a/bin/user/weatherlink_live/static/targets.py
+++ b/bin/user/weatherlink_live/static/targets.py
@@ -134,11 +134,16 @@
PM10 = ["pm10_0"]
# Battery status
-BATTERY_STATUS = {1: 'batteryStatus1',
- 2: 'batteryStatus2',
- 3: 'batteryStatus3',
- 4: 'batteryStatus4',
- 5: 'batteryStatus5',
- 6: 'batteryStatus6',
- 7: 'batteryStatus7',
- 8: 'batteryStatus8'}
+BATTERY_STATUS = ['batteryStatus1',
+ 'batteryStatus2',
+ 'batteryStatus3',
+ 'batteryStatus4',
+ 'batteryStatus5',
+ 'batteryStatus6',
+ 'batteryStatus7',
+ 'batteryStatus8']
+BATTERY_STATUS_NAMED = {'outTemp': 'outTempBatteryStatus',
+ 'rain': 'rainBatteryStatus',
+ 'tx': 'txBatteryStatus',
+ 'uv': 'uvBatteryStatus',
+ 'wind': 'windBatteryStatus'}
diff --git a/changes.md b/changes.md
index f8b9e8d..575272b 100644
--- a/changes.md
+++ b/changes.md
@@ -121,3 +121,11 @@ The driver only uses it for the rate of the rain collector spoon tripping.
- **Fix broken temperature-only mapping**
+## Version 1.0.9
+
+- **Allow named mapping targets for battery status**
+
+ `battery` mapping now maps one transmitter only, but supports mapping to WeeWX's standard named battery status fields additionally to the numeric ones.
+
+- **Fix mapping targets being used multiple times**
+
diff --git a/install.py b/install.py
index 66b0a14..b38f2af 100644
--- a/install.py
+++ b/install.py
@@ -33,7 +33,7 @@ class WeatherLinkLiveInstaller(ExtensionInstaller):
def __init__(self):
super(WeatherLinkLiveInstaller, self).__init__(
name='weatherlink-live',
- version="1.0.8",
+ version="1.0.9",
description='WeeWX driver for Davis WeatherLink Live.',
author="Michael Schantl",
author_email="floss@schantl-lx.at",
diff --git a/readme.md b/readme.md
index 136c2db..cdc36f9 100644
--- a/readme.md
+++ b/readme.md
@@ -104,7 +104,7 @@ The units of all additionally defined observations are converted as specified in
host = weatherlink
# Mapping of transmitter ids
- mapping = th:1, th_indoor, baro, rain:1, wind:1, uv:1, solar:1, thw:1, thsw:1:appTemp, windchill:1, battery
+ mapping = th:1, th_indoor, baro, rain:1, wind:1, uv:1, solar:1, thw:1, thsw:1:appTemp, windchill:1, battery:1:outTemp:rain:wind:uv
[DataBindings]
@@ -161,23 +161,23 @@ List of sensors and their ids to import into WeeWX. Each mapping definition cons
### Available mappings
-| Mapping name | Parameters | Description |
-| ---------------------------------------------- | -------------------------------- | ------------------------------------------------------------ |
-| **`t`** (temperature) | Sensor id | Maps outside temperature (no humidity) |
-| **`th`** (temperature, humidity) | Sensor id | Maps outside temperature, humidity, heat index, dew point and wet bulb temperature |
-| **`wind`** | Sensor id | Maps wind speed and direction to LOOP speed and direction.
An additional service then finds the maximum wind speed during the archive interval and assigns this speed and the respective direction to the gust observations. |
-| **`rain`** | Sensor id | Maps rain amount and rate as well as count of spoon trips, rate of spoon trips and size of spoon.
Differential rain amount is calculated from daily rain measurement. |
-| **`solar`** (solar radiation) | Sensor id | Maps solar radiation |
-| **`uv`** (UV index) | Sensor id | Maps UV index |
-| **`windchill`** (wind chill) | Sensor id | Maps wind chill as reported by the respective transmitter.
_**Note:** Only available when thermometer and anemometer are connected to the same transmitter._ |
-| **`thw`** (THW index) | Sensor id, **Option:** `appTemp` | Maps THW (temperature, humidity, wind) index as reported by the respective transmitter.
_**Note:** Only available when thermometer, hygrometer and anemometer are connected to the same transmitter.
**Option `appTemp`:** When this option is set (see examples), the THW index value is additionally mapped to the `appTemp` field available in the WeeWX default schema. |
-| **`thsw`** (THSW index) | Sensor id, **Option:** `appTemp` | Maps THSW (temperature, humidity, solar, wind) index as reported by the respective transmitter.
_**Note:** Only available when thermometer, hygrometer, pyranometer and anemometer are connected to the same transmitter._
**Option `appTemp`:** When this option is set (see examples), the THSW index value is additionally mapped to the `appTemp` field available in the WeeWX default schema. |
-| **`soil_temp`** (soil temperature) | Sensor id, Sensor number | Maps soil temperature sensors from soil/leaf stations. |
-| **`soil_moist`** (soil moisture) | Sensor id, Sensor number | Maps soil moisture sensors from soil/leaf stations. |
-| **`leaf_wet`** (leaf wetness) | Sensor id, Sensor number | Maps leaf wetness sensors from soil/leaf stations. |
-| **`th_indoor`** (indoor temperature, humidity) | _none_ | Maps indoor temperature, humidity, heat index and dew point as measured by the WLL itself |
-| **`baro`** (barometer) | _none_ | Maps station (absolute) and sea-level pressure as measured/calculated by the WLL itself |
-| **`battery`** | _none_ | Maps the battery status indicator flag of all connected transmitters to the fields `batteryStatus1` to `batteryStatus8`. I.e. the value of transmitter 1 is mapped to `batteryStatus1`, transmitter 2 to `batteryStatus2` and so on.
**`0`** = Battery OK; **`1`** = Battery low |
+| Mapping name | Parameters | Description |
+| ---------------------------------------------- | ------------------------------------------------------------ | ------------------------------------------------------------ |
+| **`t`** (temperature) | Sensor id | Maps outside temperature (no humidity) |
+| **`th`** (temperature, humidity) | Sensor id | Maps outside temperature, humidity, heat index, dew point and wet bulb temperature |
+| **`wind`** | Sensor id | Maps wind speed and direction to LOOP speed and direction.
An additional service then finds the maximum wind speed during the archive interval and assigns this speed and the respective direction to the gust observations. |
+| **`rain`** | Sensor id | Maps rain amount and rate as well as count of spoon trips, rate of spoon trips and size of spoon.
Differential rain amount is calculated from daily rain measurement. |
+| **`solar`** (solar radiation) | Sensor id | Maps solar radiation |
+| **`uv`** (UV index) | Sensor id | Maps UV index |
+| **`windchill`** (wind chill) | Sensor id | Maps wind chill as reported by the respective transmitter.
_**Note:** Only available when thermometer and anemometer are connected to the same transmitter._ |
+| **`thw`** (THW index) | Sensor id,
**Option:** `appTemp` | Maps THW (temperature, humidity, wind) index as reported by the respective transmitter.
_**Note:** Only available when thermometer, hygrometer and anemometer are connected to the same transmitter.
**Option `appTemp`:** When this option is set (see examples), the THW index value is additionally mapped to the `appTemp` field available in the WeeWX default schema. |
+| **`thsw`** (THSW index) | Sensor id,
**Option:** `appTemp` | Maps THSW (temperature, humidity, solar, wind) index as reported by the respective transmitter.
_**Note:** Only available when thermometer, hygrometer, pyranometer and anemometer are connected to the same transmitter._
**Option `appTemp`:** When this option is set (see examples), the THSW index value is additionally mapped to the `appTemp` field available in the WeeWX default schema. |
+| **`soil_temp`** (soil temperature) | Sensor id, Sensor number | Maps soil temperature sensors from soil/leaf stations. |
+| **`soil_moist`** (soil moisture) | Sensor id, Sensor number | Maps soil moisture sensors from soil/leaf stations. |
+| **`leaf_wet`** (leaf wetness) | Sensor id, Sensor number | Maps leaf wetness sensors from soil/leaf stations. |
+| **`th_indoor`** (indoor temperature, humidity) | _none_ | Maps indoor temperature, humidity, heat index and dew point as measured by the WLL itself |
+| **`baro`** (barometer) | _none_ | Maps station (absolute) and sea-level pressure as measured/calculated by the WLL itself |
+| **`battery`** | Sensor id,
**Options:** `outTemp`, `rain`, `tx`, `uv`, `wind` | Maps the battery status indicator flag the specified transmitter to the fields `batteryStatus1` to `batteryStatus8`.
**Options:** One or more options can be specified to map the battery status of the respective transmitter to the named battery field.
_`outTemp`_ = `outTempBatteryStatus`; _`rain`_ = `rainBatteryStatus`; _`tx`_ = `txBatteryStatus`; _`uv`_ = `uvBatteryStatus`; _`wind`_ = `windBatteryStatus`
**`0`** = Battery OK; **`1`** = Battery low |
### Mapping examples
@@ -186,7 +186,7 @@ List of sensors and their ids to import into WeeWX. Each mapping definition cons
This example is a valid mapping for a factory-default Vantage2 Pro Plus. All sensors are connected to the main ISS transmitter set to id 1.
```ini
-mapping = th:1, th_indoor, baro, rain:1, wind:1, uv:1, solar:1, thw:1, thsw:1:appTemp, windchill:1, battery
+mapping = th:1, th_indoor, baro, rain:1, wind:1, uv:1, solar:1, thw:1, thsw:1:appTemp, windchill:1, battery:1:outTemp:rain:wind:uv
```
#### Vantage2 Pro Plus with additional anemometer transmitter
@@ -196,7 +196,7 @@ Same as above, except the wind sensor is connected to a separate transmitter wit
Note that there is a configuration option on WeatherLink.com to import the wind measurement into the measurements of the main transmitter. If you enable this, the wind chill, THW and THSW values will still be calculated. Otherwise they should be removed from the mapping.
```ini
-mapping = th:1, th_indoor, baro, rain:1, wind:2, uv:1, solar:1, thw:1, thsw:1:appTemp, windchill:1, battery
+mapping = th:1, th_indoor, baro, rain:1, wind:2, uv:1, solar:1, thw:1, thsw:1:appTemp, windchill:1, battery:1:outTemp:rain:uv, battery:2:wind
```
#### Vantage2 Pro Plus with separate transmitter for wind, solar and UV
@@ -206,7 +206,7 @@ Same as above, except the solar and UV sensors are also connected to the separat
Note that THSW will not be calculated anymore since the solar sensor is now on a separate transmitter and unlike the wind measurements there's no configuration option.
```ini
-mapping = th:1, th_indoor, baro, rain:1, wind:2, uv:2, solar:2, thw:1:appTemp, windchill:1, battery
+mapping = th:1, th_indoor, baro, rain:1, wind:2, uv:2, solar:2, thw:1:appTemp, windchill:1, battery:1:outTemp:rain, battery:2:wind:uv
```
#### Vantage2 Pro Plus with soil/leaf station
@@ -216,7 +216,7 @@ Same as the first example with an additional soil/leaf station. The agriculture
Note that the ordering of the mapping matters: Mappings named earlier are mapped to the "lower-numbered" database columns. Remember this fact if you wish to add additional sensors later on.
```ini
-mapping = th:1, th_indoor, baro, rain:1, wind:1, uv:1, solar:1, thw:1, thsw:1:appTemp, windchill:1, soil_temp:2:1, soil_temp:2:2, soil_temp:2:3, soil_temp:2:4, soil_moist:2:1, soil_moist:2:2, soil_moist:2:3, soil_moist:2:4, leaf_wet:2:1, lef_wet:2:2, battery
+mapping = th:1, th_indoor, baro, rain:1, wind:1, uv:1, solar:1, thw:1, thsw:1:appTemp, windchill:1, soil_temp:2:1, soil_temp:2:2, soil_temp:2:3, soil_temp:2:4, soil_moist:2:1, soil_moist:2:2, soil_moist:2:3, soil_moist:2:4, leaf_wet:2:1, lef_wet:2:2, battery:1:outTemp:wind, battery:2:tx
```
## Contribution
diff --git a/testing/conf/weewx.conf b/testing/conf/weewx.conf
index 0f93fc8..4d7ba32 100644
--- a/testing/conf/weewx.conf
+++ b/testing/conf/weewx.conf
@@ -72,7 +72,7 @@ version = 4.5.1
# Mapping of transmitter ids to WeeWX records
# Default for Vantage Pro2
- mapping = th:1, th_indoor, baro, rain:1, wind:1, thw:1:appTemp, windchill:1, battery
+ mapping = th:1, th_indoor, baro, rain:1, wind:2, uv:2, solar:2, thw:1:appTemp, windchill:1, battery:1:outTemp:rain, battery:2:wind:uv
##############################################################################