ImperiHome

From Domoticz
Jump to: navigation, search

Introduction

Imperihome is a smart phone application that integrates natively with several domoticz systems. A Generic REST API has been made available for other systems to integrate themselves with it.

The below procedures are made to provide a gateway that will permit a user to use the smartphone app with Domoticz.

The Gateway will act as an interface between domoticz and Imperihome, so that Imperihome can interact with the Gateway, that will in return interract with Domoticz.

There will be a Client (ImperiHome), a protocolar gateway (The gateway below) and the Server (Domoticz). The gateway will be a REST/Web server with its own IP:port to be chosen and to be different from Domoticz if it runs on the same server.

Imperihome screen 1
Imperihome screen 2

Features

  • all switches (but no arm, no ack as not available in DZ)
  • all temp/humidity/weather/uv/pressure sensors
  • all utilities
  • all scenes
  • rooms have been mapped upon DZ tabs for more clarity
  • thermostat setpoint as in DZ
  • RGB lights
  • MultiSwitch, custom sensors...

TODO

  • Full usage curves from Imperihome


General troubleshooting

If you run the gateway on a different server than domoticz, add it in the setup so it won't require login/password if you have set so.

Support in English: [1] Support in French: [2]

Architecture

Imperihome2.png

Installation

Check the nodeJS version installed - mandatory for PI !

 sudo dpkg --list |grep nodejs // should return version 4.x or above

If not please do:

On RASPBIAN (Raspberry PI/PI2), please install first to have a stable nodeJS :

 sudo apt-get remove node
 wget -q http://www.e-nef.com/domoticz/mdah/nodejs_4.4.2_armhf.deb
 sudo dpkg -i nodejs_4.4.2_armhf.deb
 wget -q http://www.e-nef.com/domoticz/mdah/npm_2.14.7_armhf.deb
 sudo dpkg -i npm_2.14.7_armhf.deb
 sudo npm install -g [email protected]

On all other (debian, ubuntu...), version 4 is required (testing/unstable are fine):

 sudo apt-get remove node
 curl -sL https://deb.nodesource.com/setup_4.x | sudo -E bash -
 sudo apt-get install -y nodejs

The following commands install npm and then upgrade it to the latest 2.x version.

 sudo npm install -g [email protected]

Note: npm version 3 is the latest version, but is currently not recommended for use.

And check again

 node —v // should print version 4.4.x or similar
 npm —v // should print version 2.2.x or similar

Installing the software Debian package .deb

 wget -qO - http://www.e-nef.com/domoticz/mdah/gpg.key | sudo apt-key add -
 sudo vi /etc/apt/sources.list

Add the line:

 deb http://www.e-nef.com/domoticz/mdah/ /

Then:

 sudo apt-get update
 sudo apt-get install MyDomoAtHome  

edit /etc/mydomoathome/config.json with your values then restart the service:

sudo service mydomoathome restart

How to check installation is correct

In a web browser call the url:

http://gateway_ip:gateway_port/
http://gateway_ip:gateway_port/devices

If the result does not show devices, please remember to allow access without password to the gateway IP within Domoticz Settings.

In another tab call those url:

http://domoticz_ip:domoticz_port/json.htm?type=devices&filter=all&used=true&order=Name  
http://domoticz_ip:domoticz_port/json.htm?type=scenes

In the first you'll get what Imperihome will see, in the second what Domoticz provide. In case you need support in the Forum, please include both and send the domoticz.db to domoticz AT e-nef.com.

Now you can configure ImperiHome App

You can now add a device within the Imperihome app:

  • go to parameters / My Systems / Add a system
  • select Imperihome Standard System
  • type in your gateway base url your_ip:port then next and finished !

Accessing the Gateway from the outide of your network

The best way is to setup the nginx for both domoticz and the gateway: Secure Nginx Proxy Setup

In the domoticz configuration add a section to redirect to the gateway such as this (change your ip below), and create a .htpasswd for both (using htpasswd from package apache2-utils => htpasswd -c .htaccess YOURusername YOURpasswd)

     location /iss/ {
       proxy_pass http://192.168.0.28:3002/;
       auth_basic            "Access Restricted";
       auth_basic_user_file  "/etc/nginx/.htpasswd";
       access_log /var/log/nginx/domoticz.access.log;
       error_log /var/log/nginx/domoticz.error.log;
     }

Managing the service

To start the service:

 sudo service mydomoathome  start

To stop the service :

 sudo service mydomoathome  stop

To restart the service :

 sudo service mydomoathome reload


Monitoring MyDomoAtHome instance

Example configuration of monit (Monitoring_domoticz) rule to check if service is running

   check host MyDomoAtHome with address 127.0.0.1
       start program = "/usr/sbin/service mydomoathome start"
       stop program = "/usr/sbin/service mydomoathome stop"
       if failed port 3002 protocol HTTP
       request /devices
       with timeout 5 seconds
       then restart
       if 5 restart within 5 cycles then exec "/sbin/reboot"


Migrating from old/Legacy MyDomoAtHome

Shut down the old service

 sudo service MyDomoAtHome.sh stop 
 rm /etc/init.d/MyDomoAtHome.sh

N.B. you can have the both at the same time, just change the App name in the config.json file and the port.


Docker installation (only for those using this form: big synologyes, Xpenologies...)

Duplicate the image

 docker pull epierre/iss-mdah

Launch the process

Remember to change the IP below and authorize in Domoticz the docker IP range

 docker run --name=mdah --env DOMO="http://your_ip:8080" --env TZ=Europe/Paris -p 3002:3002 epierre/mdah

Check running docker processes

 docker ps

Stopping a docker process

 docker stop mdah