openhab / openhabian

openHABian - empowering the smart home, for Raspberry Pi and Debian systems
https://community.openhab.org/t/13379
ISC License
821 stars 252 forks source link

Add wifi configuration #14

Closed VD17593 closed 7 years ago

VD17593 commented 8 years ago

Hi again,

(issue following our discussion openHABian hassle-free RPi image yesterday)

Meanwhile I've been looking at the raspbian-ua-netinst links you provided, and I get your point now.

It really would be nice to be able to integrate this wifi connection, certainly for users who don't want to 'look into the PI'. And as proposed to include this opportunity into your "installer-config.txt" file would be a very nice idea !! A remark though : if users have the choice between an installation with ethernet or wifi, the ethernet should be advised for the higher speed.

So what I basically propose is by default provide the lines necessary in the config file, and at installation to check if the default values have been changed. If not changed, nothing has to be done. If changed, make the installation (described below).

Default, tested and confirmed during my own installations, only these two lines should be needed:

wifi ssid= wifi password=

More parameters could be provided as described here, but I'm not familiar with the other lines (and hence won't be able to test them).

So, if ssid and /or password blank : no wifi connection to be set up. If ssid and password provided : make wifi connection.

Now, I'm wondering if it would be easier to include this possibility form raspbian-ua-netinst, or do you think about adding something of your own. I the last case, the steps involved to make the wifi should be further analyzed.

But basically it comes down to this : . the connection should (obviously) work before any other download is needed . like mentioned before, the file to be written to is :

/etc/wpa_supplicant/wpa_supplicant.conf

. at the end of this file write this :

    network={
        ssid="YOUR_SSID"
        psk="YOUR_PASSWORD"
    }

. once the file written a reboot should be done (to be confirmed if a reboot is needed)

So, is this description something you could use?

ThomDietrich commented 8 years ago

I'm afraid I can not add new lines to installer-config.txt - or in other words, that would be a change we'd need to propose at raspbian-ua-netinst. The better and not more complicated solution for us would be to provide the file /config/wpa_supplicant.conf with the placeholder content as you proposed. A user would then have to fill the file with his wifi credentials after flashing to SD. Acceptable? In fact, I finished the new openHABian version yesterday, so you could try this right away!

VD17593 commented 8 years ago

I could have a try now. Just to be sure we are talking about the same version : I download this zip file , unzip it and copy it on the card. Correct?

Then you are talking about /config/wpa_supplicant.conf I think it doesn't matter on what ever place the wifi credentials have to be entered, as long as it can be done before inserting the card in the PI, and it is clearly documented for the user.

Since I don't find this file in the zip file, I suppose I'll have to create it (now for testing).

Then once this file provide, could you explain me how the installation takes care of the rest ?

Meanwhile I tried to copy the zip to the card without success. So I'll try to download the latest release and include the /config/wpa_supplicant.conf to see if it works

ThomDietrich commented 8 years ago

Is the README still not clear enough :cry:

It says "Write image to SD card (instructions)"

The zip you are talking about is the raw project used to build the image you are looking for. The zip is of little interest to the enduser. Go to the releases tab and download the latest image from there. I have just uploaded a brand new one called openhabian-ua-netinst-20160913-gitfad1ceb.img: https://github.com/ThomDietrich/openhabian/releases/tag/v0.8 After writing the file to your sd card by the use of the guide linked above, you will find a config folder on your sd card where you can than create wpa_supplicant.conf.

VD17593 commented 8 years ago

Ok. Did a first try. By the way : your readme is absolutely clear, I just didn't know which version we were talking about.

My try was with the v0.7. No success. Added wpa_supplicant.conf to /config, and booted with the ethernet connection on. PI was working but there was no file /etc/wpa_supplicant/wpa_supplicant.conf.

Going to have a try now with the v0.8.

ThomDietrich commented 8 years ago

Too bad. Maybe now you have more luck. Could you try without Ethernet? After installation was successful or not, send me the first few lines of /var/log/raspbian-ua-netinst.log - there should be network setup information.

ThomDietrich commented 8 years ago

I did make quite a progress yesterday btw. Nothing directly related to wifi but a lot of other improvements. I also found a major bug in the basic setup :see_no_evil: but don't worry bout that for now. I'll probably release v0.9 this evening for that matter. Would be great to include a placeholder for wifi setup ;)

VD17593 commented 8 years ago

The boot is running now. Tried first without ethernet, but the boot stalled when searching for a connection.

Then plugged in the ethernet, and setup proceeded.

Just trying the wifi setup now. After that I would like try with some tweaking around : using the menu for example. I'll have perhaps also a look to the whole process.

Would be nice to have something running for the v0.9

VD17593 commented 8 years ago

While the process is running, perhaps a few (preliminary) remarks.

At the end of previous try I had the impression that there is no GUI for the PI. Is that correct? When installing the default Jessie on the PI3 there is always a GUI. I can imagine that for people not used to Linux, such a GUI can be of great value, especially if they want to discover what PI has to offer.

Another remark, also aimed at people without Linux or PI knowledge, The whole process of having to write an image to a card can be new (or even what is an image). I know you put a reference to the PI documentation with the process to be followed, but maybe for a few MB this could be overkill. Why not just provide a zip file with everything ready, that the user just has to copy to his card (this process is familiar to everybody)?

ThomDietrich commented 8 years ago

A setup completely without ethernet would be amazing. Too bad it didn't work out right away. I do not own a Raspberry Pi 3 yet, otherwise I would try to help you.

A menu option to input your SSID and password would definitely be possible. Could you define GUI? I don't know what you are looking for but there is raspi-config and /opt/openhabian/openhabian-setup.sh providing you with two menus. Is that what you are looking for?

provide a zip file with everything ready, that the user just has to copy

Sounds easier but really, it is not. You may need to format the sd card, there might be a weird partition table, do you need to extract with or without subfolder? I have read a lot of questions related to this method. An image is absolute. Just execute one application and write the image. Done. That's the cleanest method I've encountered over the years and the fact, that raspbian itself is going this path confirms my believe...

VD17593 commented 8 years ago

Not working.

The directory /etc/wpa_supplicanteven doens't exist !

When I looked at the links you provided, I saw that those talking about the wifi setup were working on another branch. Maybe this possibility is not included in the version of raspbian-ua-netinstyou use as starting point. So then there are two possibilities:

About the image you convinced me. I didn't look at all the implications and possible unclear situations with copying the zip.

By GUI I mean the user interface for the PI. With Jessie, when you boot the PI (with screen and keyboard) it goes to a graphical interface (windows like), which I find pretty amazing (even if I don't use it). I can imaging this could be of great value for users with basic knowledge.

So what do you propose for the wifi solution?

VD17593 commented 8 years ago

These are the first line of the log. Tell me if you need more.

=================================================
raspbian-ua-netinst
=================================================
Revision git~fad1ceb
Built on Tue Sep 13 00:28:11 CEST 2016
Running on Raspberry Pi version 3
=================================================
https://github.com/debian-pi/raspbian-ua-netinst/
=================================================
Starting HWRNG succeeded!
Copying boot files... OK
=================================================
=== Start executing installer-config.txt. ===
/etc/init.d/rcS: /bootfs/installer-config.txt: line 9: de_DE.UTF-8: not found
=== Finished executing installer-config.txt. ===
=================================================

Network configuration:
  ip_addr = dhcp
  online_config = 

Waiting for eth0... 
Configuring eth0 with DHCP... 192.168.0.108
Time set using ntpdate to... Wed Sep 14 12:00:20 UTC 2016

Installation started at Wed Sep 14 11:59:40 UTC 2016.

Installer configuration:
  preset = server
  packages = sudo
  mirror = http://mirrordirector.raspbian.org/raspbian/
  release = jessie
  hostname = openHABianPi
  domainname = 
  rootpw = raspbian
  root_ssh_pubkey = 
  disable_root = 1
  username = pi
  userpw = raspberry
  user_ssh_pubkey = 
  user_is_admin = 1
  cdebootstrap_cmdline = --flavour=minimal --include=linux-image-rpi2-rpfv,cpufrequtils,kmod,libpam-systemd,rng-tools,fake-hwclock,ifupdown,net-tools,ntp,openssh-server,dosfstools,vim-tiny,iputils-ping,wget,ca-certificates,rsyslog,cron,dialog,locales,less,man-db,isc-dhcp-client,sudo
  boot_volume_label = openHABian
  bootsize = +128M
  bootoffset = 8192
  rootsize = 
  timeserver = 0.pool.ntp.org
  timezone = Europe/Berlin
  locales = 
  system_default_locale = en_US-UTF-8
  cmdline = dwc_otg.lpm_enable=0 console=ttyAMA0,115200 kgdboc=ttyAMA0,115200 console=tty1 elevator=deadline
  usbroot = 
  rootdev = /dev/mmcblk0
  rootpartition = /dev/mmcblk0p2
  rootfstype = ext4
  rootfs_mkfs_options = 
  rootfs_install_mount_options = noatime,data=writeback,nobarrier,noinit_itable
  rootfs_mount_options = errors=remount-ro,noatime
  final_action = reboot
  hardware_versions = 3
  gpu_mem = 

Waiting 5 seconds.....
Waiting for /dev/mmcblk0... OK
Applying new partition table... OK
Initializing /boot as vfat... OK
Copying /boot files in... OK
Initializing / as ext4... OK
Mounting new filesystems... OK
ThomDietrich commented 8 years ago

I saw that those talking about the wifi setup were working on another branch.

That would explain everything but nope... The merge was on branch "v1.1.x" and I am in sync with that branch, see https://github.com/ThomDietrich/openhabian/commit/d0d53c4404f417d8c9d1d41abe908c0ebf93d817

Adding wifi setup to the openhabian menu will be easy. I can do that later today. It would have been amazing though, to use the mechanism discussed here allowing to not use any ethernet at all.

About the GUI topic: Now I get it. I'm afraid I will not add that in the near future, at least not as a standard component. There are a few good reasons but my main is probably, that you are better off putting the Raspberry Pi in a corner and configuring it from a more powerful device with software you know (e.g. your Windows or Mac).

ThomDietrich commented 8 years ago

How can we proceed? I can not look into that problem but maybe someone in the community can... we could ask for testers there. On the other side: I am on the verge of a new project and will MAYBE be swamped in RPi3s soon...

In the meantime, we can add a wifi configuration to the menu. If you are willing, please provide me with the steps OR with a sketch of the setup function, just like this one https://github.com/ThomDietrich/openhabian/blob/master/openhabian-setup.sh#L332-L343

ThomDietrich commented 8 years ago

Worth watching: https://github.com/debian-pi/raspbian-ua-netinst/issues/427

VD17593 commented 8 years ago

The merge was on branch "v1.1.x" and I am in sync with that branch, see d0d53c4

In that case maybe it is worthwhile to have a closer look at possible causes. Stepping into it now.

About the GUI : it makes sense. From automation point of view.

VD17593 commented 8 years ago

I'm tying to install the v1.1.x of raspbian-ua-netinst to have a look if it works there. But I'm not too familiar with this branching business.

Could you enlighten me how to test the v1.1.x version.

VD17593 commented 8 years ago

Installing your last version now (with the wpa_supplicant.conf file in config. Just to have a look.

You repeatedly were talking about a menu. I'm not sure which menu you are talking about or where to find it.

Meanwhile I have been looking around : Apparently the last commit for raspbian-ua-netinst was done december last year, when PI3 didn't exist yet. Suppose that's why the PI2 version is installed on the PI3.

But the PI3 has some fundamental differences with the PI2, so I'm wondering if everything is optimized for this PI3.

As said before, the wifi hardware is included in the PI3, but if we are installing the PI2 software, and I'm wondering if the right driver is uploaded for it.

Now I would like to help, but I'm stuck on how to evaluate the v1.1.x branch itself, to see if there is something missing there.

ThomDietrich commented 8 years ago

Hey, how to switch over to a different branch really depends on your git client. On the console you would type git checkout v1.1.x but you are probably better off using a GUI like SmartGit for that.

The "menu" was introduced with v0.8 and got better with v0.9. You can read about it here.

Pi3 support is only incorporated in branch v1.1.x (I hope they will merge it back into master soon). Installation on a RPi3 should be working and if you can get your wifi configuration working after booting openHABian, this should also be possible during setup.

Did you see the latest answer in the issue? https://github.com/debian-pi/raspbian-ua-netinst/issues/427

VD17593 commented 8 years ago

Hi, I'm still stuck here. Installed SmartGit, but still don't see how to get an image of the branch v1.1.x, that I could install on my card. I see that the doc for branch v1.1.x is different for the master (PI 3b is added as supported), but the latest releases points to the release : raspbian-ua-netinst v1.0.8.1

A little further however saw the following description:

So, a file that you place on the SD card in /config/files/etc/wpa_supplicant/wpa_supplicant.conf will end up on the installed system as /etc/wpa_supplicant/wpa_supplicant.conf .

Perhaps this is wat is needed. I'll try this now.

ThomDietrich commented 8 years ago

You need to build the image. Have a look at https://github.com/debian-pi/raspbian-ua-netinst/blob/v1.1.x/BUILD.md

"/config/files/etc/wpa_supplicant/wpa_supplicant.conf" - this will not help us, as this only addresses the resulting system but not the setup.

VD17593 commented 8 years ago

Indeed no success. Maybe I was to quick.

Will do a last try following the whole procedure described in the chapter Bring your own files. As described there, at least the file /etc/wpa_supplicant/wpa_supplicant.conf should be created. (which doesn't necessarily mean the wifi will be working : driver installed ? ect ...)

ThomDietrich commented 8 years ago

I'm not sure if that will make anything easier. Editing "/etc/wpa_supplicant/wpa_supplicant.conf" can easier be done using openhabian-config menu, prompting for ssid/password. Supplying wifi settings beforehand would be interesting if it can be used to install the OS.

ThomDietrich commented 8 years ago

Hey @VD17593 I saw your posting over at https://github.com/debian-pi/raspbian-ua-netinst/issues/427#issuecomment-247852092 Great you got it working! The packages needed and the configurations you provided are definitely something we can and should provide as an option in openhabian-config! The fact that you need to connect via ssh at least once makes setup even easier as the user can just provide ssid and password while prompted for in the config menu!? No need to add or modify a special file on your SD card. Would you agree? I can add the procedure today or tomorrow and you could test.

VD17593 commented 8 years ago

Sounds good. Give me a sign when it's ready. I will have a try then.

Meanwhile I have been working out something of my own. With a little different perspective as yours, just to have a try. I'm going to make an image for OH1 which people can install on their PI. It's a little more restricted than your proposition (eg only PI3), and with the aim to integrate the logging option for www.intchart.com (it will take some months to integrate the logging with OH2). I will ty to put that for sale. I hope this is no problem to you.

ThomDietrich commented 8 years ago

Exchanging OH2 by OH1 would be possible through menu and adding intchart as an optional component would also be no problem. You could just add your own two functions to the openhabian-setup.sh and be done with it. No need to invest more time in a second solution. But that is of course up to you.

"for sale"? As in sell for money? o.O

VD17593 commented 8 years ago

Lets talk (whatever you mean by o.O 😄 ). I think (like the user at the openhab platform) that, since such a solution can save a lot of time (and frustration), this could be worth something. What do you really think about that?

To be able to include OH1 instead of OH2 would be really great! As well as including intchart as optional component. Not having to provide another solution would be a relief to me.

I will provide you also with the details of the z-wave installation.

Still (especially if we are talking to sell a solution) I would like to propose a nice solution, Like I told you before, I was going in the direction of providing an image (like Jessie itself is an image and like Minibian is an image). And I recorded the time needed to install such an image (of 3.5GB):

Which gives a total of 14 minutes. Is there really no way to speed up your process? Perhaps it could be conceived to let a potential user chose between the image (for certain configurations) or your standard install.

I have still some other ideas about what an 'ideal' solution should include.

Are you open to talk about that?

ThomDietrich commented 8 years ago

OH1: It should be easy to create a new menu entry which will then unistall OH2 and install OH1. I don't think that's meaningful though, as OH1 is getting more and more irrelevant and will officially be replaced by OH2 in 3-5 months.

intchart: I did not look deeper into it and am personally very happy with InfluxDB+Grafana. If you however think it's a valuable addon for users, we sure can add it to openHABian as an optional component!

z-wave steps: would be nice to have. There is probably more than one way/ one hardware to do it though!?

Regarding the image size and setup time: I do not see a problem here. The end result with both approaches is more or less the same. My chosen method is a bit slower, yes, but who cares? Go eat something, pick flowers for your special someone or use the time to read through the openHAB documentation :) No seriously: The setup could be faster but the advantages of my approach are more convincing to me. The normal end user will not see any downside in the fact that the device he will use 24/7 for possibly the next few years does take 30 minutes to get ready... don't you agree?

If you are still interested in a complete image, just take one after setup was completed ;)

Regarding o.O: openHAB is an open source effort. Dozens of developers have invested countless hours in the last decade to provide a free software many can benefit from. The system works because of the give and take principle. Now, you are legally allowed to sell open source software but it's in my personal opinion a bit unethical to capitalize on the efforts of others. Is giving something back to the community not rewarding enough?

Yes sure, let me know if you have more ideas for additional components of openHABian.

ThomDietrich commented 7 years ago

Wifi setup through menu is working. Installation over wifi will have to be on hold till it's implemented "on the other side". Thanks @VD17593