-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathmodule.php
More file actions
63 lines (53 loc) · 2.38 KB
/
Copy pathmodule.php
File metadata and controls
63 lines (53 loc) · 2.38 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
<?php
class EseraDualIO extends IPSModule {
public function Create(){
//Never delete this line!
parent::Create();
//These lines are parsed on Symcon Startup or Instance creation
//You cannot use variables here. Just static values.
$this->RegisterPropertyInteger("OWDID", 1);
$this->RegisterVariableInteger("Eingang0", "Eingang 0", "", 1);
$this->RegisterVariableInteger("Eingang1", "Eingang 1", "", 2);
$this->RegisterVariableInteger("Status0", "Status 0", "", 3);
$this->RegisterVariableInteger("Status1", "Status 1", "", 4);
$this->ConnectParent("{FCABCDA7-3A57-657D-95FD-9324738A77B9}"); //1Wire Controller
}
public function Destroy(){
//Never delete this line!
parent::Destroy();
}
public function ApplyChanges() {
//Never delete this line!
parent::ApplyChanges();
// Variables
if (!@$this->GetIDForIdent("Eingang0")) $this->RegisterVariableInteger("Eingang0", "Eingang 0", "", 1);
if (!@$this->GetIDForIdent("Eingang1")) $this->RegisterVariableInteger("Eingang1", "Eingang 1", "", 2);
if (!@$this->GetIDForIdent("Status0")) $this->RegisterVariableInteger("Status0", "Status 0", "", 3);
if (!@$this->GetIDForIdent("Status1")) $this->RegisterVariableInteger("Status1", "Status 1", "", 4);
//Apply filter
$this->SetReceiveDataFilter(".*\"DeviceNumber\":". $this->ReadPropertyInteger("OWDID") .",.*");
}
public function ReceiveData($JSONString) {
$data = json_decode($JSONString);
$this->SendDebug("ESERA-DualIO", "DataPoint:" . $data->DataPoint . " | Value: " . $data->Value, 0);
if ($this->ReadPropertyInteger("OWDID") == $data->DeviceNumber) {
if ($data->DataPoint == 1) {
$value = $data->Value;
SetValue($this->GetIDForIdent("Eingang0"), $value);
}
if ($data->DataPoint == 2) {
$value = $data->Value;
SetValue($this->GetIDForIdent("Eingang1"), $value);
}
if ($data->DataPoint == 3) {
$value = $data->Value;
SetValue($this->GetIDForIdent("Status0"), $value);
}
if ($data->DataPoint == 4) {
$value = $data->Value;
SetValue($this->GetIDForIdent("Status1"), $value);
}
}
}
}
?>