Debug app code

Another hint…if you want to debug on Homey and Docker, you can add this code to your app.js:

		if (process.env.DEBUG === '1'){
				try{ 
					require('inspector').waitForDebugger();
				}
				catch(error){
					require('inspector').open(9225, '0.0.0.0', true);
				}
		}

It first tries to connect to an existing debugger prozess (needed for docker) and opens a new one if not found (needed for Homey19 or Homey23 remote).

In lauch.json you can provide different profiles for Homey remote or docker connection or different settings for Homey19/23:

        {
            "type": "node",
            "request": "attach",
            "restart": true,
            "name": "Attach HA to Homey Dev",
            "address": "192.168.1.13",
            "port": 9225,
            "localRoot": "${workspaceFolder}",
            "remoteRoot": "/"
        },
        {
            "type": "node",
            "request": "attach",
            "restart": true,
            "name": "Attach HA to Homey Pro 23 Wifi",
            "address": "192.168.1.15",
            "port": 9225,
            "localRoot": "${workspaceFolder}",
            "remoteRoot": "/app/"
        },
        {
            "type": "node",
            "request": "attach",
            "restart": true,
            "name": "Attach HA to Homey23 Docker",
            "address": "192.168.1.15",
            "port": 9229,
            "localRoot": "${workspaceFolder}",
            "remoteRoot": "/app/"
        }
1 Like