Skip to content

Commit

Permalink
Adding features to extract test dataset and remove serial/installid i…
Browse files Browse the repository at this point in the history
…nformation (openviess#140)

* Adding Vitodens 300W data and test

* Adding tests for NotSupportedFeatureError, but leaving commented out desired outcome as Viessmann should support these as they used too

* Last update for vitodens300W for now - take it or leave it:-)

* Merged

* Adding description and changes to make it easier to extract test datasets for others
  • Loading branch information
jborup authored Aug 4, 2021
1 parent cbe3101 commit 5fbe2f4
Show file tree
Hide file tree
Showing 4 changed files with 3,143 additions and 0 deletions.
8 changes: 8 additions & 0 deletions PyViCare/PyViCareDevice.py
Original file line number Diff line number Diff line change
Expand Up @@ -188,6 +188,14 @@ def getDomesticHotWaterCirculationSchedule(self):
def getAvailableCircuits(self):
return self.service.getProperty("heating.circuits")["properties"]["enabled"]["value"]

@handleNotSupported
def getControllerSerial(self):
return self.service.getProperty("heating.controller.serial")["properties"]["value"]["value"]

@handleNotSupported
def getBoilerSerial(self):
return self.service.getProperty("heating.boiler.serial")["properties"]["value"]["value"]


class DeviceWithCircuit:
def __init__(self, device, circuit):
Expand Down
3 changes: 3 additions & 0 deletions PyViCare/PyViCareDeviceConfig.py
Original file line number Diff line number Diff line change
Expand Up @@ -62,3 +62,6 @@ def asAutoDetectDevice(self):
logger.info(
f"Could not auto detect {self.device_model}. Use generic device.")
return self.asGeneric()

def getRawJSON(self):
return self.service.cache
52 changes: 52 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -129,3 +129,55 @@ Please not that not all previous properties are available in the new API. Missin
## Rate Limits

[Due to latest changes in the Viessmann API](https://www.viessmann-community.com/t5/Konnektivitaet/Q-amp-A-Viessmann-API/td-p/127660) rate limits can be hit. In that case a `PyViCareRateLimitError` is raised. You can read from the error (`limitResetDate`) when the rate limit is reset.

## More different devices for test cases needed
In order to help ensuring making it easier to create more test cases you can run this code and make a pull request with the new test of your device type added. Your test shoudl be commited into [tests/response](tests/response) and named <family><model>.

The code to run to make this happen is below. Notice how it removes "sensitive" information like installation id and serial numbers.
You can either replace default values or use the `PYVICARE_*` environment variables.

```python
import sys
import logging
import json
import os
from PyViCare.PyViCare import PyViCare

client_id = os.getenv("PYVICARE_CLIENT_ID", "INSERT CLIENT_ID")
email = os.getenv("PYVICARE_EMAIL", "email@domain")
password = os.getenv("PYVICARE_PASSWORD", "password")

vicare = PyViCare()
vicare.initWithCredentials(email, password, client_id, "token.save")
device = vicare.devices[0]
t = device.asAutoDetectDevice()

# Extract install id and serial which we want to anonymize for test datasets
config = device.getConfig()
(installId, serial, deviceId) = (config.id, config.serial, config.device_id)

# Extract heating.controller.serial
controllerSerial = t.getControllerSerial()

# Extract heating.boiler.serial
boilerSerial = t.getBoilerSerial()
# In case you want to see what will be replaced uncomment the next two lines
#print(f"instalation (ID, serial, controllerSerial, boilerSerial) ({installId}, {serial}, {controllerSerial}, {boilerSerial})")
#exit

dumpJSON = json.dumps(device.getRawJSON(), indent=4)
# Replace all values of installationId with xxxxxx
dumpJSON = dumpJSON.replace(str(installId), "xxxxxx")

# Replace all values of gatewayId with yyyyyyyyyyyyyyyy
dumpJSON = dumpJSON.replace(serial, "yyyyyyyyyyyyyyyy")

# Replace all values of boilers serial with zzzzzzzzzzzzzzzz
dumpJSON = dumpJSON.replace(boilerSerial, "zzzzzzzzzzzzzzzz")

# Replace all values of controller serial with wwwwwwwwwwwwwwww
dumpJSON = dumpJSON.replace(controllerSerial, "wwwwwwwwwwwwwwww")

print(dumpJSON)

```
Loading

0 comments on commit 5fbe2f4

Please sign in to comment.