stefan-kaestle / openhab2-addons

Add-ons for openHAB 2.x
Eclipse Public License 2.0
16 stars 1 forks source link

Fixed pairing #52

Closed GerdZanker closed 3 years ago

GerdZanker commented 3 years ago

Fixed the Bosch SHC pairing

Adapted to openHAB 3 code Change port for pairing

GerdZanker commented 3 years ago

It took my ages to update to all the openHAB3 JRA, runtime, etc. But not the pairing worked again on my setup.

GerdZanker commented 3 years ago

But after the pairing I saw a lot of the following output

2020-09-27 18:48:43.224 [DEBUG] [devices.bridge.BoschSHCBridgeHandler] - Subscribe: Sending content: {"jsonrpc":"2.0","method":"RE/subscribe","params":["com/bosch/sh/remote/*"]} - using httpClient BoschHttpClient@6a79b65c{STARTED}
2020-09-27 18:48:43.224 [TRACE] [ernal.devices.bridge.BoschHttpClient] - create request for https://192.168.xxx.xxx:8444/remote/json-rpc and content {"jsonrpc":"2.0","method":"RE/subscribe","params":["com/bosch/sh/remote/*"]}
2020-09-27 18:48:43.311 [DEBUG] [devices.bridge.BoschSHCBridgeHandler] - Subscribe: response complete: {"jsonrpc":"2.0","error":{"code":-32001,"message":"Error handling JSON-RPC request"}}
 - return code: 200
2020-09-27 18:48:43.311 [DEBUG] [devices.bridge.BoschSHCBridgeHandler] - Subscribe: Got subscription ID: null 2.0
2020-09-27 18:48:43.311 [DEBUG] [devices.bridge.BoschSHCBridgeHandler] - longPoll: Subscription outdated, requesting .. 
2020-09-27 18:48:43.311 [DEBUG] [devices.bridge.BoschSHCBridgeHandler] - Sending subscribe request to Bosch
2020-09-27 18:48:43.311 [DEBUG] [devices.bridge.BoschSHCBridgeHandler] - Subscribe: Sending content: {"jsonrpc":"2.0","method":"RE/subscribe","params":["com/bosch/sh/remote/*"]} - using httpClient BoschHttpClient@6a79b65c{STARTED}
2020-09-27 18:48:43.311 [TRACE] [ernal.devices.bridge.BoschHttpClient] - create request for https://192.168.xxx.xxx:8444/remote/json-rpc and content {"jsonrpc":"2.0","method":"RE/subscribe","params":["com/bosch/sh/remote/*"]}
2020-09-27 18:48:43.389 [DEBUG] [devices.bridge.BoschSHCBridgeHandler] - Subscribe: response complete: {"jsonrpc":"2.0","error":{"code":-32001,"message":"Error handling JSON-RPC request"}}
 - return code: 200
2020-09-27 18:48:43.389 [DEBUG] [devices.bridge.BoschSHCBridgeHandler] - Subscribe: Got subscription ID: null 2.0
2020-09-27 18:48:43.389 [DEBUG] [devices.bridge.BoschSHCBridgeHandler] - longPoll: Subscription outdated, requesting .. 
2020-09-27 18:48:43.389 [DEBUG] [devices.bridge.BoschSHCBridgeHandler] - Sending subscribe request to Bosch
2020-09-27 18:48:43.389 [DEBUG] [devices.bridge.BoschSHCBridgeHandler] - Subscribe: Sending content: {"jsonrpc":"2.0","method":"RE/subscribe","params":["com/bosch/sh/remote/*"]} - using httpClient BoschHttpClient@6a79b65c{STARTED}

I have no other things and items configured yet and will do a bit more tests ...

coeing commented 3 years ago

Pairing works again with your fix! 👍 openHAB 3 seems to have a login now, do you know what the default admin password is? Or where to set the users?

GerdZanker commented 3 years ago

Pairing works again with your fix! 👍 openHAB 3 seems to have a login now, do you know what the default admin password is? Or where to set the users?

My fresh openHAB3 setup, contained one step where I had to enter a Name and a Password for the administrator.

GerdZanker commented 3 years ago

I have no other "things" and "items" configured yet and will do a bit more tests ...

More tests are still pending

coeing commented 3 years ago

I rebased the bosch-shc-3.0 branch and your pull request onto the openhab/main branch, so we can start a new pull request once you merged these changes. Hopefully the openHAB maintainers will find time for a second round of reviews.

GerdZanker commented 3 years ago

Thank you @coeing for the rebase and keeping the branch up to date.

With the latest code I'm able to pair and see in the log the "found devices" of the SHC bridge. But the "long poll" subscription fails with the error response complete: {"jsonrpc":"2.0","error":{"code":-32001,"message":"Error handling JSON-RPC request"}}.

Is everything working for you?

GerdZanker commented 3 years ago

With 770d002 I think I fixed the polling. The subscription needs from my point of view the null in { "com/bosch/sh/remote/*", null }. Afterwards the long poll returned with OK.

But still I'm not able to get "things" and "items" up and running in openHAB3. For example I can't get any temperature of a Twinguard nor a status on a in-wall-switch.

Current Status:

GerdZanker commented 3 years ago

But still I'm not able to get "things" and "items" up and running in openHAB3.

I fail using the Bosch SHC Bridge thing successfully, if created via the openHAB3 webpage.

With a text based thing configuration like below the binding this code is working for me

Bridge boschshc:shc:myshc [ ipAddress="192.168.x.x", password="xxx" ] {
  Thing in-wall-switch BoschSHC_leds "LEDs" [ id="hdm:HomeMaticIP:xxx" ]
  Thing in-wall-switch BoschSHC_leuchten "Leuchten" [ id="hdm:HomeMaticIP:xxx" ]
  Thing twinguard BoschSHC_tg [ id="hdm:ZigBee:xx" ]
}
coeing commented 3 years ago

@GerdZanker I had my configuration also only in text files, so I'll have to test myself if it works via the UI. Good to hear that it was only the missing null Parameter that caused the issue with the long polling. Maybe you can add a comment that it is required, so it is not removed by accident again in the future.

My shutter controls worked for me, I'll see if I can do some tests on Wednesday.

coeing commented 3 years ago

Hi @GerdZanker !

Had some time today to check the long polling. It's really a beast ;) I got it to work now, but I'm not done yet. The long poll requests are done synchronous right now because I had problems to get it working asynchronous. I will try it again on Thursday or Friday. If that works we should be ready for the next reviews.

GerdZanker commented 3 years ago

Had some time today to check the long polling. It's really a beast ;) I got it to work now, but I'm not done yet. The long poll requests are done synchronous right now because I had problems to get it working asynchronous. I will try it again on Thursday or Friday. If that works we should be ready for the next reviews.

I fully understand this point of view.

Same as your sync polling, the pairing is just fixed, but still also synchronous. A pairing change is also necessary before next review to check and pair just once in an executer call.

coeing commented 3 years ago

Still no success making the long polling asynchronous, but at least I refactored the long polling logic, so it is now nicely isolated :)

I'm on vacation next week, so I will probably give it another shot on Sunday, 18th.

coeing commented 3 years ago

Hi @GerdZanker ! I'm back from family vacation :) Would be great if we could manage to start the pull request for our 3.0 branch this weekend. So feel free to merge this pull request and I'll create the pull request.