среда, 14 декабря 2016 г.

Rsync to Synoilogy NAS

Generate public key on Rpi
 ssh-keygen

Log in to Synology Telnet as root (sudo -i , password)

Copy public key
tail ~/.ssh/id_rsa.pub

Use instruction below
http://www.thegeekstuff.com/2008/06/perform-ssh-and-scp-without-entering-password-on-openssh/

verify if password is asked:
ssh '192.168.1.23'

rsync script:
#!/bin/bash
# Script to save and copy mosq to server
cp /var/log/mosquitto/mosq.log "/var/log/mosquitto/mosq_backup$(date +%Y%m%d_%H%M%S).log"
> /var/log/mosquitto/mosq.log
sudo rsync -av -e ssh /var/log/mosquitto/ 192.168.1.23::Backup/raspberry/
rm /var/log/mosquitto/mosq_backup*


Fstab
tmpfs    /var/log    tmpfs    defaults,noatime,nosuid,mode=0777,size=100m    0 0
tmpfs    /var/log/openhab    tmpfs    defaults,noatime,nosuid,mode=0777,size=150m    0 0
tmpfs    /tmp    tmpfs    defaults,noatime,nosuid,size=20m    0 0
tmpfs    /var/tmp    tmpfs    defaults,noatime,nosuid,size=20m    0 0

 

воскресенье, 9 октября 2016 г.

Emergency launch of HA on Laptop

This article describes emergency start of HA on laptop in cas if main server is unavailable

First periodic SVN commitsh should be done:
folders:
/home/pi/.node-red
/etc/openhab/configurations

Execute svn commit command
  1. Laptop should have Node-RED, Mosquitto, Openhab and all it's bindings installed and running
  2. Checkout OpenHAB Configuration and Node-RED flows from SVN
  3. Change COM port for Z-Wave stick to COM3
  4. Run Node.js and start Node-RED
  5. Insert Z-wave USB Stick(upper right port for COM3). Lower Right port will be COM4.
  6. Run start.bat in OpenHAB folder

пятница, 7 октября 2016 г.

Moqsquitto MQTT Broker Setup and usage

Install Mosquitto

sudo apt-get install mosquitto mosquitto-clients python-mosquitto
 

Configuration File location

/etc/mosquitto

mosquitto.conf File contents

pid_file /var/run/mosquitto.pid

persistence true
persistence_location /var/lib/mosquitto/
connection_messages true
log_type all
log_dest file /var/log/mosquitto/mosquitto.log
log_dest syslog

include_dir /etc/mosquitto/conf.d
 

Create /var/log/mosquitto/mosquitto_log.sh

#!/bin/bash
# My first script
sleep 120
sudo ntpdate -s ntp.obspm.fr
mkdir -p /var/log/mosquitto
mosquitto_sub -v -t /# | xargs -d$'\n' -L1 sh -c 'date "+%D %T.%3N $0"' >> /var/log/mosquitto/mosq.log &
sudo systemctl restart homebridge



 
Change permissions chmod 777 mosquitto_log.sh

Add to start script

Add to /etc/rc.local

#Start MQTT Logging
/var/log/mosquitto/msquitto_log.sh &

суббота, 2 января 2016 г.

Smart Home on Raspberry PI 2



1. Install Debian using Noobs
The default login for Raspbian is username pi with the password raspberry.
2. Install VNC Server from https://www.raspberrypi.org/documentation/remote-access/vnc/
3. Install Openhab using instruction from https://github.com/openhab/openhab/wiki/Linux---OS-X

Install following Bindings:
sudo apt-get install openhab-addon-persistence-rrd4j
sudo apt-get install openhab-addon-persistence-logging
sudo apt-get install openhab-addon-persistence-exec 
sudo apt-get install openhab-addon-binding-z-wave 
sudo apt-get install openhab-addon-binding-mqtt 
sudo apt-get install openhab-addon-binding-http 
sudo apt-get install openhab-addon-binding-ntp
sudo apt-get install openhab-addon-binding-weather
 
Change time zone to Berlin 
sudo dpkg-reconfigure tzdata 

To autostart on reboot use Init based on systemd
sudo systemctl daemon-reload
sudo systemctl enable openhab 
 

File locations

  • service configuration /etc/default/openhab
  • site configuration /etc/openhab
  • log files /var/log/openhab
  • userdata like rrd4j databases /var/lib/openhab
  • openHAB engine, addons and /webapps folder /usr/share/openhab
  • Node RED USer Dierctory /home/pi/.node-red
4. Install HABMIN (use updated path to OH above)
 
cd /usr/share/openhab 
sudo wget https://github.com/cdjackson/HABmin/releases/download/0.1.3-snapshot/habmin.zip
sudo unzip habmin.zip
sudo rm habmin.zip
sudo rm addons/org.openhab.binding.zwave-1.5.0-SNAPSHOT.jar
 
HABMIN Path: 
http://raspberry_IP:8080/habmin/ 
 
5. Configure SMB to access configuration and log files
http://raspberrypihq.com/how-to-share-a-folder-with-a-windows-computer-from-a-raspberry-pi/

sudo nano /etc/samba/smb.conf - append at the end
[OpenHAB]
 comment=OpenHAB Folder share
 path= /usr/share/openhab
 browseable=Yes
 writeable=Yes
 only guest=no
 create mask=0777
 directory mask=0777
 public=no

[Openhab_Configuration]
 comment=OpenHAB Config
 path= /etc/openhab
 browseable=Yes
 writeable=Yes
 only guest=no
 create mask=0777
 directory mask=0777
 public=no

[Openhab_Logs]
 comment=OpenHAB Logs
 path= /var/log/openhab
 browseable=Yes
 writeable=Yes
 only guest=no
 create mask=0777
 directory mask=0777
 public=no
 
[Mosquitto_Logs]
 comment=Mosquitto Logs
 path= /var/log/mosquitto
 browseable=Yes
 writeable=Yes
 only guest=no
 create mask=0777
 directory mask=0777
 public=no 
 
 
6. Z-wave binding
sudo usermod -a -G dialout openhab
Usb Stick port - dev/ttyACM0 



8. Install my.openhab
https://klenzel.de/3687 
 
9. Set Date and Time
apt-get purge ntp
apt-get install openntpd
Next I append -s at the DAEMON_OPTS at /etc/default/openntpd
DAEMON_OPTS="-f /etc/openntpd/ntpd.conf -s"
systemctl enable openntpd.service 
systemctl start openntpd.service 
If starting the ‘openntpd’ service does not help, then try this.
ntpd -s -d 
ntpdate -s ntp.obspm.fr
     

Commands:

sudo /etc/init.d/openhab start 
sudo /etc/init.d/openhab stop 
sudo /etc/init.d/openhab status
 
systemctl status homebridge -l
systemctl start homebridge 
 
tail -f /var/log/openhab/openhab.log
tail -f /var/log/openhab/events.log
mosquitto_pub -t /myhome/command/Temperature_Setpoint/state -m 18
mosquitto_sub -v -t /#
mosquitto_sub -v -t /# | xargs -d$'\n' -L1 sh -c 'date "+%D %T.%3N $0"' 

 
Finally, stock Android does have a hidden setting to keep the screen on indefinitely, but only while charging. You need to activate Developer 
Mode first (tap the Build number entry in the About phone menu in Settings seven times) and then choose Developer options from the Settings menu. Choose Stay awake and as long as your phone or tablet is plugged in, the screen won't go to sleep after a certain period of time.
 
 
Remove SWAP
https://tino.cc/2016/05/07/raspbian-ueber-nfs-netzwerk-share-booten/
 
sudo dphys-swapfile swapoff

sudo systemctl disable dphys-swapfile

sudo update-rc.d dphys-swapfile remove

sudo apt-get purge dphys-swapfile

sudo rm /var/swap