tommasomarchionni / homebridge-openHAB

Homebridge plugin for openHAB
Apache License 2.0
49 stars 18 forks source link

Unhandled 'error' event #6

Closed mblong closed 8 years ago

mblong commented 8 years ago

This is a very welcome addition -- thanks for your efforts.

I believe I'm close to having things working, but get this error when I start homebridge:

homebridge * WARNING * The program 'node' uses the Apple Bonjour compatibility layer of Avahi. * WARNING * Please fix your application to use the native API of Avahi! * WARNING * For more information see http://0pointer.de/avahi-compat?s=libdns_sd&e=node * WARNING * The program 'node' called 'DNSServiceRegister()' which is not supported (or only supported partially) in the Apple Bonjour compatibility layer of Avahi. * WARNING * Please fix your application to use the native API of Avahi! * WARNING * For more information see http://0pointer.de/avahi-compat?s=libdns_sd&e=node&f=DNSServiceRegister Loaded plugin: homebridge-openhab

Registering platform 'homebridge-openhab.openHAB'

Loaded config.json with 0 accessories and 1 platforms.

Loading 1 platforms... [openHAB] Initializing openHAB platform... [openHAB] Platform - Fetching OpenHAB devices. [openHAB] Platform - Connecting to http://user:password@10.0.1.202:8080/rest/sitemaps/homekit?type=json Loading 0 accessories... [ Dim1: { name: 'Dim1', label: 'Living Room Light', type: 'SwitchItem', state: 'ON', link: 'http://10.0.1.202:8080/rest/items/Dim1' }, ruleTest: { name: 'ruleTest', label: 'Test Switch', type: 'SwitchItem', state: 'OFF', link: 'http://10.0.1.202:8080/rest/items/ruleTest' }, piTest: { name: 'piTest', label: 'Raspberry Pi', type: 'SwitchItem', state: 'OFF', link: 'http://10.0.1.202:8080/rest/items/piTest' } ] [openHAB] Platform - Accessory Found: Living Room Light [openHAB] Platform - Accessory Found: Test Switch [openHAB] Platform - Accessory Found: Raspberry Pi [openHAB] Initializing platform accessory 'Living Room Light'... [openHAB] Initializing platform accessory 'Demo Lightbulb Label'... [openHAB] Initializing platform accessory 'Pi Light'... Scan this code with your HomeKit App on your iOS device to pair with Homebridge:

┌────────────┐     
│ 031-45-154 │     
└────────────┘     

Homebridge is running on port 51826. events.js:142 throw er; // Unhandled 'error' event ^

Error: unexpected server response (401) at ClientRequest.response (/usr/local/lib/node_modules/homebridge-openhab/node_modules/ws/lib/WebSocket.js:694:15) at ClientRequest.g (events.js:261:16) at emitOne (events.js:78:13) at ClientRequest.emit (events.js:170:7) at HTTPParser.parserOnIncomingClient as onIncoming at HTTPParser.parserOnHeadersComplete (_http_common.js:89:23) at Socket.socketOnData (_http_client.js:312:20) at emitOne (events.js:78:13) at Socket.emit (events.js:170:7) at readableAddChunk (_stream_readable.js:147:16)

I'm not sure if this an openhab or homebridge issue. I'm running homebridge on a raspberry Pi and openhab on a second raspberry Pi.

Any suggestions would be welcome.

Thanks.

mblong commented 8 years ago

I found a workaround for this problem. The issue seems to be related to password protection in openHab.

In my openhab.cfg file I had security:option=EXTERNAL changing this to security:option=OFF

lets homebridge work if I take "user": "myUserName", "password": "myPassword", out of my config.json file. I needed these in the config.json file to get as far as I did in the previous post.

I'm not clear on why the EXTERNAL option in openHab required a username/password in the first place since both the openHab and homebridge raspberry Pis are on the same network. I would like to be able to have the password protection enabled.

Any thoughts on how to do this?

tommasomarchionni commented 8 years ago

I will try to test and fix openHAB authentication in the next days! Thank You for your highlighting!