Skip to content

Commit

Permalink
ADD: Aqara Smart pet feeder C1
Browse files Browse the repository at this point in the history
  • Loading branch information
Burki24 committed May 3, 2024
1 parent 45b5c8e commit 79ca5c9
Show file tree
Hide file tree
Showing 2 changed files with 118 additions and 0 deletions.
8 changes: 8 additions & 0 deletions Device/locale.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down Expand Up @@ -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",
Expand Down Expand Up @@ -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",
Expand Down Expand Up @@ -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",
Expand Down Expand Up @@ -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",
Expand Down
110 changes: 110 additions & 0 deletions libs/Zigbee2MQTTHelper.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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);
}
Expand Down Expand Up @@ -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', '', '', [
Expand Down Expand Up @@ -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);
}
Expand Down Expand Up @@ -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);
}
Expand Down Expand Up @@ -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) {
Expand Down Expand Up @@ -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) {
Expand Down

0 comments on commit 79ca5c9

Please sign in to comment.