ilcato / homebridge-Fibaro-HC2

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

expose BatteryLevel #112

Closed lboue closed 5 years ago

lboue commented 6 years ago

Hello,

Could you expose BatteryLevel for those Fibaro sensors ?

Currently it seems that only FGCD001 have been implemented. May be this should work?

        case "com.fibaro.FGFS101":
        case "com.fibaro.floodSensor":
            ss = [new ShadowService(new hapService.LeakSensor(device.name), [hapCharacteristic.LeakDetected, hapCharacteristic.BatteryLevel])];
            break;
        case "com.fibaro.FGSS001":
        case "com.fibaro.smokeSensor":
            ss = [new ShadowService(new hapService.SmokeSensor(device.name), [hapCharacteristic.SmokeDetected, hapCharacteristic.BatteryLevel])];
            break;
        case "com.fibaro.FGCD001":
            ss = [new ShadowService(new hapService.CarbonMonoxideSensor(device.name), [hapCharacteristic.CarbonMonoxideDetected, hapCharacteristic.CarbonMonoxideLevel, hapCharacteristic.CarbonMonoxidePeakLevel, hapCharacteristic.BatteryLevel])];
            break;

Regards, Ludovic

lboue commented 6 years ago

Unfortunately, I didn't managed to expose the hapCharacteristic.BatteryLevel Characteristic to HomeKit. I forked this repo and added a branch called "batteryLevel".

I added debug to LoadAccessories methode in the index.js class so I can see the batteryLevel attribute returned by the HC2 REST API.

[2018-8-5 23:23:43] [FibaroHC2] # 169   [ zwaveDevice ]         s.name:  Detect. Fumée etage
[2018-8-5 23:23:43] [FibaroHC2]         [ zwaveDevice ]         dead: false
[2018-8-5 23:23:43] [FibaroHC2]         [ zwaveDevice ] batteryLevel: 100 %
[2018-8-5 23:23:43] [FibaroHC2] # 170   [ FGSS001 ]     s.name:  Detect. Fumée etage
[2018-8-5 23:23:43] [FibaroHC2]         [ FGSS001 ]     dead: false
[2018-8-5 23:23:43] [FibaroHC2]         [ FGSS001 ] batteryLevel: 100 %
[2018-8-5 23:23:43] [FibaroHC2]         ==> Added/changed accessory:  Detect. Fumée etage
[2018-8-5 23:23:43] [FibaroHC2] # 171   [ temperatureSensor ]   s.name:  Temp Couloir
[2018-8-5 23:23:43] [FibaroHC2]         [ temperatureSensor ]   dead: false
[2018-8-5 23:23:43] [FibaroHC2]         [ temperatureSensor ] batteryLevel: 100 %
[2018-8-5 23:23:43] [FibaroHC2]         ==> Added/changed accessory:  Temp Couloir
[2018-8-5 23:23:43] [FibaroHC2] # 172   [ heatDetector ]        s.name:  Alerte Couloir
[2018-8-5 23:23:43] [FibaroHC2]         [ heatDetector ]        dead: false
[2018-8-5 23:23:43] [FibaroHC2]         [ heatDetector ] batteryLevel: 100 %

[2018-8-5 23:23:43] [FibaroHC2] # 179   [ FGFS101 ]     s.name:  détecteur fuite eau
[2018-8-5 23:23:43] [FibaroHC2]         [ FGFS101 ]     dead: false
[2018-8-5 23:23:43] [FibaroHC2]         [ FGFS101 ] batteryLevel: 70 %
[2018-8-5 23:23:43] [FibaroHC2]         ==> Added/changed accessory:  détecteur fuite eau
[2018-8-5 23:23:43] [FibaroHC2] # 181   [ temperatureSensor ]   s.name:  température cellier
[2018-8-5 23:23:43] [FibaroHC2]         [ temperatureSensor ]   dead: false
[2018-8-5 23:23:43] [FibaroHC2]         [ temperatureSensor ] batteryLevel: 70 %
[2018-8-5 23:23:43] [FibaroHC2]         ==> Added/changed accessory:  température cellier

Regards, Ludovic

lboue commented 6 years ago

Actually I think those 2 characteristics are related to battery are can be used:

Regards, Ludovic

lboue commented 6 years ago

Could you tell me how can I add the hapService.BatteryService service to the accessory in the createShadowAccessory method?

I find a implementation exemple here with the homebridge-mi-aqara plugin and the SmokeDetectorParser.js class

It should be something like this: new ShadowService(new hapService.BatteryService(device.name), [hapCharacteristic.StatusLowBattery, hapCharacteristic.BatteryLevel, hapCharacteristic.ChargingState])

I tried this but without success:

            case "com.fibaro.smokeSensor":
                // Declare an array of <ShadowService>
                let smokeSensorServices = new Array();         
                // Add battery service
                batService = [new ShadowService(new hapService.BatteryService(device.name), [hapCharacteristic.StatusLowBattery, hapCharacteristic.BatteryLevel, hapCharacteristic.ChargingState])];

                // Add battery Characteristic
                var lowBatCharacteristic = batService.getCharacteristic(Characteristic.StatusLowBattery);
                var batLevelCharacteristic = batService.getCharacteristic(Characteristic.BatteryLevel);
                var chargingStateCharacteristic = batService.getCharacteristic(Characteristic.ChargingState);
                lowBattery = false;
                chargingState = false;
                batteryLevel = 10;
                lowBatCharacteristic.updateValue(lowBattery);
                batLevelCharacteristic.updateValue(batteryLevel);
                chargingStateCharacteristic.updateValue(false);

                 this.log("\t[', batService, '] \tdebug", batService);

                //batCharacteristics = [hapCharacteristic.StatusLowBattery, hapCharacteristic.BatteryLevel, hapCharacteristic.ChargingState];

                // Add SmokeSensor service
                SmokeSensorService = [new ShadowService(new hapService.SmokeSensor(device.name), [hapCharacteristic.SmokeDetected])];

                // Push services in the array
                smokeSensorServices.push(batService);
                smokeSensorServices.push(SmokeSensorService);

                this.log("\t[', createShadowAccessory, '] \tdebug", ss);
                ss = smokeSensorServices;
                break;

Regards, Ludovic

ilcato commented 6 years ago

@lboue, the first step you implemented is right; after that you must also update the getFunctions.ts file in order to map the new characteristics you added to corresponding get functions. Remember to compile the files with the TypeScript compiler. Unfortunately I'm not able to help you because my Home Center died a few weeks ago and I'm not sure to send it to repair because it's too expensive. Thinking about changing platform ...

lboue commented 6 years ago

Hello,

I tried but I am getting an error even if I clone you GitHub repo without changing anything:

pi@raspberrypi:~ $ sudo npm install -g typescript
/usr/bin/tsc -> /usr/lib/node_modules/typescript/bin/tsc
/usr/bin/tsserver -> /usr/lib/node_modules/typescript/bin/tsserver
+ typescript@3.0.3
added 1 package from 1 contributor in 9.391s

pi@raspberrypi:/tmp $ git clone https://github.com/ilcato/homebridge-Fibaro-HC2.git
Clonage dans 'homebridge-Fibaro-HC2'...
remote: Counting objects: 1146, done.
remote: Total 1146 (delta 0), reused 0 (delta 0), pack-reused 1146
Réception d'objets: 100% (1146/1146), 344.74 KiB | 515.00 KiB/s, fait.
Résolution des deltas: 100% (813/813), fait.
pi@raspberrypi:/tmp $ cd homebridge-Fibaro-HC2/
pi@raspberrypi:/tmp/homebridge-Fibaro-HC2/dist $ cd src
pi@raspberrypi:/tmp/homebridge-Fibaro-HC2/src $ ls
fibaro-api.ts  getFunctions.ts  index.ts  pollerupdate.ts  setFunctions.ts  shadows.ts

pi@raspberrypi:/tmp/homebridge-Fibaro-HC2/src $ 
pi@raspberrypi:/tmp/homebridge-Fibaro-HC2/src $ tsc getFunctions.ts 
getFunctions.ts:23:23 - error TS2304: Cannot find name 'Map'.

23  getFunctionsMapping: Map<string, any>;
                         ~~~

getFunctions.ts:24:40 - error TS2304: Cannot find name 'Map'.

24  getCurrentSecuritySystemStateMapping: Map<string, any>;
                                          ~~~

getFunctions.ts:25:39 - error TS2304: Cannot find name 'Map'.

25  getTargetSecuritySystemStateMapping: Map<string, any>;
                                         ~~~

getFunctions.ts:32:34 - error TS2304: Cannot find name 'Map'.

32      this.getFunctionsMapping = new Map([
                                       ~~~

getFunctions.ts:62:51 - error TS2304: Cannot find name 'Map'.

62      this.getCurrentSecuritySystemStateMapping = new Map([
                                                        ~~~

getFunctions.ts:69:50 - error TS2304: Cannot find name 'Map'.

69      this.getTargetSecuritySystemStateMapping = new Map([
                                                       ~~~

setFunctions.ts:27:23 - error TS2304: Cannot find name 'Map'.

27  setFunctionsMapping: Map<string, any>;
                         ~~~

setFunctions.ts:28:39 - error TS2304: Cannot find name 'Map'.

28  getTargetSecuritySystemSceneMapping: Map<number, any>;
                                         ~~~

setFunctions.ts:36:34 - error TS2304: Cannot find name 'Map'.

36      this.setFunctionsMapping = new Map([
                                       ~~~

setFunctions.ts:51:50 - error TS2304: Cannot find name 'Map'.

51      this.getTargetSecuritySystemSceneMapping = new Map([
                                                       ~~~

setFunctions.ts:142:39 - error TS2339: Property 'trunc' does not exist on type 'Math'.

142                     this.command("setTime", [0 + Math.trunc((new Date()).getTime()/1000)], service, IDs);
                                                          ~~~~~

setFunctions.ts:169:86 - error TS2339: Property 'trunc' does not exist on type 'Math'.

169                     this.command("setTime", [parseInt(this.platform.config.thermostattimeout) + Math.trunc((new Date()).getTime()/1000)], service, IDs);

So I still have the error:

[2018-9-24 18:12:37] [FibaroHC2] # 169  [ zwaveDevice ]         s.name:  Smoke sensor
[2018-9-24 18:12:37] [FibaroHC2]        [ zwaveDevice ]         dead: false
[2018-9-24 18:12:37] [FibaroHC2]        [ zwaveDevice ] batteryLevel: 100 %
[2018-9-24 18:12:37] [FibaroHC2] # 170  [ FGSS001 ]     s.name:  Smoke sensor
[2018-9-24 18:12:37] [FibaroHC2]        [ FGSS001 ]     dead: false
[2018-9-24 18:12:37] [FibaroHC2]        [ FGSS001 ] batteryLevel: 100 %
[2018-9-24 18:12:37] [FibaroHC2] Error getting data from Home Center:  ReferenceError: batService is not defined
    at Function.createShadowAccessory (/usr/lib/node_modules/homebridge-fibaro-hc2/src/shadows.ts:214:10)
    at LoadAccessories.devices.map (/usr/lib/node_modules/homebridge-fibaro-hc2/src/index.ts:200:45)
    at Array.map (<anonymous>)
    at FibaroHC2.LoadAccessories (/usr/lib/node_modules/homebridge-fibaro-hc2/src/index.ts:185:5)
    at fibaroClient.getScenes.then.then (/usr/lib/node_modules/homebridge-fibaro-hc2/src/index.ts:148:6)
    at process._tickCallback (internal/process/next_tick.js:68:7)

What did I miss?

Regards, Ludovic

lboue commented 6 years ago

I managed to find the right syntax to compile the files with the TypeScript compiler:

pi@raspberrypi:/usr/lib/node_modules/homebridge-fibaro-hc2 $ tsc -p tsconfig.json                          
src/shadows.ts:18:7 - error TS6133: 'util' is declared but its value is never read.

18 const util = require('util')

         ~~~~

src/shadows.ts:18:14 - error TS2304: Cannot find name 'require'.

18 const util = require('util')

I added debugs to print siblings object in 'object.ts' file:

    LoadAccessories(devices) {
        this.log('Loading accessories', '');
        devices.map((s, i, a) => {
            if (s.visible == true && s.name.charAt(0) != "_") {
                let siblings = this.findSiblingDevices(s, a);
                this.log('DEBUG siblings:', siblings);
                this.addAccessory(ShadowAccessory.createShadowAccessory(s, siblings, Accessory, Service, Characteristic, this));
            }
        });
[2018-9-24 18:45:09] [FibaroHC2] DEBUG siblings: Map {
  'com.fibaro.temperatureSensor' => { id: 171,
  name: 'Temp Couloir',
  roomID: 79,
  type: 'com.fibaro.temperatureSensor',
  baseType: 'com.fibaro.multilevelSensor',
  enabled: true,
  visible: true,
  isPlugin: false,
  parentId: 169,
  remoteGatewayId: 0,
  viewXml: false,
  configXml: false,
  interfaces: [ 'battery', 'zwave', 'zwaveWakeup' ],
  properties:
   { batteryLevel: 100,
     pollingTimeSec: 0,
     wakeUpTime: 21600,
     zwaveCompany: 'Fibargroup',
     zwaveInfo: '3,4,5',
     zwaveVersion: '3.2',
     batteryLowNotification: 'true',
     configured: true,
     dead: 'false',
     defInterval: '0',
     deviceControlType: '0',
     deviceIcon: '30',
     emailNotificationID: '0',
     emailNotificationType: '0',
     endPointId: '0',
     liliOffCommand: '',
     liliOnCommand: '',
     log: '',
     logTemp: '',
     manufacturer: '',
     markAsDead: 'true',
     maxInterval: '0',
     minInterval: '0',
     model: '',
     nodeId: '15',
     offset: '0.00',
     parametersTemplate: '566',
     productInfo: '1,15,12,2,16,2,3,2',
     pushNotificationID: '0',
     pushNotificationType: '0',
     remoteGatewayId: '0',
     saveLogs: 'true',
     serialNumber: '',
     showFireAlarm: 'true',
     showFreezeAlarm: 'false',
     smsNotificationID: '0',
     smsNotificationType: '0',
     stepInterval: '0',
     unit: 'C',
     useTemplate: 'true',
     userDescription: '',
     value: '19.90' },
  actions: { reconfigure: 0, setInterval: 1 },
  created: 1537304038,
  modified: 1537304038,
  sortOrder: 8 },
  'com.fibaro.heatDetector' => { id: 172,
  name: 'Alerte Couloir',
  roomID: 79,
  type: 'com.fibaro.heatDetector',
  baseType: 'com.fibaro.lifeDangerSensor',
  enabled: true,
  visible: true,
  isPlugin: false,
  parentId: 169,
  remoteGatewayId: 0,
  viewXml: false,
  configXml: false,
  interfaces: [ 'battery', 'fibaroBreach', 'zwave', 'zwaveWakeup' ],
  properties:
   { batteryLevel: 100,
     pollingTimeSec: 0,
     wakeUpTime: 21600,
     zwaveCompany: 'Fibargroup',
     zwaveInfo: '3,4,5',
     zwaveVersion: '3.2',
     batteryLowNotification: 'true',
     configured: true,
     dead: 'false',
     defInterval: '0',
     deviceControlType: '0',
     deviceIcon: '88',
     emailNotificationID: '0',
     emailNotificationType: '0',
     endPointId: '0',
     lastBreached: '0',
     liliOffCommand: '',
     liliOnCommand: '',
     log: '',
     logTemp: '',
     manufacturer: '',
     markAsDead: 'true',
     maxInterval: '0',
     minInterval: '0',
     model: '',
     nodeId: '15',
     parametersTemplate: '566',
     productInfo: '1,15,12,2,16,2,3,2',
     pushNotificationID: '0',
     pushNotificationType: '0',
     remoteGatewayId: '0',
     saveLogs: 'true',
     serialNumber: '',
     smsNotificationID: '0',
     smsNotificationType: '0',
     stepInterval: '0',
     useTemplate: 'true',
     userDescription: '',
     value: 'false' },
  actions:
   { forceArm: 0,
     meetArmConditions: 0,
     reconfigure: 0,
     setArmed: 1,
     setInterval: 1 },
  created: 1537304038,
  modified: 1537304038,
  sortOrder: 9 } }

And another debug:

[
    {
        "controlService": {
            "displayName": "Detect. Fumee etage",
            "UUID": "00000096-0000-1000-8000-0026BB765291",
            "iid": null,
            "characteristics": [
                {
                    "displayName": "Name",
                    "UUID": "00000023-0000-1000-8000-0026BB765291",
                    "iid": null,
                    "value": "Detect. Fumee etage",
                    "status": null,
                    "eventOnlyCharacteristic": false,
                    "props": {
                        "format": "string",
                        "unit": null,
                        "minValue": null,
                        "maxValue": null,
                        "minStep": null,
                        "perms": [
                            "pr"
                        ]
                    },
                    "subscriptions": 0,
                    "_events": {},
                    "_eventsCount": 1
                },
                {
                    "displayName": "Battery Level",
                    "UUID": "00000068-0000-1000-8000-0026BB765291",
                    "iid": null,
                    "value": 0,
                    "status": null,
                    "eventOnlyCharacteristic": false,
                    "props": {
                        "format": "uint8",
                        "unit": "percentage",
                        "minValue": 0,
                        "maxValue": 100,
                        "minStep": 1,
                        "perms": [
                            "pr",
                            "ev"
                        ]
                    },
                    "subscriptions": 0,
                    "_events": {},
                    "_eventsCount": 1
                },
                {
                    "displayName": "Charging State",
                    "UUID": "0000008F-0000-1000-8000-0026BB765291",
                    "iid": null,
                    "value": 0,
                    "status": null,
                    "eventOnlyCharacteristic": false,
                    "props": {
                        "format": "uint8",
                        "unit": null,
                        "minValue": 0,
                        "maxValue": 2,
                        "minStep": null,
                        "perms": [
                            "pr",
                            "ev"
                        ],
                        "validValues": [
                            0,
                            1,
                            2
                        ]
                    },
                    "subscriptions": 0,
                    "_events": {},
                    "_eventsCount": 1
                },
                {
                    "displayName": "Status Low Battery",
                    "UUID": "00000079-0000-1000-8000-0026BB765291",
                    "iid": null,
                    "value": 0,
                    "status": null,
                    "eventOnlyCharacteristic": false,
                    "props": {
                        "format": "uint8",
                        "unit": null,
                        "minValue": 0,
                        "maxValue": 1,
                        "minStep": null,
                        "perms": [
                            "pr",
                            "ev"
                        ],
                        "validValues": [
                            0,
                            1
                        ]
                    },
                    "subscriptions": 0,
                    "_events": {},
                    "_eventsCount": 1
                }
            ],
            "optionalCharacteristics": [
                {
                    "displayName": "Name",
                    "UUID": "00000023-0000-1000-8000-0026BB765291",
                    "iid": null,
                    "value": "",
                    "status": null,
                    "eventOnlyCharacteristic": false,
                    "props": {
                        "format": "string",
                        "unit": null,
                        "minValue": null,
                        "maxValue": null,
                        "minStep": null,
                        "perms": [
                            "pr"
                        ]
                    },
                    "subscriptions": 0
                }
            ],
            "isHiddenService": false,
            "isPrimaryService": false,
            "linkedServices": []
        },
        "characteristics": [
            null,
            null,
            null
        ]
    }
]

This is my code:

            case "com.fibaro.FGSS001":
            case "com.fibaro.smokeSensor":
                let smokeSensorServices = new Array();

                // Add battery service
                batService = [new ShadowService(new hapService.BatteryService(device.name), [hapCharacteristic.StatusLowBattery, hapCharacteristic.BatteryLevel, hapCharacteristic.ChargingState])];
                console.log(JSON.stringify(batService, null, 4));

                // Add battery Characteristic
                var lowBatCharacteristic = batService.getCharacteristic(hapCharacteristic.StatusLowBattery);
                var batLevelCharacteristic = batService.getCharacteristic(hapCharacteristic.BatteryLevel);
                var chargingStateCharacteristic = batService.getCharacteristic(hapCharacteristic.ChargingState);
                let lowBattery = false;
                let chargingState = false;
                let batteryLevel = 10;
                lowBatCharacteristic.updateValue(lowBattery);
                batLevelCharacteristic.updateValue(batteryLevel);
                chargingStateCharacteristic.updateValue(chargingState);

                //batCharacteristics = [hapCharacteristic.StatusLowBattery, hapCharacteristic.BatteryLevel, hapCharacteristic.ChargingState];

                // Add SmokeSensor service
                let SmokeSensorService = [new ShadowService(new hapService.SmokeSensor(device.name), [hapCharacteristic.SmokeDetected])];
                console.log(JSON.stringify(SmokeSensorService, null, 4));

                // Push services in the array
                smokeSensorServices.push(batService);
                smokeSensorServices.push(SmokeSensorService);

                // Return an arroy of <ShadowService>
                ss = smokeSensorServices;

                // Previous code
                //ss = [new ShadowService(new hapService.SmokeSensor(device.name), [hapCharacteristic.SmokeDetected])];
                break;
            case "com.fibaro.FGCD001":
                ss = [new ShadowService(new hapService.CarbonMonoxideSensor(device.name), [hapCharacteristic.CarbonMonoxideDetected, hapCharacteristic.CarbonMonoxideLevel, hapCharacteristic.CarbonMonoxidePeakLevel, hapCharacteristic.BatteryLevel])];
                break;

And I get this error:

[2018-9-24 18:45:09] [FibaroHC2] Error getting data from Home Center:  TypeError: batService.getCharacteristic is not a function
    at Function.createShadowAccessory (/usr/lib/node_modules/homebridge-fibaro-hc2/src/shadows.ts:197:55)
    at LoadAccessories.devices.map (/usr/lib/node_modules/homebridge-fibaro-hc2/src/index.ts:186:39)
    at Array.map (<anonymous>)
    at FibaroHC2.LoadAccessories (/usr/lib/node_modules/homebridge-fibaro-hc2/src/index.ts:182:11)
    at fibaroClient.getScenes.then.then (/usr/lib/node_modules/homebridge-fibaro-hc2/src/index.ts:147:10)
    at process._tickCallback (internal/process/next_tick.js:68:7)

Could you help me to fix it?

Regards, Ludovic

ilcato commented 6 years ago

Whats 'util' ?

ilcato commented 6 years ago

Regarding the runtime error, as I mentioned earlier, you must also implement a new entry in GetFunctions.ts

lboue commented 6 years ago

I was trying to import util for using the util.inspect method to help debugging

this.log(util.inspect(batService))

I commented it out.

I also added this in GetFunctions.ts

    getBatteryLevel(callback, characteristic, service, IDs, properties) {
        let r = parseFloat(properties.batteryLevel);
        this.platform.log("properties.batteryLevel: ", properties.batteryLevel);
        console.log(JSON.stringify(characteristic, null, 4));
        this.returnValue(r, callback, characteristic);
    }
lboue commented 6 years ago

I commited my changes on my GitHub repo here: https://github.com/lboue/homebridge-Fibaro-HC2/commit/4f91d7f04a9106870cfe668b31455119f5ea28d5

Now I got this new error:

[2018-9-24 20:40:03] [FibaroHC2] Error getting data from Home Center:  TypeError: Cannot read property 'subtype' of undefined
    at new ShadowAccessory (/usr/lib/node_modules/homebridge-fibaro-hc2/src/shadows.ts:57:35)
    at Function.createShadowAccessory (/usr/lib/node_modules/homebridge-fibaro-hc2/src/shadows.ts:291:12)
    at LoadAccessories.devices.map (/usr/lib/node_modules/homebridge-fibaro-hc2/src/index.ts:186:39)
    at Array.map (<anonymous>)
    at FibaroHC2.LoadAccessories (/usr/lib/node_modules/homebridge-fibaro-hc2/src/index.ts:182:11)
    at fibaroClient.getScenes.then.then (/usr/lib/node_modules/homebridge-fibaro-hc2/src/index.ts:147:10)
    at process._tickCallback (internal/process/next_tick.js:68:7)
(node:527) UnhandledPromiseRejectionWarning: Error: Startup error: get scenes or devices
    at fibaroClient.getScenes.then.then.catch (/usr/lib/node_modules/homebridge-fibaro-hc2/src/index.ts:151:11)
    at process._tickCallback (internal/process/next_tick.js:68:7)
(node:527) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). (rejection id: 1)
(node:527) [DEP0018] DeprecationWarning: Unhandled promise rejections are deprecated. In the future, promise rejections that are not handled will terminate the Node.js process with a non-zero exit code.
lboue commented 6 years ago

I did have the last error anymore but I didn't understand why I can't see any changes on the HomeKit app.

So I decided to rename the accessory on the HC2 side. And it worked only for "Status Low Battery":

pi@raspberrypi:/usr/lib/node_modules/homebridge-fibaro-hc2 $ tsc -p tsconfig.json 
pi@raspberrypi:/usr/lib/node_modules/homebridge-fibaro-hc2 $ homebridge -D 2>&1 |grep FibaroHC2
[2018-9-24 22:33:25] Registering platform 'homebridge-fibaro-hc2.FibaroHC2'
[2018-9-24 22:33:31] [FibaroHC2] Initializing FibaroHC2 platform...
[2018-9-24 22:33:31] [FibaroHC2] Configured Accessory:  Guirlande
[2018-9-24 22:33:31] [FibaroHC2] Configured Accessory:  VR Sejour
[2018-9-24 22:33:31] [FibaroHC2] Configured Accessory:  VR Chambre Parents
[2018-9-24 22:33:31] [FibaroHC2] Configured Accessory:  VR Chambre Coline
[2018-9-24 22:33:31] [FibaroHC2] Configured Accessory:  Lampe Etagère
[2018-9-24 22:33:31] [FibaroHC2] Configured Accessory:  PC
[2018-9-24 22:33:31] [FibaroHC2] Configured Accessory:  LightBox
[2018-9-24 22:33:31] [FibaroHC2] Configured Accessory:  Ecran PC
[2018-9-24 22:33:31] [FibaroHC2] Configured Accessory:  Sonnette
[2018-9-24 22:33:31] [FibaroHC2] Configured Accessory:  Multiprise - P6
[2018-9-24 22:33:31] [FibaroHC2] Configured Accessory:  VR Salon
[2018-9-24 22:33:31] [FibaroHC2] Configured Accessory:  Seche-serviettes
[2018-9-24 22:33:31] [FibaroHC2] Configured Accessory:  VR Cuisine
[2018-9-24 22:33:31] [FibaroHC2] Configured Accessory:  VR Bureau
[2018-9-24 22:33:31] [FibaroHC2] Configured Accessory:  Temp Couloir
[2018-9-24 22:33:31] [FibaroHC2] Configured Accessory:  détecteur fuite eau
[2018-9-24 22:33:31] [FibaroHC2] Configured Accessory:  température cellier
[2018-9-24 22:33:31] [FibaroHC2] Configured Accessory:  VR Parents Etage
[2018-9-24 22:33:31] [FibaroHC2] Configured Accessory:  VR Coline Étage
[2018-9-24 22:33:31] [FibaroHC2] Configured Accessory:  Lampe couloir étage
[2018-9-24 22:33:31] [FibaroHC2] Configured Accessory:  Lampe Ch. parents 2
[2018-9-24 22:33:31] [FibaroHC2] Configured Accessory:  Freebox mini
[2018-9-24 22:33:31] [FibaroHC2] Configured Accessory:  Detect. Fumee etage
[2018-9-24 22:33:32] [FibaroHC2] didFinishLaunching. 
[2018-9-24 22:33:32] [FibaroHC2] Loading accessories 
[2018-9-24 22:33:32] [FibaroHC2] Added/changed accessory:  Guirlande
[2018-9-24 22:33:32] [FibaroHC2] Added/changed accessory:  Freebox mini
[2018-9-24 22:33:32] [FibaroHC2] Added/changed accessory:  VR Sejour
[2018-9-24 22:33:32] [FibaroHC2] Added/changed accessory:  VR Chambre Parents
[2018-9-24 22:33:32] [FibaroHC2] Added/changed accessory:  VR Chambre Coline
[2018-9-24 22:33:32] [FibaroHC2] Added/changed accessory:  Lampe Etagère
[2018-9-24 22:33:32] [FibaroHC2] Added/changed accessory:  PC
[2018-9-24 22:33:32] [FibaroHC2] Added/changed accessory:  LightBox
[2018-9-24 22:33:32] [FibaroHC2] Added/changed accessory:  Ecran PC
[2018-9-24 22:33:33] [FibaroHC2] Added/changed accessory:  Sonnette
[2018-9-24 22:33:33] [FibaroHC2] Added/changed accessory:  Multiprise - P6
[2018-9-24 22:33:33] [FibaroHC2] Added/changed accessory:  VR Salon
[2018-9-24 22:33:33] [FibaroHC2] Added/changed accessory:  Seche-serviettes
[2018-9-24 22:33:33] [FibaroHC2] Added/changed accessory:  VR Cuisine
[2018-9-24 22:33:33] [FibaroHC2] Added/changed accessory:  VR Bureau
[2018-9-24 22:33:33] [FibaroHC2] Added/changed accessory:  Detect. Fumee etage
[2018-9-24 22:33:33] [FibaroHC2] Added/changed accessory:  Temp Couloir
[2018-9-24 22:33:33] [FibaroHC2] Added/changed accessory:  Detecteur fuite
[2018-9-24 22:33:33] [FibaroHC2] Added/changed accessory:  température cellier
[2018-9-24 22:33:33] [FibaroHC2] Added/changed accessory:  VR Parents Etage
[2018-9-24 22:33:33] [FibaroHC2] Added/changed accessory:  VR Coline Étage
[2018-9-24 22:33:33] [FibaroHC2] Added/changed accessory:  Lampe couloir étage
[2018-9-24 22:33:33] [FibaroHC2] Added/changed accessory:  Lampe Ch. parents 2
[2018-9-24 22:33:33] [FibaroHC2] Remove accessory détecteur fuite eau
[2018-9-24 22:34:00] [FibaroHC2] Getting value from device:  104  parameter: Current Position
[2018-9-24 22:34:00] [FibaroHC2] Getting value from device:  104  parameter: Target Position
[2018-9-24 22:34:00] [FibaroHC2] Getting value from device:  60  parameter: Current Position
[2018-9-24 22:34:00] [FibaroHC2] Getting value from device:  60  parameter: Target Position
[2018-9-24 22:34:00] [FibaroHC2] Getting value from device:  57  parameter: On
[2018-9-24 22:34:00] [FibaroHC2] Getting value from device:  74  parameter: On
[2018-9-24 22:34:00] [FibaroHC2] Getting value from device:  56  parameter: On
[2018-9-24 22:34:00] [FibaroHC2] Getting value from device:  59  parameter: Target Position
[2018-9-24 22:34:00] [FibaroHC2] Getting value from device:  59  parameter: Current Position
[2018-9-24 22:34:00] [FibaroHC2] Getting value from device:  203  parameter: Target Position
[2018-9-24 22:34:00] [FibaroHC2] Getting value from device:  203  parameter: Current Position
[2018-9-24 22:34:00] [FibaroHC2] Getting value from device:  170  parameter: Smoke Detected
[2018-9-24 22:34:00] [FibaroHC2] Getting value from device:  170  parameter: Status Low Battery
[2018-9-24 22:34:00] [FibaroHC2] Getting value from device:  171  parameter: Current Temperature
[2018-9-24 22:34:00] [FibaroHC2] Getting value from device:  69  parameter: Target Position
[2018-9-24 22:34:00] [FibaroHC2] Getting value from device:  69  parameter: Current Position
[2018-9-24 22:34:00] [FibaroHC2] Getting value from device:  212  parameter: On
[2018-9-24 22:34:00] [FibaroHC2] Getting value from device:  212  parameter: Brightness
[2018-9-24 22:34:00] [FibaroHC2] Getting value from device:  58  parameter: Current Position
[2018-9-24 22:34:00] [FibaroHC2] Getting value from device:  58  parameter: Target Position
[2018-9-24 22:34:00] [FibaroHC2] Getting value from device:  152  parameter: Target Position
[2018-9-24 22:34:00] [FibaroHC2] Getting value from device:  152  parameter: Current Position
[2018-9-24 22:34:00] [FibaroHC2] Getting value from device:  206  parameter: Target Position
[2018-9-24 22:34:00] [FibaroHC2] Getting value from device:  206  parameter: Current Position
[2018-9-24 22:34:00] [FibaroHC2] Getting value from device:  217  parameter: On
[2018-9-24 22:34:00] [FibaroHC2] Getting value from device:  217  parameter: Brightness
[2018-9-24 22:34:01] [FibaroHC2] Getting value from device:  104  parameter: Current Position
[2018-9-24 22:34:01] [FibaroHC2] Getting value from device:  104  parameter: Target Position
[2018-9-24 22:34:01] [FibaroHC2] Getting value from device:  60  parameter: Current Position
[2018-9-24 22:34:01] [FibaroHC2] Getting value from device:  60  parameter: Target Position
[2018-9-24 22:34:01] [FibaroHC2] Getting value from device:  57  parameter: On
[2018-9-24 22:34:01] [FibaroHC2] Getting value from device:  74  parameter: On
[2018-9-24 22:34:01] [FibaroHC2] Getting value from device:  56  parameter: On
[2018-9-24 22:34:01] [FibaroHC2] Getting value from device:  59  parameter: Target Position
[2018-9-24 22:34:01] [FibaroHC2] Getting value from device:  59  parameter: Current Position
[2018-9-24 22:34:01] [FibaroHC2] Getting value from device:  203  parameter: Target Position
[2018-9-24 22:34:01] [FibaroHC2] Getting value from device:  203  parameter: Current Position
[2018-9-24 22:34:01] [FibaroHC2] Getting value from device:  170  parameter: Smoke Detected
[2018-9-24 22:34:01] [FibaroHC2] Getting value from device:  170  parameter: Status Low Battery
[2018-9-24 22:34:01] [FibaroHC2] Getting value from device:  171  parameter: Current Temperature
[2018-9-24 22:34:01] [FibaroHC2] Getting value from device:  69  parameter: Current Position
[2018-9-24 22:34:01] [FibaroHC2] Getting value from device:  69  parameter: Target Position
[2018-9-24 22:34:01] [FibaroHC2] Getting value from device:  179  parameter: Leak Detected
[2018-9-24 22:34:01] [FibaroHC2] Getting value from device:  179  parameter: Status Low Battery
[2018-9-24 22:34:01] [FibaroHC2] Getting value from device:  212  parameter: Brightness
[2018-9-24 22:34:01] [FibaroHC2] Getting value from device:  212  parameter: On
[2018-9-24 22:34:01] [FibaroHC2] Getting value from device:  58  parameter: Current Position
[2018-9-24 22:34:01] [FibaroHC2] Getting value from device:  58  parameter: Target Position
[2018-9-24 22:34:01] [FibaroHC2] Getting value from device:  152  parameter: Target Position
[2018-9-24 22:34:01] [FibaroHC2] Getting value from device:  152  parameter: Current Position
[2018-9-24 22:34:01] [FibaroHC2] Getting value from device:  206  parameter: Target Position
[2018-9-24 22:34:01] [FibaroHC2] Getting value from device:  206  parameter: Current Position
[2018-9-24 22:34:01] [FibaroHC2] Getting value from device:  217  parameter: On
[2018-9-24 22:34:01] [FibaroHC2] Getting value from device:  217  parameter: Brightness
[2018-9-24 22:34:14] [FibaroHC2] Getting value from device:  67  parameter: On
[2018-9-24 22:34:14] [FibaroHC2] Getting value from device:  62  parameter: On
[2018-9-24 22:34:14] [FibaroHC2] Getting value from device:  65  parameter: On
[2018-9-24 22:34:14] [FibaroHC2] Getting value from device:  63  parameter: On
[2018-9-24 22:34:14] [FibaroHC2] Getting value from device:  181  parameter: Current Temperature
[2018-9-24 22:34:14] [FibaroHC2] Getting value from device:  64  parameter: On
[2018-9-24 22:34:14] [FibaroHC2] Getting value from device:  66  parameter: On

How can I flush the cache for all accessories?

ilcato commented 6 years ago

Delete the accessories folder in .homebridge

lboue commented 6 years ago

What if I can't loose all my history (fakegato-history) stored in the accessories folder in .homebridge?

ilcato commented 6 years ago

Don't know

lboue commented 5 years ago

Fixed by PR #150.