|
8 | 8 | from warrant import Cognito
|
9 | 9 | from warrant.aws_srp import AWSSRP
|
10 | 10 |
|
| 11 | +from .waterguru_device import WaterGuruDevice |
| 12 | + |
11 | 13 | _LOGGER = logging.getLogger(__name__)
|
12 | 14 |
|
13 | 15 | class WaterGuruApiError(Exception):
|
@@ -75,89 +77,3 @@ def get(self):
|
75 | 77 |
|
76 | 78 | data = response.json()
|
77 | 79 | return {waterBodyData['waterBodyId']: WaterGuruDevice(waterBodyData) for waterBodyData in data['waterBodies']}
|
78 |
| - |
79 |
| - |
80 |
| - |
81 |
| -class WaterGuruDevice: |
82 |
| - """Representation of a WaterGuru device.""" |
83 |
| - |
84 |
| - def __init__(self, waterBodyData): |
85 |
| - """Initialize the device.""" |
86 |
| - self._data = waterBodyData |
87 |
| - self._sensors = dict[str, str] |
88 |
| - self._standard_sensors = { |
89 |
| - 'temp': self._data['waterTemp'], |
90 |
| - 'rssi': self._data['pods'][0]['rssiInfo']['rssi'], |
91 |
| - } |
92 |
| - for r in self._data['pods'][0]['refillables']: |
93 |
| - if r['type'] == 'BATT': |
94 |
| - self._standard_sensors['battery'] = r['pctLeft'] |
95 |
| - if r['type'] == 'LAB': |
96 |
| - self._standard_sensors['cassette'] = r['pctLeft'] |
97 |
| - if 'timeLeftText' in r: |
98 |
| - number = int(r['timeLeftText'].split()[0]) |
99 |
| - if "weeks" in r['timeLeftText']: |
100 |
| - number = number * 7 |
101 |
| - elif "months" in r['timeLeftText']: |
102 |
| - number = number * 30 |
103 |
| - self._standard_sensors['cassette_days_remaining'] = number |
104 |
| - self._measurements = {measurement['type']: measurement for measurement in self._data['measurements']} |
105 |
| - |
106 |
| - @property |
107 |
| - def device_id(self): |
108 |
| - """Return the device ID.""" |
109 |
| - return self._data['waterBodyId'] |
110 |
| - |
111 |
| - @property |
112 |
| - def name(self): |
113 |
| - """Return the name of the device.""" |
114 |
| - return f"WaterGuru {self._data['name']}" |
115 |
| - |
116 |
| - @property |
117 |
| - def product_name(self): |
118 |
| - """Return the product name of the device.""" |
119 |
| - return self._data['pods'][0]['pod']['product'] |
120 |
| - |
121 |
| - @property |
122 |
| - def serial_number(self): |
123 |
| - """Return the serial number of the device.""" |
124 |
| - return self._data['pods'][0]['pod']['podId'] |
125 |
| - |
126 |
| - @property |
127 |
| - def firmware_version(self): |
128 |
| - """Return the firmware version of the device.""" |
129 |
| - return self._data['pods'][0]['pod']['fwUpdateVersion'] |
130 |
| - |
131 |
| - @property |
132 |
| - def sensors(self): |
133 |
| - """Return the sensors of the device.""" |
134 |
| - return self._standard_sensors |
135 |
| - |
136 |
| - @property |
137 |
| - def measurements(self): |
138 |
| - """Return the measurements of the device.""" |
139 |
| - return self._measurements |
140 |
| - |
141 |
| - @property |
142 |
| - def status(self): |
143 |
| - """Return the status of the device.""" |
144 |
| - return self._data['status'] |
145 |
| - |
146 |
| - @property |
147 |
| - def last_measurement_time(self): |
148 |
| - """Return the last measurement time.""" |
149 |
| - return self._data['latestMeasureTime'] |
150 |
| - |
151 |
| - @property |
152 |
| - def diagnostics(self): |
153 |
| - """Return the diagnostics of the device.""" |
154 |
| - return { |
155 |
| - "name": self.name, |
156 |
| - "product_name": self.product_name, |
157 |
| - "firmware_version": self.firmware_version, |
158 |
| - "status": self.status, |
159 |
| - "last_measurement_time": self.last_measurement_time, |
160 |
| - "standard_sensors": self.sensors, |
161 |
| - "measurements": self.measurements, |
162 |
| - "raw_data": self._data |
163 |
| - } |
0 commit comments