rudyberends / homebridge-loxone-proxy

Homebridge Dynamic Platform Plugin which exposes a Loxone System to Homekit
Apache License 2.0
12 stars 6 forks source link

WebSocket error - Connection failed: [object Object] or Request failed with status code 401 #17

Closed ccky closed 1 year ago

ccky commented 1 year ago

Hi, could you please help me find out what is going wrong here:

request: dns.loxonecloud.com/?getip&snr={my-SNR}&json=true

response: {"cmd":"getip","Code":200,"IPHTTPS":"{my-IP}:{my-PORT}","PortOpenHTTPS":true,"RemoteConnect":true,"DNS-Status":"registered","DataCenter":"loxonecloud.com"}

[7/23/2023, 3:53:53 PM] [homebridge-loxone-proxy] Loaded homebridge-loxone-proxy v1.1.0 child bridge successfully
[7/23/2023, 3:53:53 PM] Loaded 0 cached accessories from cachedAccessories.0E3112CECBAC.
[7/23/2023, 3:53:53 PM] [homebridge-loxone-proxy] Trying to connect to Miniserver
[7/23/2023, 3:53:54 PM] Homebridge v1.6.1 (HAP v0.11.1) (homebridge-loxone-proxy) is running on port 49045.
[7/23/2023, 3:53:54 PM] [homebridge-loxone-proxy] Connection failed: Error: Request failed with status code 401

Have I missed something?

rudyberends commented 1 year ago

I have only tested the code against a v1 miniserver which does not use TLS on port 443, but it is using Loxone's lxcommunicator under the hood, so it should work.

For internal communication you should use ip4 notation. So for example (192.168.1.200). Port should be 443. (not sure if a v2 miniserver accepts port 80)

Does it work using this notation?

ccky commented 1 year ago

With clear mind I've once again sat to "try everything" While I couldn't get TLS connection in accordance to lxcommunicator readme I got a connection on local IP http - http://192.168.xx.xx:80 This made another error surface:

[7/30/2023, 6:17:27 PM] [homebridge-loxone-proxy] Connected to Miniserver
TypeError: Cannot read properties of undefined (reading 'name')
    at LoxonePlatform.parseLoxoneConfig (/homebridge/node_modules/homebridge-loxone-proxy/src/LoxonePlatform.ts:62:42)
    at LoxonePlatform.LoxoneInit (/homebridge/node_modules/homebridge-loxone-proxy/src/LoxonePlatform.ts:34:10)
    at HomebridgeAPI.<anonymous> (/homebridge/node_modules/homebridge-loxone-proxy/src/LoxonePlatform.ts:23:7)
[7/30/2023, 6:17:28 PM] [homebridge-loxone-proxy] Child bridge process ended
[7/30/2023, 6:17:28 PM] [homebridge-loxone-proxy] Process Ended. Code: 1, Signal: null
[7/30/2023, 6:17:35 PM] [homebridge-loxone-proxy] Restarting Process...
[7/30/2023, 6:17:36 PM] [homebridge-loxone-proxy] Launched child bridge with PID 145144
[7/30/2023, 6:17:36 PM] Registering platform 'homebridge-loxone-proxy.LoxonePlatform'
[7/30/2023, 6:17:36 PM] [homebridge-loxone-proxy] Loaded homebridge-loxone-proxy v1.1.0 child bridge successfully
[7/30/2023, 6:17:36 PM] Loaded 0 cached accessories from cachedAccessories.0E1569744A57.
[7/30/2023, 6:17:36 PM] [homebridge-loxone-proxy] Trying to connect to Miniserver

but... found an "install alternate version" option in HB and seems that version 1.0.6 works OK so a problem seems to hide in the code - something with mapping of room name on item?

rudyberends commented 1 year ago

Thank you for your feedback.

https://github.com/rudyberends/homebridge-loxone-proxy/commit/f03c6867261313db0b8b5c1335afb78 Should fix your issues. It's in the latest beta. Perhaps you can test it?

ccky commented 1 year ago

Thanks, fix confirmed. Connection established now. I will eventually try again to make TLS connection work as documented on LxCommunicator One note - after switching from 1.0.6 I had to manually remove intercom from cached accessories as it was not responding in Home App initially.

ccky commented 1 year ago

Actually speaking of intercom (v2)

  1. Do you know if it would be possible to have an audio from Intercom in home app. When I open camera feed from Home on macOS I get a notification that microphone got activated so I'd assume it should work.
  2. Is there a way to workaround and allow recording on motion to iCloud as with other HomeKit cameras?
rudyberends commented 1 year ago

Thanks for testing. To answer your questions;

  1. The code on the homebridge side for 2 way audio is already in place. That is why you see the microphone. However on the Loxone side this still needs to be implemented. For intercomV1 this should be easy to implement as there is a SIP connection available. On the V2 it should be also available, but I don't think Loxone has already implemented it (documentation claims SIP is available.) It should still be possible using webrtc, but it requires some more research. The Loxone implementation uses a websocket for the WebRTC signaling, so I need to figure out how this works.

  2. I will try to implement Homekit secure video. It should be possible as other plugins already use it.