Skip to content

Commit

Permalink
Merge pull request #150 from Burki24/patch-1
Browse files Browse the repository at this point in the history
ADD: Z2M_TransmitPower
  • Loading branch information
Schnittcher authored Nov 28, 2023
2 parents 6952850 + 373e6b9 commit b8741f5
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 3 deletions.
3 changes: 2 additions & 1 deletion Device/locale.json
Original file line number Diff line number Diff line change
Expand Up @@ -621,6 +621,7 @@
"Toggle": "Wechsel",
"Toilet": "Badezimmer",
"Tokyo": "Tokio",
"Transmit Power": "Signalstärke",
"Trigger Indicator": "Auslöseanzeige",
"Trigger Time": "Auslösezeit",
"Trigger": "Auslöser",
Expand Down Expand Up @@ -677,4 +678,4 @@
"Near": "Reset"
}
}
}
}
21 changes: 19 additions & 2 deletions libs/Zigbee2MQTTHelper.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,12 +11,15 @@ public function RequestAction($Ident, $Value)
$variableID = $this->GetIDForIdent($Ident);
$variableType = IPS_GetVariable($variableID)['VariableType'];
switch ($Ident) {
case 'Z2M_TransmitPower':
$Payload['transmit_power'] = $Value;
break;
case 'Z2M_PresenceSensitivity':
$Payload['presence_sensitivity'] = $Value;
break;
break;
case 'Z2M_DetectionDistanceMin':
$Payload['detection_distance_min'] = $Value;
break;
break;
case 'Z2M_DetectionDistanceMax':
$Payload['detection_distance_max'] = $Value;
break;
Expand Down Expand Up @@ -667,6 +670,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('transmit_power', $Payload)) {
$this->SetValue('Z2M_TransmitPower', $Payload['transmit_power']);
}
if (array_key_exists('presence_sensitivity', $Payload)) {
$this->SetValue('Z2M_PresenceSensitivity', $Payload['presence_sensitivity']);
}
Expand Down Expand Up @@ -3748,6 +3754,13 @@ private function registerVariableProfile($expose)
$this->RegisterProfileFloat($ProfileName, 'Distance', '', ' m', $expose['value_min'], $expose['value_max'], $expose['value_step'], 0);
}
break;
case 'transmit_power':
$ProfileName .= $expose['value_min'] . '_' . $expose['value_max'];
$ProfileName = str_replace(',', '.', $ProfileName);
if (!IPS_VariableProfileExists($ProfileName)) {
$this->RegisterProfileFloat($ProfileName, 'Intensity', '', ' dBm', $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 @@ -5263,6 +5276,10 @@ private function mapExposesToVariables(array $exposes)
break;
case 'sensitivity':
$ProfileName = $this->registerVariableProfile($expose);
if ($ProfileName != false) {
$this->RegisterVariableFloat('Z2M_TransmitPower', $this->Translate('Transmit Power'), $ProfileName);
}
break;
if ($ProfileName != false) {
$this->RegisterVariableFloat('Z2M_Sensitivity', $this->Translate('Sensitivity'), $ProfileName);
$this->EnableAction('Z2M_Sensitivity');
Expand Down

0 comments on commit b8741f5

Please sign in to comment.