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.setupdevice.js is not necessary (and therefore network-manager is not necessary) #1

Closed andrewerrington closed 6 years ago

andrewerrington commented 6 years ago

Hello,

I had great trouble setting things up to run on my Raspberry Pi. In particular, network-manager was not installed, so I installed it (to get nmcli) and it was tiresome to get it going, and I'm not even sure it was working properly. I couldn't get your setupdevice script to work, or rather, it ran, but it didn't seem to program the wifi settings into the Sonoff device.

Instead, I think this will work (it works for me), once you have put the Sonoff into AP mode and connected to it: wget -O- --post-data='{"version":4,"ssid":"SSID","password":"PASSWORD","serverName":"n.n.n.n","port":1080}' --header=Content-Type:application/json "http://10.10.7.1/ap"

Your server itself doesn't seem to need network-manager, so I have it running, and my Sonoff is configured and connecting.

Thanks!

posipov34 commented 6 years ago

Hi. Raspbery pi works fine with network manager after tuning. (i found solution after hours of googling at https://raspberrypi.stackexchange.com/questions/29783/how-to-setup-network-manager-on-raspbian)

  1. Install packages sudo apt install network-manager network-manager-gnome openvpn openvpn-systemd-resolved network-manager-openvpn network-manager-openvpn-gnome
  2. Remove unneeded packages sudo apt purge openresolv dhcpcd5
  3. Create a simlink sudo ln -sf /lib/systemd/resolv.conf /etc/resolv.conf
  4. Remove "Wireless & Wired Network" applet from top right corner of desktop
  5. Adjust network settings in /etc/network/interfaces
  6. Reboot
  7. Add "Manage Networks" applet to top right corner of desktop

maybe the author will add this description for raspeby pi users into readme?

andrewerrington commented 6 years ago

It's much easier to avoid it.

mdopp commented 6 years ago

I have to admit, that I use the setup script on Windows only. There everything works out of the box. The Network Manager is needed for the script to check available networks and if one of it is an SonOff, then connect to it. Connecting manually to the SonOff Wifi and then run the wget would remove the need for the network manager installation and hence make it easier to use on a raspberry. But at least me would not want to run it on an raspberry, as it would stop my openhab from working (even if only for a few minutes) I think that adding a hint to the readme and place your wget script there could help others. Do you agree @andrewerrington ?

andrewerrington commented 6 years ago

Sure, that would work. There is one more step, and that is to add a route to the device (as mentioned in the ipsumdomus blog).

So, my steps (on a Raspberry Pi) are: 1) put Wemos device in AP mode (press and hold button for 5s) 2) find device and connect to it (SSID: ITEAD-10000xxxxx Password: 12345678) 3) add route if necessary (sudo route change 0.0.0.0 mask 0.0.0.0 10.10.7.1) 4) (optional) use wget to read device info (wget -O- 10.10.7.1/device) 5) use wget to send local WiFi settings to device (wget -O- --post-data='{"version":4,"ssid":"SSID","password":"PASSWORD","serverName":"n.n.n.n","port":1080}' --header=Content-Type:application/json "http://10.10.7.1/ap") 6) device automatically drops out of AP mode and tries to connect to WiFi and server.

mdopp commented 6 years ago

@andrewerrington cool, will add this later tonight to the readme. Thanks for the details!

andrewerrington commented 6 years ago

Thanks for the server software!

mdopp commented 6 years ago

Description changed, please let me know if it is clear enough, then i will close this issue.

andrewerrington commented 6 years ago

Looks good. I hope someone else tries it and that it works.