Skip to content

Commit

Permalink
Merge branch 'testing'
Browse files Browse the repository at this point in the history
  • Loading branch information
hfedcba committed Sep 18, 2018
2 parents 09db5fb + f85083a commit ec78ab1
Show file tree
Hide file tree
Showing 119 changed files with 17,873 additions and 14,888 deletions.
2 changes: 1 addition & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -110,6 +110,6 @@ set(SOURCE_FILES
src/Monitor.h
config.h src/ScriptEngine/CacheInfo.h)

add_custom_target(homegear COMMAND ../../makeAll.sh SOURCES ${SOURCE_FILES})
add_custom_target(homegear COMMAND ../../devscripts/makeAll.sh SOURCES ${SOURCE_FILES})

add_library(homegear-dummy ${SOURCE_FILES})
4 changes: 2 additions & 2 deletions debian/control
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,12 @@ Maintainer: Sathya Laufer <sathya@laufers.net>
Section: misc
Priority: optional
Standards-Version: 3.9.6
Build-Depends: debhelper (>= 8), libhomegear-base (= <BASELIBVER>), libhomegear-node, libhomegear-ipc, libsqlite3-dev (>= 3.7.13), libreadline6-dev | libreadline-dev, libgcrypt20-dev, libgpg-error-dev (>= 1.10), libgnutls28-dev, php7-homegear-dev, libxslt1-dev, libedit-dev, libenchant-dev, libqdbm-dev, libltdl-dev, zlib1g-dev, libtinfo-dev, libgmp-dev, libxml2-dev, libssl-dev, libcurl4-gnutls-dev
Build-Depends: debhelper (>= 8), libhomegear-base (= <BASELIBVER>), libhomegear-node, libhomegear-ipc, libsqlite3-dev (>= 3.7.13), libreadline6-dev | libreadline-dev, libgcrypt20-dev, libgpg-error-dev (>= 1.10), libgnutls28-dev, php7-homegear-dev, libxslt1-dev, libedit-dev, libenchant-dev, libqdbm-dev, libltdl-dev, zlib1g-dev, libtinfo-dev, libgmp-dev, libxml2-dev, libssl-dev, libcurl4-gnutls-dev, zlib1g-dev, libicu-dev
Homepage: https://homegear.eu

Package: homegear
Architecture: any
Depends: ${shlibs:Depends}, ${misc:Depends}, libhomegear-base (= <BASELIBVER>), libhomegear-node, libhomegear-ipc, wget, libsqlite3-0 (>= 3.7.13), libreadline7 | libreadline6, adduser (>= 3.113), libgcrypt20, libgnutlsxx28, libgpg-error0 (>= 1.10), unzip (>= 6.0), p7zip-full (>= 9.0), procps, libxslt1.1, libedit2, libenchant1c2a, libqdbm14, libltdl7, zlib1g, libtinfo5, libgmp10, libxml2, libssl1.1 | libssl1.0.0, openssl, libcurl3-gnutls, libmariadbclient20 | libmariadbclient18 | libmysqlclient20 | libmysqlclient18
Depends: ${shlibs:Depends}, ${misc:Depends}, libhomegear-base (= <BASELIBVER>), libhomegear-node, libhomegear-ipc, wget, libsqlite3-0 (>= 3.7.13), libreadline7 | libreadline6, adduser (>= 3.113), libgcrypt20, libgnutlsxx28, libgpg-error0 (>= 1.10), unzip (>= 6.0), p7zip-full (>= 9.0), procps, libxslt1.1, libedit2, libenchant1c2a, libqdbm14, libltdl7, zlib1g, libtinfo5, libgmp10, libxml2, libssl1.1 | libssl1.0.0, openssl, libcurl3-gnutls, libmariadbclient20 | libmariadbclient18 | libmysqlclient20 | libmysqlclient18, zlib1g, libicu52 | libicu55 | libicu57 | libicu60
Replaces: homegear (<< 0.6)
Breaks: homegear (<< 0.6)
Description: Interface program to your smart home devices
Expand Down
2 changes: 1 addition & 1 deletion debian/postinst
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ case $1 in
chown homegear:homegear /var/lib/homegear
chmod 750 /var/lib/homegear

if test ! -e /var/lib/homegear/scripts/HM-XMLRPC-Client; then
if test ! -e /tmp/HOMEGEAR_STATIC_INSTALLATION && test ! -e /var/lib/homegear/scripts/HM-XMLRPC-Client; then
rm -Rf /tmp/HomegearScriptsDir
[ $? -ne 0 ] && exit 1
mkdir /tmp/HomegearScriptsDir
Expand Down
5 changes: 4 additions & 1 deletion debian/rules
Original file line number Diff line number Diff line change
Expand Up @@ -50,8 +50,11 @@ override_dh_auto_install:
chmod 755 $(CURDIR)/debian/homegear/var/lib/homegear/scripts/*.sh

mkdir -p $(CURDIR)/debian/homegear/usr/share/homegear
cp -R /usr/share/homegear/php/ $(CURDIR)/debian/homegear/usr/share/homegear
rm -f $(CURDIR)/debian/homegear/usr/share/homegear/php/*/*.a
chown -R root:root $(CURDIR)/debian/homegear/usr/share/homegear
chmod -R 550 $(CURDIR)/debian/homegear/usr/share/homegear
find $(CURDIR)/debian/homegear/usr/share/homegear -type d -exec chmod 555 {} \;
find $(CURDIR)/debian/homegear/usr/share/homegear -type f -exec chmod 444 {} \;

override_dh_strip:
dh_strip --dbg-package=homegear
Expand Down
4 changes: 2 additions & 2 deletions git-pre-commit
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,11 @@ SCRIPTDIR="$( cd "$(dirname $0)" && pwd )"

cd $SCRIPTDIR/../../../libhomegear-base
BRANCH=$(git branch | grep "\*")
[[ "$BRANCH" == "* master" ]] && exit 0
[[ "$BRANCH" == "* master" || "$BRANCH" == "* testing" ]] && exit 0

cd $SCRIPTDIR/../..
BRANCH=$(git branch | grep "\*")
[[ "$BRANCH" == "* master" ]] && exit 0
[[ "$BRANCH" == "* master" || "$BRANCH" == "* testing" ]] && exit 0

REVISION_FILE=$SCRIPTDIR/../../../libhomegear-base/revision.txt
REVISION=$(cat $REVISION_FILE)
Expand Down
201 changes: 201 additions & 0 deletions homegear-miscellaneous/misc/Device Description Files/VirtualDimmer.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,201 @@
<?xml version="1.0" encoding="utf-8"?>
<homegearDevice xmlns="https://homegear.eu/xmlNamespaces/HomegearDevice" version="1">
<supportedDevices xmlns="https://homegear.eu/xmlNamespaces/DeviceType">
<device id="VirtualDimmer">
<description>VirtualDimmer</description>
<typeNumber>0xF001</typeNumber>
</device>
</supportedDevices>
<runProgram>
<startType>permanent</startType>
<script2>
<![CDATA[<?php
/**
* Class to share data between the main script and the event thread.
*/
class SharedData extends Threaded
{
public $scriptId = 0;
public $peerId = 0;
public $stop = false;
public $eventThread = NULL;
public function run() {}
}
class EventThread extends Thread
{
private $sharedData;
public function __construct($sharedData)
{
$this->sharedData = $sharedData;
}
public function run()
{
$hg = new \Homegear\Homegear();
if($hg->registerThread($this->sharedData->scriptId) === false)
{
$hg->log(2, "Could not register thread.");
return;
}
$hg->subscribePeer($this->sharedData->peerId);
while(!$this->sharedData->stop)
{
$result = $hg->pollEvent();
if($result["TYPE"] == "event" && $result["PEERID"] == $this->sharedData->peerId && $result["EVENTSOURCE"] && $result["EVENTSOURCE"] != 'device-'.$this->sharedData->peerId)
{
if($result["VARIABLE"] == 'LEVEL')
{
$hg->setValue($this->sharedData->peerId, 1, 'STATE', $result["VALUE"] != 0);
$hg->setValue($this->sharedData->peerId, 1, 'LEVEL_FAST', $result["VALUE"]);
}
else if($result["VARIABLE"] == 'LEVEL_FAST')
{
$hg->setValue($this->sharedData->peerId, 1, 'STATE', $result["VALUE"] != 0);
$hg->setValue($this->sharedData->peerId, 1, 'LEVEL', $result["VALUE"]);
}
else if($result["VARIABLE"] == 'STATE')
{
$hg->setValue($this->sharedData->peerId, 1, 'LEVEL', $result["VALUE"] ? $hg->getValue($this->sharedData->peerId, 1, 'STATE_LEVEL') : 0);
$hg->setValue($this->sharedData->peerId, 1, 'LEVEL_FAST', $result["VALUE"] ? $hg->getValue($this->sharedData->peerId, 1, 'STATE_LEVEL') : 0);
}
}
}
}
}
class HomegearDevice extends HomegearDeviceBase
{
private $hg = NULL;
private $peerId = NULL;
private $sharedData = NULL;
private $eventThread = NULL;
function __construct()
{
$this->hg = new \Homegear\Homegear();
}
function __destruct()
{
$this->stop();
$this->waitForStop();
}
public function init($peerId) : bool
{
$this->peerId = $peerId;
return true;
}
public function start() : bool
{
$this->sharedData = new SharedData();
$this->sharedData->peerId = $this->peerId;
$this->sharedData->scriptId = $this->hg->getScriptId();
$this->eventThread = new EventThread($this->sharedData);
$this->eventThread->start();
$this->sharedData->eventThread = $this->eventThread;
return true;
}
public function stop()
{
if($this->eventThread) $this->sharedData->stop = true;
}
public function waitForStop()
{
if($this->eventThread) $this->eventThread->join();
$this->eventThread = NULL;
}
}
]]>
</script2>
</runProgram>
<properties/>
<functions xmlns="https://homegear.eu/xmlNamespaces/DeviceType">
<function xmlns="https://homegear.eu/xmlNamespaces/FunctionGroupType" channel="0" type="MAINTENANCE">
<properties>
<internal>true</internal>
</properties>
<configParameters>config</configParameters>
</function>
<function xmlns="https://homegear.eu/xmlNamespaces/FunctionGroupType" channel="1" type="VirtualDimmer">
<variables>custom_ch1_values</variables>
</function>
</functions>
<parameterGroups xmlns="https://homegear.eu/xmlNamespaces/DeviceType">
<configParameters id="config"/>
<variables id="custom_ch1_values">
<parameter id="LEVEL">
<properties>
<readable>true</readable>
<writeable>true</writeable>
</properties>
<logicalInteger>
<minimumValue>0</minimumValue>
<maximumValue>100</maximumValue>
<defaultValue>0</defaultValue>
</logicalInteger>
<physicalNone>
<operationType>store</operationType>
</physicalNone>
</parameter>
<parameter id="LEVEL_FAST">
<properties>
<readable>true</readable>
<writeable>true</writeable>
</properties>
<logicalInteger>
<minimumValue>0</minimumValue>
<maximumValue>100</maximumValue>
<defaultValue>0</defaultValue>
</logicalInteger>
<physicalNone>
<operationType>store</operationType>
</physicalNone>
</parameter>
<parameter id="DIM_SPEED">
<properties>
<readable>true</readable>
<writeable>true</writeable>
</properties>
<logicalInteger>
<minimumValue>0</minimumValue>
<maximumValue>255</maximumValue>
<defaultValue>0</defaultValue>
</logicalInteger>
<physicalNone>
<operationType>store</operationType>
</physicalNone>
</parameter>
<parameter id="STATE_LEVEL">
<properties>
<readable>true</readable>
<writeable>true</writeable>
</properties>
<logicalInteger>
<minimumValue>0</minimumValue>
<maximumValue>100</maximumValue>
<defaultValue>0</defaultValue>
</logicalInteger>
<physicalNone>
<operationType>store</operationType>
</physicalNone>
</parameter>
<parameter id="STATE">
<properties>
<readable>true</readable>
<writeable>true</writeable>
</properties>
<logicalBoolean/>
<physicalNone>
<operationType>store</operationType>
</physicalNone>
</parameter>
</variables>
</parameterGroups>
</homegearDevice>
Original file line number Diff line number Diff line change
@@ -1,55 +1,56 @@
<?xml version="1.0" encoding="utf-8"?>
<homegearUiElements lang="en-US">
<homegearUiElement>
<id>254.100.Refresh</id>
<uniqueUiElementId>254.0x100.Refresh</uniqueUiElementId>
<type>simple</type>
<control>button</control>
<icons>
<icon>
<icon id="refresh">
<name>refresh</name>
</icon>
</icons>
<variableOutputs>
<variable>
<familyId>254</familyId>
<family>254</family>
<deviceTypeId>0x100</deviceTypeId>
<channel>1</channel>
<name>REQUEST</name>
</variable>
</variableOutputs>
</homegearUiElement>
<homegearUiElement>
<id>254.100.OpenWeatherMap</id>
<id>254.0x100.OpenWeatherMap</id>
<type>complex</type>
<icons>
<icon>
<icon id="weather">
<name>weather</name>
</icon>
</icons>
<width>3</width>
<height>3</height>
<cols>1</cols>
<rows>3</rows>
<grid>
<width>3</width>
<height>3</height>
<columns>1</columns>
<rows>3</rows>
</grid>
<controls>
<control id="Base.Temperature.Channel1">
<posX>0</posX>
<posY>0</posY>
<colWidth>1</colWidth>
<control id="Base.Temperature">
<x>0</x>
<y>0</y>
<columns>1</columns>
<rows>1</rows>
</control>
<control id="Base.Humidity.Channel1">
<posX>0</posX>
<posY>1</posY>
<colWidth>1</colWidth>
<control id="Base.Humidity">
<x>0</x>
<y>1</y>
<columns>1</columns>
<rows>1</rows>
</control>
<control id="254.100.Refresh">
<posX>0</posX>
<posY>2</posY>
<colWidth>1</colWidth>
<control id="254.0x100.Refresh">
<x>0</x>
<y>2</y>
<columns>1</columns>
<rows>1</rows>
</control>
</controls>
<metadata>
<!--<foo></foo>-->
<!--<bar></bar>-->
</metadata>
</homegearUiElement>
</homegearUiElements>
8 changes: 5 additions & 3 deletions homegear-miscellaneous/src/MiscPeer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ MiscPeer::~MiscPeer()
if(_scriptInfo)
{
int32_t i = 0;
while(!_scriptInfo->finished && i < 30)
while(_scriptRunning && !_scriptInfo->finished && i < 30)
{
GD::out.printInfo("Info: Peer " + std::to_string(_peerID) + " Waiting for script to finish...");
std::this_thread::sleep_for(std::chrono::milliseconds(1000));
Expand Down Expand Up @@ -153,7 +153,7 @@ void MiscPeer::stopScript(bool callStop)

int32_t i = 0;
_stopRunProgramThread = true;
if(!(!_rpcDevice->runProgram->script2.empty() && _shuttingDown && !GD::bl->shuttingDown))
if(!_rpcDevice->runProgram->script2.empty())
{
while(_scriptRunning && i < 30)
{
Expand All @@ -162,6 +162,8 @@ void MiscPeer::stopScript(bool callStop)
i++;
}
if(i == 30) GD::out.printError("Error: Script of peer " + std::to_string(_peerID) + " did not finish.");
std::lock_guard<std::mutex> scriptInfoGuard(_scriptInfoMutex);
if(_scriptInfo) _scriptInfo->scriptFinishedCallback = nullptr;
}

if(_programPID != -1)
Expand Down Expand Up @@ -357,7 +359,7 @@ void MiscPeer::scriptFinished(BaseLib::ScriptEngine::PScriptInfo& scriptInfo, in
_bl->threadManager.start(_runProgramThread, true, &MiscPeer::runScript, this, BaseLib::HelperFunctions::getTime() - _lastScriptFinished.load() < 10000 ? 10000 : 0);
_lastScriptFinished.store(BaseLib::HelperFunctions::getTime());
}
else if(deleting) GD::out.printInfo("Info: Script of peer " + std::to_string(_peerID) + " finished.");
else GD::out.printInfo("Info: Script of peer " + std::to_string(_peerID) + " finished.");
}
catch(const std::exception& ex)
{
Expand Down

0 comments on commit ec78ab1

Please sign in to comment.