Git Product home page Git Product logo

Comments (20)

snowdd1 avatar snowdd1 commented on August 14, 2024

It's a topic of the new homebridge plugin structure. I need to implement an accessory remover that can erase single accessories without deleting all of the data.

from homebridge-knx.

snowdd1 avatar snowdd1 commented on August 14, 2024

Now there is a tiny webserver at {yourIp}:18081/list that shows which devices (accessories) are in the homebridge cache:

Restored devices from homebridge cache:

Device Arbeitszimmerlampe
Device Arbeitszimmerrollo
Device TestDevice

Next step is to make them deletable.

from homebridge-knx.

misc2000 avatar misc2000 commented on August 14, 2024

OK I will take a look tomorrow.
But whats about making a hash over the device configuration and store it together with the cache.
And compare this hash every time homebridge is starting up again and if the hash is changed during the startup the cache of the device with the changed hash value need to be also deleted...

from homebridge-knx.

snowdd1 avatar snowdd1 commented on August 14, 2024

The hash is already there. I could include a setting to tell homebridge-KNX to remove all accessories that were loaded from cache but are not found in the configuration.
The UUID fields that homebridge-knx writes to the config are the keys that can be used to identify accessories. That's why users must not change them after first startup.

from homebridge-knx.

snowdd1 avatar snowdd1 commented on August 14, 2024

Sorry misunderstood your post. You want to re-create the whole device if it was changed. That would mean removing it from any scene, room etc if you change a group address- I don't think that's a good idea.

from homebridge-knx.

misc2000 avatar misc2000 commented on August 14, 2024

my idea was to remove devices that are no longer in the config file and more important to remove the cache of changed devices. most time when you try out new things you do step by step modifications on the same device and homebridge do not care this changes inside the device or show the device twice (old and new version) :-(

from homebridge-knx.

snowdd1 avatar snowdd1 commented on August 14, 2024

Homebridge caches the accessories, and they are identified on startup by their UUID strings (services with their subtype strings). Those strings are written to the knx_config.json.

So when you change the knx_config you should always start with the version from the homebridge server, and not with a fresh one, because with a fresh knx_config will not match any of the cached devices, and you have all devices twice.

I will implement the accessory remover that will do both - be able to delete orphaned devices (no config entry) and delete the cache of existing devices in order to reload the device on next startup.

How ever, I will not be able to work on that probably for the next days, until then you will need to delete the accessories folder in the homebridge folder to reload the accessories from the config.

from homebridge-knx.

misc2000 avatar misc2000 commented on August 14, 2024

OK Thanks.
In the past I never copied the knx_config.json from the RasPI back to modify it. I think I need to do it from now on.

from homebridge-knx.

snowdd1 avatar snowdd1 commented on August 14, 2024

I just committed some changes for the cached accessories.
You can now open a browser at http://yourServerNameOrIP:18081/list and delete accessories from the cache. right now, only accessories that were already in the cache when homebridge started are shown. So you probably need to restart homebridge twice if you want to make changes to a new device.

from homebridge-knx.

snowdd1 avatar snowdd1 commented on August 14, 2024

Fun thing is: they immediately vanish in Home 😄

from homebridge-knx.

snowdd1 avatar snowdd1 commented on August 14, 2024

Next push: shows also devices from knx_config.json that were not loaded from cache at startup.

from homebridge-knx.

misc2000 avatar misc2000 commented on August 14, 2024

sounds good. I will give it a try right now...

from homebridge-knx.

misc2000 avatar misc2000 commented on August 14, 2024

I did try to delete a device from the cache with the web gui and get this error:

/usr/local/lib/node_modules/homebridge/lib/api.js:166
throw new Error(pluginName + " - " + platformName + " attempt to unregister an accessory that isn't PlatformAccessory!");
^

Error: undefined - undefined attempt to unregister an accessory that isn't PlatformAccessory!
at API.unregisterPlatformAccessories (/usr/local/lib/node_modules/homebridge/lib/api.js:166:13)
at KNXPlatform. (/usr/local/lib/node_modules/homebridge-knx/index.js:263:20)
at emitTwo (events.js:87:13)
at Server.emit (events.js:172:7)
at HTTPParser.parserOnIncoming as onIncoming
at HTTPParser.parserOnHeadersComplete (_http_common.js:88:23)

during next start (after the crash) the status web page looks like this::
(2 devices are shown as cached and also as new loaded and the device I tried to delete from the cache is not shown at all.

Restored devices from homebridge cache:

Device Einbruchmeldezentrale alpha [Delete from cache!]
Device Test alpha [Delete from cache!]

Devices from homebridge-knx config:

Device Einbruchmeldezentrale alpha [Delete from cache!]
Device Test alpha [Delete from cache!]

from homebridge-knx.

snowdd1 avatar snowdd1 commented on August 14, 2024

Strange. Have to investigate this evening.

from homebridge-knx.

snowdd1 avatar snowdd1 commented on August 14, 2024

Did you manage to click twice on the delete link? Because it got deleted - a second attempt to delete the same accessory will exactly look like your error.

from homebridge-knx.

misc2000 avatar misc2000 commented on August 14, 2024

I don't think I clicked twice, but who knows. Later today during a second try it worked without a crash.

from homebridge-knx.

snowdd1 avatar snowdd1 commented on August 14, 2024

Maybe I can see to catch that possibility in the code, later this weekend maybe.

from homebridge-knx.

snowdd1 avatar snowdd1 commented on August 14, 2024

Caught in latest commit - a little nasty with a try-catch block but should suffice for that.

from homebridge-knx.

snowdd1 avatar snowdd1 commented on August 14, 2024

All devices that were present at startup occur twice in the list - once as read from cache, and once as read from knx_config.json:
image

from homebridge-knx.

snowdd1 avatar snowdd1 commented on August 14, 2024

Now you can even restart homebridge - given that you have it running as a systemd service with restart option, or are using forever to restart it if it fails:

image

It simply throws an exception ("Committed_Suicide") and that kills the node process as all unhandled exceptions kill it.

from homebridge-knx.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.