Skip to content

Commit

Permalink
Merge pull request #189 from Burki24/patch_6
Browse files Browse the repository at this point in the history
  • Loading branch information
Schnittcher authored May 27, 2024
2 parents 727619e + e782734 commit c5c653a
Show file tree
Hide file tree
Showing 2 changed files with 251 additions and 0 deletions.
11 changes: 11 additions & 0 deletions Device/locale.json
Original file line number Diff line number Diff line change
Expand Up @@ -252,6 +252,7 @@
"Display Ontime": "Display Einschaltdauer",
"Display Orientation": "Display Ausrichtung",
"Displayed Temperature": "Angezeigte Temperatur",
"Total Dissolved Solids": "Gesamtmenge gelöster Feststoffe",
"Distance": "Entfernung",
"Disturbia": "Störungen",
"Dots 1 Double Press": "Taster 1 doppelt gedrückt",
Expand Down Expand Up @@ -284,6 +285,9 @@
"Eco Temperature": "Eco Temperatur",
"Eco": "Eco",
"Effect": "Effekt",
"Electrical Conductivity": "Elektrische Konductivität",
"Electrical Conductivity Max": "Elektrische Konductivität Max",
"Electrical Conductivity Min": "Elektrische Konductivität Min",
"Emerald Flutter": "Smaragd Flattern",
"Emerald Isle": "Grüne Insel",
"Emergency Panic": "Notfall-Panik",
Expand Down Expand Up @@ -325,6 +329,9 @@
"Formaldehyd": "Formaldehyd",
"Forward": "Vorwärts",
"Found": "Gefunden",
"Free Chlorine": "Freies Chlor",
"Free Chlorine Max": "Freies Chlor Max",
"Free Chlorine Min": "Freies Chlor Min",
"Friday": "Freitag",
"Frost Protection": "Frostschutz",
"Frosty Dawn": "Frostige Dämmerung",
Expand Down Expand Up @@ -537,6 +544,9 @@
"OU": "OU",
"Out of range": "Außer Reichweite",
"Overload Protection": "Überspannungschutz",
"Oxidation Reduction Potential": "Oxidationsreduktionswert",
"Oxidation Reduction Potential Min": "Oxidationsreduktionswert Min",
"Oxidation Reduction Potential Max": "Oxidationsreduktionswert Max",
"Undirected": "Ungerichtet",
"Left/Right": "Links/Rechts",
"Painted Sky": "Gemalter Himmel",
Expand Down Expand Up @@ -645,6 +655,7 @@
"Ruby Romance": "Rubinromantik",
"Running State": "Betriebszustand",
"Runy Glow": "Flüssiges Glühen",
"Salinity": "Salzgehalt",
"Saturday": "Samstag",
"Savanna Sunset": "Savanna Sonnenuntergang",
"Scale Protection": "Ventil Schutz",
Expand Down
240 changes: 240 additions & 0 deletions libs/Zigbee2MQTTHelper.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,30 @@ public function RequestAction($Ident, $Value)
$variableID = $this->GetIDForIdent($Ident);
$variableType = IPS_GetVariable($variableID)['VariableType'];
switch ($Ident) {
case 'Z2M_PHMax':
$Payload['ph_max'] = $Value;
break;
case 'Z2M_PHMin':
$Payload['ph_min'] = $Value;
break;
case 'Z2M_ECMax':
$Payload['ec_max'] = $Value;
break;
case 'Z2M_ECMin':
$Payload['ec_min'] = $Value;
break;
case 'Z2M_ORPMax':
$Payload['orp_max'] = $Value;
break;
case 'Z2M_ORPMin':
$Payload['orp_min'] = $Value;
break;
case 'Z2M_FreeChlorineMax':
$Payload['free_chlorine_max'] = $Value;
break;
case 'Z2M_FreeChlorineMin':
$Payload['free_chlorine_min'] = $Value;
break;
case 'Z2M_Feed':
$Payload['feed'] = strval($Value);
break;
Expand Down Expand Up @@ -838,6 +862,48 @@ 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('ph', $Payload)) {
$this->SetValue('Z2M_PH', $Payload['ph']);
}
if (array_key_exists('tds', $Payload)) {
$this->SetValue('Z2M_TDS', $Payload['tds']);
}
if (array_key_exists('ec', $Payload)) {
$this->SetValue('Z2M_EC', $Payload['ec']);
}
if (array_key_exists('orp', $Payload)) {
$this->SetValue('Z2M_ORP', $Payload['orp']);
}
if (array_key_exists('free_chlorine', $Payload)) {
$this->SetValue('Z2M_FreeChlorine', $Payload['free_chlorine']);
}
if (array_key_exists('ph_max', $Payload)) {
$this->SetValue('Z2M_PHMax', $Payload['ph_max']);
}
if (array_key_exists('ph_min', $Payload)) {
$this->SetValue('Z2M_PHMin', $Payload['ph_min']);
}
if (array_key_exists('ec_max', $Payload)) {
$this->SetValue('Z2M_ECMax', $Payload['ec_max']);
}
if (array_key_exists('ec_min', $Payload)) {
$this->SetValue('Z2M_ECMin', $Payload['ec_min']);
}
if (array_key_exists('orp_max', $Payload)) {
$this->SetValue('Z2M_ORPMax', $Payload['orp_max']);
}
if (array_key_exists('orp_min', $Payload)) {
$this->SetValue('Z2M_ORPMin', $Payload['orp_min']);
}
if (array_key_exists('free_chlorine_max', $Payload)) {
$this->SetValue('Z2M_FreeChlorineMax', $Payload['free_chlorine_max']);
}
if (array_key_exists('free_chlorine_min', $Payload)) {
$this->SetValue('Z2M_FreeChlorineMin', $Payload['free_chlorine_min']);
}
if (array_key_exists('salinity', $Payload)) {
$this->SetValue('Z2M_Salinity', $Payload['salinity']);
}
if (array_key_exists('feed', $Payload)) {
$this->SetValue('Z2M_Feed', $Payload['feed']);
}
Expand Down Expand Up @@ -2462,6 +2528,13 @@ private function registerVariableProfile($expose)
$ProfileName .= '.';
$ProfileName .= dechex(crc32($tmpProfileName));
switch ($ProfileName) {
case 'Z2M.identify.12619917':
if (!IPS_VariableProfileExists($ProfileName)) {
$this->RegisterProfileStringEx($ProfileName, 'Identify', '', '', [
['Identify', $this->Translate('Identify'), '', 0x00FF00],
]);
}
break;
case 'Z2M.feeding_source.00000000':
if (!IPS_VariableProfileExists($ProfileName)) {
$this->RegisterProfileStringEx($ProfileName, 'Feeding Source', '', '', [
Expand Down Expand Up @@ -4084,6 +4157,74 @@ private function registerVariableProfile($expose)
break;
case 'numeric':
switch ($expose['property']) {
case 'tds':
if (!IPS_VariableProfileExists($ProfileName)) {
$this->RegisterProfileFloat($ProfileName, 'Information', '', ' ' . $expose['unit'], 0, 0, 0, 2);
}
break;
case 'ph':
if (!IPS_VariableProfileExists($ProfileName)) {
$this->RegisterProfileFloat($ProfileName, 'Information', '', ' ' . $expose['unit'], 0, 0, 0, 2);
}
break;
case 'ec':
if (!IPS_VariableProfileExists($ProfileName)) {
$this->RegisterProfileFloat($ProfileName, 'Information', '', ' ' . $expose['unit'], 0, 0, 0, 2);
}
break;
case 'orp':
if (!IPS_VariableProfileExists($ProfileName)) {
$this->RegisterProfileFloat($ProfileName, 'Information', '', ' ' . $expose['unit'], 0, 0, 0, 2);
}
break;
case 'free_chlorine':
if (!IPS_VariableProfileExists($ProfileName)) {
$this->RegisterProfileFloat($ProfileName, 'Information', '', ' ' . $expose['unit'], 0, 0, 0, 2);
}
break;
case 'salinity':
if (!IPS_VariableProfileExists($ProfileName)) {
$this->RegisterProfileFloat($ProfileName, 'Information', '', ' ' . $expose['unit'], 0, 0, 0, 2);
}
break;
case 'voc_index':
if (!IPS_VariableProfileExists($ProfileName)) {
$this->RegisterProfileFloat($ProfileName, 'Information', '', ' ', 0, 0, 0, 2);
}
break;
case 'ph_max':
case 'ph_min':
$ProfileName = $expose['value_min'] . '_' . $expose['value_max'];
if (!IPS_VariableProfileExists($ProfileName)) {
$this->RegisterProfileInteger($ProfileName, 'Information', '', ' ' . $expose['unit'], $expose['value_min'], $expose['value_max'], 1, 0);
}
break;
case 'ec_max':
case 'ec_min':
$ProfileName = $expose['value_min'] . '_' . $expose['value_max'];
if (!IPS_VariableProfileExists($ProfileName)) {
$this->RegisterProfileInteger($ProfileName, 'Information', '', ' ' . $expose['unit'], $expose['value_min'], $expose['value_max'], 1, 0);
}
break;
case 'orp_max':
case 'orp_min':
$ProfileName = $expose['value_min'] . '_' . $expose['value_max'];
if (!IPS_VariableProfileExists($ProfileName)) {
$this->RegisterProfileInteger($ProfileName, 'Information', '', ' ' . $expose['unit'], $expose['value_min'], $expose['value_max'], 1, 0);
}
break;
case 'free_chlorine_max':
case 'free_chlorine_min':
$ProfileName = $expose['value_min'] . '_' . $expose['value_max'];
if (!IPS_VariableProfileExists($ProfileName)) {
$this->RegisterProfileInteger($ProfileName, 'Information', '', ' ' . $expose['unit'], $expose['value_min'], $expose['value_max'], 1, 0);
}
break;
case 'salinity':
if (!IPS_VariableProfileExists($ProfileName)) {
$this->RegisterProfileFloat($ProfileName, 'Information', '', ' ' . $expose['unit'], 0, 0, 0, 2);
}
break;
case 'voc_index':
if (!IPS_VariableProfileExists($ProfileName)) {
$this->RegisterProfileFloat($ProfileName, 'Information', '', ' ', 0, 0, 0, 2);
Expand Down Expand Up @@ -5433,6 +5574,13 @@ private function mapExposesToVariables(array $exposes)
break; //binary break
case 'enum':
switch ($expose['property']) {
case 'identify':
$ProfileName = $this->registerVariableProfile($expose);
if ($ProfileName != false) {
$this->RegisterVariableString('Z2M_Identify', $this->Translate('Identify'), $ProfileName);
$this->EnableAction('Z2M_Identify');
}
break;
case 'feeding_source':
$ProfileName = $this->registerVariableProfile($expose);
if ($ProfileName != false) {
Expand Down Expand Up @@ -5950,6 +6098,98 @@ private function mapExposesToVariables(array $exposes)
break; //enum break
case 'numeric':
switch ($expose['property']) {
case 'tds':
$ProfileName = $this->registerVariableProfile($expose);
if ($ProfileName != false) {
$this->RegisterVariableFloat('Z2M_TDS', $this->Translate('Total Dissolved Solids'), $ProfileName);
}
break;
case 'ph':
$ProfileName = $this->registerVariableProfile($expose);
if ($ProfileName != false) {
$this->RegisterVariableFloat('Z2M_PH', $this->Translate('pH'), $ProfileName);
}
break;
case 'ec':
$ProfileName = $this->registerVariableProfile($expose);
if ($ProfileName != false) {
$this->RegisterVariableFloat('Z2M_EC', $this->Translate('Electrical Conductivity'), $ProfileName);
}
break;
case 'orp':
$ProfileName = $this->registerVariableProfile($expose);
if ($ProfileName != false) {
$this->RegisterVariableFloat('Z2M_ORP', $this->Translate('Oxidation Reduction Potential'), $ProfileName);
}
break;
case 'free_chlorine':
$ProfileName = $this->registerVariableProfile($expose);
if ($ProfileName != false) {
$this->RegisterVariableFloat('Z2M_FreeChlorine', $this->Translate('Free Chlorine'), $ProfileName);
}
break;
case 'salinity':
$ProfileName = $this->registerVariableProfile($expose);
if ($ProfileName != false) {
$this->RegisterVariableFloat('Z2M_Salinity', $this->Translate('Salinity'), $ProfileName);
}
break;
case 'ph_max':
$ProfileName = $this->registerVariableProfile($expose);
if ($ProfileName != false) {
$this->RegisterVariableInteger('Z2M_PHMax', $this->Translate('pH Max'), $ProfileName);
$this->EnableAction('Z2M_PHMax');
}
break;
case 'ph_min':
$ProfileName = $this->registerVariableProfile($expose);
if ($ProfileName != false) {
$this->RegisterVariableInteger('Z2M_PHMin', $this->Translate('pH Min'), $ProfileName);
$this->EnableAction('Z2M_PHMin');
}
break;
case 'ec_max':
$ProfileName = $this->registerVariableProfile($expose);
if ($ProfileName != false) {
$this->RegisterVariableInteger('Z2M_ECMax', $this->Translate('Electrical Conductivity Max'), $ProfileName);
$this->EnableAction('Z2M_ECMax');
}
break;
case 'ec_min':
$ProfileName = $this->registerVariableProfile($expose);
if ($ProfileName != false) {
$this->RegisterVariableInteger('Z2M_ECMin', $this->Translate('Electrical Conductivity Min'), $ProfileName);
$this->EnableAction('Z2M_ECMin');
}
break;
case 'orp_max':
$ProfileName = $this->registerVariableProfile($expose);
if ($ProfileName != false) {
$this->RegisterVariableInteger('Z2M_ORPMax', $this->Translate('Oxidation Reduction Potential Max'), $ProfileName);
$this->EnableAction('Z2M_ORPMax');
}
break;
case 'orp_min':
$ProfileName = $this->registerVariableProfile($expose);
if ($ProfileName != false) {
$this->RegisterVariableInteger('Z2M_ORPMin', $this->Translate('Oxidation Reduction Potential Min'), $ProfileName);
$this->EnableAction('Z2M_ORPMin');
}
break;
case 'free_chlorine_max':
$ProfileName = $this->registerVariableProfile($expose);
if ($ProfileName != false) {
$this->RegisterVariableInteger('Z2M_FreeChlorineMax', $this->Translate('Free Chlorine Max'), $ProfileName);
$this->EnableAction('Z2M_FreeChlorineMax');
}
break;
case 'free_chlorine_min':
$ProfileName = $this->registerVariableProfile($expose);
if ($ProfileName != false) {
$this->RegisterVariableInteger('Z2M_FreeChlorineMin', $this->Translate('Free Chlorine Min'), $ProfileName);
$this->EnableAction('Z2M_FreeChlorineMin');
}
break;
case 'portions_per_day':
$ProfileName = $this->registerVariableProfile($expose);
if ($ProfileName != false) {
Expand Down

0 comments on commit c5c653a

Please sign in to comment.