Skip to content

Commit

Permalink
Merge pull request #141 from Burki24/patch-4
Browse files Browse the repository at this point in the history
ADD: numeric - Z2M_DetectionDistanceMax
  • Loading branch information
Schnittcher authored Nov 6, 2023
2 parents cbe6912 + bf3c6fc commit 1c28fff
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 0 deletions.
1 change: 1 addition & 0 deletions Device/locale.json
Original file line number Diff line number Diff line change
Expand Up @@ -206,6 +206,7 @@
"Deadzone Temperature": "Totzonentemperatur",
"Default": "Default",
"Detection Delay": "Erkennungsverzögerung",
"Detection Distance Max": "Erkennungsbereich Max",
"Detection Interval": "Erkennungsintervall",
"Device Temperature": "Geräte Temperatur",
"Dial Rotate Left Fast": "Rad schnell links gedreht",
Expand Down
20 changes: 20 additions & 0 deletions libs/Zigbee2MQTTHelper.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,9 @@ public function RequestAction($Ident, $Value)
$variableID = $this->GetIDForIdent($Ident);
$variableType = IPS_GetVariable($variableID)['VariableType'];
switch ($Ident) {
case 'Z2M_DetectionDistanceMax':
$Payload['detection_distance_max'] = $Value;
break;
case 'Z2M_DeviceMode':
$Payload['device_mode'] = $Value;
break;
Expand Down Expand Up @@ -640,6 +643,9 @@ public function ReceiveData($JSONString)
$this->RegisterVariableInteger('Z2M_LastSeen', $this->Translate('Last Seen'), '~UnixTimestamp');
$this->SetValue('Z2M_LastSeen', ($Payload['last_seen'] / 1000));
}
if (array_key_exists('detection_distance_max', $Payload)) {
$this->SetValue('Z2M_DetectionDistanceMax', $Payload['detection_distance_max']);
}
if (array_key_exists('presence_state', $Payload)) {
$this->SetValue('Z2M_PresenceState', $Payload['presence_state']);
}
Expand Down Expand Up @@ -3602,6 +3608,13 @@ private function registerVariableProfile($expose)
break;
case 'numeric':
switch ($expose['property']) {
case 'detection_distance_max':
$ProfileName .= $expose['value_min'] . '_' . $expose['value_max'];
$ProfileName = str_replace(',', '.', $ProfileName);
if (!IPS_VariableProfileExists($ProfileName)) {
$this->RegisterProfileFloat($ProfileName, 'Distance', '', ' m', $expose['value_min'], $expose['value_max'], $expose['value_step'], 0);
}
break;
case 'motion_sensitivity':
$ProfileName .= $expose['value_min'] . '_' . $expose['value_max'];
$ProfileName = str_replace(',', '.', $ProfileName);
Expand Down Expand Up @@ -5066,6 +5079,13 @@ private function mapExposesToVariables(array $exposes)
break; //enum break
case 'numeric':
switch ($expose['property']) {
case 'detection_distance_max':
$ProfileName = $this->registerVariableProfile($expose);
if ($ProfileName != false) {
$this->RegisterVariableFloat('Z2M_DetectionDistanceMax', $this->Translate('Detection Distance Max'), $ProfileName);
$this->EnableAction('Z2M_DetectionDistanceMax');
}
break;
case 'error':
$ProfileName = $this->registerVariableProfile($expose);
if ($ProfileName != false) {
Expand Down

0 comments on commit 1c28fff

Please sign in to comment.