Skip to content

Commit

Permalink
Initial commit
Browse files Browse the repository at this point in the history
  • Loading branch information
H2CK committed Dec 11, 2018
1 parent 3d2fc85 commit 1eb2686
Show file tree
Hide file tree
Showing 53 changed files with 8,787 additions and 2 deletions.
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
*.swp
/hm_pdetect.conf
.DS_Store
5 changes: 3 additions & 2 deletions LICENSE
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
GNU LESSER GENERAL PUBLIC LICENSE
GNU LESSER GENERAL PUBLIC LICENSE
Version 3, 29 June 2007

Copyright (C) 2007 Free Software Foundation, Inc. <https://fsf.org/>
Copyright (C) 2007 Free Software Foundation, Inc. <http://fsf.org/>
Everyone is permitted to copy and distribute verbatim copies
of this license document, but changing it is not allowed.

Expand Down Expand Up @@ -163,3 +163,4 @@ whether future versions of the GNU Lesser General Public License shall
apply, that proxy's public statement of acceptance of any version is
permanent authorization for you to choose that version for the
Library.

77 changes: 77 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,77 @@
## CalDav integration for HomeMatic - hm_caldav

[![Release](https://img.shields.io/github/release/H2CK/hm_caldav.svg)](https://github.com/H2CK/hm_caldav/releases/latest)
[![Downloads](https://img.shields.io/github/downloads/H2CK/hm_caldav/latest/total.svg)](https://github.com/H2CK/hm_caldav/releases/latest)
[![Issues](https://img.shields.io/github/issues/H2CK/hm_caldav.svg)](https://github.com/H2CK/hm_caldav/issues)
[![License](http://img.shields.io/:license-lgpl3-blue.svg?style=flat)](http://www.gnu.org/licenses/lgpl-3.0.html)
[![Donate](https://img.shields.io/badge/donate-PayPal-green.svg)](https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick&hosted_button_id=QRSDVQA2UMJQC&source=url)


This CCU-Addon reads an ics file from the given url. In the configuration you can define which meeting are represented as system variables within the HomeMatic CCU environment. If a defined meeting is running this is represented by the value of the corresponding system variable.

Important: This addon is based on wget. On your CCU there might be an outdated version of wget, which might not support TLS 1.1 or TLS 1.2.

## Supported CCU models
* [HomeMatic CCU3](https://www.eq-3.de/produkte/homematic/zentralen-und-gateways/smart-home-zentrale-ccu3.html) / [RaspberryMatic](http://raspberrymatic.de/)
* [HomeMatic CCU2](https://www.eq-3.de/produkt-detail-zentralen-und-gateways/items/homematic-zentrale-ccu-2.html)
* HomeMatic CCU1

## Installation as CCU Addon
1. Download of recent Addon-Release from [Github](https://github.com/H2CK/hm_caldav/releases)
2. Installation of Addon archive (```hm_caldav-X.X.tar.gz```) via WebUI interface of CCU device
3. Configuration of Addon using the WebUI accessible config pages

## Manual Installation as stand-alone script (e.g. on RaspberryPi)
1. Create a new directory for hm_caldav:

mkdir /opt/hm_caldav

2. Change to new directory:

cd /opt/hm_caldav

3. Download latest hm_caldav.sh:

wget https://github.com/H2CK/hm_caldav/raw/master/hm_caldav.sh

4. Download of sample config:

wget https://github.com/H2CK/hm_caldav/raw/master/hm_caldav.conf.sample

5. Rename sample config to active one:

mv hm_caldav.conf.sample hm_caldav.conf

6. Modify configuration according to comments in config file:

vim hm_caldav.conf

7. Execute hm_caldav manually:

/opt/hm_caldav/hm_caldav.sh

8. If you want to automatically start hm_caldav on system startup a startup script

## Using 'system.Exec()'
Instead of automatically calling hm_caldav on a predefined interval one can also trigger its execution using the `system.Exec()` command within HomeMatic scripts on the CCU following the following syntax:

system.Exec("/usr/local/addons/hm_caldav/run.sh <iterations> <waittime> &");

Please note the &lt;iterations&gt; and &lt;waittime&gt; which allows to additionally specify how many times hm_caldav should be executed with a certain amount of wait time in between. One example of such an execution can be:

system.Exec("/usr/local/addons/hm_caldav/run.sh 5 2 &");

This will execute hm_caldav for a total amount of 5 times with a waittime of 2 seconds between each execution.

## Support
In case of problems/bugs or if you have any feature requests please feel free to open a [new ticket](https://github.com/H2CK/hm_caldav/issues) at the Github project pages.

## License
The use and development of this addon is based on version 3 of the LGPL open source license.

## Authors
Copyright (c) 2018 Thorsten Jagel &lt;dev@jagel.net&gt;

## Notice
This Addon uses KnowHow that was developed throughout the following projects:
* https://github.com/jens-maus/hm_pdetect
1 change: 1 addition & 0 deletions VERSION
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
0.1
Binary file added addon/ccu1/bin/bash
Binary file not shown.
Binary file added addon/ccu1/bin/fold
Binary file not shown.
Binary file added addon/ccu1/bin/iconv
Binary file not shown.
Binary file added addon/ccu1/bin/md5sum
Binary file not shown.
Binary file added addon/ccu1/bin/setsid
Binary file not shown.
Binary file added addon/ccu1/bin/update_addon
Binary file not shown.
Binary file added addon/ccu1/bin/wget
Binary file not shown.
8 changes: 8 additions & 0 deletions addon/ccu1/etc/hm_caldav-addon.cfg
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
{
CONFIG_URL /addons/hm_caldav
CONFIG_DESCRIPTION {
<li>CalDav Integration</li>
}
ID hm_caldav
CONFIG_NAME "HM-caldav"
}
Binary file added addon/ccu2/bin/bash
Binary file not shown.
Binary file added addon/ccu2/bin/iconv
Binary file not shown.
Binary file added addon/ccu2/bin/update_addon
Binary file not shown.
Binary file added addon/ccurm/bin/bash
Binary file not shown.
Binary file added addon/ccurm/bin/iconv
Binary file not shown.
Binary file added addon/ccurm/bin/update_addon
Binary file not shown.
9 changes: 9 additions & 0 deletions addon/common/etc/hm_caldav-addon.cfg
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
{
CONFIG_URL /addons/hm_caldav
CONFIG_DESCRIPTION {
de {<li>CalDav Integration</li>}
en {<li>CalDav Integration</li>}
}
ID hm_caldav
CONFIG_NAME "HM-caldav"
}
5 changes: 5 additions & 0 deletions addon/common/etc/hm_caldav.conf
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
# This is a minimalistic default config for CCU devices.
HM_CCU_IP=127.0.0.1
HM_PROCESSLOG_FILE="/var/log/hm_caldav.log"
HM_DAEMON_PIDFILE="/var/run/hm_caldav.pid"
HM_INTERVAL_TIME="60"
47 changes: 47 additions & 0 deletions addon/common/run.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
#!/bin/sh
#
# wrapper script to execute hm_caldav in non-daemon
# mode with the possibility to run it a certain amount
# of time by specifying the maximum iterations and
# interval time as command-line options
#
# Example:
# -------
#
# Runs hm_caldav only once:
#
# $ /usr/local/addons/hm_caldav/run.sh
#
# Runs hm_kostalpiko 10 times with a waittime of 5
# seconds between each execution:
#
# $ /usr/local/addons/hm_caldav/run.sh 10 5
#
# Copyright (c) 2018 Thorsten Jagel <dev@jagel.net>
#

# directory path to hm_caldav addon dir.
ADDON_DIR=/usr/local/addons/hm_caldav

# set default settings (will be overwritten by config file)
export HM_PROCESSLOG_FILE="/var/log/hm_caldav.log"
export CONFIG_FILE="${ADDON_DIR}/etc/hm_caldav.conf"

# the interval settings can be specified on the command-line
if [ $# -gt 0 ]; then
export HM_INTERVAL_MAX=${1}
if [ $# -gt 1 ]; then
export HM_INTERVAL_TIME=${2}
else
export HM_INTERVAL_TIME=15
fi
else
# otherwise do one iteration only with no
# defined interval time
export HM_INTERVAL_MAX=1
export HM_INTERVAL_TIME=
fi

# execute hm_caldav in non-daemon mode
export PATH="${ADDON_DIR}/bin:${PATH}"
${ADDON_DIR}/bin/hm_caldav.sh >/dev/null 2>&1
28 changes: 28 additions & 0 deletions addon/generate_img.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
#!/bin/bash
#
# script to generate the CCU addon package.

# generate tempdir
mkdir -p tmp
rm -rf tmp/*

# copy all relevant stuff
cp -a update_script tmp/
cp -a common tmp/
cp -a rc.d tmp/
cp -a www tmp/
cp -a ../VERSION tmp/www/
cp -a ccu1 tmp/
cp -a ccu2 tmp/
cp -a ccurm tmp/

# copy hm_caldav main script + config
mkdir -p tmp/common/bin
cp -a ../hm_caldav.sh tmp/common/bin/

# generate archive
cd tmp
find . -not -name '.DS_Store' -not -name '*.sha256' -type f -print0 | xargs -0 sha256sum >hm_caldav-$(cat ../../VERSION).sha256
tar --owner=root --group=root --exclude=.DS_Store -czvf ../hm_caldav-$(cat ../../VERSION).tar.gz *
cd ..
rm -rf tmp
86 changes: 86 additions & 0 deletions addon/rc.d/hm_caldav
Original file line number Diff line number Diff line change
@@ -0,0 +1,86 @@
#!/bin/sh

ADDONNAME=hm_caldav
ADDONDIR=/usr/local/addons/${ADDONNAME}
WWWDIR=/usr/local/etc/config/addons/www/${ADDONNAME}
RCDDIR=/usr/local/etc/config/rc.d

# function that starts hm_caldav as a daemon
start() {
# default settings (will be overwritten by config file)
export HM_PROCESSLOG_FILE="/var/log/hm_caldav.log"
export CONFIG_FILE="${ADDONDIR}/etc/hm_caldav.conf"

# check for new+missing options in conf file and add them
# if necessary
if ! grep -q HM_CCU_REGAPORT ${ADDONDIR}/etc/hm_caldav.conf; then
echo "HM_CCU_REGAPORT=8183" >>${ADDONDIR}/etc/hm_caldav.conf
fi

# set path settings to let it search in the bin directory as well.
export PATH="${ADDONDIR}/bin:${PATH}"

# run hm_caldav in daemon mode
${ADDONDIR}/bin/hm_caldav.sh start >/dev/null 2>&1
}

# function that stops/kills hm_caldav
stop() {
# default settings (will be overwritten by config file)
export CONFIG_FILE="${ADDONDIR}/etc/hm_caldav.conf"

# set path settings to let it search in the bin directory as well.
export PATH="${ADDONDIR}/bin:${PATH}"

# stop/kill hm_caldav
${ADDONDIR}/bin/hm_caldav.sh stop >/dev/null 2>&1
}

case "$1" in

""|start)
start
;;

stop)
stop
;;

restart|reload)
stop
sleep 2
start
;;

info)
echo "Info: <b>CalDav Integration Addon</b><br>"
echo "Info: (c) 2018 Thorsten Jagel<br>"
echo "Info: <a href='http://github.com/H2CK/hm_kostalpiko'>http://github.com/H2CK/hm_caldav</a>"
echo "Version: $(cat ${WWWDIR}/VERSION)"
echo "Name: hm_caldav"
echo "Operations: uninstall restart"
echo "Config-Url: /addons/${ADDONNAME}/"
echo "Update: /addons/${ADDONNAME}/update-check.cgi"
;;

uninstall)
# make sure to stop hm_caldav
stop

# remove the addon button
${ADDONDIR}/bin/update_addon hm_caldav

# remove the whole addon related stuff
rm -rf ${ADDONDIR}
rm -rf ${WWWDIR}
rm -f ${RCDDIR}/${ADDONNAME}
;;

*)
echo "Usage: hm_caldav {start|stop|restart|info|uninstall}" >&2
exit 1
;;

esac

exit $?
67 changes: 67 additions & 0 deletions addon/update_script
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
#!/bin/sh

ADDONNAME=hm_caldav
CONFIG_DIR=/usr/local/etc/config
ADDON_DIR=/usr/local/addons/${ADDONNAME}
RCD_DIR=${CONFIG_DIR}/rc.d
WWW_DIR=${CONFIG_DIR}/addons/www/${ADDONNAME}

# mount /usr/local if not already mounted
mount | grep /usr/local 2>&1 >/dev/null
if [ $? -eq 1 ]; then
mount /usr/local
fi

# create necessary directories
mkdir -p ${ADDON_DIR}
chmod 755 ${ADDON_DIR}
mkdir -p ${RCD_DIR}
chmod 755 ${RCD_DIR}

# make sure to not overwrite
# and existing config
if [ -e ${ADDON_DIR}/etc/hm_caldav.conf ]; then
rm -f common/etc/hm_caldav.conf
fi

# copy addon (common stuff)
cp -af common/* ${ADDON_DIR}/

# copy addon (CCU dependent stuff)
if [ "$1" = "" ]; then
cp -af ccu1/* ${ADDON_DIR}/
elif [ "$1" = "CCU2" ]; then
cp -af ccu2/* ${ADDON_DIR}/
elif [ "$1" == "HM-RASPBERRYMATIC" ]; then
cp -af ccurm/* ${ADDON_DIR}/
fi

# copy startup script
cp -af rc.d/* ${RCD_DIR}

# copy www stuff
cp -af www ${ADDON_DIR}/
if [ ! -e ${WWW_DIR} ]; then
ln -sf ${ADDON_DIR}/www ${WWW_DIR}
fi

# add menu entry
touch /usr/local/etc/config/hm_addons.cfg
${ADDON_DIR}/bin/update_addon hm_caldav ${ADDON_DIR}/etc/hm_caldav-addon.cfg

# make sure to remove any hm_caldav cronjobs
# since this is not required since 0.8+ anymore
if [ -s /usr/local/crontabs/root ]; then
cat /usr/local/crontabs/root | grep -v "${ADDON_DIR}/run.sh" | sort | uniq >/tmp/crontab.$$
# we make sure we don't overwrite with an empty file
# because on the CCU2+RaspberryMatic it should never be empty!
if [ -s /tmp/crontab.$$ ]; then
mv /tmp/crontab.$$ /usr/local/crontabs/root
fi
fi

sync

# exit with 0 to signal install succeeded and no reboot
# is required
exit 0
Loading

0 comments on commit 1eb2686

Please sign in to comment.