COMPONENTNAME_NOT_FOUND

Patrick  Michael Vogt

I am getting the COMPONENTNAME_NOT_FOUND wemoSwitch error with the following code

const WeMoLightSwitch = neeoapi.buildDevice('WeMo LightSwitch')
.setManufacturer('Belkin')
.addAdditionalSearchToken('wemo')
.setType('LIGHT')
.enableDiscovery({headerText: 'Belkin WeMo Discovery', description: 'Press NEXT to discover Belkin WeMo LightSwitches'}, controller.discoverWeMoLightSwitch)
.registerInitialiseFunction(controller.initialise)
.registerSubscriptionFunction(controller.registerStateUpdateCallback)
.addButton({ name: 'POWER ON', label: 'Power On' })
.addButton({ name: 'POWER OFF', label: 'Power Off' })
.addButtonHandler(controller.onButtonPressed)
.addSwitch({ name: 'wemoSwitch', label: 'Power' },
{ setter: controller.switchSet, getter: controller.switchGet } )
;

const WeMoInsight = neeoapi.buildDevice('WeMo Insight')
.setManufacturer('Belkin')
.addAdditionalSearchToken('wemo')
.setType('LIGHT')
.enableDiscovery({headerText: 'Belkin WeMo Discovery', description: 'Press NEXT to discover Belkin WeMo Insight Switches'}, controller.discoverWeMoInsight)
.registerInitialiseFunction(controller.initialise)
.registerSubscriptionFunction(controller.registerStateUpdateCallback)
.addButton({ name: 'POWER ON', label: 'Power On' })
.addButton({ name: 'POWER OFF', label: 'Power Off' })
.addButtonHandler(controller.onButtonPressed)
.addSwitch({ name: 'wemoISwitch', label: 'Power' },
{ setter: controller.switchSet, getter: controller.switchGet } )
;

sendComponentUpdate({uniqueDeviceId: deviceid, component: 'wemoSwitch', value: bool})

When I remove the second device, it works as expected. Note that the component name for the switch is different for the second device.

Reply
4replies Oldest first
  • Oldest first
  • Newest first
  • Active threads
  • Popular
  • Patrick Michael Vogt

    If I return one device profile, either one, the code works as expected. If I return both device profiles, I can install both device types, but I get the COMPONENTNAME_NOT_FOUND error when executing the status callback function. It always errors on the first component, the ‘wemoSwitch’ component.

    At this point, I am stuck. Any help is appreciated.

    Like
    • Just an idea, Paul Spee: I believe the callbacks that you are supposed to use for status update might be carrying context. So if you are using the same `controller.registerStateUpdateCallback` for both devices, you are might be replacing your first received callback (with context for updating `WeMo LightSwitch`) with the callback received second. Any chance you could try to use two different callbacks there?

      Like 1
    • Thanks Boris Pruessmann 

      Definitely worth trying. Just duplicate the callback function and rename it.

      Like
    • Boris Pruessmann 

      Interesting. I now use to different functions which each store the callback function in a different variable. Unfortunately, it also means that I need to check which device type generated the notification so I call the right call back function. It doesn’t make the code prettier.

      I assumed that I would be passed a pointer to the same callback function which obviously not the case. It shows my lack of understanding of JavaScript.

      It works great now. Thanks Boris. 

      Like 1
Like Follow