hxmelab / node-red-contrib-bosch-shc

Bosch Smart Home Controller (SHC) nodes for Node-Red
https://flows.nodered.org/node/node-red-contrib-bosch-shc
MIT License
20 stars 6 forks source link

No SHC found in local network #4

Closed btotherunner closed 4 years ago

btotherunner commented 4 years ago

Hey hymelab,

thanks for deploy the bosch smart home plugin for nodered.

When i search my Smart Home Controller - Press the Button till the lights are blinking - i become the follow message:

Searching SHCs in local network, please wait... No SHC found in local network

Do you have any idea?

Thank you :D

hxmelab commented 4 years ago

This project uses "node-dns-sd" which is a javascript implementation of mDNS/DNS-SD (Apple Bonjour) for discovering a SHC in your local network.

As described here, the service is not properly working on windows, if Apple Bonjour is installed at the same time: https://github.com/futomi/node-dns-sd/issues/1

If no discovery is possible you can always enter the IP manually. However, on which OS are you running Node-RED?

By the way: The discovery should work also, if the SHC is in pairing mode but must not necessarily be in pairing mode.

btotherunner commented 4 years ago

Thanks for the fast response.

I use an Docker Container - based in an CentOS Host

I added the Up manuell.

But when i press the pair Button - i become the follows message: ERROR - Button pressed?

The SHC is in Paring mode ATM.

hxmelab commented 4 years ago

Could you please try to ping the SHC from the machine you are running Node-RED. The SHC should respond to the ping.

hxmelab commented 4 years ago

Or open a browser and try this: https://192.168.0.10:8446/smarthome/public/information

With curl: curl -X GET -k https://192.168.0.10:8446/smarthome/public/information

This is useful to just test the connection although it is not paired.

btotherunner commented 4 years ago

Could you please try to ping the SHC from the machine you are running Node-RED. The SHC should respond to the ping.

From Docker host (works fine) [root@dockersrv01 ~]# ping 192.168.114.192 PING 192.168.114.192 (192.168.114.192) 56(84) bytes of data. 64 bytes from 192.168.114.192: icmp_seq=1 ttl=64 time=0.966 ms 64 bytes from 192.168.114.192: icmp_seq=2 ttl=64 time=0.616 ms

From Docker Container (works fine) bash-5.0$ ping 192.168.114.192 PING 192.168.114.192 (192.168.114.192) 56(84) bytes of data. 64 bytes from 192.168.114.192: icmp_seq=1 ttl=63 time=0.420 ms 64 bytes from 192.168.114.192: icmp_seq=2 ttl=63 time=0.570 ms

btotherunner commented 4 years ago

Or open a browser and try this: https://192.168.0.10:8446/smarthome/public/information

With curl: curl -X GET -k https://192.168.0.10:8446/smarthome/public/information

This is useful to just test the connection although it is not paired.

Browser: Works fine:

{"apiVersions":["1.0"],"softwareUpdateState":{"@type":"softwareUpdateState","swUpdateState":"NO_UPDATE_AVAILABLE","swUpdateLastResult":"UPDATE_SUCCESS","swUpdateAvailableVersion":"","swInstalledVersion":"9.14.1279-9457","swActivationDate":{"@type":"softwareActivationDate","timeout":604800000}},"claimed":true,"country":"DEU","tacVersion":"DEU-9","shcIpAddress":"192.168.114.192.......

Curl works fine: [root@dockersrv01 ~]# curl -X GET -k https://192.168.114.192:8446/smarthome/public/information {"apiVersions":["1.0"],"softwareUpdateState":{"@type":"softwareUpdateState","swU.....

Curl from Dockercontainer: (Works fine) bash-5.0$ curl -X GET -k https://192.168.114.192:8446/smarthome/public/information {"apiVersions":["1.0"],"softwareUpdateState":{"@type":"softwareUpdateState","swUpdateState":"NO...

hxmelab commented 4 years ago

Ok, then the pairing process should work. Well, I wanted to update the pairing process anyway, as there is a major update of the shc library. Then I will also provide a better error logging.

btotherunner commented 4 years ago

but the Paring does Not Work - i become the Error Message - Press Paring Button? ;)

hxmelab commented 4 years ago

The pairing process should work, but I don't know why it is not working in your network. Please, give me some time to provide a better error handling and logging. I hope we can figure out what is going on then.

btotherunner commented 4 years ago

is the problem the different ip-adress from the internal docker-container (nodered 172.17.0.5) The Hostmaschine and the only way of communication runs over the Host-Docker IP-Adress 192.168.114.210. The Bosch Device has 192.168.114.192

When the Bosch device send data to the nodered - he cant use the nodered internal adress 172.17.0.5).

hxmelab commented 4 years ago

The SHC does not send data via the IP, instead it sends data via long polling. Therefore, the SHC does not need the IP of Node-RED. You could try again the connection directly from Node-RED with the following flow:

[{"id":"f556229e.387f8","type":"http request","z":"4ee19f46.563e6","name":"","method":"GET","ret":"txt","paytoqs":false,"url":"https://192.168.114.192:8446/smarthome/public/information","tls":"9d8437d0.bd0718","persist":false,"proxy":"","authType":"","x":330,"y":500,"wires":[["808b318a.b848f"]]},{"id":"299f9008.e3cca","type":"inject","z":"4ee19f46.563e6","name":"","topic":"","payload":"","payloadType":"date","repeat":"","crontab":"","once":false,"onceDelay":0.1,"x":160,"y":500,"wires":[["f556229e.387f8"]]},{"id":"808b318a.b848f","type":"debug","z":"4ee19f46.563e6","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"false","x":520,"y":500,"wires":[]},{"id":"9d8437d0.bd0718","type":"tls-config","z":"","name":"","cert":"","key":"","ca":"","certname":"","keyname":"","caname":"","servername":"","verifyservercert":false}]

btotherunner commented 4 years ago

sorry how can i create this flow :D

hxmelab commented 4 years ago

Copy the json array, go to the Node-RED menu, click on Import and paste the json.

btotherunner commented 4 years ago

oh gott :D sorry :D ^^

Output:

"{"apiVersions":["1.0"],"softwareUpdateState":{"@type":"softwareUpdateState","swUpdateState":"NO_UPDATE_AVAILABLE","swUpdateLastResult":"UPDATE_SUCCESS","swUpdateAvailableVersion":"","swInstalledVersion":"9.14.1279-9457","swActivationDate":{"@type":"softwareActivationDate","timeout":604800000}},"claimed":true,"country":"DEU","tacVersion":"DEU-9","shcIpAddress":"192.168.114.192","clientIds":["508506C1-3E9C-43DC-8F0D-DB813B0638BE","112B6F87-05C5-4252-AD59-143A8AA44270","57acdde5-7aae-4d27-b121-1398c9c02c4b","aed4b51e-5c74-4df1-a4c4-da0676532147"],"featureToggles":{"http-rest.api":false,"app-store-rating.ios":true,"app-logging":false,"app-analytics":false,"shading.slats.values":false,"cameras.extension":true,"shading.advance.menu":true,"wallthermostat.pairing":true,"app-store-rating.android":true,"whitegoods.pairing":true},"connectivityVersions":[{"name":"claiming","minVersion":1,"maxVersion":1},{"name":"noncePairing","minVersion":1,"maxVersion":1},{"name":"buttonPairing","minVersion":1,"m..."

Is the Problem: http-rest.api:false?

hxmelab commented 4 years ago

No, it has nothing to do with this.

Ok, well did you pressed the button of the SHC until LEDs are flashing before you try to POST the client?

Because, if the communication between your docker container and the SHC is working, the pairing should work also. The only difference is the SHC pairing mode.

But finally you could try if it is working without a docker container.

btotherunner commented 4 years ago

ok i will test it later (with pairring mode active). And will check the same - from an other system.

btotherunner commented 4 years ago

ok i testet the pairing - with an docker container and from my windows pc. the shc is in paring mode - but i become on all systems the error: "ERROR - Button pressed?"

Furthermore: The Output From https://192.168.114.192:8446/smarthome/public/information is the same (in paring mode or in normal mode || on my windows notebook or in my docker container)

thanks for your effort

btotherunner commented 4 years ago

i become the follow error console message:

TypeError: Cannot read property 'toString' of null
    at CertificateGenerator.createAndStartProcess (C:\Users\info\.node-red\node_modules\bosch-smart-home-bridge\dist\certificate-generator.js:49:39)
    at CertificateGenerator.createNewKey (C:\Users\info\.node-red\node_modules\bosch-smart-home-bridge\dist\certificate-generator.js:40:14)
    at CertificateGenerator.createNewCertificate (C:\Users\info\.node-red\node_modules\bosch-smart-home-bridge\dist\certificate-generator.js:36:14)
    at CertificateStorage.generateClientCertificateIfNeeded (C:\Users\info\.node-red\node_modules\bosch-smart-home-bridge\dist\certificate-storage.js:70:39)
    at CertificateStorage.getClientCertificateKey (C:\Users\info\.node-red\node_modules\bosch-smart-home-bridge\dist\certificate-storage.js:63:14)
    at BshcClient.AbstractBshcClient.simpleCall (C:\Users\info\.node-red\node_modules\bosch-smart-home-bridge\dist\api\abstract-bshc-client.js:68:61)
    at BshcClient.getRooms (C:\Users\info\.node-red\node_modules\bosch-smart-home-bridge\dist\api\bshc-client.js:64:21)
    at Observable._subscribe (C:\Users\info\.node-red\node_modules\bosch-smart-home-bridge\dist\bosch-smart-home-bridge.js:64:30)
    at Observable._trySubscribe (C:\Users\info\.node-red\node_modules\rxjs\internal\Observable.js:44:25)
    at Observable.subscribe (C:\Users\info\.node-red\node_modules\rxjs\internal\Observable.js:30:22)
btotherunner commented 4 years ago

The same error in my DockerContainer Error Log:

TypeError: Cannot read property 'toString' of null

    at CertificateGenerator.createAndStartProcess (/data/node_modules/bosch-smart-home-bridge/dist/certificate-generator.js:49:39)

    at CertificateGenerator.createNewKey (/data/node_modules/bosch-smart-home-bridge/dist/certificate-generator.js:40:14)

    at CertificateGenerator.createNewCertificate (/data/node_modules/bosch-smart-home-bridge/dist/certificate-generator.js:36:14)

    at CertificateStorage.generateClientCertificateIfNeeded (/data/node_modules/bosch-smart-home-bridge/dist/certificate-storage.js:70:39)

    at CertificateStorage.getClientCertificateKey (/data/node_modules/bosch-smart-home-bridge/dist/certificate-storage.js:63:14)

    at BshcClient.AbstractBshcClient.simpleCall (/data/node_modules/bosch-smart-home-bridge/dist/api/abstract-bshc-client.js:68:61)

    at BshcClient.getRooms (/data/node_modules/bosch-smart-home-bridge/dist/api/bshc-client.js:64:21)

    at Observable._subscribe (/data/node_modules/bosch-smart-home-bridge/dist/bosch-smart-home-bridge.js:64:30)

    at Observable._trySubscribe (/data/node_modules/rxjs/internal/Observable.js:44:25)

    at Observable.subscribe (/data/node_modules/rxjs/internal/Observable.js:30:22)

    at RED.httpAdmin.get (/data/node_modules/node-red-contrib-bosch-shc/nodes/shc-config.js:125:74)

    at Layer.handle [as handle_request] (/usr/src/node-red/node_modules/express/lib/router/layer.js:95:5)

    at next (/usr/src/node-red/node_modules/express/lib/router/route.js:137:13)

    at /usr/src/node-red/node_modules/@node-red/editor-api/lib/auth/index.js:74:13

    at Layer.handle [as handle_request] (/usr/src/node-red/node_modules/express/lib/router/layer.js:95:5)

    at next (/usr/src/node-red/node_modules/express/lib/router/route.js:137:13)

    at Route.dispatch (/usr/src/node-red/node_modules/express/lib/router/route.js:112:3)

    at Layer.handle [as handle_request] (/usr/src/node-red/node_modules/express/lib/router/layer.js:95:5)

    at /usr/src/node-red/node_modules/express/lib/router/index.js:281:22

    at Function.process_params (/usr/src/node-red/node_modules/express/lib/router/index.js:335:12)

    at next (/usr/src/node-red/node_modules/express/lib/router/index.js:275:10)

    at expressInit (/usr/src/node-red/node_modules/express/lib/middleware/init.js:40:5)
hxmelab commented 4 years ago

There is an issue with the SHC library and Windows. The version of the lib which this project uses is not able to generate a certificate on Windows. That's why you get this error message. The current version solves this problem. I will fix that hopefully this week.

btotherunner commented 4 years ago

hey hxmelab,

i have the same error on my linux system. TypeError: Cannot read property 'toString' of null

hxmelab commented 4 years ago

Alright, the new version is now available and you should now be able to pair with the SHC. If you like you can try it again. If you have any configurations, please delete them before the update.

However, the changes I made will not solve the problem that you cannot discover the SHC in your local network. Try to repeat the search several times. Maybe this already solves the problem. If not, the problem could be that you are searching inside a docker container. Then maybe you should consider to get rid of the container or enter the IP manually.

Hope it is working!

anfische commented 4 years ago

Hey hxmelab, I tried the shc node yesterday without success. The SHC was found, but the pairing always went wrong with the error message "ERROR - Button pressed?". After your update today the pairing works. I use Node Red in a docker container (with parameter --net=host) on a linux server. Thanks for your effort!

btotherunner commented 4 years ago

Hey @hxmelab,

thanks for fixing the Problem. The SHC was not found automatically - but with an fix ip adress the paring works finde. The Device Search works also fine. Thank you :D Now i can test my flows ^^ 💃