Could not get the device by id

I’m making a new app (based on an old app) I’m using to controlling may Wiz Connected devices. When I’m testing the new app everything is normal when it comes to detecting the device, and I can see the device in the phone app. When I try to use the device I get the error message: Could not get the device by id (on top of the phone screen). No error message when I’m compiling the app or when I’m detecting the device. The descriptor returned from the driver are:

{
name: ‘WizSmartPlug’,
data: { name: ‘WizSmartPlug’, id: ‘6c2990a1824b’ },
settings: { id: ‘6c2990a1824b’, ip: ‘192.168.1.101’, mac: ‘6c:29:90:a1:82:4b’ },
capabilities: [ ‘onoff’ ]
}

What could be wrong?

How? What code paths does it trigger? What’s being shown on console (assuming you’re running the app with homey app run)?

The console show are normal and shows no messages at all. Everything seems the same as when I’m running the old app (that works).

Console output:
Pre-processing app…
Validating app…
App validated successfully against level debug
Packing Homey App…
— App archive size: 1.37 MB, 116 files
Installing Homey App on Homey Pro (https://192-168-1-114.homey.homeylocal.com)…
Homey App no.jib.WizDevice successfully installed
Running no.jib.WizDevice, press CTRL+C to quit
— Profile your app’s performance at https://go.athom.com/app-profiling homey=5fa’'…68c2db07&app=no.jib.WizDevice
─────────────── Logging stdout & stderr ───────────────
[log] 2023-04-28 13:26:42 [WizDeviceApp] init

So the old app works, and the one you changed doesn’t? What changes have you made? Are you using a different format of the device data property?

The devices has changed names and new functionality (flows) are added. The app is new (other name), and the “data” is the same, but “id” is also added to “settings”. The old app (another name on the app and devices) is running, but not on the same device.

It looks like you’re using “old” devices with the new app. Did you change the app id in app.json?

Sorry, I had a long weekend off. Yes, the app name / id are changed (old: no.jib.WizBulbs - new: no.jib.WizDevice). All the devices has new names. The device (smartplug) I’m testing has been deleted from the old app, but the old app is still running. I have also tested smartplugs that never been in the old app (same result).

I started seeing the same error with my app that is in development. The error is thrown when doing an operation/action on a device, either through a flow or through the app or web interface.

My app was working fine in rc.78, but as soon as the upgrade to rc.90 took place automatically, it started throwing the same error. (I was on holiday, and the app was working fine for a couple of days until the error path in my flow started triggering almost the minute after the upgrade.

Also, interestingly enough, under ‘homey app run’ the app runs fine without any errors, while after a ‘homey app install’ it throws the error.

I have reported the issue to athom, since based on the above I believe this is most likely a bug/regression on their side. Not only because a firmware upgrade triggered it, but also because ‘homey app run’ does not show the behaviour (and hence making it quite hard to diagnose).

Turns out that in my case the error was caused by a missing library (in my case node-fetch), that I did not have installed using npm, but somehow was available by default in rc.78 and in the docker container that is used for ‘homey app run’. My app should never have worked, and that it did work was a bug that was ‘fixed’ in rc90.

Once I found the ‘homey app run --remote’ command, the issue was quickly identified and resolved. The problem was that due to the missing dependency, the driver could not instantiate the device.

@Jan-Ivar_Boyum did you manage to resolve your issue?

No, unfortunately I don’t have that. First I wanted to replace an old app with a new one (all the old drivers were out of date). Then problems arose. Now I am trying to create a new version of the old one where the old drivers are set to “deprecated”. I’m a bit unsure if I should take the chance to test as I have to replace the app. I will post here when/if I solve the problem.

Solved: When I moved the device drivers from the new to the old app and set existing drivers in the old app to “deprecated”. Then everything worked as it should. I’m not sure what the problem is, but it seems to me that Homey Pro doesn’t accept two apps that access the same type of device (and use the same API) at the same time. So now I’m testing my app as a new version of the old one and everything seems to work normally.