Merge pull request #3938 from stintel/domoticz

Add Open-ZWave and Domoticz
This commit is contained in:
Stijn Tintel 2017-03-03 04:22:51 +01:00 committed by GitHub
commit c4cbcb30b7
15 changed files with 961 additions and 0 deletions

100
utils/domoticz/Makefile Normal file
View File

@ -0,0 +1,100 @@
#
# Copyright (C) 2016 - 2017 Stijn Tintel <stijn@linux-ipv6.be>
#
# This is free software, licensed under the GNU General Public License v2.
# See /LICENSE for more information.
#
include $(TOPDIR)/rules.mk
PKG_NAME:=domoticz
PKG_VERSION_MAJOR:=3
PKG_VERSION_PATCH:=5877
PKG_VERSION:=$(PKG_VERSION_MAJOR).$(PKG_VERSION_PATCH)
PKG_RELEASE:=1
PKG_SOURCE:=$(PKG_NAME)-$(PKG_VERSION).tar.gz
PKG_SOURCE_URL:=https://github.com/domoticz/domoticz/archive/$(PKG_VERSION)/$(PKG_SOURCE)
PKG_HASH:=fb88edbe428851a7a337a85faa93f6da00713b3ad086ff6957031dc9b3b58bba
PKG_LICENSE:=GPL-3.0
PKG_LICENSE_FILES:=License.txt
PKG_BUILD_PARALLEL:=1
PKG_USE_MIPS16:=0
CMAKE_INSTALL:=1
include $(INCLUDE_DIR)/package.mk
include $(INCLUDE_DIR)/cmake.mk
define Package/domoticz
SECTION:=utils
CATEGORY:=Utilities
TITLE:=Open Source Home Automation System
URL:=http://domoticz.com/
MAINTAINER:=Stijn Tintel <stijn@linux-ipv6.be>
USERID:=domoticz=6144:domoticz=6144
DEPENDS:= \
+boost \
+boost-date_time \
+boost-system \
+boost-thread \
+libcurl \
+libmosquittopp \
+libopenssl \
+libopenzwave \
+libsqlite3 \
+libstdcpp \
+zlib
endef
define Package/domoticz/description
Domoticz is a Home Automation System that lets you monitor and configure various devices like: Lights, Switches, various sensors/meters like Temperature, Rain, Wind, UV, Electra, Gas, Water and much more. Notifications/Alerts can be sent to any mobile device.
endef
CMAKE_OPTIONS += \
-DCMAKE_BUILD_TYPE=Release \
-DUSE_BUILTIN_MQTT=no \
-DUSE_BUILTIN_SQLITE=no \
-DUSE_STATIC_BOOST=no \
-DUSE_STATIC_LIBSTDCXX=no \
-DUSE_STATIC_OPENZWAVE=no \
-DUSE_PYTHON=no
define Build/Prepare
$(call Build/Prepare/Default)
# Fix APPVERSION to suppress update popup
sed -i 's/#define APPVERSION.*/#define APPVERSION $(PKG_VERSION_PATCH)/' \
$(PKG_BUILD_DIR)/appversion.default
# Remove unwanted scripts
cd $(PKG_BUILD_DIR)/scripts && rm -rf \
buienradar_rain_example.pl \
_domoticz_main.bat \
download_update.sh \
logrotate/ \
python/ \
readme.txt \
restart_domoticz \
templates/All.Python \
update_domoticz
endef
define Package/domoticz/install
$(INSTALL_DIR) $(1)/etc/config $(1)/etc/hotplug.d/tty $(1)/etc/init.d
$(INSTALL_BIN) ./files/domoticz.hotplug $(1)/etc/hotplug.d/tty/domoticz
$(INSTALL_BIN) ./files/domoticz.init $(1)/etc/init.d/domoticz
$(INSTALL_CONF) ./files/domoticz.config $(1)/etc/config/domoticz
$(INSTALL_DIR) $(1)/usr/share/domoticz $(1)/usr/bin
$(CP) $(PKG_INSTALL_DIR)/usr/Config $(1)/usr/share/domoticz/openzwave
$(CP) $(PKG_INSTALL_DIR)/usr/scripts $(1)/usr/share/domoticz/
$(CP) $(PKG_INSTALL_DIR)/usr/www $(1)/usr/share/domoticz/
$(INSTALL_BIN) $(PKG_INSTALL_DIR)/usr/domoticz $(1)/usr/bin/domoticz
endef
define Package/domoticz/conffiles
/etc/config/domoticz
/var/lib/domoticz/
endef
$(eval $(call BuildPackage,domoticz))

View File

@ -0,0 +1,28 @@
config domoticz
option disabled '1'
option loglevel '1'
option syslog 'daemon'
# option sslcert '/path/to/ssl.crt'
# option sslkey '/path/to/ssl.key'
# option sslpass 'passphrase'
option sslwww '0'
# CAUTION - by default, /var is not persistent accross reboots
# Don't forget the trailing / - domoticz requires it
option userdata '/var/lib/domoticz/'
#config device
# option product '658/200/0'
# option symlink 'ttyACM-aeotec-zstick-g5'
#config device
# option serial '526359'
# option symlink 'ttyUSB-serial'
#config device
# option usbif '2-1:1.0'
# option symlink 'ttyUSB-port1'
#config device
# option product '67b/2303/202'
# option usbif '2-2:1.0'
# option symlink 'ttyUSB-port2'

View File

@ -0,0 +1,44 @@
#!/bin/sh
. /lib/functions.sh
[ "$SUBSYSTEM" = "tty" ] || exit 0
add() {
local cfg="$1"
local product serial symlink usbif
[ -c "/dev/$DEVICENAME" ] || return
config_get product "$cfg" product
config_get serial "$cfg" serial
config_get symlink "$cfg" symlink
config_get usbif "$cfg" usbif
[ -z "$product" -a -z "$serial" -a -z "$usbif" ] && return
. "/sys/$DEVPATH/device/../uevent"
SERIAL="$(cat /sys/$DEVPATH/device/../../serial)" 2>/dev/null
USBIF="$(echo $DEVPATH | awk -F/ 'BEGIN {i=3}; /ACM/ {i=2}; END {print $(NF-i)}')"
[ -n "$product" -a "$product" != "$PRODUCT" ] && return
[ -n "$serial" -a "$serial" != "$SERIAL" ] && return
[ -n "$usbif" -a "$usbif" != "$USBIF" ] && return
chgrp domoticz "/dev/$DEVICENAME"
chmod g+rw "/dev/$DEVICENAME"
[ -n "$symlink" ] && ln -s "/dev/$DEVICENAME" "/dev/$symlink"
}
remove() {
local cfg="$1"
local symlink
config_get symlink "$cfg" symlink
[ "/dev/$DEVICENAME" = "$(readlink /dev/$symlink)" ] && rm "/dev/$symlink"
}
config_load "domoticz"
config_foreach "$ACTION" device

View File

@ -0,0 +1,54 @@
#!/bin/sh /etc/rc.common
START=99
USE_PROCD=1
PROG=/usr/bin/domoticz
PIDFILE=/var/run/domoticz.pid
start_domoticz() {
local section="$1"
local loglevel sslcert sslpass sslwww syslog userdata
config_get loglevel "$section" "loglevel"
config_get sslcert "$section" "sslcert"
config_get sslkey "$section" "sslkey"
config_get sslpass "$section" "sslpass"
config_get sslwww "$section" "sslwww"
config_get syslog "$section" "syslog"
config_get userdata "$section" "userdata"
[ -n "$loglevel" ] && procd_append_param command -loglevel "$loglevel"
[ -n "$syslog" ] && procd_append_param command -syslog "$syslog"
[ -n "$userdata" ] && procd_append_param command -userdata "$userdata"
[ -n "$sslcert" -a "${sslwww:-0}" -gt 0 ] && {
procd_append_param command -sslcert "$sslcert"
procd_append_param command -sslwww "$sslwww"
[ -n "$sslkey" ] && procd_append_param command -sslkey "$sslkey"
[ -n "$sslpass" ] && procd_append_param command -sslpass "$sslpass"
} || procd_append_param command -sslwww 0
}
start_service() {
mkdir -p /var/lib/domoticz
chmod 0770 /var/lib/domoticz
chown domoticz:domoticz /var/lib/domoticz
procd_open_instance
procd_set_param command "$PROG"
procd_append_param command -scripts /usr/share/domoticz/scripts/
procd_append_param command -wwwroot /usr/share/domoticz/www/
config_load "domoticz"
config_get_bool disabled "$section" "disabled" 0
[ "$disabled" -gt 0 ] && return 1
config_foreach start_domoticz domoticz
procd_set_param pidfile "$PIDFILE"
procd_set_param respawn
procd_set_param stdout 0
procd_set_param term_timeout 10
procd_set_param user "domoticz"
procd_close_instance
}

View File

@ -0,0 +1,48 @@
From 2504f02de752aceb5a3c1d4749032147efde8082 Mon Sep 17 00:00:00 2001
From: dwmw2 <dwmw2@infradead.org>
Date: Fri, 3 Feb 2017 07:40:35 +0000
Subject: [PATCH] Add -sslkey option to allow separate cert/key files (#1195)
---
main/domoticz.cpp | 11 +++++++++++
webserver/server_settings.hpp | 2 +-
2 files changed, 12 insertions(+), 1 deletion(-)
--- a/main/domoticz.cpp
+++ b/main/domoticz.cpp
@@ -76,6 +76,7 @@ const char *szHelp=
#ifdef WWW_ENABLE_SSL
"\t-sslwww port (for example -sslwww 443, or -sslwww 0 to disable https)\n"
"\t-sslcert file_path (for example /opt/domoticz/server_cert.pem)\n"
+ "\t-sslkey file_path (if different from certificate file)\n"
"\t-sslpass passphrase (to access to server private key in certificate)\n"
"\t-sslmethod method (for SSL method)\n"
"\t-ssloptions options (for SSL options, default is 'default_workarounds,no_sslv2,single_dh_use')\n"
@@ -682,6 +683,16 @@ int main(int argc, char**argv)
return 1;
}
secure_webserver_settings.cert_file_path = cmdLine.GetSafeArgument("-sslcert", 0, "");
+ secure_webserver_settings.private_key_file_path = secure_webserver_settings.cert_file_path;
+ }
+ if (cmdLine.HasSwitch("-sslkey"))
+ {
+ if (cmdLine.GetArgumentCount("-sslkey") != 1)
+ {
+ _log.Log(LOG_ERROR, "Please specify a file path for your server SSL key file");
+ return 1;
+ }
+ secure_webserver_settings.private_key_file_path = cmdLine.GetSafeArgument("-sslkey", 0, "");
}
if (cmdLine.HasSwitch("-sslpass"))
{
--- a/webserver/server_settings.hpp
+++ b/webserver/server_settings.hpp
@@ -227,7 +227,7 @@ public:
// use certificate file for all usage by default
certificate_chain_file_path = ssl_settings.cert_file_path;
ca_cert_file_path = ssl_settings.cert_file_path;
- private_key_file_path = ssl_settings.cert_file_path;
+ private_key_file_path = ssl_settings.private_key_file_path;
tmp_dh_file_path = ssl_settings.cert_file_path;
verify_file_path = ssl_settings.cert_file_path;
}

View File

@ -0,0 +1,68 @@
diff --git a/hardware/evohome.cpp b/hardware/evohome.cpp
index fcbee6d..f77291e 100644
--- a/hardware/evohome.cpp
+++ b/hardware/evohome.cpp
@@ -423,11 +423,11 @@ void CEvohome::RunScript(const char *pdata, const unsigned char length)
boost::replace_all(OnAction, "{state}", s_strid.str());
boost::replace_all(OnAction, "{until}", CEvohomeDateTime::GetISODate(tsen->EVOHOME2));
//Execute possible script
- std::string scriptname;
- if (OnAction.find("script:///") != std::string::npos)
- scriptname = OnAction.substr(9);
- else
- scriptname = OnAction.substr(8);
+ std::string scriptname = OnAction.substr(9);
+#if !defined WIN32
+ if (scriptname.find("/") != 0)
+ scriptname = szUserDataFolder + "scripts/" + scriptname;
+#endif
std::string scriptparams="";
//Add parameters
int pindex=scriptname.find(' ');
@@ -439,7 +439,7 @@ void CEvohome::RunScript(const char *pdata, const unsigned char length)
if (file_exist(scriptname.c_str()))
{
- m_sql.AddTaskItem(_tTaskItem::ExecuteScript(1,scriptname,scriptparams));
+ m_sql.AddTaskItem(_tTaskItem::ExecuteScript(0.2f,scriptname,scriptparams));
}
else
_log.Log(LOG_ERROR,"evohome: Error script not found '%s'",scriptname.c_str());
@@ -1321,7 +1321,7 @@ bool CEvohome::DecodeZoneName(CEvohomeMsg &msg)
}
if(memcmp(&msg.payload[2],m_szNameErr,18)==0)
{
- Log(true,LOG_STATUS,"evohome: %s: Warning zone name not set: %d", tag, msg.payload[0]);
+ Log(true,LOG_STATUS,"evohome: %s: Warning zone name not set: %d", tag, msg.payload[0]+1);
m_bStartup[0]=false;
return true;
}
@@ -1606,9 +1606,11 @@ bool CEvohome::DecodeBatteryInfo(CEvohomeMsg &msg)
RFX_SETID3(msg.GetID(0),tsen.EVOHOME2.id1,tsen.EVOHOME2.id2,tsen.EVOHOME2.id3)
tsen.EVOHOME2.updatetype = updBattery;
- double dbCharge=0;
- if(nBattery!=0xFF)
- dbCharge=(double)nBattery/2.0; //Presumed to be the charge level where sent
+ if (nBattery == 0xFF)
+ nBattery = 100; // recode full battery (0xFF) to 100 for consistency across device types
+ else
+ nBattery = nBattery / 2; // recode battery level values to 0-100 from original 0-200 values
+
if(nLowBat==0)
nBattery=0;
tsen.EVOHOME2.battery_level=nBattery;
@@ -1657,9 +1659,11 @@ bool CEvohome::DecodeBatteryInfo(CEvohomeMsg &msg)
tsen.EVOHOME2.type=pTypeEvohomeWater;
tsen.EVOHOME2.subtype=sTypeEvohomeWater;
tsen.EVOHOME2.zone=nDevNo;
- sDecodeRXMessage(this, (const unsigned char *)&tsen.EVOHOME2, NULL, nBattery);
+ RFX_SETID3(GetControllerID(), tsen.EVOHOME2.id1, tsen.EVOHOME2.id2, tsen.EVOHOME2.id3);
+ sDecodeRXMessage(this, (const unsigned char *)&tsen.EVOHOME2, "DHW Temp", nBattery); // Update DHW Zone sensor
}
- Log(true,LOG_STATUS,"evohome: %s: %s=%d charge=%d (%.1f %%) level=%d (%s)",tag,szType.c_str(),nDevNo,nBattery,dbCharge,nLowBat,(nLowBat==0)?"Low":"OK");
+
+ Log(true,LOG_STATUS,"evohome: %s: %s=%d charge=%d(%%) level=%d (%s)",tag,szType.c_str(),nDevNo,nBattery,nLowBat,(nLowBat==0)?"Low":"OK");
return true;
}

View File

@ -0,0 +1,11 @@
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -606,8 +606,6 @@ else()
target_link_libraries(domoticz -lrt ${Boost_LIBRARIES} ${ZLIB_LIBRARIES} ${CURL_LIBRARIES} pthread ${LUA_LIBRARIES} ${MQTT_LIBRARIES} ${SQLite_LIBRARIES} ${CMAKE_DL_LIBS} ${TELLDUS_LIBRARIES} ${EXECINFO_LIBRARIES})
ENDIF()
-ADD_PRECOMPILED_HEADER(domoticz "main/stdafx.h")
-
IF(CMAKE_COMPILER_IS_GNUCXX)
option(USE_STATIC_LIBSTDCXX "Build with static libgcc/libstdc++ libraries" YES)
IF(USE_STATIC_LIBSTDCXX)

View File

@ -0,0 +1,42 @@
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -534,39 +534,6 @@ IF(OpenZWave)
target_link_libraries(domoticz ${OpenZWave})
include_directories(${CMAKE_SOURCE_DIR}/hardware/openzwave)
add_definitions(-DWITH_OPENZWAVE)
- # open-zwave needs libudev
- IF(CMAKE_SYSTEM_NAME STREQUAL "Darwin")
- set(IOKIT_LIBRARY "-framework IOKit -framework CoreFoundation" CACHE FILEPATH "IOKit framework" FORCE)
- target_link_libraries(domoticz ${IOKIT_LIBRARY})
- else()
- IF(CMAKE_SYSTEM_NAME STREQUAL "FreeBSD")
- MESSAGE(STATUS "Building on FreeBSD, libudev not needed!")
- FIND_PATH(ICONV_INCLUDE_DIR iconv.h)
- FIND_LIBRARY(ICONV_LIBRARIES NAMES iconv libiconv libiconv-2 c)
- IF(ICONV_INCLUDE_DIR AND ICONV_LIBRARIES)
- SET(ICONV_FOUND TRUE)
- #target_link_libraries(domoticz ${ICONV_INCLUDE_DIR})
- target_link_libraries(domoticz ${ICONV_LIBRARIES} -lrt)
- message(STATUS ${ICONV_LIBRARIES})
- else()
- MESSAGE(FATAL_ERROR "libiconv not found on your system")
- ENDIF(ICONV_INCLUDE_DIR AND ICONV_LIBRARIES)
- else()
- find_library(UDEV NAMES libudev.a)
- IF(UDEV)
- message(STATUS ${UDEV})
- target_link_libraries(domoticz ${UDEV} -lrt)
- else()
- find_library(UDEV NAMES libudev.so)
- IF(UDEV)
- message(STATUS ${UDEV})
- target_link_libraries(domoticz ${UDEV} -lrt)
- else()
- MESSAGE(FATAL_ERROR "LIB UDEV not found on your system, see install.txt how to get them installed.\nsudo apt-get install libudev-dev")
- ENDIF(UDEV)
- ENDIF(UDEV)
- ENDIF()
- ENDIF()
else()
MESSAGE(STATUS "==== OpenZWave not found, support disabled!")
ENDIF(OpenZWave)

View File

@ -0,0 +1,262 @@
--- a/hardware/OpenZWave.cpp
+++ b/hardware/OpenZWave.cpp
@@ -993,7 +993,7 @@ bool COpenZWave::OpenSerialConnector()
}
m_nodes.clear();
m_bNeedSave = false;
- std::string ConfigPath = szStartupFolder + "Config/";
+ std::string ConfigPath = "/usr/share/domoticz/openzwave/";
std::string UserPath = ConfigPath;
if (szStartupFolder != szUserDataFolder)
{
--- a/main/EventSystem.cpp
+++ b/main/EventSystem.cpp
@@ -44,7 +44,7 @@ extern "C" {
using namespace boost::python;
#endif
-extern std::string szUserDataFolder;
+extern std::string szScriptsFolder;
CEventSystem::CEventSystem(void)
{
@@ -1086,9 +1086,9 @@ void CEventSystem::EvaluateEvent(const s
std::stringstream lua_DirT;
#ifdef WIN32
- lua_DirT << szUserDataFolder << "scripts\\lua\\";
+ lua_DirT << szScriptsFolder << "lua\\";
#else
- lua_DirT << szUserDataFolder << "scripts/lua/";
+ lua_DirT << szScriptsFolder << "lua/";
#endif
std::string lua_Dir = lua_DirT.str();
@@ -1139,9 +1139,9 @@ void CEventSystem::EvaluateEvent(const s
{
std::stringstream python_DirT;
#ifdef WIN32
- python_DirT << szUserDataFolder << "scripts\\python\\";
+ python_DirT << szScriptsFolder << "python\\";
#else
- python_DirT << szUserDataFolder << "scripts/python/";
+ python_DirT << szScriptsFolder << "python/";
#endif
std::string python_Dir = python_DirT.str();
@@ -2021,7 +2021,7 @@ bool CEventSystem::parseBlocklyActions(c
}
#if !defined WIN32
if (sPath.find("/") != 0)
- sPath = szUserDataFolder + "scripts/" + sPath;
+ sPath = szScriptsFolder + sPath;
#endif
m_sql.AddTaskItem(_tTaskItem::ExecuteScript(1, sPath, sParam));
@@ -2133,9 +2133,9 @@ void CEventSystem::EvaluatePython(const
std::stringstream python_DirT;
#ifdef WIN32
- python_DirT << szUserDataFolder << "scripts\\python\\";
+ python_DirT << szScriptsFolder << "python\\";
#else
- python_DirT << szUserDataFolder << "scripts/python/";
+ python_DirT << szScriptsFolder << "python/";
#endif
std::string python_Dir = python_DirT.str();
if(!Py_IsInitialized()) {
@@ -3909,9 +3909,9 @@ namespace http {
std::stringstream template_file;
#ifdef WIN32
- template_file << szUserDataFolder << "scripts\\templates\\" << eventType << "." << interpreter;
+ template_file << szScriptsFolder << "templates\\" << eventType << "." << interpreter;
#else
- template_file << szUserDataFolder << "scripts/templates/" << eventType << "." << interpreter;
+ template_file << szScriptsFolder << "templates/" << eventType << "." << interpreter;
#endif
std::ifstream file;
std::stringstream template_content;
--- a/main/LuaHandler.cpp
+++ b/main/LuaHandler.cpp
@@ -22,7 +22,7 @@ extern "C" {
#include "mainworker.h"
#include "../hardware/hardwaretypes.h"
-extern std::string szUserDataFolder;
+extern std::string szScriptsFolder;
int CLuaHandler::l_domoticz_applyXPath(lua_State* lua_state)
{
@@ -319,9 +319,9 @@ bool CLuaHandler::executeLuaScript(const
{
std::stringstream lua_DirT;
#ifdef WIN32
- lua_DirT << szUserDataFolder << "scripts\\lua_parsers\\";
+ lua_DirT << szScriptsFolder << "lua_parsers\\";
#else
- lua_DirT << szUserDataFolder << "scripts/lua_parsers/";
+ lua_DirT << szScriptsFolder << "lua_parsers/";
#endif
std::string lua_Dir = lua_DirT.str();
--- a/main/SQLHelper.cpp
+++ b/main/SQLHelper.cpp
@@ -612,6 +612,7 @@ const char *sqlCreateMobileDevices =
"[LastUpdate] DATETIME DEFAULT(datetime('now', 'localtime'))"
");";
+extern std::string szScriptsFolder;
extern std::string szUserDataFolder;
CSQLHelper::CSQLHelper(void)
@@ -3408,9 +3409,9 @@ unsigned long long CSQLHelper::UpdateVal
//Execute possible script
std::string scriptname;
#ifdef WIN32
- scriptname = szUserDataFolder + "scripts\\domoticz_main.bat";
+ scriptname = szScriptsFolder + "domoticz_main.bat";
#else
- scriptname = szUserDataFolder + "scripts/domoticz_main";
+ scriptname = szScriptsFolder + "domoticz_main";
#endif
if (file_exist(scriptname.c_str()))
{
@@ -6460,7 +6461,7 @@ bool CSQLHelper::HandleOnOffAction(const
std::string scriptname = OnAction.substr(9);
#if !defined WIN32
if (scriptname.find("/") != 0)
- scriptname = szUserDataFolder + "scripts/" + scriptname;
+ scriptname = szScriptsFolder + scriptname;
#endif
std::string scriptparams="";
//Add parameters
@@ -6492,7 +6493,7 @@ bool CSQLHelper::HandleOnOffAction(const
std::string scriptname = OffAction.substr(9);
#if !defined WIN32
if (scriptname.find("/") != 0)
- scriptname = szUserDataFolder + "scripts/" + scriptname;
+ scriptname = szScriptsFolder + scriptname;
#endif
std::string scriptparams="";
int pindex=scriptname.find(' ');
--- a/main/WebServer.cpp
+++ b/main/WebServer.cpp
@@ -55,6 +55,7 @@
#define round(a) ( int ) ( a + .5 )
+extern std::string szScriptsFolder;
extern std::string szUserDataFolder;
extern std::string szWWWFolder;
@@ -2614,9 +2615,9 @@ namespace http {
if (scriptname.find("..") != std::string::npos)
return;
#ifdef WIN32
- scriptname = szUserDataFolder + "scripts\\" + scriptname;
+ scriptname = szScriptsFolder + scriptname;
#else
- scriptname = szUserDataFolder + "scripts/" + scriptname;
+ scriptname = szScriptsFolder + scriptname;
#endif
if (!file_exist(scriptname.c_str()))
return;
--- a/main/domoticz.cpp
+++ b/main/domoticz.cpp
@@ -135,6 +135,7 @@ static const _facilities facilities[] =
};
std::string logfacname = "user";
#endif
+std::string szScriptsFolder;
std::string szStartupFolder;
std::string szUserDataFolder;
std::string szWWWFolder;
@@ -603,6 +604,19 @@ int main(int argc, char**argv)
szUserDataFolder = szroot;
}
+ szScriptsFolder=szStartupFolder;
+ if (cmdLine.HasSwitch("-scripts"))
+ {
+ if (cmdLine.GetArgumentCount("-scripts") != 1)
+ {
+ _log.Log(LOG_ERROR, "Please specify a path for scripts directory");
+ return 1;
+ }
+ std::string szroot = cmdLine.GetSafeArgument("-scripts", 0, "");
+ if (szroot.size() != 0)
+ szScriptsFolder = szroot;
+ }
+
if (cmdLine.HasSwitch("-startupdelay"))
{
if (cmdLine.GetArgumentCount("-startupdelay") != 1)
--- a/main/mainworker.cpp
+++ b/main/mainworker.cpp
@@ -139,6 +139,7 @@
#define round(a) ( int ) ( a + .5 )
+extern std::string szScriptsFolder;
extern std::string szStartupFolder;
extern std::string szUserDataFolder;
extern std::string szWWWFolder;
@@ -1394,8 +1395,8 @@ void MainWorker::Do_Work()
m_sql.GetPreferencesVar("ReleaseChannel", nValue);
bool bIsBetaChannel = (nValue != 0);
- std::string scriptname = szUserDataFolder + "scripts/download_update.sh";
- std::string strparm = szUserDataFolder;
+ std::string scriptname = szScriptsFolder + "download_update.sh";
+ std::string strparm = szScriptsFolder;
if (bIsBetaChannel)
strparm += " /beta";
--- a/notifications/NotificationHTTP.cpp
+++ b/notifications/NotificationHTTP.cpp
@@ -6,7 +6,7 @@
#include "../main/SQLHelper.h"
#include "../main/Logger.h"
-extern std::string szUserDataFolder;
+extern std::string szScriptsFolder;
CNotificationHTTP::CNotificationHTTP() : CNotificationBase(std::string("http"), OPTIONS_NONE)
{
@@ -97,7 +97,7 @@ bool CNotificationHTTP::SendMessageImple
std::string scriptparams = "";
#if !defined WIN32
if (scriptname.find("/") != 0)
- scriptname = szUserDataFolder + "scripts/" + scriptname;
+ scriptname = szScriptsFolder + scriptname;
#endif
//Add parameters
uPos = scriptname.find(" ");
--- a/push/GooglePubSubPush.cpp
+++ b/push/GooglePubSubPush.cpp
@@ -20,7 +20,7 @@ extern "C" {
using namespace boost::python;
#endif
-extern std::string szUserDataFolder;
+extern std::string szScriptsFolder;
// this should be filled in by the preprocessor
extern const char * Python_exe;
@@ -222,11 +222,11 @@ void CGooglePubSubPush::DoGooglePubSubPu
#ifdef ENABLE_PYTHON
#ifdef WIN32
- python_DirT << szUserDataFolder << "scripts\\python\\";
- std::string filename = szUserDataFolder + "scripts\\python\\" + "googlepubsub.py";
+ python_DirT << szScriptsFolder << "python\\";
+ std::string filename = szScriptsFolder + "python\\" + "googlepubsub.py";
#else
- python_DirT << szUserDataFolder << "scripts/python/";
- std::string filename = szUserDataFolder + "scripts/python/" + "googlepubsub.py";
+ python_DirT << szScriptsFolder << "python/";
+ std::string filename = szScriptsFolder + "python/" + "googlepubsub.py";
#endif
char * argv[1];

View File

@ -0,0 +1,39 @@
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -476,20 +476,23 @@ else()
MESSAGE(FATAL_ERROR "cURL not found on your system, see install.txt how to get them installed. (for example 'sudo apt-get install curl libcurl4-openssl-dev')")
ENDIF(CURL_FOUND)
-find_path(LIBUSB_INCLUDE_DIR usb.h
- HINTS ${PC_LIBUSB_INCLUDEDIR} ${PC_LIBUSB_INCLUDE_DIRS})
-find_library(LIBUSB_LIBRARY NAMES usb
- HINTS ${PC_LIBUSB_LIBDIR} ${PC_LIBUSB_LIBRARY_DIRS})
-set(LIBUSB_LIBRARIES ${LIBUSB_LIBRARY})
+option(WITH_LIBUSB "Enable libusb support" NO)
+ if(WITH_LIBUSB)
+ find_path(LIBUSB_INCLUDE_DIR usb.h
+ HINTS ${PC_LIBUSB_INCLUDEDIR} ${PC_LIBUSB_INCLUDE_DIRS})
+ find_library(LIBUSB_LIBRARY NAMES usb
+ HINTS ${PC_LIBUSB_LIBDIR} ${PC_LIBUSB_LIBRARY_DIRS})
+ set(LIBUSB_LIBRARIES ${LIBUSB_LIBRARY})
-find_package_handle_standard_args(LIBUSB DEFAULT_MSG LIBUSB_LIBRARIES LIBUSB_INCLUDE_DIR)
-IF(LIBUSB_FOUND)
- MESSAGE(STATUS "LIBUSB found at: ${LIBUSB_LIBRARIES}")
- add_definitions(-DWITH_LIBUSB)
- target_link_libraries(domoticz ${LIBUSB_LIBRARIES})
-else()
- MESSAGE(STATUS "==== LibUSB not found, support for TE923/Voltcraft disabled!")
-ENDIF(LIBUSB_FOUND)
+ find_package_handle_standard_args(LIBUSB DEFAULT_MSG LIBUSB_LIBRARIES LIBUSB_INCLUDE_DIR)
+ IF(LIBUSB_FOUND)
+ MESSAGE(STATUS "LIBUSB found at: ${LIBUSB_LIBRARIES}")
+ add_definitions(-DWITH_LIBUSB)
+ target_link_libraries(domoticz ${LIBUSB_LIBRARIES})
+ else()
+ MESSAGE(STATUS "==== LibUSB not found, support for TE923/Voltcraft disabled!")
+ ENDIF(LIBUSB_FOUND)
+endif(WITH_LIBUSB)
#
# Find MD5/RMD160/SHA library

95
utils/openzwave/Makefile Normal file
View File

@ -0,0 +1,95 @@
#
# Copyright (C) 2017 Hauke Mehrtens <hauke@hauke-m.de>
# Copyright (C) 2016 - 2017 Stijn Tintel <stijn@linux-ipv6.be>
#
# This is free software, licensed under the GNU General Public License v2.
# See /LICENSE for more information.
#
include $(TOPDIR)/rules.mk
PKG_NAME:=openzwave
PKG_REV:=164
PKG_VERSION:=1.4.$(PKG_REV)
PKG_RELEASE:=1
PKG_SOURCE:=$(PKG_NAME)-$(PKG_VERSION).tar.gz
PKG_SOURCE_URL:=http://old.openzwave.com/downloads
PKG_HASH:=4ecf39787aaf278c203764069b581dbc26094ce57cafeab4a0c1f012d2c0ac69
PKG_BUILD_DIR:=$(BUILD_DIR)/$(PKG_NAME)-$(PKG_VERSION)
PKG_INSTALL:=1
include $(INCLUDE_DIR)/package.mk
define Package/openzwave/default
URL:=http://openzwave.com
MAINTAINER:=Stijn Tintel <stijn@linux-ipv6.be>
DEPENDS:=+libpthread +libstdcpp
endef
define Package/openzwave/description
Open-ZWave is a library that interfaces with selected Z-Wave PC controllers
endef
define Package/libopenzwave
$(call Package/openzwave/default)
SECTION:=Libs
CATEGORY:=Libraries
TITLE:=Open-ZWave Library
endef
define Package/openzwave
$(call Package/openzwave/default)
SECTION:=Utils
CATEGORY:=Utilities
TITLE:=Open-ZWave MinOZW test utility
DEPENDS:=+libopenzwave +openzwave-config
endef
define Package/openzwave-config
$(call Package/openzwave/default)
SECTION:=Utils
CATEGORY:=Utilities
TITLE:=Open-ZWave Device Configs
endef
MAKE_FLAGS += \
LD="$(TARGET_CROSS)g++" \
PREFIX=$(CONFIGURE_PREFIX) \
instlibdir=/usr/lib \
pkgconfigdir=/usr/lib/pkgconfig \
sysconfdir=/etc/openzwave
define Build/Prepare
$(call Build/Prepare/Default)
rm $(PKG_BUILD_DIR)/cpp/src/platform/HidController.*
sed -i -e '/hidapi/d;/HidController/d' $(PKG_BUILD_DIR)/distfiles.mk
endef
define Package/libopenzwave/install
$(INSTALL_DIR) $(1)/usr/lib
$(CP) $(PKG_INSTALL_DIR)/usr/lib/libopenzwave.so* $(1)/usr/lib/
endef
define Package/openzwave/install
$(INSTALL_DIR) $(1)/usr/bin
$(CP) $(PKG_INSTALL_DIR)/usr/bin/MinOZW $(1)/usr/bin/
endef
define Package/openzwave-config/install
$(INSTALL_DIR) $(1)/etc/
$(CP) $(PKG_INSTALL_DIR)/etc/openzwave $(1)/etc/
endef
define Build/InstallDev
$(INSTALL_DIR) $(1)/usr/include
$(CP) $(PKG_INSTALL_DIR)/usr/include/openzwave $(1)/usr/include/
$(INSTALL_DIR) $(1)/usr/lib
$(CP) $(PKG_INSTALL_DIR)/usr/lib/libopenzwave.* $(1)/usr/lib/
$(INSTALL_DIR) $(1)/usr/lib/pkgconfig
$(CP) $(PKG_INSTALL_DIR)/usr/lib/pkgconfig/libopenzwave.pc $(1)/usr/lib/pkgconfig/
endef
$(eval $(call BuildPackage,libopenzwave))
$(eval $(call BuildPackage,openzwave))
$(eval $(call BuildPackage,openzwave-config))

View File

@ -0,0 +1,28 @@
From eab45f0959ccb1deb662c6f8c036651088e2e8d6 Mon Sep 17 00:00:00 2001
From: Stijn Tintel <stijn@linux-ipv6.be>
Date: Fri, 17 Feb 2017 05:42:25 +0100
Subject: [PATCH] unix: fix compilation against musl libc (#1127)
POSIX.1-2001 requires sys/select.h for select() and friends.
Compile-tested on glibc and musl, runtime tested on musl.
Signed-off-by: Stijn Tintel <stijn@linux-ipv6.be>
---
cpp/src/platform/unix/SerialControllerImpl.cpp | 1 +
1 file changed, 1 insertion(+)
diff --git a/cpp/src/platform/unix/SerialControllerImpl.cpp b/cpp/src/platform/unix/SerialControllerImpl.cpp
index d95f848..b52b74f 100644
--- a/cpp/src/platform/unix/SerialControllerImpl.cpp
+++ b/cpp/src/platform/unix/SerialControllerImpl.cpp
@@ -25,6 +25,7 @@
// along with OpenZWave. If not, see <http://www.gnu.org/licenses/>.
//
//-----------------------------------------------------------------------------
+#include <sys/select.h>
#include <unistd.h>
#include <pthread.h>
#include "Defs.h"
--
2.10.2

View File

@ -0,0 +1,29 @@
--- a/cpp/build/Makefile
+++ b/cpp/build/Makefile
@@ -15,7 +15,7 @@
# what flags we will use for compiling in debug mode
DEBUG_CFLAGS := -Wall -Wno-unknown-pragmas -Wno-inline -Wno-format -Werror -Wno-error=sequence-point -Wno-sequence-point -ggdb -DDEBUG -fPIC -DSYSCONFDIR="\"$(PREFIX)/etc/openzwave/\""
# what flags we will use for compiling in release mode
-RELEASE_CFLAGS := -Wall -Wno-unknown-pragmas -Werror -Wno-format -Wno-error=sequence-point -Wno-sequence-point -O3 -DNDEBUG -fPIC -DSYSCONFDIR="\"$(PREFIX)/etc/openzwave/\""
+RELEASE_CFLAGS := -Wall -Wno-unknown-pragmas -Wno-error=sequence-point -Wno-sequence-point -DNDEBUG -fPIC -DSYSCONFDIR="\"/etc/openzwave/\""
#what flags we will use for linking in debug mode
DEBUG_LDFLAGS := -g
@@ -139,7 +139,7 @@ $(LIBDIR)/libopenzwave.a: $(patsubst %.c
$(patsubst %.cpp,$(OBJDIR)/%.o,$(indep)) \
$(OBJDIR)/vers.o
@echo "Linking Static Library"
- @$(AR) $@ $+
+ @$(AR) q $@ $+
@$(RANLIB) $@
$(LIBDIR)/$(SHARED_LIB_NAME): $(patsubst %.cpp,$(OBJDIR)/%.o,$(tinyxml)) \
@@ -161,7 +161,7 @@ $(top_builddir)/libopenzwave.pc: $(top_s
-e 's|[@]exec_prefix@|$(PREFIX)/bin|g' \
-e 's|[@]libdir@|$(instlibdir)|g' \
-e 's|[@]includedir@|$(PREFIX)/include/openzwave/|g' \
- -e 's|[@]sysconfdir@|$(PREFIX)/etc/openzwave/|g' \
+ -e 's|[@]sysconfdir@|/etc/openzwave/|g' \
-e 's|[@]gitversion@|$(GITVERSION)|g' \
-e 's|[@]docdir@|$(docdir)/|g' \
-e 's|[@]VERSION@|$(VERSION)|g' \

View File

@ -0,0 +1,89 @@
--- a/cpp/src/Driver.cpp
+++ b/cpp/src/Driver.cpp
@@ -37,11 +37,6 @@
#include "platform/Event.h"
#include "platform/Mutex.h"
#include "platform/SerialController.h"
-#ifdef WINRT
-#include "platform/winRT/HidControllerWinRT.h"
-#else
-#include "platform/HidController.h"
-#endif
#include "platform/Thread.h"
#include "platform/Log.h"
#include "platform/TimeStamp.h"
@@ -223,14 +218,7 @@ m_nonceReportSentAttempt( 0 )
initNetworkKeys(false);
- if( ControllerInterface_Hid == _interface )
- {
- m_controller = new HidController();
- }
- else
- {
- m_controller = new SerialController();
- }
+ m_controller = new SerialController();
m_controller->SetSignalThreshold( 1 );
Options::Get()->GetOptionAsBool( "NotifyTransactions", &m_notifytransactions );
--- a/cpp/build/Makefile
+++ b/cpp/build/Makefile
@@ -66,16 +66,7 @@ CFLAGS += $(CPPFLAGS)
#where to put the temporary library
LIBDIR ?= $(top_builddir)
-INCLUDES := -I $(top_srcdir)/cpp/src -I $(top_srcdir)/cpp/tinyxml/ -I $(top_srcdir)/cpp/hidapi/hidapi/
-
-ifeq ($(UNAME),Darwin)
-SOURCES_HIDAPI =$(top_srcdir)/cpp/hidapi/mac
-else ifeq ($(UNAME),FreeBSD)
-SOURCES_HIDAPI =$(top_srcdir)/cpp/hidapi/libusb
-else
-SOURCES_HIDAPI =$(top_srcdir)/cpp/hidapi/linux
-endif
-
+INCLUDES := -I $(top_srcdir)/cpp/src -I $(top_srcdir)/cpp/tinyxml/
SOURCES := $(top_srcdir)/cpp/src $(top_srcdir)/cpp/src/command_classes $(top_srcdir)/cpp/tinyxml \
$(top_srcdir)/cpp/src/value_classes $(top_srcdir)/cpp/src/platform $(top_srcdir)/cpp/src/platform/unix $(SOURCES_HIDAPI) $(top_srcdir)/cpp/src/aes/
@@ -85,14 +76,6 @@ VPATH = $(top_srcdir)/cpp/src:$(top_srcd
tinyxml := $(notdir $(wildcard $(top_srcdir)/cpp/tinyxml/*.cpp))
-ifeq ($(UNAME),Darwin)
-hidapi := $(notdir $(wildcard $(top_srcdir)/cpp/hidapi/mac/*.c))
-else ifeq ($(UNAME),FreeBSD)
-hidapi := $(notdir $(wildcard $(top_srcdir)/cpp/hidapi/libusb/*.c))
-else
-hidapi := $(notdir $(wildcard $(top_srcdir)/cpp/hidapi/linux/*.c)) # we do not want the libusb version
-endif
-
cclasses := $(notdir $(wildcard $(top_srcdir)/cpp/src/command_classes/*.cpp))
vclasses := $(notdir $(wildcard $(top_srcdir)/cpp/src/value_classes/*.cpp))
pform := $(notdir $(wildcard $(top_srcdir)/cpp/src/platform/*.cpp)) \
@@ -111,7 +94,6 @@ printversion:
-include $(patsubst %.cpp,$(DEPDIR)/%.d,$(tinyxml))
--include $(patsubst %.c,$(DEPDIR)/%.d,$(hidapi))
-include $(patsubst %.cpp,$(DEPDIR)/%.d,$(cclasses))
-include $(patsubst %.cpp,$(DEPDIR)/%.d,$(vclasses))
-include $(patsubst %.cpp,$(DEPDIR)/%.d,$(pform))
@@ -131,7 +113,6 @@ $(top_srcdir)/cpp/src/vers.cpp:
#$(OBJDIR)/vers.o: $(top_builddir)/vers.cpp
$(LIBDIR)/libopenzwave.a: $(patsubst %.cpp,$(OBJDIR)/%.o,$(tinyxml)) \
- $(patsubst %.c,$(OBJDIR)/%.o,$(hidapi)) \
$(patsubst %.c,$(OBJDIR)/%.o,$(aes)) \
$(patsubst %.cpp,$(OBJDIR)/%.o,$(cclasses)) \
$(patsubst %.cpp,$(OBJDIR)/%.o,$(vclasses)) \
@@ -143,7 +124,6 @@ $(LIBDIR)/libopenzwave.a: $(patsubst %.c
@$(RANLIB) $@
$(LIBDIR)/$(SHARED_LIB_NAME): $(patsubst %.cpp,$(OBJDIR)/%.o,$(tinyxml)) \
- $(patsubst %.c,$(OBJDIR)/%.o,$(hidapi)) \
$(patsubst %.c,$(OBJDIR)/%.o,$(aes)) \
$(patsubst %.cpp,$(OBJDIR)/%.o,$(cclasses)) \
$(patsubst %.cpp,$(OBJDIR)/%.o,$(vclasses)) \

View File

@ -0,0 +1,24 @@
--- a/cpp/src/platform/unix/SerialControllerImpl.cpp
+++ b/cpp/src/platform/unix/SerialControllerImpl.cpp
@@ -34,10 +34,6 @@
#include "SerialControllerImpl.h"
#include "platform/Log.h"
-#ifdef __linux__
-#include <libudev.h>
-#endif
-
using namespace OpenZWave;
//-----------------------------------------------------------------------------
--- a/cpp/build/Makefile
+++ b/cpp/build/Makefile
@@ -59,7 +59,7 @@ endif
else
LDFLAGS += -shared -Wl,-soname,libopenzwave.so.$(VERSION)
-LIBS += -ludev
+LIBS +=
endif
CFLAGS += $(CPPFLAGS)