-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathmodule.php
More file actions
50 lines (39 loc) · 1.52 KB
/
Copy pathmodule.php
File metadata and controls
50 lines (39 loc) · 1.52 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
<?php
class SingleIO 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->RegisterVariableFloat("Eingang", "Eingang", "", 1);
$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("Eingang")) $this->RegisterVariableFloat("Eingang", "Eingang", "", 1);
if (!@$this->GetIDForIdent("Output")) {
$this->RegisterVariableInteger("Output", "Output", "ESERA.ShutterPro");
$this->EnableAction("Output");
}
//Apply filter
$this->SetReceiveDataFilter(".*\"DeviceNumber\":". $this->ReadPropertyInteger("OWDID") .",.*");
}
public function ReceiveData($JSONString) {
$data = json_decode($JSONString);
$this->SendDebug("ESERA-SingleIO", "DataPoint:" . $data->DataPoint . " | Value: " . $data->Value, 0);
if ($this->ReadPropertyInteger("OWDID") == $data->DeviceNumber) {
if ($data->DataPoint == 1) {
$value = $data->Value / 100;
SetValue($this->GetIDForIdent("Eingang"), $value);
}
}
}
}
?>