|
| 1 | +# py_ecowater |
| 2 | + |
| 3 | + |
| 4 | +A python library for getting device data from Ecowater API for devices such as the Rheem RHW42 water softener, which |
| 5 | +provides WI-FI connectivity via the iQua app. |
| 6 | + |
| 7 | +## Installation |
| 8 | + |
| 9 | +```bash |
| 10 | +pip install py_ecowater |
| 11 | +``` |
| 12 | + |
| 13 | +## Usage |
| 14 | +The primary class is `EcowaterClient`. It takes two parameters, `username` and `password`. |
| 15 | +These are the same credentials you use to log in to the app. The primary methods are `get_devices`, `get_user_profile`, |
| 16 | +`get_systems`, and `get_system_state`. |
| 17 | + |
| 18 | +The `get_system_state` method takes a single parameter, `serial_number`, which is the serial number of the system you |
| 19 | +want to get the state of and can be found from the system information returned by `get_systems`. |
| 20 | + |
| 21 | +The methods return python objects that can be accessed as attributes. |
| 22 | + |
| 23 | +```python |
| 24 | +import os |
| 25 | +from py_ecowater import EcowaterClient |
| 26 | + |
| 27 | +username = os.environ.get('ECOWATER_USERNAME') |
| 28 | +password = os.environ.get('ECOWATER_PASSWORD') |
| 29 | + |
| 30 | +client = EcowaterClient(username, password) |
| 31 | + |
| 32 | +devices = client.get_devices() |
| 33 | +''' |
| 34 | +{ |
| 35 | + "devices": [ |
| 36 | + { |
| 37 | + "id": 12345, |
| 38 | + |
| 39 | + "type": "AC", |
| 40 | + "status": "READY", |
| 41 | + "role": "user", |
| 42 | + "user_uuid": null, |
| 43 | + "dealer_id": null, |
| 44 | + "members": null, |
| 45 | + "alerts_ack": null, |
| 46 | + "mydata": null, |
| 47 | + "date": 1650692107704, |
| 48 | + "created_by": "user" |
| 49 | + } |
| 50 | + ] |
| 51 | +} |
| 52 | +''' |
| 53 | + |
| 54 | +profile = client.get_user_profile() |
| 55 | +''' |
| 56 | +{ |
| 57 | + "id": "<unique id>", |
| 58 | + "name": "Bob,Ross", |
| 59 | + |
| 60 | + "company": { |
| 61 | + "phone_country_code": "", |
| 62 | + "phone": "1234567890", |
| 63 | + "primary_phone_code": "", |
| 64 | + "primary_phone": "1234567890", |
| 65 | + "members_count": 2, |
| 66 | + "support_phone": "", |
| 67 | + "support_phone_code": "" |
| 68 | + }, |
| 69 | + "phone": "1234567890", |
| 70 | + "time_zone": null, |
| 71 | + "address_line_1": "123 My Addr Rd", |
| 72 | + "address_line_2": "", |
| 73 | + "city": "My City", |
| 74 | + "state": null, |
| 75 | + "zip_code": "98765", |
| 76 | + "country": "US", |
| 77 | + "contact_language": "en", |
| 78 | + "roles": [ |
| 79 | + "user" |
| 80 | + ], |
| 81 | + "change_password": false, |
| 82 | + "manufacturer_id": "", |
| 83 | + "first_name": "Bob", |
| 84 | + "last_name": "Ross", |
| 85 | + "meta": { |
| 86 | + "phone_country_code": "", |
| 87 | + "phone": "1234567890", |
| 88 | + "primary_phone_code": "+1", |
| 89 | + "primary_phone": "1234567890", |
| 90 | + "members_count": 2, |
| 91 | + "support_phone": "", |
| 92 | + "support_phone_code": "" |
| 93 | + } |
| 94 | +} |
| 95 | +''' |
| 96 | + |
| 97 | +systems = client.get_systems() |
| 98 | +''' |
| 99 | +{ |
| 100 | + "systems": [ |
| 101 | + { |
| 102 | + "id": "<system id>", |
| 103 | + "serial_number": "SL0<serial number>", |
| 104 | + "nickname": "Water Softener", |
| 105 | + "description": { |
| 106 | + "unit_owner": "customer", |
| 107 | + "rental_access": 1 |
| 108 | + }, |
| 109 | + "ac_role_name": "User", |
| 110 | + "role": "user", |
| 111 | + "model_id": "<model id>", |
| 112 | + "model_name": "108201", |
| 113 | + "model_description": "Rheem RHW42", |
| 114 | + "system_type": "demand softener", |
| 115 | + "dealer_access": false, |
| 116 | + "alarms_alerts": false, |
| 117 | + "is_rental": false, |
| 118 | + "is_restricted": false, |
| 119 | + "alerts_active": null, |
| 120 | + "is_super_hero": false, |
| 121 | + "is_filter_system": false, |
| 122 | + "product_image": "Rheem", |
| 123 | + "water_shut_off_valve_control": true |
| 124 | + } |
| 125 | + ] |
| 126 | +} |
| 127 | +
|
| 128 | +''' |
| 129 | + |
| 130 | +system_state = client.get_system_state(systems.systems[0].serial_number) |
| 131 | +''' |
| 132 | +{ |
| 133 | + "iron_level_tenths_ppm": { |
| 134 | + "value": 0 |
| 135 | + }, |
| 136 | + "hardness_unit_enum": { |
| 137 | + "value": 0 |
| 138 | + }, |
| 139 | + "hardness_grains": { |
| 140 | + "value": 11 |
| 141 | + }, |
| 142 | + "salt_level_tenths": { |
| 143 | + "value": 20, |
| 144 | + "percent": 25 |
| 145 | + }, |
| 146 | + "salt_monitor_enum": { |
| 147 | + "value": 1 |
| 148 | + }, |
| 149 | + "volume_unit_enum": { |
| 150 | + "value": 0 |
| 151 | + }, |
| 152 | + "regen_enable_enum": { |
| 153 | + "value": 1 |
| 154 | + }, |
| 155 | + "regen_time_secs": { |
| 156 | + "value": 7200 |
| 157 | + }, |
| 158 | + "time_format_enum": { |
| 159 | + "value": 0 |
| 160 | + }, |
| 161 | + "time_zone_enum": { |
| 162 | + "value": "America/Denver" |
| 163 | + }, |
| 164 | + "date_format_enum": { |
| 165 | + "value": 0 |
| 166 | + }, |
| 167 | + "water_shutoff_valve_req": { |
| 168 | + "value": 0 |
| 169 | + }, |
| 170 | + "total_water_available_gallons": { |
| 171 | + "value": 2224 |
| 172 | + }, |
| 173 | + "current_water_flow": { |
| 174 | + "value": 0.0 |
| 175 | + }, |
| 176 | + "gallons_used_today": { |
| 177 | + "value": 38 |
| 178 | + }, |
| 179 | + "average_daily_use_gallons": { |
| 180 | + "value": 90 |
| 181 | + }, |
| 182 | + "regen_status_enum": { |
| 183 | + "value": 0 |
| 184 | + }, |
| 185 | + "out_of_salt_estimated_days": { |
| 186 | + "value": 130 |
| 187 | + }, |
| 188 | + "days_since_last_regen": { |
| 189 | + "value": 14 |
| 190 | + }, |
| 191 | + "model_id": { |
| 192 | + "value": <model id> |
| 193 | + }, |
| 194 | + "model_description": { |
| 195 | + "value": "Rheem RHW42" |
| 196 | + }, |
| 197 | + "system_type": { |
| 198 | + "value": "demand softener", |
| 199 | + "type": "softener" |
| 200 | + }, |
| 201 | + "water_shutoff_valve": { |
| 202 | + "value": 0 |
| 203 | + }, |
| 204 | + "water_shutoff_valve_installed": { |
| 205 | + "value": 1 |
| 206 | + }, |
| 207 | + "water_shutoff_valve_override": { |
| 208 | + "value": 0 |
| 209 | + }, |
| 210 | + "water_shutoff_valve_device_action": { |
| 211 | + "value": 0 |
| 212 | + }, |
| 213 | + "water_shutoff_valve_error_code": { |
| 214 | + "value": 0 |
| 215 | + }, |
| 216 | + "base_software_version": { |
| 217 | + "value": "r4.4 MPC01082" |
| 218 | + }, |
| 219 | + "power": "Online", |
| 220 | + "device_date": "2023-07-29T09:44:38.149000", |
| 221 | + "refresh_policy": { |
| 222 | + "delay": "low", |
| 223 | + "time": 300000 |
| 224 | + } |
| 225 | +} |
| 226 | +''' |
| 227 | +``` |
| 228 | + |
| 229 | +## Contributing and Development |
| 230 | + |
| 231 | +### Update git-submod-lib submodule for current Makefile Targets |
| 232 | +```shell |
| 233 | +git submodule update --init --remote |
| 234 | +``` |
| 235 | + |
| 236 | +### Make Python venv and install requirements |
| 237 | +```shell |
| 238 | +make -f git-submod-lib/makefile/Makefile venv |
| 239 | +``` |
| 240 | + |
| 241 | +Make and commit changes, and then build locally as follows. |
| 242 | + |
| 243 | +### Build Locally |
| 244 | +```shell |
| 245 | +make -f git-submod-lib/makefile/Makefile build-python |
| 246 | +``` |
| 247 | + |
| 248 | +### Make a pull request to `main` with your changes |
| 249 | +```shell |
| 250 | +make -f git-submod-lib/makefile/Makefile pull-request-main |
| 251 | +``` |
| 252 | + |
| 253 | +## Releasing |
| 254 | + |
| 255 | +### Minor releases |
| 256 | +```shell |
| 257 | +make -f git-submod-lib/makefile/Makefile promotion-alpha |
| 258 | +``` |
| 259 | + |
| 260 | +Once the PR is approved and merged: |
| 261 | +```shell |
| 262 | +make -f git-submod-lib/makefile/Makefile github-release |
| 263 | +``` |
| 264 | + |
| 265 | +Once the Release is published: |
| 266 | +```shell |
| 267 | +make -f git-submod-lib/makefile/Makefile twine-upload |
| 268 | +``` |
| 269 | + |
| 270 | +Now cut a version release branch: |
| 271 | +```shell |
| 272 | +make -f git-submod-lib/makefile/Makefile github-branch |
| 273 | +``` |
| 274 | + |
| 275 | +Now move `main` to the next `alpha` version to capture future development |
| 276 | +```shell |
| 277 | +make -f git-submod-lib/makefile/Makefile version-alpha |
| 278 | +``` |
| 279 | + |
| 280 | +### Patch releases |
| 281 | +Start with the version branch to be patched (ie `0.0.x`) |
| 282 | +```shell |
| 283 | +make -f git-submod-lib/makefile/Makefile promotion-patch |
| 284 | +``` |
| 285 | + |
| 286 | +Once the PR is approved and merged: |
| 287 | +```shell |
| 288 | +make -f git-submod-lib/makefile/Makefile github-release-patch |
| 289 | +``` |
| 290 | + |
| 291 | +Once the Patch Release is published: |
| 292 | +```shell |
| 293 | +make -f git-submod-lib/makefile/Makefile twine-upload |
| 294 | +``` |
0 commit comments