From 79ca5c95fe16eec9ac7786017812441f1636426e Mon Sep 17 00:00:00 2001 From: Burki24 Date: Fri, 3 May 2024 06:48:29 +0200 Subject: [PATCH] ADD: Aqara Smart pet feeder C1 --- Device/locale.json | 8 +++ libs/Zigbee2MQTTHelper.php | 110 +++++++++++++++++++++++++++++++++++++ 2 files changed, 118 insertions(+) diff --git a/Device/locale.json b/Device/locale.json index 366867b..a8d0e83 100644 --- a/Device/locale.json +++ b/Device/locale.json @@ -309,6 +309,9 @@ "Fan Speed": "Lüftergeschwindigkeit", "Fan State": "Lüfterstatus", "Far": "Weit", + "Feed": "Fütterung", + "Feeding Size": "Futtergröße", + "Feeding Source": "Futterquelle", "Festive Fun": "Festlicher Spaß", "Filter Age": "Filter Alter", "Fire Panic": "Feuer-Panik", @@ -544,6 +547,8 @@ "Play Pause": "Abspielen pausieren", "Police Panic": "Polizei-Panik", "Poor": "Schlecht", + "Portions Per Day": "Portionen pro Tag", + "Portion Weight": "Portionsgewicht", "Position Left": "Position Links", "Position Right": "Position Rechts", "Position": "Position", @@ -617,6 +622,7 @@ "Release 3": "Freigabe 3", "Release 4": "Freigabe 4", "Release": "Loslassen", + "Remote Control": "Fernsteuerung", "Remote Temperature": "Ferntemperatur", "Replace Filter": "Ersetze Filter", "Requested Brightness Level": "gewünschte Helligkeitsstufe", @@ -659,6 +665,7 @@ "Sensor": "Sensor", "Sensitivity": "Empfindlichkeit", "Seperated": "Getrennt", + "Serving Size": "Verteilungsgröße", "Set": "Setzen", "Set Upper Limit": "Obergrenze festlegen", "Set Bottom Limit": "Untergrenze festlegen", @@ -802,6 +809,7 @@ "Water Leak": "Wasserleck", "Wednesday": "Mittwoch", "Week Day": "Wochentag", + "Weight Per Day": "Gewicht pro Tag", "Window Detection": "Fenstererkennung", "Window Open External": "Fenster offen extern", "Window Open Feature": "Fensteröffnungsfunktion", diff --git a/libs/Zigbee2MQTTHelper.php b/libs/Zigbee2MQTTHelper.php index 6b2c9a4..dbab01e 100644 --- a/libs/Zigbee2MQTTHelper.php +++ b/libs/Zigbee2MQTTHelper.php @@ -11,6 +11,15 @@ public function RequestAction($Ident, $Value) $variableID = $this->GetIDForIdent($Ident); $variableType = IPS_GetVariable($variableID)['VariableType']; switch ($Ident) { + case 'Z2M_Feed': + $Payload['feed'] = strval($Value); + break; + case 'Z2M_ServingSize': + $Payload['serving_size'] = $Value; + break; + case 'Z2M_PortionWeight': + $Payload['portion_weight'] = $Value; + break; case 'Z2M_OccupancySensitivity': $Payload['occupancy_sensitivity'] = $Value; break; @@ -829,6 +838,36 @@ 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('feed', $Payload)) { + $this->SetValue('Z2M_Feed', $Payload['feed']); + } + if (array_key_exists('feeding_source', $Payload)) { + $this->SetValue('Z2M_FeedingSource', $Payload['feeding_source']); + } + if (array_key_exists('feeding_size', $Payload)) { + $this->SetValue('Z2M_FeedingSize', $Payload['feeding_size']); + } + if (array_key_exists('portions_per_day', $Payload)) { + $this->SetValue('Z2M_PortionsPerDay', $Payload['portions_per_day']); + } + + if (array_key_exists('weight_per_day', $Payload)) { + $this->SetValue('Z2M_WeightPerDay', $Payload['weight_per_day']); + } + if (array_key_exists('serving_size', $Payload)) { + $this->SetValue('Z2M_ServeingSize', $Payload['serving_size']); + } + if (array_key_exists('portion_weight', $Payload)) { + $this->SetValue('Z2M_PortionWeight', $Payload['portion_weight']); + } + if (array_key_exists('portions_per_day', $Payload)) { + $this->SetValue('Z2M_PortionsPerDay', $Payload['portions_per_day']); + } + + + + + if (array_key_exists('execute_if_off', $Payload)) { $this->handleStateChange('execute_if_off', 'Z2M_ExecuteIfOff', 'Execute If Off', $Payload); } @@ -2427,6 +2466,22 @@ private function registerVariableProfile($expose) $ProfileName .= '.'; $ProfileName .= dechex(crc32($tmpProfileName)); switch ($ProfileName) { + case 'Z2M.feeding_source.00000000': + if (!IPS_VariableProfileExists($ProfileName)) { + $this->RegisterProfileStringEx($ProfileName, 'Feeding Source', '', '', [ + ['schadule', $this->Translate('Schedule'), '', 0x00FF00], + ['manual', $this->Translate('Manual'), '', 0x00FF00], + ['remote', $this->Translate('Remote'), '', 0x00FF00], + ]); + } + break; + case 'Z2M.feed.00000000': + if (!IPS_VariableProfileExists($ProfileName)) { + $this->RegisterProfileStringEx($ProfileName, 'Feed', '', '', [ + ['START', $this->Translate('Start'), '', 0x00FF00], + ]); + } + break; case 'Z2M.occupancy_sensitivity.b8421401': if (!IPS_VariableProfileExists($ProfileName)) { $this->RegisterProfileStringEx($ProfileName, 'Intensity', '', '', [ @@ -4166,7 +4221,15 @@ private function registerVariableProfile($expose) $this->RegisterProfileFloat($ProfileName, 'Shuffle', '', ' ', 0, 0, 0, 2); } break; + case 'serving_size': + case 'portion_weight': + if (!IPS_VariableProfileExists($ProfileName)) { + $this->RegisterProfileInteger($ProfileName, 'Information', '', ' ' . $expose['unit'], $expose['value_min'], $expose['value_max'], 1); + } + break; case 'ac_frequency': + case 'feeding_size': + case 'weight_per_day': if (!IPS_VariableProfileExists($ProfileName)) { $this->RegisterProfileFloat($ProfileName, 'Information', '', ' ' . $expose['unit'], 0, 0, 0, 2); } @@ -4212,6 +4275,7 @@ private function registerVariableProfile($expose) case 'action_rate': case 'action_level': case 'action_transition_time': + case 'portions_per_day': if (!IPS_VariableProfileExists($ProfileName)) { $this->RegisterProfileInteger($ProfileName, 'Information', '', ' ', 0, 0, 0); } @@ -5352,6 +5416,19 @@ private function mapExposesToVariables(array $exposes) break; //binary break case 'enum': switch ($expose['property']) { + case 'feeding_source': + $ProfileName = $this->registerVariableProfile($expose); + if ($ProfileName != false) { + $this->RegisterVariableString('Z2M_FeedingSource', $this->Translate('Feeding Source'), $ProfileName); + } + break; + case 'feed': + $ProfileName = $this->registerVariableProfile($expose); + if ($ProfileName != false) { + $this->RegisterVariableString('Z2M_Feed', $this->Translate('Feed'), $ProfileName); + $this->EnableAction('Z2M_Feed'); + } + break; case 'occupancy_sensitivity': $ProfileName = $this->registerVariableProfile($expose); if ($ProfileName != false) { @@ -5856,6 +5933,39 @@ private function mapExposesToVariables(array $exposes) break; //enum break case 'numeric': switch ($expose['property']) { + case 'portions_per_day': + $ProfileName = $this->registerVariableProfile($expose); + if ($ProfileName != false) { + $this->RegisterVariableInteger('Z2M_PortionsPerDay', $this->Translate('Portions Per Day'), $ProfileName); + } + break; + case 'weight_per_day': + $ProfileName = $this->registerVariableProfile($expose); + if ($ProfileName != false) { + $this->RegisterVariableInteger('Z2M_WeightPerDay', $this->Translate('Weight Per Day'), $ProfileName); + } + break; + case 'serving_size': + $ProfileName = $this->registerVariableProfile($expose); + if ($ProfileName != false) { + $this->RegisterVariableInteger('Z2M_ServingSize', $this->Translate('Serving Size'), $ProfileName); + $this->EnableAction('Z2M_ServingSize'); + } + break; + case 'portion_weight': + $ProfileName = $this->registerVariableProfile($expose); + if ($ProfileName != false) { + $this->RegisterVariableInteger('Z2M_PortionWeight', $this->Translate('Portion Weight'), $ProfileName); + $this->EnableAction('Z2M_PortionWeight'); + } + break; + case 'feeding_size': + $ProfileName = $this->registerVariableProfile($expose); + if ($ProfileName != false) { + $this->RegisterVariableInteger('Z2M_FeedingSize', $this->Translate('Feeding Size'), $ProfileName); + $this->EnableAction('Z2M_FeedingSize'); + } + break; case 'voc_index': $ProfileName = $this->registerVariableProfile($expose); if ($ProfileName != false) {