johannrichard / homebridge-dingz

Emerging Homebridge Plugin for dingz & myStrom WiFi Switch Devices. Replaces the obsolete homebridge-mystrom plugin
https://github.com/johannrichard/homebridge-dingz/wiki
Apache License 2.0
12 stars 6 forks source link

[BUG] v1.8.0 breaks HomeKit / Homebridge integration for possible edge cases #116

Closed simonnelli closed 3 years ago

simonnelli commented 3 years ago

Describe the bug Latest update breaks connection between HomeKit and Homebridge. Deleting Homebridge in HomeKit and trying to add the Bridge to HomeKit leads to Error message: "accessory is out of compliance"

Deleting Dingz-plugin from HomeKit resolves the issue

To Reproduce Steps to reproduce the behavior: Install latest Dingz-plugin in Homebridge

Plugin environment (please complete the following information):

        {
            "name": "dingz",
            "motionPoller": true,
            "autoDiscover": false,
            "callbackHostname": "192.168.227.10",
            "devices": [
                {
                    "type": "dingz",
                    "name": "dingz Küche",
                    "address": "192.168.227.12"
                }
            ],
            "platform": "Dingz"
        },

Additional context Remember https://github.com/johannrichard/homebridge-dingz/issues/5 ? :D

johannrichard commented 3 years ago

Aw shucks. I'll have a look at it. Just to confirm:

If yes: is there a specific reason why you removed it in the first place (i.e. another error that made you remove it)?

And what iOS version did you test with?

And as a workaround: you can downgrade to v1.7.1 by installing via the terminal in HomeBridge:

npm install homebridge-dingz@1.7.1

(I suspect the reachability attribute I introduce w/ v1.8.1 might trigger that error. I haven't seen that on my side yet but will do more tests)

johannrichard commented 3 years ago

Oh and yes, of course: #5. Have to check the code I reused when updating didn't miss that (They're still working on a fix in HomeBridge/Hap-JS. AFAIK it hasn't made it into a release yet). 🤪

simonnelli commented 3 years ago

I completely removed HomeBridge from HomeKit because all HB-Accessories showed up as "no response". Tried to resolve the problem this way before I tried removing the Dingz-Plugin.

iOS is 14.2, rolling back to 1.7.1 works.

johannrichard commented 3 years ago
    {
        "name": "dingz",
        "motionPoller": true,
        "autoDiscover": false,
        "callbackHostname": "192.168.227.10",
        "devices": [
            {
                "type": "dingz",
                "name": "dingz Küche",
                "address": "192.168.227.12"
            }
        ],
        "platform": "Dingz"
    },

May I ask you to post the output from /api/v1/device as well? As I've said elsewhere (e.g. #114 #87) , the API for v1.2.x firmware changed quite a bit and some information that was beforehand returned (but empty) might now be not returned at all for non-existing serial numbers ...

simonnelli commented 3 years ago

There you go:

{"246F28A65F30":{"type":"dingz","battery":false,"reachable":true,"meshroot":true,"fw_version":"1.2.7","hw_version":"1.1.2","fw_version_puck":"1.1.21","bl_version_puck":"1.0.0","hw_version_puck":"1.1.1","hw_id_puck":1,"puck_sn":"","puck_production_date":{"year":20,"month":1,"day":2},"puck_hw_model":"","front_hw_model":"dz1f-4b","front_production_date":"20/4/26","front_sn":"F20042600212","dip_config":3,"has_pir":false,"hash":"e6e52dab"}}
qx54 commented 3 years ago

Updated to 1.8 and only discovered this issue afterwards. Luckily it seems this issue doesn't happen in all circumstances, my Homekit/Homebridge connection still works.

myStrom Button Firmware Version [2.74] myStrom PIR Firmware Version [3.8.2] Homebridge Server: [Raspberry Pi 4] Plugin Version [1.8.0] Node.js Version [14.15.1] Homebridge Version [1.1.6]

Maybe this helps.

johannrichard commented 3 years ago

@simonnelli: I couldn't find any cases of empty serial numbers and the remaining info seems complete, so this is a bit weird.

In the meantime I've worked on a v2.0.0-nightly of the plug-in. If you install the nightly w/ homebridge-dingz@nightly you should be upgraded to this version.

The functionality remains largely the same but the code is less cluttered and better structured so should generally run better. There might be bugs though but you can always downgrade to v1.7.1 (although I think the newest nightlies are much more robust).

I've had it running over longer periods of time now on my production dingz. So far I could not observe any problems with its operation.

The biggest change I reverted w.r.t. v1.8.0 is the reachability. If the nightly works now, that might somehow have been the cause.

I'd be grateful if you could run it and let me know if it (still) works.

simonnelli commented 3 years ago

I've been testing v2.0.0-nightly since Monday an this version seems to have fixed the bug described. I've run into other error messages in the log, but will open another bug for this.

simonnelli commented 3 years ago

Strangely my setup broke again. I havn't changed anything except always updating to the last version of your plugin. Not sure when and why it broke but I've rolled back version by version (deleting plugin incl. configuration, restarting HB, starting from scratch), but every version since 1.7.1 now seems to be broken with my setup. Even with your plugin uninstalled (but leaving the config in the config-file) my setup breaks.

Not sure how to give you more precise info to debug. Staying on 1.7.1 for now but willing to help debug :)

simonnelli commented 3 years ago

Just found out why I didn't notice that my setup breaks: When I update your plugin, everything works as long as I don't restart HB. As soon as I restart HB and the updated plugin loads it breaks. Likely since v.1.7.1

johannrichard commented 3 years ago

Do you have any errors in the log (early on)? I've sometimes seen cases where ports remained blocked in auto-discovery when HB was restarted, but only on my development machine and not on my "production" system (where I install the nightlies as well after first testing on my dev).

simonnelli commented 3 years ago

Just the already reported errors (dead, alive). Auto discovery is off

johannrichard commented 3 years ago

Was wondering: do you still have the mixed IPv4/IPv6 setup you had when we worked on the initial bugs (#13)? From some (other) problems I had with homebridge crashing because of network issues, I fear it might be network stack related.

I made one change in the callback server, binding the plug-in to 0.0.0.0, in v2.0.0. I've removed that in the latest nightly, if you want test that one, we might confirm/exclude this as a probable cause.

simonnelli commented 3 years ago

Yes I'm still running dualstack IPv4/v6. Will test with v6 off tomorrow.

Still breaking with latest nightly (2.0.7-nightly.3)

johannrichard commented 3 years ago

Yes I'm still running dualstack IPv4/v6. Will test with v6 off tomorrow.

Don't bother. If it wasn't the IPv6 stack related to the callback server and the change with binding or not to the IPv4 then it's something else.

johannrichard commented 3 years ago

Just an update on my investigations: On my side, I've lately seen some weird HomeKit behaviour (endless "Updating", especially when away) which I first attributed to my Apple TV/Hub running iOS beta and/or another HomeKit device being the culprit (since rebooting either one made the issues go away).

I will do some more tests and report back ASAP.

johannrichard commented 3 years ago

@simonnelli With a bit more time to reflect on your bug report and a fresh look, I have a few questions related to the breaking (sorry to ask them, but we never discussed these):

HB_Accessories_Cache

> dns-sd -B _hap._tcp
21:16:59.341  Add        3   4 local.               _hap._tcp.           Serenity XXXX
simonnelli commented 3 years ago

Just tried following:

Uninstall dingz-plugin, removing configuration clearing dingz from HB-cache restarted HB installed 2.0.0, configured one dingz manually, no auto-discovery dingz is displayed in Config UI X but HB connection immediately breaks.

Here the output from dns-sd -B _hap._tcp. I assume the duplicated entries are because of IPv4/v6

9:46:30.893 Add 3 4 local. _hap._tcp. Philips hue - 2C8000 9:46:30.893 Add 3 8 local. _hap._tcp. Philips hue - 2C8000 9:46:30.893 Add 3 4 local. _hap._tcp. Switch 01d3f8 9:46:30.893 Add 3 8 local. _hap._tcp. Switch 01d3f8 9:46:30.893 Add 3 4 local. _hap._tcp. Smart AC Control WR1741951488 9:46:30.893 Add 3 8 local. _hap._tcp. Smart AC Control WR1741951488 9:46:30.893 Add 3 4 local. _hap._tcp. DINGZ A65F30 9:46:30.893 Add 3 8 local. _hap._tcp. DINGZ A65F30 9:46:30.893 Add 3 4 local. _hap._tcp. Homebridge AC78 9:46:30.893 Add 2 8 local. _hap._tcp. Homebridge AC78

johannrichard commented 3 years ago

This really sounds like our famous #5 again, only it's much harder to catch. The only difference in the device config I saw was the empty puck_hw_model. But the code handling this didn't change between the v1.7.1 and v2.0.0.

I'm almost tempted to propose a dingz swap: I send you my test dingz and you send me your prototype. Would make my programming harder and (hopefully) solve your problem (and if not, it would be something else ...). Let me know if this is something you'd consider.

johannrichard commented 3 years ago

I've gone through a bit more looking around if other plugin developers had similar issues. Although I also run my HB setup on homebridge@1.2.3 like you, I saw quite some reports of people who had issues running their setup under this version, and reverted back to homebridge@1.1.6.

So what I suggest to further debug: