From 36470854b06da17d4baf654d52d726b68e0c0d74 Mon Sep 17 00:00:00 2001 From: IceOnly Date: Tue, 16 Oct 2018 23:08:04 +0200 Subject: [PATCH] Sync time of RF Daemon every 30min (#425) * sync homematic time periodically * Show "Run SetInterfaceClock" in log file * signal handler added * version incremented * Update CHANGELOG.md --- homematic/CHANGELOG.md | 3 +++ homematic/config.json | 2 +- homematic/run.sh | 19 +++++++++++++++++++ 3 files changed, 23 insertions(+), 1 deletion(-) diff --git a/homematic/CHANGELOG.md b/homematic/CHANGELOG.md index 421249a..291083a 100644 --- a/homematic/CHANGELOG.md +++ b/homematic/CHANGELOG.md @@ -1,5 +1,8 @@ # Changelog +## 3 + - Add periodically time sync + ## 2 - Fix wrong Timezone - Update OCCU to 3.37.8 diff --git a/homematic/config.json b/homematic/config.json index 6709f13..f302808 100644 --- a/homematic/config.json +++ b/homematic/config.json @@ -1,6 +1,6 @@ { "name": "HomeMatic OCCU", - "version": "2", + "version": "3", "slug": "homematic", "description": "HomeMatic central based on OCCU", "url": "https://home-assistant.io/addons/homematic/", diff --git a/homematic/run.sh b/homematic/run.sh index 189e6ad..27c9e54 100644 --- a/homematic/run.sh +++ b/homematic/run.sh @@ -75,5 +75,24 @@ if [ "$WIRED_ENABLE" == "true" ]; then WAIT_PIDS+=($!) fi +# Register stop +function stop_homematic() { + echo "Kill Processes..." + kill -15 "${WAIT_PIDS[@]}" + wait "${WAIT_PIDS[@]}" + echo "Done." +} +trap "stop_homematic" SIGTERM SIGHUP + +# sync time periodically +if [ "$RF_ENABLE" == "true" ]; then + while true + do + sleep 30m + echo "$(date '+%Y-%m-%d %H:%M:%S.%3N') Run SetInterfaceClock now." + "$HM_HOME/bin/SetInterfaceClock" 127.0.0.1:2001 + done +fi + # Wait until all is done wait "${WAIT_PIDS[@]}"