Hello, I’m having problems with discovery service of Nuki binding I’m updating. The discovery process for discovering Nuki bridges works like this:
- User starts discovery, the binding calls API for obtaining list of Nuki bridges on the same network
- Binding attemps to obtain API token for each bridge by calling HTTP endpoint on the bridge
- If user then presses button on the bridge, that HTTP call succeedes and returns valid API token. Binding then creates bridge with token as a discovery result
- If user fails to press button within 30s, the HTTP call fails, binding then creates discovery result wihtout token (and user must supply it manually)
Every time discovery is started, it will discover the same bridge which was already previously configured. User does not expect this and won’t press the button on bridge again and thus after the 30s interval bridge is discovered without API token. But since the id of bridge is the same as the id of existing bridge, it is not displayed in inbox as a new thing.
Now the problem - every time bridge discovery result is created without token, it will call
initialize() method on existing bridge, but now
getConfigAs method returns configuration without API token - the discovery result rewrites configuration of existing thing.
Is there a way to prevent this? Maybe somehow get list of existing things when starting discovery and skip discovering already configured bridges?