mdopp / simple-sonoff-server

Emulates the original sonoff-cloud-servers within your local network.
BSD 2-Clause "Simplified" License
144 stars 47 forks source link

Sonoff paired & connected to WLAN... but not connected to server #26

Closed meingraham closed 6 years ago

meingraham commented 6 years ago

To perform some my testing, I edited the configuration JSON file and started the simple-sonoff-server from the command prompt. I set the SSID and password and told it the static IP address I assigned to my Raspberry Pi. The server process printed the ports it is listening on and sat there waiting to respond to a Sonoff device.

1 - I succeeded in pairing with a Sonoff device and "manually" sending it the access point and server information. The Sonoff drops its AP and I see it connected to my WLAN. But then it sits there and eventually errors out. It's not able to connect to the simple server.

  Where can I look to troubleshoot?

2 - This is more to do with the Node-RED installation method... but I'm not sure how much support that gets. There are issues in that git that have gone unanswered for months. None of the posted issues have any responses. So I thought I'd cross-post here since it's recommended here.

I installed the node-red-contrib-sonoff-server package as you suggest (via npm per the documentation).

In Node-RED, only four of the five nodes appear in the nodelist. The sonoff-server node is missing. If I go to Manage Palette and filter on 'sonoff', five nodes are displayed. All five show as "enabled" (i.e., the function button displays 'Disable' for all of the nodes). However, the checkbox for the sonoff-server is not "checked" (checkbox is "hollow"). The checkbox for the other four nodes are "selected" and thus those nodes appear in the node palette. I tried toggling the sonoff-server to disabled and then enabled but it had no effect.

Is there any other configuration I need to perform to the Node-RED environment? Obviously without being able to run config-server, the server isn't configured and thus won't run, the Sonoff device will not complete its configuration, and I won't be able to add it to Node-RED.

mdopp commented 6 years ago

Hi,

about 2) its on purpose, the server will be shown, when you edit a node. There you can add a new server.

image

mdopp commented 6 years ago

about 1) that is more difficult.

mdopp commented 6 years ago

12 might be the same problem...but not sure.

meingraham commented 6 years ago

Node-RED - thanks. Makes sense now.

I'm not sure I understand "router allow device to device communication". My home network is 192.168.1/24. I use my tablet to establish a connection to the Sonoff ITEAD01000xxxxx AP. This network is 10.10.7/24. I can communicate with the Sonoff and receive the device information (http://10.10.7.1/device). I can also send it the SSID and server JSON payload. and the Sonoff response is "error":0. Immediately after this, my tablet's connection to the Sonoff AP drops... and then I can see that the "new" Sonoff is on the 192.168.1/24 subnet. At this point my Simple Server Raspberry Pi is connected to that subnet as well. Thus the networking seems to be working in the intended architecture (not device to device).

The server shows no output after the initial port outputs.

I left the port definition as: sonoff.config.json "httpPort": 1080, "httpsPort": 1081, "websocketPort": 1443

I'm sending the Sonoff my SSID, password, server IP, and port 1080.

Is 1080 the right port to use?

mdopp commented 6 years ago

1080 is for http access to the server via browser. 1081 is for the devices to connect. Please try this one

meingraham commented 6 years ago

OK, I'll give this a try later. I wiped the slate clean on my openHAB deployment (I'm going through the learning and testing) and had made so many attempts and tweaks that I wanted to start fresh and apply only the right setup to end up with a clean deployment. So, I have to re-install some stuff and then I'll give the Sonoff setup a shot using port 1081.

Thanks for the troubleshooting dialog! TTYL

Mike

meingraham commented 6 years ago

Michael,

I just gave it a try with sending port 1081 in the setup. Still no progress. The server is not seeing a request as the is no additional output from the server after its initial ports notification:

$ node sonoff.server.js
SONOFF Server Started On Port 1081
API Server Started On Port 1080

For grins, I decided to add the device to eWeLink. It configured successfully. I took the opportunity to look at the firmware version - 1.6.0. I know that this newer firmware made the SonOTA OTA flashing stop working. Has simple-sonoff-server been tested with this newer firmware?

mdopp commented 6 years ago

We are using the same method. So it will not work.

meingraham commented 6 years ago

Perhaps this "no firmware" hack has now also suffered from the same Sonoff firmware upgrade change that impacted SonOTA. That is, the firmware now uses security certificates. Since simple-sonoff-server is not built with using encrypted communications with the Sonoff device, and the certificates are not available, this may be the end of the road for the "no firmware hack" hack. It was good while it lasted!

mdopp commented 6 years ago

The problem is not encryption, but that a special server certificate is needed. If any certificate would work (like in the past) or just a correct certificate would be needed (like one you could get from letsencrypt) it would just be a simple code change.

Still this works for older devices