Skip to content

Don't call handleDeviceAdded() on startup #66

@benfrancis

Description

@benfrancis

I've noticed that when the virtual things adapter is installed and enabled, the adapter sends a bunch of thingAdded IPC messages to the gateway on startup.

I think this is a result of this.adapter.handleDeviceAdded(this)) being called in the constructor of the VirtualThingsDevice class https://github.com/WebThingsIO/virtual-things-adapter/blob/master/virtual-things-adapter.js#L1318

The result of this is that when the add-on starts up, it sends a thingAdded message to the gateway for each of the many virtual things exposed by the add-on. For things which have already been added to the gateway this results in its Thing Description being over-written in the gateway's database with the Thing Description provided in the IPC message.

This means that every time the gateway starts up there are multiple database writes happening that don't need to happen.

I think thingAdded messages are only meant to be sent by adapters when the gateway starts the pairing process, so these messages shouldn't be sent at all on startup.

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions