-
Notifications
You must be signed in to change notification settings - Fork 37
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
119 changed files
with
17,873 additions
and
14,888 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
201 changes: 201 additions & 0 deletions
201
homegear-miscellaneous/misc/Device Description Files/VirtualDimmer.xml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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> |
51 changes: 26 additions & 25 deletions
51
homegear-miscellaneous/misc/Device Description Files/ui/en-US/OpenWeatherMap.xml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.