### Raspberry Pi as Domoticz Server

Information using Raspberry Pi as a Domoticz Server
Raspberry Pi Installation
http://www.domoticz.com/wiki/Domoticz_RaspberryPi_SD_Image
and here for detailed when starting from scratch:
http://www.domoticz.com/wiki/Installing_and_running_Domoticz_on_a_Raspberry_PI
or read the Domoticz manual:
http://www.domoticz.com/DomoticzManual.pdf
Define Fixed IP-Address
After installation, setup the network. Recommend to define a fixed IP Address.
The Domoticz server can then be reached by , like http://192.168.0.20:8080
$sudo nano /etc/network/interfaces
Change
iface eth0 inet dhcp
To
iface eth0 inet static
address 192.168.1.4
netmask 255.255.255.0
gateway 192.168.1.1
Use WiFi
To setup WiFi, a configuration like below prooved to work = took a while to get there :-(
1. Edit the wpa_supplicant.conf file:
$sudo nano /etc/wpa_supplicant/wpa_supplicant.conf
ctrl_interface=DIR=/var/run/wpa_supplicant GROUP=netdev
update_config=1
network={
ssid=""
proto=RSN
key_mgmt=WPA-PSK
pairwise=CCMP
group=CCMP
psk=""
}
2. Edit the interfaces file
$sudo nano /etc/network/interfaces
auto lo
iface lo inet loopback
allow-hotplug wlan0
auto wlan0
iface wlan0 inet manual
wireless-power off
wpa-roam /etc/wpa_supplicant/wpa_supplicant.conf
iface default inet static
address 192.168.0.21
netmask 255.255.255.0
gateway 192.168.0.1
CHECK IF WIFI IS UP AND RUNNING
$lsusb
Output like: Bus 001 Device 004: ID 148f:5370 Ralink Technology, Corp. RT5370 Wireless Adapter
$sudo ifdown wlan0
$sudo ifup wlan0
$ifconfig
wlan0 Link encap:Ethernet HWaddr 7c:dd:90:4c:75:63
inet addr:192.168.0.21 Bcast:192.168.0.255 Mask:255.255.255.0
UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1
RX packets:582 errors:0 dropped:21 overruns:0 frame:0
TX packets:308 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:1000
RX bytes:80434 (78.5 KiB) TX bytes:49614 (48.4 KiB)
Updates
When opening the Domoticz website in the Browser, updates are provided automatically.
To manually update in Domoticz > Main Menu > Setup > Check for Updates.
German Blog setting up Raspberry Pi with Domoticz and Home Easy
http://www.it-adviser.net/hausautomation-mit-raspberry-pi-domoticz-und-home-easy/
Using GPIO
http://www.domoticz.com/wiki/GPIO
When adding the GPIO commands, ensure to call $sudo nano /etc/init.d/domoticz.sh to define the pins.
Add to the end of domoticz.sh the role of each pin to be used.
Example to set GPIO PIN 18 as output.
/usr/local/bin/gpio export 18 out
Raspberry Pi Domoticz Server accessing from PC
Use Putty and WinSCP to access the Raspberry Pi. Username: pi, Password:
Raspberry Pi Example using API
Scenario: To switch an LED connected to GPIO 18 on the Raspberry Pi.
For tests, the Raspberry Pi has IP 192.168.0.20 with Port 8080.
Define a Domoticz Switch
This is described here: http://www.domoticz.com/wiki/GPIO .In a nutshell:
Declare the GPIO port in Domoticz:
1.Main Menu > Hardware > type name like "GPIO Port", select "Raspberry's GPIO Port" as type, then Add.
2.Main Menu > Switches > for each GPIO pin, click "Manual Light/Switch"
3.For Outputs:
Select the GPIO port hardware configured, name it, select the "On/Off" switch type and a "GPIO" type.
Select the pin in the list. Obviously, the ones you configured above should not start with the "! NON EXPORTED" mention.
Test the output, the "Test" button will just set the output to HI, and then click "Add Device".
4.For inputs
Select the GPIO port hardware configured, name it, select the "Contact" switch type and a "GPIO" type.
Select the pin in the list. Obviously, the ones you configured above should not start with the "! NON EXPORTED" mention.
Then click "Add Device".
The mention "open/closed" corresponds to a switch connected between the pin and the ground, with the pin also connected to a pull-up
(as you have read on the wiringPi website, some GPIO have an internal permanent pull-up.
5.Check
Click on the light bulb to toggle the outputs, and the contact status changes.
Get the Idx of the Switch as required
From a Browser sent this API Command:
http://192.168.0.20:8080/json.htm?type=command¶m=getlightswitches
The JSON Result displayed in the Browser Window:
{ "result" : [ { "IsDimmer" : false, "Name" : "LED GPIO18", "SubType" : "Impuls", "Type" : "Lighting 1", "idx" : "6" } ], "status" : "OK", "title" : "GetLightSwitches" }
Note:
The Idx can also be found in the Domoticz UI under Tab Setup > Devices from the Main Menu (Example IP http://192.168.0.20:8080).
Switch the LED ON (for this example using idx = 6):
http://192.168.0.20:8080/json.htm?type=command¶m=switchlight&idx=6&switchcmd=On&level=0
JSON Result:
{ "status" : "OK", "title" : "SwitchLight" }
Switch the LED OFF (for this example using idx = 6):
http://192.168.0.20:8080/json.htm?type=command¶m=switchlight&idx=6&switchcmd=Off&level=0
JSON Result:
{ "status" : "OK", "title" : "SwitchLight" }

Changed: , Category: Domoticz Home Automation, File: T6C186M1354.htm, ID: 1354