iPhone (simple webclient)

Simple iPhone client, supports controlling house mode, audio mode, and switching switchable devices, displays value1 of all devices.

Thanks Mike for sharing this with us!
Any help extending this is welcome, we could add groups, dim slider etc.

In screen dumps above the location selection feature is shown.
If you want to use it, edit config.php and add:

// Group devices based on location?
// Set this option to true if you want to group devices by locations.
$locations=true;

There is support for dimming on selected devices as well, as shown in the last of 4 screen dumps, just below the off button.

Installation

The iPhone webclient is the simple webbased client to view and control devices.

This Wiki page describes the steps to install DomotiYii on your system.

The installation consists of the following steps:

Requirements

The domotiga webclient has the following requirements:
  • DomotiGa 1.0.00 or higher
  • JSON-RPC server enabled for DomotiGa 1.0.019 or later
    • Earlier versions used XML-RPC.
  • Web Server (installation steps are described below)


Web Servers

The iPhone web client requires a web server to run, the following 3 types of web servers have been successfully tested with the iPhone webclient:

  • Apache HTTP Server
  • Lighttpd
  • nginx

The choice between the 3 web servers is trivial, because they deliver all the same functionality. Lighttpd and nginx have a lower memory footprint, thus those are recommended for systems with 512MB or less memory.

The installation and configuration below are based on Ubuntu


Apache HTTP Server

Apache HTTP Server

The Apache HTTP Server, commonly referred to as Apache, is a web server application notable for playing a key role in the initial growth of the World Wide Web. In 2009, it became the first web server software to serve more than 100 million websites. Apache is developed and maintained by an open community of developers under the auspices of the Apache Software Foundation. Released under the Apache License, Apache is open-source software.

1. Apache and the required PHP5 software can be installed with the following command:

$ sudo apt-get install apache2 php5 libapache2-mod-php5 php5-mysql php5-curl

If you are using ubuntu 13.04 or higher:

$ sudo apt-get install php5-json

2. Enable the required Apache rewrite module as follows:

$ sudo a2enmod rewrite

3. Make Apache more secure, modify the file /etc/apache2/sites-enabled/000-default.conf and change or replace the following (it is directly below the DocumentRoot /var/www directive):

        <Directory /var/www/>
                Options None
                AllowOverride None
                Order allow,deny
                allow from all
        </Directory>

4. Allow .htaccess file to overwrite settings by modify the file /etc/apache2/sites-enabled/000-default.conf and add the following:

        <Directory /var/www/iphone/>
                AllowOverride All
        </Directory>

5. Restart Apache to use the rewrite module:

$ sudo service apache2 restart


Lighttpd

Lighttpd

Lighttpd (pronounced "lighty") is an open-source web server more optimized for speed-critical environments than common products while remaining standards-compliant, secure and flexible. It was originally written by Jan Kneschke as a proof-of-concept of the c10k problem - how to handle 10,000 connections in parallel on one server, but has gained worldwide popularity.

1. Lighttpd and the required PHP5 software can be installed with the following command:

$ sudo apt-get install lighttpd php5-cgi php5-mysql php5-curl

If you are using ubuntu 13.04 or higher:

$ sudo apt-get install php5-json

2. The default PHP CGI configuration needs to be changed, to make the pathinfo compliant to the official specification. Modify the file /etc/php5/cgi/php.ini and locate the following line and remove the ";" character from it:

;cgi.fix_pathinfo=1

If this line doesn't exist, add the following line to the end of the file:

cgi.fix_pathinfo=1

2. Enable the required Lighttpd fastcgi module as follows:

$ sudo lighttpd-enable-mod fastcgi

3. Tell Lighttpd where to find php binary, add the following to the end of the file /etc/lighttpd/lighttpd.conf:

fastcgi.server = ( ".php" => ((
                     "bin-path" => "/usr/bin/php5-cgi",
                     "socket" => "/tmp/php.socket" 
                 )))

4. The Lighttpd rewrite module needs to be enabled, this can only be done by modifying the /etc/lighttpd/lighttpd.conf. Remove in the following section the "#" from the line "mod_rewrite":

server.modules = (
        "mod_access",
        "mod_alias",
        "mod_compress",
        "mod_redirect",
#       "mod_rewrite",
)

The section should then look as follows:

server.modules = (
        "mod_access",
        "mod_alias",
        "mod_compress",
        "mod_redirect",
        "mod_rewrite",
)

5. Restart Lighttpd to use the new configuration and module:

$ sudo /etc/init.d/lighttpd force-reload


nginx

nginx

Nginx (pronounced "engine x") is an open source reverse proxy server for HTTP, HTTPS, SMTP, POP3, and IMAP protocols, as well as a load balancer, HTTP cache, and a web server (origin server). The nginx project started with a strong focus on high concurrency, high performance and low memory usage. It is licensed under the 2-clause BSD-like license.

1. Nginx and the required PHP5 software can be installed with the following command:

$ sudo apt-get install nginx php5 php5-fpm php5-mysql php5-curl

If you are using ubuntu 13.04 or higher:

$ sudo apt-get install php5-json

2. modify the file /etc/nginx/sites-enabled/default and replace the complete file with the following:

server {

    listen 80;
    listen [::]:80 default_server ipv6only=on;

    server_name  domotiga;
    root   /var/www;

    charset utf-8;

    location / {
        deny  all;
    }

    location /iphone {
        index  index.html index.php;

        # pass the PHP scripts to FastCGI server listening on 127.0.0.1:9000
        #
        location ~ \.php {
            fastcgi_split_path_info  ^(.+\.php)(.*)$;
            # NOTE: You should have "cgi.fix_pathinfo = 0" in php.ini

            fastcgi_pass   127.0.0.1:9000;
            include fastcgi_params;

            fastcgi_param  SCRIPT_FILENAME  $document_root$fastcgi_script_name;

            #PATH_INFO and PATH_TRANSLATED can be omitted, but RFC 3875 specifies them for CGI
            fastcgi_param  PATH_INFO        $fastcgi_path_info;
            fastcgi_param  PATH_TRANSLATED  $document_root$fastcgi_script_name;
        }

        location ~ /\.(ht|git) {
            deny  all;
        }

    }

    # pass the PHP scripts to FastCGI server listening on 127.0.0.1:9000 for other sub dirs
    location ~ \.php {
        fastcgi_split_path_info  ^(.+\.php)(.*)$;
        # NOTE: You should have "cgi.fix_pathinfo = 0;" in php.ini

        fastcgi_pass   127.0.0.1:9000;
        include fastcgi_params;
    }

}

3. Create the file /etc/php5/fpm/pool.d/phpfpm.conf and insert the following content:

[phpfpm]

;listen = /var/run/php5-fpm.sock
listen = 127.0.0.1:9000
listen.allowed_clients = 127.0.0.1
listen.owner = www-data
listen.group = www-data
listen.mode = 0666
;listen.backlog = 4096
user = www-data
group = www-data
pm = dynamic
pm.max_children = 50
pm.start_servers = 20
pm.min_spare_servers = 5
pm.max_spare_servers = 35
pm.status_path = /fpm-status
ping.path = /fpm-ping
ping.response = pong
chdir = /var/www
catch_workers_output = yes

request_terminate_timeout = 180s

; The following php_admin_* settings below, override php.ini settings
php_admin_value[error_log] = /var/log/fpm-php-error.log

; The following settings are specifically used on development sites
; Should review/disable for production site
php_admin_value[max_execution_time] = 180
php_admin_flag[log_errors] = on
php_admin_value[memory_limit] = 50m
php_admin_value[error_reporting] = E_ALL
php_admin_flag[display_errors] = on
php_admin_flag[display_startup_errors] = on

4. Configure PHP

Edit php.ini file.

$ sudo vi /etc/php5/fpm/php.ini

Insert the following parameter:

cgi.fix_pathinfo = 0

5. Restart nginx:

$ sudo service nginx restart

6. Restart php-fpm:

$ sudo service php5-fpm restart


domotiga webclient

After you installed the Web Server, the domotiga webclient can be copied to the Servers directory. Execute the following steps for this:

$ sudo cp -rp ~/domotiga/webclients/iphone /var/www/
$ sudo chown -R www-data:www-data /var/www/iphone
$ sudo cp -p /var/www/iphone/config.php.example /var/www/iphone/config.php


Configure

Normally no additional configuration is required, it will standard connect to the DomotiGa server on the default JSON-RPC port.

The following configuration items are available in /var/www/iphone/config.php:

TBD
In below screen dumps the location selection feature is shown.
If you want to use it, edit config.php and add:

// Group devices based on location?
// Set this option to true if you want to group devices by locations.
$locations=true;

TBD


Authorisation

The domotiga webclient, nor the DomotiGa JSON-RPC server have a buildin authentication mechanism. Thus it is important to setup the Web Server basic authentication.

Apache HTTP Server

1. The following steps will install the required Apache utilities and create the guest user:

$ sudo apt-get install apache2-utils
$ sudo htpasswd -c /var/users guest
New password:
Re-type new password:
Adding password for user guest

2. Now make sure you have checked the contents of the htaccess.example file inside the directory /var/www/domotiga and rename it to the correct filename to activate it (notice the point before htaccess!)

$ cd /var/www/domotiga
$ sudo mv htaccess.example .htaccess

Lighttpd

1. The following steps will install the required Apache utilities, because Lighttpd has no tools for it. and create the guest user:

$ sudo apt-get install apache2-utils
$ sudo htpasswd -c /etc/lighttpd/htpasswd guest
New password:
Re-type new password:
Adding password for user guest

2. Add the following lines to /etc/lighttpd/lighttpd.conf to enable usage of the htpasswd file:

# Authentication config
auth.debug             = 2
auth.backend            = "htpasswd" 
auth.backend.htpasswd.userfile   = "/etc/lighttpd/htpasswd" 
auth.require = ( "/" => ( "method" => "basic", "realm" => "DomotiGa webclient", "require" => "user=guest" ) )

3. The Lighttpd auth module needs to be enabled, this can only be done by modifying the /etc/lighttpd/lighttpd.conf. The section should then look as follows:

server.modules = (
        "mod_access",
        "mod_alias",
        "mod_compress",
        "mod_redirect",
        "mod_rewrite",
        "mod_auth",
)

4. Restart Lighttpd to use the new configuration and module:

$ sudo /etc/init.d/lighttpd force-reload

nginx

1. The following steps will install the required Apache utilities, because Lighttpd has no tools for it. and create the guest user:

$ sudo apt-get install apache2-utils
$ sudo htpasswd -c /etc/nginx/htpasswd guest
New password:
Re-type new password:
Adding password for user guest

2. Add the following lines to /etc/nginx/lighttpd/lighttpd.conf in the section location /domotiga {:

    auth_basic           "DomotiGa webclient";
    auth_basic_user_file /etc/nginx/htpasswd;
}

3. Restart nginx:

$ sudo service nginx restart


Use domotiga webclient

After the Server and the iPhone webclient are installed and configured you can start using the client.

Go to http://serverip/iphone


Screenshots (Android)

BTW: This interface also works on an Android device, see screenshots below.


Resources

    Updated by: Alexie, Updated about 2 years ago
    Access count: 65983

    Attached Files

    lighttpd.png (7.29 KB) Alexie, 02/14/2014 08:18 PM

    nginx.gif (524 Bytes) Alexie, 02/14/2014 08:18 PM

    apache.png (2.91 KB) Alexie, 02/14/2014 08:18 PM

    iphone-all.jpg (112 KB) Alexie, 02/14/2014 10:12 PM

    iphone-devices.png (51.2 KB) Alexie, 02/14/2014 10:29 PM

    iphone-switch.png (50.3 KB) Alexie, 02/14/2014 10:29 PM

    iphone-main.png (57.1 KB) Alexie, 02/14/2014 10:29 PM

    Also available in: PDF HTML TXT