Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Crash and loosing setting in Home app #36

Closed
beatpaul opened this issue Apr 12, 2022 · 14 comments
Closed

Crash and loosing setting in Home app #36

beatpaul opened this issue Apr 12, 2022 · 14 comments
Labels
bug Something isn't working

Comments

@beatpaul
Copy link

Hi Erik!

I'm quite desperate. About some hours ago I lost all my settings in home app for the second time and I have to reconfigure all may Lights, Sensors and Switches ... :(
I switched from hue- to deconz-plugin (50+ accessories ... ) before and generally it was working flawless.
Homebridge-deconz runs on a dedicated raspberry pi in a child bridge no other plugins except home bridge-ui and the deconz software.

I lost all my home app settings 2 times:

1st incident:

  • i was updating raspberry pi software ( sudo npm -g update / sudo hb-servoce update-node ))
  • i restarted homebridge using homebridge-ui
  • all settings were gone ...

2nd incident:

  • i updated my Synology NAS (that shouldn't effect the raspberry)
  • after updating I checked homebridge-ui and i saw some errors in the log, here an example:
�[37m[12.4.2022, 20:50:15] �[39m�[36m[deCONZ]�[39m �[31merror: RangeError: 00212EFFFF0101A8-G5: unknown device ID�[39m
�[31m�[0m�[90m    at Gateway.addAccessory (/usr/lib/node_modules/homebridge-deconz/lib/DeconzAccessory/Gateway.js:505:13)�[39m�[31m�[0m�[39m
�[31m�[0m�[90m    at DeconzPlatform.accessoryRestored (/usr/lib/node_modules/homebridge-deconz/lib/DeconzPlatform.js:241:19)�[39m�[31m�[0m�[39m
�[31m�[0m�[90m    at DeconzPlatform.emit (node:events:526:28)�[39m�[31m�[0m�[39m
�[31m�[0m�[90m    at DeconzPlatform.emit (/usr/lib/node_modules/homebridge-lib/lib/Delegate.js:174:13)�[39m�[31m�[0m�[39m
�[31m�[0m�[90m    at DeconzPlatform.configureAccessory (/usr/lib/node_modules/homebridge-lib/lib/Platform.js:416:10)�[39m�[31m�[0m�[39m
�[31m�[0m�[90m    at /usr/lib/node_modules/homebridge/src/bridgeService.ts:328:25�[39m�[31m�[0m�[39m
�[31m�[0m�[90m    at Array.filter (<anonymous>)�[39m�[31m�[0m�[39m
�[31m�[0m�[90m    at BridgeService.restoreCachedPlatformAccessories (/usr/lib/node_modules/homebridge/src/bridgeService.ts:288:69)�[39m�[31m�[0m�[39m
�[31m�[0m�[90m    at ChildBridgeFork.startBridge (/usr/lib/node_modules/homebridge/src/childBridgeFork.ts:170:24)�[39m�[31m�[0m�[39m

Here is the full log:
homebridge.log

  • i restarted home bridge using the ui plugin
  • all settings gone ... :( :(

I don't know what I do wrong, I tried to describe what happened, if you need further information, please tell me

hopefully you can give me advice, since this happened 2 times now and i'm really frustrated spending hours in reconfiguring everything.

thanks in advance

Paul

@beatpaul
Copy link
Author

i constantly get similar Error messages like:

[14.4.2022, 23:01:23] [deCONZ] RaspBee Gateway: error: TypeError: Cannot create property 'config' on string '<html><head></head><body><h1>This is not the page you are looking for</h1><p>The file /api/D999C4171B couldn't be found.</p></body></html>'
    at Gateway.poll (/usr/lib/node_modules/homebridge-deconz/lib/DeconzAccessory/Gateway.js:692:39)
    at processTicksAndRejections (node:internal/process/task_queues:96:5)
    at Gateway.heartbeat (/usr/lib/node_modules/homebridge-deconz/lib/DeconzAccessory/Gateway.js:256:9)

does anyone have an idea what thats related to ?

very thx!

@ebaauw
Copy link
Owner

ebaauw commented Apr 15, 2022

You're running deCONZ beta v2.15.0. Did you upgrade to that version just before the errors started to appear?

The string seems to be an HTML error page for a non-existent page. I think Homebridge deCONZ is connecting to a web server that is not deCONZ. What's you config.json? Do you specify the deCONZ gateway there, or do you use automatic discovery? Did you double-check that deCONZ is still running on the same IP and port?

@beatpaul
Copy link
Author

I'm not sure, but ist quite possible that problems start with 2.15.0.

I specified the gateway in my config 1.0.0.127 ( I Also tried my eth0 IP: 10.0.x.x)

I didn't change any port of deconz, just using the sd card image version (how can i check the port ?)

Problems (loosing all home settings) occure when restarting the raspberry ...

my config.json:

{
  "bridge": {
    "name": "HomebridgeINS0",
    "username": "xx:xx:xx:xx:xx:xx",
    "port": 51800,
    "pin": "123-45-678",
    "advertiser": "bonjour-hap",
    "bind": [
      "eth0"
    ]
  },
  "plugins": [
    "homebridge-config-ui-x",
    "homebridge-hue",
    "homebridge-deconz"
  ],
  "platforms": [
    {
      "name": "Config_0",
      "port": 8581,
      "auth": "none",
      "theme": "dark-mode-pink",
      "tempUnits": "c",
      "lang": "auto",
      "platform": "config"
    },
    {
      "name": "deCONZ",
      "hosts": [
        "127.0.0.1"
      ],
      "_bridge": {
        "username": "xx:xx:xx:xx:xx:xx",
        "port": 50347
      },
      "platform": "deCONZ"
    }
  ],
  "accessories": []
}


@ebaauw
Copy link
Owner

ebaauw commented Apr 15, 2022

I specified the gateway in my config 1.0.0.127 ( I Also tried my eth0 IP: 10.0.x.x)

localhost is 127.0.0.1

Are you sure deCONZ is running at port 80, and not some other program like Pihole?

Check the address bar of your browser when running the Phoscon web app.

@ebaauw
Copy link
Owner

ebaauw commented Apr 16, 2022

Normally, Homebridge deCONZ works as follows:

  • Homebridge deCONZ keeps a cached copy of the full state of the gateway in memory. This is copy persisted in cachedAccessories.
  • On startup, Homebridge deCONZ restores the gateway accessory first, restoring the cached copy of the full state. Then, it restores the accessories for the devices exposed by the gateway, using the restored cached copy of the gateway full state.
  • When it connects to the gateway, Homebridge deCONZ refreshes the full state (doing a GET /); on subsequent polling, it does separate requests for /config, /lights, /sensors, and/or /groups (depending on whats needed for the current configuration), updating the cached copy of the full state.

I think what happened is the following:

  • Because of misconfiguration and/or changed IP address, Homebridge deCONZ connects to another server instead of to the deCONZ gateway. This server returns an HTML page "this is not the page you are looking for", but with HTTP status 200 OK.
  • Homebridge deCONZ doesn't check whether the response is actually a JSON string, and overrides its internal cached copy of the gateway full state with the HTML string, instead of the full state.
  • On consequent gateway polls, Homebridge deCONZ fails to update the /config part in the full state, resulting in the TypeError: Cannot create property 'config' on string '<html><head></head><body><h1>This is not the page you are looking for</h1><p>The file /api/236C79A8FD couldn't be found.</p></body></html>
  • On restarting Homebridge (apparently after fixing the config error/IP address), the invalid full state is restored, causing the restore of the connected devices to fail, due to the RangeError: 0017880100BEA0A9: unknown device ID. Because of this, Homebridge deCONZ concludes the device is no longer exposed by the "gateway", and removes the associated accessory from HomeKit.
  • When Homebridge deCONZ connects to the proper gateway, it refreshes the full state and re-creates the accessories, but HomeKit sees these as new accessories.

ebaauw added a commit that referenced this issue Apr 18, 2022
Change initialisation logic, see #36.
ebaauw added a commit that referenced this issue Apr 18, 2022
Change startup logic, see #36.
@ebaauw ebaauw added the bug Something isn't working label Apr 18, 2022
@ebaauw
Copy link
Owner

ebaauw commented Apr 18, 2022

Changed the startup logic in v0.0.15. Homebridge deCONZ should now only call a GET / once it has confirmed that indeed a gateway is at the configured/cached IP address and port.

@beatpaul
Copy link
Author

Thanks for your detailed replay about the problem.

  • Because of misconfiguration and/or changed IP address, Homebridge deCONZ connects to another server instead of to the deCONZ gateway. This server returns an HTML page "this is not the page you are looking for", but with HTTP status 200 OK.

I now (after Easterbreak) i checked the IP and the port deconz is running (80)

The problem still persists.
in Detail:

  • Restarting Homebridege using homebridge-ui works
  • Restarting the Raspberry Pi results in the Error as described before

I will now update deconz to version 0.0.15 and report back if this solved the problem.

very thx!!

@beatpaul
Copy link
Author

so by now it seems to work for me :)

I restarted several times and still there is a this warning, but it connects after 60s:

8.4.2022, 19:28:22] [deCONZ] Wohnzimmer Stehlampe: Adaptive Lighting: disabled
[18.4.2022, 19:28:22] [deCONZ] Wohnzimmer Bodenlampe: Adaptive Lighting: disabled
[18.4.2022, 19:28:22] [deCONZ] Kinderzimmer Leselampe: Adaptive Lighting: disabled
[18.4.2022, 19:28:24] [deCONZ] 127.0.0.1: request 1: GET /config
[18.4.2022, 19:28:24] [deCONZ] warning: 127.0.0.1: request 1: http status 404 Not Found
[18.4.2022, 19:28:24] [deCONZ] warning: 127.0.0.1: http status 404 Not Found - retrying in 60s
[18.4.2022, 19:28:56] [deCONZ] warning: heartbeat 35, drift -595
[18.4.2022, 19:29:22] [deCONZ] RaspBee Gateway Button: Programmable Switch Event: Single Press
[18.4.2022, 19:29:24] [deCONZ] RaspBee Gateway: websocket connected to ws://127.0.0.1:443
[18.4.2022, 19:29:24] [deCONZ] Wohnzimmer Bewegungsmelder: set Current Ambient Light Level from 9.0365 lux to 7.8253 lux
[18.4.2022, 19:29:24] [deCONZ] Wohnzimmer Bewegungsmelder: set Motion Detected from true to false

everything works so far, still don't know the issue for the warning.

thx a lot

@ebaauw
Copy link
Owner

ebaauw commented Apr 18, 2022

Could you try, in the server running Homebridge, deconz -DD config?

@beatpaul
Copy link
Author

this is what i get:

deconz: localhost: request 1: GET /config
deconz: localhost: request 1: GET http://localhost/api/config
deconz: localhost: request 1: response: {"apiversion":"1.16.0","bridgeid":"00212EFFFF0101A8","datastoreversion":"93","devicename":"RaspBee II","factorynew":false,"mac":"b8:27:eb:37:2e:d6","modelid":"deCONZ","name":"RaspBee Gateway","replacesbridgeid":null,"starterkitid":"","swversion":"2.15.1"}
deconz: localhost: request 1: 200 OK
{
  "apiversion": "1.16.0",
  "bridgeid": "00212EFFFF0101A8",
  "datastoreversion": "93",
  "devicename": "RaspBee II",
  "factorynew": false,
  "mac": "b8:27:eb:37:2e:d6",
  "modelid": "deCONZ",
  "name": "RaspBee Gateway",
  "replacesbridgeid": null,
  "starterkitid": "",
  "swversion": "2.15.1"
}

@ebaauw
Copy link
Owner

ebaauw commented Apr 18, 2022

Do you restart only Homebridge, or the server, incl. deCONZ? It looks like deCONZ gives the 404 when queried while it's still starting up. That's new to me.

$ dc_off; dc_on; while true; do deconz -DD -H 127.0.0.1 config; done
deconz: 127.0.0.1: request 1: GET /config
deconz: 127.0.0.1: request 1: GET http://127.0.0.1/api/config
deconz: 127.0.0.1: request 1: GET /config
deconz: warning: 127.0.0.1: request 1: http status 404 Not Found
deconz: fatal: 127.0.0.1: deCONZ gateway not found
deconz: 127.0.0.1: request 1: GET /config
deconz: 127.0.0.1: request 1: GET http://127.0.0.1/api/config
deconz: 127.0.0.1: request 1: response: {"apiversion":"1.16.0","bridgeid":"00212EFFFF03D4A7","datastoreversion":"93","factorynew":false,"mac":"dc:a6:32:6f:81:2c","modelid":"deCONZ","name":"pi5","replacesbridgeid":null,"starterkitid":"","swversion":"2.15.1"}
deconz: 127.0.0.1: request 1: 200 OK
deconz: fatal: 127.0.0.1: not a deCONZ gateway
deconz: 127.0.0.1: request 1: GET /config
deconz: 127.0.0.1: request 1: GET http://127.0.0.1/api/config
deconz: 127.0.0.1: request 1: response: {"apiversion":"1.16.0","bridgeid":"00212EFFFF03D4A7","datastoreversion":"93","factorynew":false,"mac":"dc:a6:32:6f:81:2c","modelid":"deCONZ","name":"pi5","replacesbridgeid":null,"starterkitid":"","swversion":"2.15.1"}
deconz: 127.0.0.1: request 1: 200 OK
deconz: fatal: 127.0.0.1: not a deCONZ gateway
deconz: 127.0.0.1: request 1: GET /config
deconz: 127.0.0.1: request 1: GET http://127.0.0.1/api/config
deconz: 127.0.0.1: request 1: response: {"apiversion":"1.16.0","bridgeid":"00212EFFFF03D4A7","datastoreversion":"93","factorynew":false,"mac":"dc:a6:32:6f:81:2c","modelid":"deCONZ","name":"pi5","replacesbridgeid":null,"starterkitid":"","swversion":"2.15.1"}
deconz: 127.0.0.1: request 1: 200 OK
deconz: fatal: 127.0.0.1: not a deCONZ gateway
deconz: 127.0.0.1: request 1: GET /config
deconz: 127.0.0.1: request 1: GET http://127.0.0.1/api/config
deconz: 127.0.0.1: request 1: response: {"apiversion":"1.16.0","bridgeid":"00212EFFFF03D4A7","datastoreversion":"93","factorynew":false,"mac":"dc:a6:32:6f:81:2c","modelid":"deCONZ","name":"pi5","replacesbridgeid":null,"starterkitid":"","swversion":"2.15.1"}
deconz: 127.0.0.1: request 1: 200 OK
deconz: fatal: 127.0.0.1: not a deCONZ gateway
deconz: 127.0.0.1: request 1: GET /config
deconz: 127.0.0.1: request 1: GET http://127.0.0.1/api/config
deconz: 127.0.0.1: request 1: response: {"apiversion":"1.16.0","bridgeid":"00212EFFFF03D4A7","datastoreversion":"93","devicename":"ConBee II","factorynew":false,"mac":"dc:a6:32:6f:81:2c","modelid":"deCONZ","name":"pi5","replacesbridgeid":null,"starterkitid":"","swversion":"2.15.1"}
deconz: 127.0.0.1: request 1: 200 OK
{
  "apiversion": "1.16.0",
  "bridgeid": "00212EFFFF03D4A7",
  "datastoreversion": "93",
  "devicename": "ConBee II",
  "factorynew": false,
  "mac": "dc:a6:32:6f:81:2c",
  "modelid": "deCONZ",
  "name": "pi5",
  "replacesbridgeid": null,
  "starterkitid": "",
  "swversion": "2.15.1"
}
deconz: 127.0.0.1: request 1: GET /config
deconz: 127.0.0.1: request 1: GET http://127.0.0.1/api/config
deconz: 127.0.0.1: request 1: response: {"apiversion":"1.16.0","bridgeid":"00212EFFFF03D4A7","datastoreversion":"93","devicename":"ConBee II","factorynew":false,"mac":"dc:a6:32:6f:81:2c","modelid":"deCONZ","name":"pi5","replacesbridgeid":null,"starterkitid":"","swversion":"2.15.1"}
deconz: 127.0.0.1: request 1: 200 OK
{
  "apiversion": "1.16.0",
  "bridgeid": "00212EFFFF03D4A7",
  "datastoreversion": "93",
  "devicename": "ConBee II",
  "factorynew": false,
  "mac": "dc:a6:32:6f:81:2c",
  "modelid": "deCONZ",
  "name": "pi5",
  "replacesbridgeid": null,
  "starterkitid": "",
  "swversion": "2.15.1"
}

dc_off and dc_on are my aliases to stop and start the deCONZ service.

Also note that devicename takes a while to become available, and Homebridge deCONZ won't accept the response until then.

The warning can now be ignored safely. To prevent it, you would have to delay the startup of Homebridge deCONZ, until after deCONZ has initialised.

@ebaauw
Copy link
Owner

ebaauw commented Apr 18, 2022

And, indeed, deCONZ serves an HTML page on the 404:

$ dc_off; dc_on; while true; do echo; echo ====; curl http://127.0.0.1/api/config; done

====
curl: (7) Failed to connect to 127.0.0.1 port 80: Connection refused

====
curl: (7) Failed to connect to 127.0.0.1 port 80: Connection refused

====
curl: (7) Failed to connect to 127.0.0.1 port 80: Connection refused

====
curl: (7) Failed to connect to 127.0.0.1 port 80: Connection refused

====
curl: (7) Failed to connect to 127.0.0.1 port 80: Connection refused

====
curl: (7) Failed to connect to 127.0.0.1 port 80: Connection refused

====
<html><head></head><body><h1>This is not the page you are looking for</h1><p>The file /api/config couldn't be found.</p></body></html>
====
{"apiversion":"1.16.0","bridgeid":"00212EFFFF03D4A7","datastoreversion":"93","factorynew":false,"mac":"dc:a6:32:6f:81:2c","modelid":"deCONZ","name":"pi5","replacesbridgeid":null,"starterkitid":"","swversion":"2.15.1"}
====
{"apiversion":"1.16.0","bridgeid":"00212EFFFF03D4A7","datastoreversion":"93","factorynew":false,"mac":"dc:a6:32:6f:81:2c","modelid":"deCONZ","name":"pi5","replacesbridgeid":null,"starterkitid":"","swversion":"2.15.1"}

@beatpaul
Copy link
Author

i do restart the hole server including deconz, like powering it off and on again

maybe the start up query is new in in this version ?

anyways i'm really happy that it seems to work now !

maybe this problem wasn't an issue before i updated the raspberry pi, maybe the startup order got changed during update process and so it became an issue ... also because of my wrong localhost ip :( ....

thx for your great work and help !!

Paul

PS: I'm gonna sort some lights & sensors now :)

@beatpaul
Copy link
Author

So everything works fine again 👍

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants