Hi guys, I’m trying to connect a websocket and mqtt (JavaScript Paho mqtt client) to my Home Assistant in order to get the status of Sonoff switches, or send commands to them and show the info in my private custom built site. Is there any way to do that? I tried almost everything but I always get error like: WebSocket connection to ‘ws://192.168.1.107:8085/’ failed: Error in connection establishment: net::ERR_CONNECTION_REFUSED. I tried websocket ports like 9001, 9002, 8085, 8123 …Same error anytime …
EDIT:
In order to explain my pain better:
I have a web server, on a separate machine in my home network, with IP 192.168.1.111. There is a web site on it where I’ve built web interface for wireless IR Remote controls (one for each of my room) to control my TV’s, Air Conditioners and Audio Systems. I want to show the status of the light switches (Sonoff relays) connected to hass (installed on Raspberry Pi with IP 192.168.1.107). Also, if there is a possibility, to integrate html+css switch to send mqtt commands to switch them on\off. I decided to use Paho mqtt javascript in the pages for each room to make the connection and send the topics. As you can see this is where the problems started.
I’m still getting:
WebSocket connection to ‘ws://192.168.1.107:8080/’ failed: Error in connection establishment: net::ERR_CONNECTION_REFUSED
Do I have to do any configurations in home assistant in order to connect to it?
I’m using Mosquitto for mqtt if that matters … :
This is my mosquitto.conf
listener 1883
listener 1884
protocol mqtt3.1.1 // I also tried with “mqtt3.1” and “mqtt”
listener 8080
protocol websockets
Websockets support is currently disabled by default at compile time.
So are you sure you have websockets enabled?
Really, your problem is between your client and mosquitto, so you would probably be better off asking your question on the mosquitto mailing list, rather than on the HA forum.
Excuse me for my dumb questions, but I’m very new in this IoT thing. I’m very excited of it and it is interesting for me. I’m playing around with it from a month and I think home assistant is great, but I don’t know many things of it. Even simple things like socket connection is starting to drive me crazy … But I won’t give up. That’s why I’m asking for help from you guys.