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

"Invalid password" after some period #12

Open
cbrunnkvist opened this issue Feb 10, 2024 · 3 comments
Open

"Invalid password" after some period #12

cbrunnkvist opened this issue Feb 10, 2024 · 3 comments

Comments

@cbrunnkvist
Copy link

cbrunnkvist commented Feb 10, 2024

I'm observing a consistent issue between my Homebridge and the two Shelly 1 PM that I have connected: it was all fine and dandy. I added password auth on the Shelly devices, and it still works, initially. What seems to happen with homebridge-shelly-ng though is that after a certain amount of time (haven't measured, but it seems to be about 60 mins) of idling, the accessories just stop working, and I see the following in the logs when I try and toggle their switches:

[2/9/2024, 9:11:50 PM] [Shelly NG] [Floor Fan] Failed to set switch: Invalid password
[2/9/2024, 11:05:41 PM] [Shelly NG] [Disco Light] Failed to set switch: Invalid password

I immediately suspected some kind of underlying code-related issue (since I didn't change passwords either in Homebridge or on the devices) so I added rudimentary extra logging to the place where the message originates:

[2/9/2024, 9:11:50 PM] [Shelly NG] [Floor Fan] Failed to set switch: Invalid password (correct-password-here): {"auth_type": "digest", "nonce": 1707487913, "nc": 1, "realm": "shellyplus1pm-441793aaaaaa", "algorithm": "SHA-256"}

so I can only conclude that that far, it looks like we have the right password and we are still seeing a Digest challenge with new nonce and so on.

Restarting the plugin/child-bridge clears the problem, but only until next period.

@cbrunnkvist cbrunnkvist changed the title "Invalid password" after timeout "Invalid password" after some period Feb 12, 2024
@cbrunnkvist
Copy link
Author

cbrunnkvist commented Feb 12, 2024

I'm currently resorting to a lame workaround - a systemd timer & service that just pkill:s the named child bridge process every 58th minute - but that's clearly far from optimal.

I'm going to double-check that it is the password auth that provokes the issue, and that it's not something more general related to some missing resource de-allocation.

(I'm NOT using HTTPS btw)

@cbrunnkvist
Copy link
Author

cbrunnkvist commented Feb 16, 2024

Okay, okay... Despite searching for anything similar, I didn't understand where the bug was originally so I didn't register the fact that the root-cause is already documented in both PR:s and Issues. Namely:

I will still opt to leave this issue open for now at least, let's see if @alexryd returns or whether the issue can be fixed by creation of new forks of both projects.

@cbrunnkvist
Copy link
Author

cbrunnkvist commented Feb 16, 2024

Quite tangential topic, but in case anyone wants to replace what could be a crontab oneliner with a recurring systemd timer unit (as used on my Raspbian box), this is how:

# /etc/systemd/system/restart-shelly-ng.service 
[Unit]
Description=Trigger a restart of the Homebridge Shelly-NG plugin

DefaultDependencies=no

[Service]
Type=oneshot
User=1000
# NOTE: this obviously requires you to create a child-bridge for said plugin in Homebridge first
ExecStart=pkill -f 'homebridge: homebridge-shelly-ng'
SuccessExitStatus=0 1

[Install]
WantedBy=multi-user.target
# /etc/systemd/system/restart-shelly-ng.timer 
[Unit]
Description=Trigger Homebridge Shelly NG plugin restart

[Timer]
#OnUnitActiveSec=29min
OnUnitActiveSec=55min

[Install]
WantedBy=timers.target
sudo systemctl enable restart-shelly-ng.service
sudo systemctl enable restart-shelly-ng.timer
sudo systemctl start restart-shelly-ng.service

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant