ebaauw / homebridge-deconz

Homebridge plugin for deCONZ
Apache License 2.0
135 stars 7 forks source link

empty Gateway works but gives error: TypeError: host: missing string value #118

Closed wmutschl closed 1 year ago

wmutschl commented 1 year ago

I have moved sucessfully from homebridge hue to this new plugin. Works like a charm so far! Thank you.

I have noticed, though, the following error in my logs (after restart), but it seems like it does not affect my setup. Just wanted to know if that is okay? Here is the snippet:

[2/21/2023, 11:50:10 AM] [deCONZ] Phoscon-GW-new: warning: recommended version: deCONZ v2.19.3
[2/21/2023, 11:50:10 AM] [deCONZ] error: TypeError: host: missing string value
    at newTypeError (/var/lib/homebridge/node_modules/homebridge-deconz/node_modules/hb-lib-tools/lib/OptionParser.js:33:52)
    at Function.toString (/var/lib/homebridge/node_modules/homebridge-deconz/node_modules/hb-lib-tools/lib/OptionParser.js:288:13)
    at Object._callbacks.<computed> [as host] (/var/lib/homebridge/node_modules/homebridge-deconz/node_modules/hb-lib-tools/lib/OptionParser.js:844:40)
    at OptionParser.parse (/var/lib/homebridge/node_modules/homebridge-deconz/node_modules/hb-lib-tools/lib/OptionParser.js:871:29)
    at new ApiClient (/var/lib/homebridge/node_modules/homebridge-deconz/lib/Deconz/ApiClient.js:142:8)
    at Gateway.createClient (/var/lib/homebridge/node_modules/homebridge-deconz/lib/DeconzAccessory/Gateway.js:363:19)
    at new Gateway (/var/lib/homebridge/node_modules/homebridge-deconz/lib/DeconzAccessory/Gateway.js:227:10)
    at DeconzPlatform.accessoryRestored (/var/lib/homebridge/node_modules/homebridge-deconz/lib/DeconzPlatform.js:251:33)
    at DeconzPlatform.emit (node:events:513:28)
    at DeconzPlatform.emit (/var/lib/homebridge/node_modules/homebridge-deconz/node_modules/homebridge-lib/lib/Delegate.js:173:13)

I am running a Rasperry Pi 4b using the official Homebridge image and deConz runs on a Raspbee II following the official installation instructions (or more precisely activating the extra package in the hb-config menu).

ebaauw commented 1 year ago

Could you please attach the dump file?

wmutschl commented 1 year ago

homebridge-deconz.json.gz

wmutschl commented 1 year ago

Just for further information: I only get this error after I reboot the pi; but otherwise I don't see it affecting anything.

ebaauw commented 1 year ago

The serialised gateway accessory in cachedAccessories seems to be corrupted, missing the host value. If this doens't happen when restarting deCONZ, but does on rebooting the PI, your uSD card is likely broken, and has switched to read-only mode. You can check by doing a touch x on the terminal, double check that a file x has been created, reboot the Pi, and check whether x is still there.

wmutschl commented 1 year ago

You got me worried here for a second, but the SD card is okay, I can write to it just fine and it stays there after a reboot and also after installing updates etc.

I also checked sudo dmesg --level=emerg,alert,crit,err, and the only thing I got there was [ 15.135572] rtc-pcf85063 1-0051: hctosys: unable to read the hardware clock but no other errors. I was able to fix this issue by following the official Dresden Elektronik guide for installing the RTC kernel module manually on the Raspbian II.

wmutschl commented 1 year ago

Is it maybe due to the case that my deCONZ version is higher than the recommended one?

[2/22/2023, 10:25:30 AM] [deCONZ] Phoscon-GW-new: dresden elektronik deCONZ / RaspBee gateway v2.20.1
[2/22/2023, 10:25:30 AM] [deCONZ] Phoscon-GW-new: warning: recommended version: deCONZ v2.19.3
[2/22/2023, 10:25:30 AM] [deCONZ] error: TypeError: host: missing string value
    at newTypeError (/var/lib/homebridge/node_modules/homebridge-deconz/node_modules/hb-lib-tools/lib/OptionParser.js:33:52)
    at Function.toString (/var/lib/homebridge/node_modules/homebridge-deconz/node_modules/hb-lib-tools/lib/OptionParser.js:288:13)
    at Object._callbacks.<computed> [as host] (/var/lib/homebridge/node_modules/homebridge-deconz/node_modules/hb-lib-tools/lib/OptionParser.js:844:40)
    at OptionParser.parse (/var/lib/homebridge/node_modules/homebridge-deconz/node_modules/hb-lib-tools/lib/OptionParser.js:871:29)
    at new ApiClient (/var/lib/homebridge/node_modules/homebridge-deconz/lib/Deconz/ApiClient.js:142:8)
    at Gateway.createClient (/var/lib/homebridge/node_modules/homebridge-deconz/lib/DeconzAccessory/Gateway.js:363:19)
    at new Gateway (/var/lib/homebridge/node_modules/homebridge-deconz/lib/DeconzAccessory/Gateway.js:227:10)
    at DeconzPlatform.accessoryRestored (/var/lib/homebridge/node_modules/homebridge-deconz/lib/DeconzPlatform.js:251:33)
    at DeconzPlatform.emit (node:events:513:28)
    at DeconzPlatform.emit (/var/lib/homebridge/node_modules/homebridge-deconz/node_modules/homebridge-lib/lib/Delegate.js:173:13)

Also here is the relevant part of my config:

    "platforms": [
        {
            "name": "Config",
            "port": 8581,
            "platform": "config"
        },
        {
            "name": "deCONZ",
            "_bridge": {
                "username": "XX:XX:XX:XX:XX:XX",
                "port": 58483
            },
            "platform": "deCONZ"
        },
wmutschl commented 1 year ago

Nope, I downgraded to v2.19.3, but still get the same error after rebooting the pi twice:

[2/22/2023, 10:48:52 AM] [deCONZ] Phoscon-GW-new: dresden elektronik deCONZ / RaspBee gateway v2.19.3
[2/22/2023, 10:48:52 AM] [deCONZ] error: TypeError: host: missing string value
    at newTypeError (/var/lib/homebridge/node_modules/homebridge-deconz/node_modules/hb-lib-tools/lib/OptionParser.js:33:52)
    at Function.toString (/var/lib/homebridge/node_modules/homebridge-deconz/node_modules/hb-lib-tools/lib/OptionParser.js:288:13)
    at Object._callbacks.<computed> [as host] (/var/lib/homebridge/node_modules/homebridge-deconz/node_modules/hb-lib-tools/lib/OptionParser.js:844:40)
    at OptionParser.parse (/var/lib/homebridge/node_modules/homebridge-deconz/node_modules/hb-lib-tools/lib/OptionParser.js:871:29)
    at new ApiClient (/var/lib/homebridge/node_modules/homebridge-deconz/lib/Deconz/ApiClient.js:142:8)
    at Gateway.createClient (/var/lib/homebridge/node_modules/homebridge-deconz/lib/DeconzAccessory/Gateway.js:363:19)
    at new Gateway (/var/lib/homebridge/node_modules/homebridge-deconz/lib/DeconzAccessory/Gateway.js:227:10)
    at DeconzPlatform.accessoryRestored (/var/lib/homebridge/node_modules/homebridge-deconz/lib/DeconzPlatform.js:251:33)
    at DeconzPlatform.emit (node:events:513:28)
    at DeconzPlatform.emit (/var/lib/homebridge/node_modules/homebridge-deconz/node_modules/homebridge-lib/lib/Delegate.js:173:13)
wmutschl commented 1 year ago

Is it because I leave the Gateway setting empty?

Screenshot 2023-02-22 at 11 10 21

I tried changing it to the websocket port which is 192.168.178.50:4531, but that gave me:

[2/22/2023, 11:16:24 AM] [deCONZ] warning: 192.168.178.50:4531: socket hang up - retrying in 60s

Again when I leave it empty, I get the error, but the plugin works fine. Weird.

wmutschl commented 1 year ago

Okay, I found the solution, I needed to add the correct port of the Gateway (not the Websocket), which in my case was 192.168.178.50:4530 which is the way homebridge installs it. So basically the address one uses to login to Phoscon App. Another way to find this out is by ssh into the pi and running:

sudo hb-shell
deconz discover
# {
#   "192.168.178.50:4530": {

When I leave the Gateway empty, I run into this error. Anyways, I changed the issue name accordingly. I will close this issue as it is not really affecting functionality.

ebaauw commented 1 year ago

I don’t understand why the message appears after reboot, but not after restarting deCONZ. If it ware related to an empty hosts in config.json, I would expect the message on each restart of deCONZ.

wmutschl commented 1 year ago

I have to correct myself here, the message appears after restarting of deCONZ. Sorry for the confusion.

ebaauw commented 1 year ago

Fixed in v0.1.9.