openviess / PyViCare

Python Library to access Viessmann ViCare API
Apache License 2.0
135 stars 88 forks source link

Question: Wrong serial for gateways? #335

Open CFenner opened 1 year ago

CFenner commented 1 year ago

When I print the serials of my device, I get two times the same number for the heating device and the gateway. Is this due to the missing autodetect and fallback to HeatingDevice? Would a dedicated gateway class as in #334 help?

2023-10-19 23:22:24.938 INFO (SyncWorker_6) [ViCare] detected VScotHO1_40 asGazBoiler
2023-10-19 23:22:25.181 INFO (SyncWorker_6) [custom_components.vicare] Found device: xxx572105 <class 'PyViCare.PyViCareGazBoiler.GazBoiler'>

2023-10-19 23:22:25.185 INFO (SyncWorker_6) [ViCare] Could not auto detect Heatbox1. Use generic device.
2023-10-19 23:22:25.326 INFO (SyncWorker_6) [custom_components.vicare] Found device: xxx572105 <class 'PyViCare.PyViCareHeatingDevice.HeatingDevice'>

2023-10-19 23:22:25.327 INFO (SyncWorker_6) [ViCare] detected VScotHO1_72 asGazBoiler
2023-10-19 23:22:25.563 INFO (SyncWorker_6) [custom_components.vicare] Found device: xxx545103 <class 'PyViCare.PyViCareGazBoiler.GazBoiler'>

2023-10-19 23:22:25.563 INFO (SyncWorker_6) [ViCare] Could not auto detect Heatbox1. Use generic device.
2023-10-19 23:22:25.745 INFO (SyncWorker_6) [custom_components.vicare] Found device: xxx545103 <class 'PyViCare.PyViCareHeatingDevice.HeatingDevice'>

API gives these values:

{
    "data": [
        {
            "gatewaySerial": "xxx160106",
            "id": "0",
            "boilerSerial": "xxx545103",
            "boilerSerialEditor": "DeviceCommunication",
            "bmuSerial": "xxx740107",
            "bmuSerialEditor": "DeviceCommunication",
            "createdAt": "2018-06-08T12:48:28.806Z",
            "editedAt": "2023-07-04T12:25:31.733Z",
            "modelId": "VScotHO1_72",
            "status": "Online",
            "deviceType": "heating",
            "roles": [
                "type:boiler",
                "type:legacy",
                "type:product;VScotHO1"
            ],
            "isBoilerSerialEditable": false
        },
        {
            "gatewaySerial": "xxx160106",
            "id": "gateway",
            "boilerSerial": null,
            "boilerSerialEditor": null,
            "bmuSerial": null,
            "bmuSerialEditor": null,
            "createdAt": "2021-05-19T06:32:22.925Z",
            "editedAt": "2023-10-09T14:23:14.464Z",
            "modelId": "Heatbox1",
            "status": "Online",
            "deviceType": "vitoconnect",
            "roles": [
                "type:gateway;VitoconnectOpto1",
                "type:legacy"
            ],
            "isBoilerSerialEditable": false
        }
    ]
}
Nibot1 commented 7 months ago

This issue can be closed because with the merged PR it should be fixed, right?

CFenner commented 7 months ago

Not sure, the log from above is from Home Assistant Integration. In there the serial is currently fetched with deviceConfig.getConfig().serial which always gives the gateway serial. Instead the integration should use device.getSerial() which should now also be possible for the gateways with the PR merged.

To me it's unclear if the behavior is correct that deviceConfig.getConfig().serial gives the gateway serial.

woehrl01 commented 7 months ago

@CFenner returning the gateway is correct as this value returns the accessor id which is the gateway. It also returns the device id. That method is basically an implementation detail how the url for the rest call is constructed.

We could argue if the method should be renamed to make this more obvious.