First Time Setup¶
- Table of contents
- First Time Setup
- Next Steps
- Attached Files
This chapter describes the first time startup of DomotiGa, to initialize the required MySQL database tables. Currently DomotiGa can only be setup via DomotiGa GUI (running as backend or as a client connecting to DomotiGaServer). Both methods are described on this Wiki page, but the DomotiGa GUI as backend is recommended for first time users.
This is the recommended option for the first time users of DomotiGa, to setup and run DomotiGa on the Linux graphical desktop. DomotiGa will start the wizard to setup the MySQL database tables, also it will create log directories and configuration files.
After DomotiGa has been setup, it is still possible to switch to DomotiGaServer and DomotiGa GUI client.
Open a terminal window and change to the DomotiGa directory and start-up the application.
$ cd ~/domotiga $ ./DomotiGa3.gambas
The terminal window will be as the following screen:
Database Install Wizard¶
At first time use the required DomotiGa database in the MySQL server hasn't been setup, DomotiGa will show the following install wizard screen when it detects the database doesn't exist:
Before you can continue, you need to accept the GPLv3 license and disclaimer of DomotiGa. If you disagree with the GPLv3 (http://www.gnu.org/licenses/gpl-3.0.html) license and disclaimer, you can still exit DomotiGa by clicking on the Cancel button. If you agree with the license and disclaimer check the box I agree and want to use this program and on the Next button as the following screen shows:
At this moment there isn't a DomotiGa database yet, the Database Install Wizard gives you the option to setup a Demo database or an empty database. For first time user it is recommend (and default option) to setup the Demo database. Then the database will be filled with example devices, events and other data – this will give you a good overview what is possible with DomotiGa. If you want to setup from scratch, click on the Empty database option and press on Next button as the following screen shows:
After selected the Demo database it is still easy to remove these examples from the database. This is documented further in this document.
The database isn't setup yet, we only selected to setup the Demo or empty database. The following screen shows the MySQL database parameters. If it is a default installation, you can leave the Host, Database and User parameters as shown. Only the password need to be supplied, this is the password which has been configured during the installation of MySQL Server. Click on the Next button to execute the real data import.
The data import has been executed now. If all went well, the following screen shows the output what you should have. If you typed in a wrong password, you can click on Previous button and try again. Click on the OK button to continue.
If all previous steps are successful, DomotiGa will start and show the following screen.
The MySQL error message can be safely ignored, because this always happens during the first time setup.
Now DomotiGa is up-and-running we can continue with the first time setup of DomotiGa, because some localized things like timezone need to be configured. Also interfaces, devices, events, triggers, conditions and actions need to be added to make it a complete domotica system.
This section describes the first time startup if you want to run DomotiGa backend without a GUI, the so-called DomotiGaServer. This can be an option if your hardware isn't powerful (e.g. Raspberry Pi and other ARM processor based systems) enough or you don't want run a graphical desktop on your server with the DomotiGa backend. The DomotiGa backend can only be configured via the GUI and this needs to be installed as a full client on another Linux system.
If you already have setup DomotiGa in the previous section, you can skip this section.
Create DomotiGa Database¶
The DomotiGaServer doesn't have a wizard to install the example or empty database, thus this need to be done manually. Execute the following commands to install the example database on the DomotiGa backend:
$ mysqladmin -u root -p create domotiga $ mysql -u root -p domotiga <~/domotiga/install/domotiga.sql
If you want to install the empty database, replace “domotiga.sql” with “domotiga-empty.sql”.
Setup MySQL IP Address¶
The DomotiGa client communicates directly with the DomotiGa backend and MySQL database. By default, MySQL only allows connections from the localhost address, and the DomotiGa client can't connect. This procedure will re-configure MySQL to listen on all the network interfaces. The configuration file is usually found in /etc/mysql/my.cnf. Execute the following command on the DomotiGa backend system to edit the MySQL configuration file:
$ sudo nano /etc/mysql/my.cnf Locate the following line in the file: Bind-address = 127.0.0.1 Replace the line with the following content (remove any “#” in front of the line): Bind-address = 0.0.0.0
If unfamiliar with the “nano” editor, please check the following link for a cheat sheet: http://www.tuxradar.com/content/text-editing-nano-made-easy
Restart the MySQL Server to use the new configuration with the following command:
$ sudo /etc/init.d/mysql restart
Setup MySQL Authorisation¶
By default, MySQL only allows local connections, and the DomotiGa client can't connect from another Linux system in the network.
Start the MySQL command-line tool as follows:
$ mysql -u root -p
It will ask for the password of the MySQL root user, this has been configured in previous Installation of MySQL Server. After the password has been supplied, it will start the editor and you type in the following MySQL commands to give the right authorisation:
mysql> GRANT ALL ON domotiga.* TO domouser@'%' IDENTIFIED BY 'kung-fu'; mysql> FLUSH PRIVILEGES; To exit the MySQL command-line tool, just type in the “quit” command as follows: mysql> quit
Change to the DomotiGa directory and start-up the DomotiGaServer application. The DomotiGaServer can run in a terminal of the Linux system with and without a graphical desktop.
$ cd ~/domotiga $ ./DomotiGaServer3.gambas
DomotiGaServer will start and writes the main logging to the standard output (on your screen).
2013/11/17 13:34:33 [Main] Found broadcast address '192.168.100.255' 2013/11/17 13:34:33 [Main] ---- Program Restart ---- 2013/11/17 13:34:33 [Main] Starting DomotiGaServer3 V1.0.012 last updated on 2013-11-17 13:12:21 2013/11/17 13:34:33 [Main] Running on host 'domotiga-vm' (pid 21517) as user 'domo' (id 1001) with language en_US.UTF-8 2013/11/17 13:34:33 [Main] Program base directory is '/home/domo/domotiga'. 2013/11/17 13:34:33 [Main] Database settings are loaded from 'server-domotiga.conf'. 2013/11/17 13:34:33 [Main] Active logfiles are 'server-main-2013-11.log', 'server-speak-2013-11.log' and 'server-debug-2013-11.log'. 2013/11/17 13:34:33 [Main] Running on Gambas version 3.5.1 2013/11/17 13:34:33 [Main] Server uptime is 13:34:33 up 1 day, 1:08, 5 users, load average: 0.00, 0.01, 0.05 2013/11/17 13:34:33 [Main] Checking directory structure ... 2013/11/17 13:34:33 [Main] Connecting to database ... 2013/11/17 13:34:33 [Main] Loading modules ... 2013/11/17 13:34:33 [Main] Starting setup ... 2013/11/17 13:34:33 [Main] NOTE: All disabled module log entries are muted, enable main debug if you want to see them! 2013/11/17 13:34:33 [XMLRPC] XML-RPC Server listening on Port 9009 2013/11/17 13:34:33 [XMLRPC] UDP Broadcasts are enabled on Port 19009 2013/11/17 13:34:33 [Plugin] Server Statistics enabled. 2013/11/17 13:34:33 [Plugin] JSON-RPC enabled. 2013/11/17 13:34:33 [JSONRPC] JSON-RPC Server listening on Port 9090 2013/11/17 13:34:33 [Main] Done with setup ... 2013/11/17 13:34:33 [Main] Starting main program ... 2013/11/17 13:34:33 [Main] House mode is set to 'Normal'. 2013/11/17 13:34:33 [Main] Mute mode is set to 'Audio Enabled'. 2013/11/17 13:34:33 [Main] Entering main program loop ... 2013/11/17 13:34:33 [Astro] Latitude: 52.8167, Longitude: -5.7667, Timezone: CET 2013/11/17 13:34:33 [Astro] Sunrise at 08:47, Sunset at 17:27 2013/11/17 13:34:33 [Astro] Twilight Sunrise at 08:08, Twilight Sunset at 18:06 civil 2013/11/17 13:34:33 [Astro] Moon phase is Full. 2013/11/17 13:34:33 [Astro] Moon is in Taurus. 2013/11/17 13:34:33 [Astro] Age from new 14 days. 2013/11/17 13:34:33 [Astro] Distance 62.09 Earth radii. 2013/11/17 13:34:33 [Astro] Ecliptic latitude: -1.09 degrees. 2013/11/17 13:34:33 [Astro] Ecliptic longitude: 53.13 degrees. 2013/11/17 13:34:33 [Astro] Season is fall. 2013/11/17 13:34:33 [Main] The Time of Day is afternoon. 2013/11/17 13:34:33 [Main] It's light outside. 2013/11/17 13:34:33 [Main] DomotiGa is running for 0 days, 0 hrs, 0 mins, and 0 secs. 2013/11/17 13:34:33 [Main] The current tagline is 'Do well, you hear it never. Do ill, hear it forever.'
Autostart DomotiGaServer3 on startup¶
For Raspberry and other debian based hardware, see Hardware RaspberryPi.
If you are running Ubuntu execute the following steps to install and activate a start-up script.
$ cd ~/domotiga/tools $ sudo cp domotigaserver3.debian /etc/init.d/domotigaserver3 $ sudo vi /etc/init.d/domotigaserver3
Edit USER= variable so it reflects the user you run DomotiGa as.
$ sudo update-rc.d domotigaserver3 defaults Adding system startup for /etc/init.d/domotigaserver3 ... /etc/rc0.d/K20domotigaserver3 -> ../init.d/domotigaserver3 /etc/rc1.d/K20domotigaserver3 -> ../init.d/domotigaserver3 /etc/rc6.d/K20domotigaserver3 -> ../init.d/domotigaserver3 /etc/rc2.d/S20domotigaserver3 -> ../init.d/domotigaserver3 /etc/rc3.d/S20domotigaserver3 -> ../init.d/domotigaserver3 /etc/rc4.d/S20domotigaserver3 -> ../init.d/domotigaserver3 /etc/rc5.d/S20domotigaserver3 -> ../init.d/domotigaserver3
Start DomotiGa Client¶
The MySQL and DomotiGaServer steps are executed on the Domotiga backend. Now we are switching to the other Linux system which also has gambas and DomotiGa application installed. Open a terminal window on the graphical desktop and change to the DomotiGa directory and start-up the application.
$ cd ~/domotiga $ ./DomotiGa3.gambas
DomotiGa will shown the same screen as seen in previous section “DomotiGa Started”.
Configure Client/Server mode¶
The default mode DomotiGa is running in, is the server mode. To connect to the DomotiGa backend, DomotiGa needs to be reconfigured to run in client mode. Go to the top menu bar and click on Setup, this will show a big drop-down list. In this list click on GUI and the will give you the following screen:
The program mode is on Server, click on this and select Client option. After selection of the Client option the XMLRPC Host and XMLRPC Port can be configured. Configure the XMLRPC Host to the IP addresses of your DomotiGa backend. The XMLRPC Port can be left as is, unless you changed this on your DomotiGa backend.
After the configuration is done, click on the Save button. This will show you the message that DomotiGa needs to be restarted to activate the changes, as the following screen shows:
Click on the OK button to continue, but we aren't restarting DomotiGa at this point yet.
The DomotiGa client also needs to connect remotely to the MySQL database and for that to function, the IP address of the database connection needs to be changed. Go to the top menu bar and click on Setup, this will show a big drop-down list. In this list click on Database and this will give you the following screen:
Configure the Server from localhost to the DomotiGa backend IP address and click on the Save button.
After Domotiga has been set to client mode and the database reconfigured, we need restart DomotiGa to make the changes active and start it as DomotiGa client. Go to the top menu bar and click on File, this will a short drop-down list. Click on the Quit button and then show a big drop-down list. In this list click on Database and this will give you the following screen:
Click on the Yes button to exit DomotiGa. Restart the DomotiGa client with the following command:
After the DomotiGa client has started, the window should show DomotiGa Client instead of the earlier DomotiGa Server. This is also shown in the following screen:
Now DomotiGa is up-and-running we can continue with the first time configuration of DomotiGa and configure things like timezone, season and other localized settings. Also interfaces, Devices, events, triggers, conditions and actions need to be added to make it a complete domotica system.