From bdaf4c29f07feee585d648cca93bfe40f1769297 Mon Sep 17 00:00:00 2001 From: Burkhard Kneiseler Date: Sun, 5 Nov 2023 05:18:08 +0100 Subject: [PATCH 1/2] ADD: Enum - presence_state Belongs to: https://community.symcon.de/t/modul-zigbee2mqtt/49507/2609?u=burki24 ToDo: Z2M_presence_state.xxxxxx after Feedback --- libs/Zigbee2MQTTHelper.php | 21 ++++++++++++++++++++- 1 file changed, 20 insertions(+), 1 deletion(-) diff --git a/libs/Zigbee2MQTTHelper.php b/libs/Zigbee2MQTTHelper.php index 78cf0053..074df732 100644 --- a/libs/Zigbee2MQTTHelper.php +++ b/libs/Zigbee2MQTTHelper.php @@ -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']); } @@ -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], @@ -4664,6 +4677,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) { From 57a67265bd4a29ce980ef2db21be7ff451211ab2 Mon Sep 17 00:00:00 2001 From: Burkhard Kneiseler Date: Sun, 5 Nov 2023 05:20:21 +0100 Subject: [PATCH 2/2] Update locale.json --- Device/locale.json | 2 ++ 1 file changed, 2 insertions(+) diff --git a/Device/locale.json b/Device/locale.json index 71b52fc2..98eed170 100644 --- a/Device/locale.json +++ b/Device/locale.json @@ -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",