Skip to content

Commit b450299

Browse files
committed
Added set_rain_collector
1 parent bdcb035 commit b450299

File tree

3 files changed

+13
-7
lines changed

3 files changed

+13
-7
lines changed

pyproject.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ build-backend = "setuptools.build_meta"
44

55
[project]
66
name = "PyVantagePro_MarcoGos"
7-
version = "0.3.19"
7+
version = "0.3.20"
88
authors = [
99
{ name="Salem Harrache", email="[email protected]" },
1010
{ name="Marco Gosselink", email="[email protected]" },

pyvantagepro/__init__.py

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -9,9 +9,6 @@
99
:license: GNU GPL v3.
1010
1111
'''
12-
# Make sure the logger is configured early:
13-
from .logger import LOGGER, active_logger
14-
from .device import VantagePro2
1512

16-
VERSION = '0.3.19'
13+
VERSION = '0.3.20'
1714
__version__ = VERSION

pyvantagepro/device.py

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -154,9 +154,10 @@ def read_from_eeprom(self, hex_address, size):
154154

155155
def write_to_eeprom(self, hex_address, size, data):
156156
'''Writes to EEPROM the `size` number of bytes starting at the
157-
`hex_address` with the given `data`. `data` needs to be bytes.'''
157+
`hex_address` with the given `data`. `data` needs to be bytes. CRC will be automatically added.'''
158158
self.send("EEBWR %s %.2d\n" % (hex_address, size), self.ACK)
159-
self.send(data)
159+
data_with_crc = VantageProCRC(data).data_with_checksum
160+
self.send(data_with_crc, self.ACK)
160161

161162
def gettime(self):
162163
'''Returns the current datetime of the console.'''
@@ -307,6 +308,14 @@ def newsetup(self) -> None:
307308
self.wake_up()
308309
self.send("NEWSETUP", self.ACK)
309310

311+
def set_rain_collector(self, type) -> None:
312+
'''Set rain collector type. 0x00 = 0.01", 0x10 = 0.2mm, 0x20 = 0.1mm'''
313+
setup_bits = struct.unpack(b"B", self.read_from_eeprom("2B", 1))[0] # type: ignore
314+
setup_bits = (setup_bits & 0xCF) | type
315+
data = struct.pack(b'>B', setup_bits)
316+
self.write_to_eeprom("2B", 1, data)
317+
self.newsetup()
318+
310319
@cached_property
311320
def archive_period(self):
312321
'''Returns number of minutes in the archive period.'''

0 commit comments

Comments
 (0)