nicoduj / homebridge-harmony

Harmony websocket plugin for homebridge
The Unlicense
215 stars 23 forks source link

Changes in cachedAccessories killing complete Harmony structure #235

Closed mensa84 closed 4 years ago

mensa84 commented 4 years ago

Hello,

today I removed an old entry (unused power outlet from plugin TplinkSmarthome) so that it will disappear in Apple HomeKit. But the problem is, that everytime I change anything in the file cachedAccessories, that I have to re-create alle automations and set all rooms for each Harmony Hub in HomeKit again. Why is that?? This is really annoying, cause I have 3 hubs and a lot of automations.

Other plugins does not have that behaviour.

nicoduj commented 4 years ago

Hi, can you explain a bit more what you did exactly ? Purge cachedAccessories folder ? If plugins don't rely on cache, but on a static "id", indeed they won't behave like this if you clean cache but plugins that behaves on cache should have the same behavior.

On the opposite, as far as I konw, you could have same problems with plugins that don't use cache if they can't publish the accessory for any reason (hub not available, device not reachable at startup) : device will be lost from home point of view and thus will be lost like automations.

I think the right way to deal with such things is that plugins which rely on cache should adapt themselves if any device is removed / added on the platform itself, which is I agree not always easy to do. In your case,, I think you should have to relaunch homebirdge with a correct config of tplink and the plugin should remove the old devices from cache.

However, I don't think there is a silver bullet for such problems, but f anyone as any idea ...

mensa84 commented 4 years ago

Hello, I just removed the part below for one device from cachedAccessories file and got the result what I wanted: That this device is gone. I do not complain about any other plugins, I report, that it seems that your Plugins seems to have big problems when one changes something of other plugins in cachedAccessories. All my Harmony icons and automations in HomeKit was mixxed up or stopped working. Why???

Here is the part I removed correctly:

{"plugin":"homebridge-tplink-smarthome","platform":"TplinkSmarthome","displayName":"Heizlüfter","UUID":"467435f4-2c2e-4e12-b5c4-daf1bb06d63a","category":7,"context":{"deviceId":"80060532CA0078FA341CCA86B33B408B19E2DA60"},"linkedServices":{"0000003E-0000-1000-8000-0026BB765291":[],"00000047-0000-1000-8000-0026BB765291":[]},"services":[{"UUID":"0000003E-0000-1000-8000-0026BB765291","characteristics":[{"displayName":"Identify","UUID":"00000014-0000-1000-8000-0026BB765291","props":{"format":"bool","unit":null,"minValue":null,"maxValue":null,"minStep":null,"perms":["pw"]},"value":false,"eventOnlyCharacteristic":false},{"displayName":"Manufacturer","UUID":"00000020-0000-1000-8000-0026BB765291","props":{"format":"string","unit":null,"minValue":null,"maxValue":null,"minStep":null,"perms":["pr"]},"value":"TP-Link","eventOnlyCharacteristic":false},{"displayName":"Model","UUID":"00000021-0000-1000-8000-0026BB765291","props":{"format":"string","unit":null,"minValue":null,"maxValue":null,"minStep":null,"perms":["pr"]},"value":"HS110(EU)","eventOnlyCharacteristic":false},{"displayName":"Name","UUID":"00000023-0000-1000-8000-0026BB765291","props":{"format":"string","unit":null,"minValue":null,"maxValue":null,"minStep":null,"perms":["pr"]},"value":"Heizlüfter","eventOnlyCharacteristic":false},{"displayName":"Serial Number","UUID":"00000030-0000-1000-8000-0026BB765291","props":{"format":"string","unit":null,"minValue":null,"maxValue":null,"minStep":null,"perms":["pr"]},"value":"AC:84:C6:29:02:EA 80060532CA0078FA341CCA86B33B408B19E2DA60","eventOnlyCharacteristic":false},{"displayName":"Firmware Revision","UUID":"00000052-0000-1000-8000-0026BB765291","props":{"format":"string","unit":null,"minValue":null,"maxValue":null,"minStep":null,"perms":["pr"]},"value":"1.5.4 Build 180815 Rel.121440","eventOnlyCharacteristic":false},{"displayName":"Hardware Revision","UUID":"00000053-0000-1000-8000-0026BB765291","props":{"format":"string","unit":null,"minValue":null,"maxValue":null,"minStep":null,"perms":["pr"]},"value":"2.0","eventOnlyCharacteristic":false}]},{"displayName":"Heizlüfter","UUID":"00000047-0000-1000-8000-0026BB765291","characteristics":[{"displayName":"Name","UUID":"00000023-0000-1000-8000-0026BB765291","props":{"format":"string","unit":null,"minValue":null,"maxValue":null,"minStep":null,"perms":["pr"]},"value":"Heizlüfter","eventOnlyCharacteristic":false},{"displayName":"On","UUID":"00000025-0000-1000-8000-0026BB765291","props":{"format":"bool","unit":null,"minValue":null,"maxValue":null,"minStep":null,"perms":["pr","pw","ev"]},"value":false,"eventOnlyCharacteristic":false},{"displayName":"Outlet In Use","UUID":"00000026-0000-1000-8000-0026BB765291","props":{"format":"bool","unit":null,"minValue":null,"maxValue":null,"minStep":null,"perms":["pr","ev"]},"value":false,"eventOnlyCharacteristic":false},{"displayName":"Amperes","UUID":"E863F126-079E-48FF-8F27-9C2605A29F52","props":{"format":"float","unit":"A","minValue":0,"maxValue":65535,"minStep":0.01,"perms":["pr","ev"]},"value":0.02,"eventOnlyCharacteristic":false},{"displayName":"Total Consumption","UUID":"E863F10C-079E-48FF-8F27-9C2605A29F52","props":{"format":"float","unit":"kWh","minValue":0,"maxValue":65535,"minStep":0.001,"perms":["pr","ev"]},"value":66.529,"eventOnlyCharacteristic":false},{"displayName":"Apparent Power","UUID":"E863F110-079E-48FF-8F27-9C2605A29F52","props":{"format":"uint16","unit":"VA","minValue":0,"maxValue":65535,"minStep":1,"perms":["pr","ev"]},"value":6,"eventOnlyCharacteristic":false},{"displayName":"Volts","UUID":"E863F10A-079E-48FF-8F27-9C2605A29F52","props":{"format":"float","unit":"V","minValue":0,"maxValue":65535,"minStep":0.1,"perms":["pr","ev"]},"value":230,"eventOnlyCharacteristic":false},{"displayName":"Consumption","UUID":"E863F10D-079E-48FF-8F27-9C2605A29F52","props":{"format":"float","unit":"W","minValue":0,"maxValue":65535,"minStep":0.1,"perms":["pr","ev"]},"value":0,"eventOnlyCharacteristic":false}]}]},

nicoduj commented 4 years ago

"why ???" Don't know, especially if you don't share your conf at least first.

Moreover, this plugin is developed as it is, free, and I am doing my best as a hobby developper to support it. You are welcome to code / participate yourself through pull request, learn the not so easy structure of homekit / homebridge plugin, and if you are not pleased with it, choose another plugin .

mensa84 commented 4 years ago

I understand absolutely, and I don't mean something bad. But I just don't understand why removing something of another plugin effects the harmony plugin.

This is my config, is this OK?

    "platforms": [{
        "platform": "HarmonyHubWebSocket",
        "name": "Wohnzimmer Fernseher",
        "hubIP": "192.168.1.20",
        "mainActivity": "Apple TV",
        "switchAccessories": true,
        "otherPlatforms": [{
            "name": "Schlafzimmer Fernseher",
            "hubIP": "192.168.1.30",
            "mainActivity": "Apple TV",
            "switchAccessories": true
        }, {
            "name": "Badezimmer Fernseher",
            "hubIP": "192.168.1.40",
            "mainActivity": "Apple TV",
            "switchAccessories": true
        }]
    }
nicoduj commented 4 years ago

The config seems ok, don't know what happened, can you reproduce it or not ?

I add / remove plugins quite often and don't have such problems, but like I said, I never play with the file in cached accessory, don't even know if it is a homebridge or plugin problem, or an error while editing the file.

From my side, accessories are created from cache at startup if they exist. If they were removed, you should have a log at startup saying so in my plugin.

What logs did you have after restarting homebridge (after deleting item in the cache file, homebridge stopped I think).

nicoduj commented 4 years ago

I can't reproduce your problem. If you have any backup of your cachedAccessory file before and after the change, might take a look, but can't do more without .

nicoduj commented 4 years ago

Closing, can't reproduce. Since it was a "manual" and undocumented operation, not sure what happened, sorry.