ilcato / homebridge-Fibaro-HC2

Homebridge plugin for Fibaro Home Center 2 (and Home Center Lite ...)
Apache License 2.0
66 stars 27 forks source link

Improve AccessoryInformation exposes #111

Closed lboue closed 5 years ago

lboue commented 6 years ago

Hello,

Could you improve AccessoryInformation published informations? For exemple with something like this code:

class ShadowAccessory {
...
        var type = device.type.replace(/com.fibaro./i, ''); // ex: com.fibaro.FGRM222 => FGRM222
        this.model = type;
        this.version = '4.140' // Replace with dynamic REST API GET 

        /* TODO get API INFO
        this.serial = "HC2-123456" // Replace with dynamic REST API GET 
        https://manuals.fibaro.com/content/other/FIBARO_System_REST_API.pdf
        http://@HC2/api/settings/info
        "serialNumber": "HC2-123456",
        "hcName": "HC2-123456",
        "mac": "00:22:4d:ab:aa:aa",
        "softVersion": "4.140",
        */
        this.accessory = null,
        this.hapAccessory = hapAccessory;
...
    initAccessory() {
        this.accessory.getService(this.hapService.AccessoryInformation)
            .setCharacteristic(this.hapCharacteristic.Manufacturer, "Fibaro")
            .setCharacteristic(this.hapCharacteristic.Model, this.model)
            .setCharacteristic(Characteristic.FirmwareRevision, this.version)
            .setCharacteristic(this.hapCharacteristic.SerialNumber, this.serial);
    }

I don't know exactly where and how implement a getInfo() method to pull URL http://@HC2/api/settings/info and get values:

{
    "serialNumber": "HC2-123456",
    "hcName": "HC2-123456",
    "mac": "00:22:4d:ab:aa:aa",
    "softVersion": "4.140",
    "beta": false,
    "zwaveVersion": "3.67",
    "timeFormat": 24,
    "zwaveRegion": "EU",
    "serverStatus": 1532815954,
    "defaultLanguage": "fr",
    "sunsetHour": "21:32",
    "sunriseHour": "06:45",
    "hotelMode": false,
    "updateStableAvailable": true,
    "temperatureUnit": "C",
    "newestStableVersion": "4.180",
    "updateBetaAvailable": true,
    "newestBetaVersion": "4.162",
    "batteryLowNotification": true,
    "smsManagement": true,
    "date": "18:05 | 5.8.2018",
    "timestamp": 1533485157,
    "online": true,
    "recoveryCondition": "Ok"
}

Regards, Ludovic

lboue commented 5 years ago

Fixed by #149