Skip to content

Commit

Permalink
Merge pull request #139 from Burki24/patch-2
Browse files Browse the repository at this point in the history
ADD: Enum - presence_state
  • Loading branch information
Schnittcher authored Nov 6, 2023
2 parents 1fee8b7 + 57a6726 commit 5f28b54
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 1 deletion.
2 changes: 2 additions & 0 deletions Device/locale.json
Original file line number Diff line number Diff line change
Expand Up @@ -461,7 +461,9 @@
"Power": "Leistung",
"Precious": "Kostbar",
"Preheat Status": "Vorheizstatus",
"Presence": "Anwesendheit",
"Presence State": "Präsenz Status",
"Present": "Anwesend",
"Preset": "Default",
"Press 1": "Drücke 1",
"Press 2": "Drücke 2",
Expand Down
21 changes: 20 additions & 1 deletion libs/Zigbee2MQTTHelper.php
Original file line number Diff line number Diff line change
Expand Up @@ -640,6 +640,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('presence_state', $Payload)) {
$this->SetValue('Z2M_PresenceState', $Payload['presence_state']);
}
if (array_key_exists('action_zone', $Payload)) {
$this->SetValue('Z2M_ActionZone', $Payload['action_zone']);
}
Expand Down Expand Up @@ -2315,7 +2318,17 @@ private function registerVariableProfile($expose)
$ProfileName .= '.';
$ProfileName .= dechex(crc32($tmpProfileName));
switch ($ProfileName) {
case 'Z2M.device_mode':
case 'Z2M.presence_state.':
if (!IPS_VariableProfileExists($ProfileName)) {
$this->RegisterProfileStringEx($ProfileName, 'Information', '', '', [
['none', $this->Translate('None'), '', 0xFF0000],
['present', $this->Translate('Present'), '', 0x00FF00],
['moving', $this->Translate('Moving'), '', 0x00FF00],
['presence', $this->Translate('Presence'), '', 0x00FF00]
]);
}
break;
case 'Z2M.device_mode.':
if (!IPS_VariableProfileExists($ProfileName)) {
$this->RegisterProfileStringEx($ProfileName, 'Information', '', '', [
['single_rocker', $this->Translate('Single Rocker'), '', 0xFF0000],
Expand Down Expand Up @@ -4677,6 +4690,12 @@ private function mapExposesToVariables(array $exposes)
break; //binary break
case 'enum':
switch ($expose['property']) {
case 'presence_state':
$ProfileName = $this->registerVariableProfile($expose);
if ($ProfileName != false) {
$this->RegisterVariableString('Z2M_PresenceState', $this->Translate('Presence State'), $ProfileName);
}
break;
case 'device_mode':
$ProfileName = $this->registerVariableProfile($expose);
if ($ProfileName != false) {
Expand Down

0 comments on commit 5f28b54

Please sign in to comment.