/
module.php
162 lines (147 loc) · 4.55 KB
/
module.php
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
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
<?php
declare(strict_types=1);
/**
* @addtogroup HomeMaticExtended
* @{
*
* @file module.php
*
* @author Michael Tröger <micha@nall-chan.net>
* @copyright 2023 Michael Tröger
* @license https://creativecommons.org/licenses/by-nc-sa/4.0/ CC BY-NC-SA 4.0
*
* @version 3.73
*/
require_once __DIR__ . '/../libs/HMBase.php'; // HMBase Klasse
/**
* HomeMaticParasetInterface ist die Klasse für das IPS-Modul 'HomeMatic Paraset Interface'.
* Erweitert HMBase.
*/
class HomeMaticParasetInterface extends HMBase
{
/**
* Interne Funktion des SDK.
*/
public function Create()
{
parent::Create();
$this->RegisterPropertyBoolean(\HMExtended\Device\Property::EmulateStatus, false);
$this->RegisterPropertyString(\HMExtended\Device\Property::Address, '');
$this->RegisterPropertyInteger(\HMExtended\Device\Property::Protocol, 0);
}
/**
* Interne Funktion des SDK.
*/
public function ApplyChanges()
{
parent::ApplyChanges();
$this->SetReceiveDataFilter('.*9999999999.*');
if (IPS_GetKernelRunlevel() != KR_READY) {
return;
}
}
//################# PUBLIC
/**
* IPS-Instanz-Funktion 'HM_ReadParamSet'.
* Liest die Daten des WR-Interface.
*
* @return bool True bei Erfolg, sonst false.
*/
public function ReadParamSet()
{
return $this->GetParamSet($this->ReadPropertyString(\HMExtended\Device\Property::Address), \HMExtended\CCU::MASTER);
}
/**
* IPS-Instanz-Funktion 'HM_WriteParameterBoolean'.
* Liest die Daten des WR-Interface.
*
* @return bool True bei Erfolg, sonst false.
*/
public function WriteParameterBoolean(string $Parameter, bool $Data)
{
$Result = $this->PutParamSet([$Parameter=> $Data]);
return $Result;
}
/**
* IPS-Instanz-Funktion 'HM_WriteParameterInteger'.
* Liest die Daten des WR-Interface.
*
* @return bool True bei Erfolg, sonst false.
*/
public function WriteParameterInteger(string $Parameter, int $Data)
{
$Result = $this->PutParamSet([$Parameter=> $Data]);
return $Result;
}
/**
* IPS-Instanz-Funktion 'HM_WriteParameterFloat'.
* Liest die Daten des WR-Interface.
*
* @return bool True bei Erfolg, sonst false.
*/
public function WriteParameterFloat(string $Parameter, float $Data)
{
$Result = $this->PutParamSet([$Parameter=> $Data]);
return $Result;
}
/**
* IPS-Instanz-Funktion 'HM_WriteParameterString'.
* Liest die Daten des WR-Interface.
*
* @return bool True bei Erfolg, sonst false.
*/
public function WriteParameterString(string $Parameter, string $Data)
{
$Result = $this->PutParamSet([$Parameter=> $Data]);
return $Result;
}
/**
* IPS-Instanz-Funktion 'HM_WriteParamSet'.
* Liest die Daten des WR-Interface.
*
* @return bool True bei Erfolg, sonst false.
*/
public function WriteParamSet(string $ParamSet)
{
$Data = @json_decode($ParamSet, true);
if ($Data === false) {
trigger_error('Error in Parameter', E_USER_NOTICE);
return false;
}
$Result = $this->PutParamSet($Data);
return $Result;
}
//################# PRIVATE
/**
* Schreibt Parameter zu einem Devices.
*
* @return bool
*/
private function PutParamSet(array $Parameter)
{
if (!$this->HasActiveParent()) {
trigger_error($this->Translate('Instance has no active Parent Instance!'), E_USER_NOTICE);
return false;
}
$EmulateStatus = $this->ReadPropertyBoolean(\HMExtended\Device\Property::EmulateStatus);
$ParentData = [
'DataID' => \HMExtended\GUID::SendRpcToIO,
'Protocol' => $this->ReadPropertyInteger(\HMExtended\Device\Property::Protocol),
'MethodName' => 'PutParamSet',
'WaitTime' => 3,
'Data' => [$this->ReadPropertyString(\HMExtended\Device\Property::Address), \HMExtended\CCU::MASTER, json_encode($Parameter)]
];
$this->SendDebug('Send', $ParentData, 0);
$Result = @$this->SendDataToParent(json_encode($ParentData));
if ($EmulateStatus) {
return true;
}
if ($Result === false) {
trigger_error('Error on Write Paramset', E_USER_NOTICE);
$this->SendDebug('Error', '', 0);
return false;
}
return true;
}
}
/* @} */