OH4: Shelly PlusPlugS - Authentication not working

Hello community,

I’m using Shelly devices with openHAB 4.0.4 successfully for a long time and every device is protected by a username and password. Yesterday I installed the “new” Shelly PlusPlugS and activated the “protection” which requires only a password.

The openHAB binding also detects that only a password is required and doesn’t ask for a username. So far, so good.

Unfortunately after setting the password the configured thing reports a “CONFIGURATION_ERROR” (Access denied. Check username and password).

After checking the debug log of the binding it seems like the binding is trying to connect to the device with a username (admin) and the password:

08:06:44.536 [DEBUG] [ly.internal.handler.ShellyBaseHandler] - shellyplusplugs-64b7080ce738: Using userId admin from bindingConfig
08:06:44.537 [DEBUG] [ly.internal.handler.ShellyBaseHandler] - shellyplusplugs-64b7080ce738: Device config: Device address=192.168.89.198, HTTP user/password=admin/***, update interval=60
08:06:44.537 [DEBUG] [ly.internal.handler.ShellyBaseHandler] - shellyplusplugs-64b7080ce738: Configured Events: Button: false, Switch (on/off): true, Push: true, Roller: true, Sensor: true, CoIoT: false, Enable AutoCoIoT: true
08:06:44.538 [DEBUG] [ly.internal.handler.ShellyBaseHandler] - shellyplusplugs-64b7080ce738: Start initializing for thing shellyplusplugs-64b7080ce738 - 192.168.89.198, type shellyplusplug, IP address 192.168.89.198, Gen2: true, CoIoT: false
08:06:44.540 [INFO ] [hab.event.ThingStatusInfoChangedEvent] - Thing 'shelly:shellyplusplug:64b7080ce738' changed from INITIALIZING to UNKNOWN (CONFIGURATION_PENDING): Initialisierung oder Gerät im Schlafmodus.
08:06:44.657 [DEBUG] [ng.shelly.internal.api2.Shelly2ApiRpc] - shellyplusplugs-64b7080ce738: Connect Rpc Socket (discovery = false)
08:06:44.657 [DEBUG] [shelly.internal.api2.Shelly2RpcSocket] - shellyplusplugs-64b7080ce738 - 192.168.89.198: Connect WebSocket, URI=ws://192.168.89.198/rpc
08:06:44.687 [DEBUG] [shelly.internal.api2.Shelly2RpcSocket] - shellyplusplugs-64b7080ce738 - 192.168.89.198: WebSocket connected /192.168.89.242:45806<-/192.168.89.198:80, Idle Timeout=2147483647
08:06:44.712 [DEBUG] [ng.shelly.internal.api2.Shelly2ApiRpc] - shellyplusplugs-64b7080ce738: Closing Rpc API (socket is connected, discovery=false)
08:06:44.712 [INFO ] [hab.event.ThingStatusInfoChangedEvent] - Thing 'shelly:shellyplusplug:64b7080ce738' changed from UNKNOWN (CONFIGURATION_PENDING): Initialisierung oder Gerät im Schlafmodus. to OFFLINE (CONFIGURATION_ERROR): Zugriff verweigert. Überprüfen Sie Benutzerkennung und Passwort.
08:06:44.712 [DEBUG] [shelly.internal.api2.Shelly2RpcSocket] - shellyplusplugs-64b7080ce738 - 192.168.89.198: Disconnecting WebSocket (/192.168.89.242:45806 -> /192.168.89.198:80)
08:06:44.715 [DEBUG] [ng.shelly.internal.api2.Shelly2ApiRpc] - shellyplusplugs-64b7080ce738: WebSocket connection closed, status = 1006/Disconnected
08:06:44.716 [DEBUG] [ly.internal.handler.ShellyBaseHandler] - shellyplusplugs-64b7080ce738: Unable to initialize: POST http://192.168.89.198/rpc > , retrying later

Is there a solution for this behaviour?

Kind regards,
Vince

I thoughy that admin username is hardcoded, but it is not: https://github.com/openhab/openhab-addons/blob/a4da9863301dec962ec4cf395bce813761ed24f7/bundles/org.openhab.binding.shelly/src/main/java/org/openhab/binding/shelly/internal/handler/ShellyBaseHandler.java#L181

It is being loaded from config. From your message I suppose that you use non-admin username, am I right?

I don’t use a username at all.
Shelly:

Thing config:

UID: shelly:shellyplusplug:64b7080ce738
label: shellyplusplugs-64b7080ce738 - 192.168.89.198
thingTypeUID: shelly:shellyplusplug
configuration:
  enableBluGateway: false
  deviceIp: 192.168.89.198
  updateInterval: 60
  password: "*********"

Hello,
I’ve the same problem. Is there a solution ?

And a beginner question, how can I enable the debug logging for the Shelly binding ?

Kind regards
Jens

Hello Jens,
it seems like there is no solution at the moment. I guess somebody needs to create a new issue on github for this topic.

Regarding your question about the “debug logging”:

  1. Login into your openHAB console (via ssh on your system)
openhab-cli console
  1. Set the log-level for the binding (e.g.: DEFAULT, DEBUG, WARNING,…)
log:set DEBUG org.openhab.binding.shelly
  1. Check the log:
log:tail

Please keep in mind to change the log level back to “DEFAULT” after you finished your analysis.

Kind regards,
Vince

Hello Vince,

thanks for the help regarding logging.

As consideration the solution for our problem:

  • in the “code” tab of the thing add “userId: admin” and save

UID: shelly:shellyplusplug:SH04
label: ShellyPlus Plug SH04
thingTypeUID: shelly:shellyplusplug
configuration:
enableBluGateway: false
deviceIp: 192.168.11.11
password: “more-secret”
updateInterval: 60
userId: admin
location:

Kind regards
Jens

Hello Jens,

it works :-). Thank you for the solution.

Kind regards,
Vince