Skip to content

Commit

Permalink
no message
Browse files Browse the repository at this point in the history
  • Loading branch information
Nall-chan committed Dec 15, 2023
1 parent 2dbe31e commit 36d0f03
Show file tree
Hide file tree
Showing 14 changed files with 930 additions and 469 deletions.
6 changes: 6 additions & 0 deletions ClimacontrolRegulator/form.json
Original file line number Diff line number Diff line change
Expand Up @@ -116,6 +116,12 @@
"caption": "Holiday/Party",
"expanded": true,
"items": [
{
"name": "enable_TEMPERATUR_PARTY_VALUE",
"type": "CheckBox",
"caption": "Holiday/Party set point temperature",
"width": "250px"
},
{
"name": "enable_PARTY_END_TIME",
"type": "CheckBox",
Expand Down
1 change: 1 addition & 0 deletions ClimacontrolRegulator/locale.json
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@
"Open": "Geöffnet",
"Lowering temperature": "Absenktemperatur",
"Comfort temperature": "Komforttemperatur",
"Holiday/Party set point temperature": "Urlaub/Party Solltemperatur",
"Holiday/Party end": "Urlaub/Party Ende",
"Time cannot be in the past": "Zeitpunkt kann nicht in der Vergangenheit liegen",
"Time too far in the future": "Zeitpunkt zu weit in der Zukunft",
Expand Down
101 changes: 51 additions & 50 deletions ClimacontrolRegulator/module.php
Original file line number Diff line number Diff line change
Expand Up @@ -50,104 +50,105 @@ public function RequestAction($Ident, $Value)
if (array_key_exists($Ident, \HMExtended\ValuesSet::$Variables[static::DeviceTyp])) {
$Ident = is_string(\HMExtended\ValuesSet::$Variables[static::DeviceTyp][$Ident][2]) ? \HMExtended\ValuesSet::$Variables[static::DeviceTyp][$Ident][2] : $Ident;
$this->FixValueType(\HMExtended\ValuesSet::$Variables[static::DeviceTyp][$Ident][0], $Value);
$SendValue = $Value;
switch ($Ident) {
case \HMExtended\ClimacontrolRegulator\SETPOINT:
$this->SetValue($Ident, $Value);
if ($Value == 4.5) {
$Value = 0;
}
if ($Value == 30.5) {
$Value = 100;
case \HMExtended\ClimacontrolRegulator::SETPOINT:
if ($this->GetValue(\HMExtended\ClimacontrolRegulator::MODE_TEMPERATUR_REGULATOR) != 0) {
$this->PutParamSet([\HMExtended\ClimacontrolRegulator::MODE_TEMPERATUR_REGULATOR => 0], true);
}
break;
}
$Paramset = [$this->ReadPropertyString(\HMExtended\Device\Property::Address) . static::ValuesChannel, $Ident];
return $this->SendRPC('setValue', $Paramset, $Value, true);
$this->PutValue($Ident, $SendValue, true);
return;
}
if (array_key_exists($Ident, \HMExtended\ParamSet::$Variables[static::DeviceTyp])) {
$Ident = is_string(\HMExtended\ParamSet::$Variables[static::DeviceTyp][$Ident][2]) ? \HMExtended\ValuesSet::$Variables[static::DeviceTyp][$Ident][2] : $Ident;
$this->FixValueType(\HMExtended\ParamSet::$Variables[static::DeviceTyp][$Ident][0], $Value);
$SendValue = $Value;
switch ($Ident) {
case 'DECALCIFICATION_TIME':
case \HMExtended\ClimacontrolRegulator::DECALCIFICATION_TIME: // Sonderfall Entkalkung
$d = (new DateTime())->setTimestamp((int) $Value);
$CalcMin = (int) $d->format('i');
$CalcHour = (int) $d->format('H');
if ($this->PutParamSet(
[
'DECALCIFICATION_MINUTE'=> ($CalcMin > 50) ? 50 : $CalcMin,
'DECALCIFICATION_HOUR' => $CalcHour
]
\HMExtended\ClimacontrolRegulator::DECALCIFICATION_MINUTE => ($CalcMin > 50) ? 50 : $CalcMin,
\HMExtended\ClimacontrolRegulator::DECALCIFICATION_HOUR => $CalcHour
],
true
)) {
$this->SetValue($Ident, $Value);
return true;
}
return false;
case 'PARTY_END_TIME':
return;
case \HMExtended\ClimacontrolRegulator::PARTY_END_TIME: // Sonderfall Party Variablen
if ($Value < time()) {
trigger_error($this->Translate('Time cannot be in the past'));
return false;
return;
}

$d = (new DateTime())->setTimestamp((int) $Value);
$CalcMin = (int) $d->format('i');
$CalcHour = (int) $d->format('H');
$d->setTime(0, 0, 0, 0);
$days = ((new DateTime())->setTime(0, 0, 0, 0))->diff($d);
if ($days > 200) {
if ($days->days > 200) {
trigger_error($this->Translate('Time too far in the future'));
return false;
return;
}
$d->setTime($CalcHour, ($CalcMin >= 30) ? 1 : 0, 0, 0);

$d->setTime($CalcHour, ($CalcMin >= 30) ? 30 : 0, 0, 0);
if ($this->PutParamSet(
[
'MODE_TEMPERATUR_REGULATOR'=> 3,
'PARTY_END_DAY' => $days->format('%a'),
'PARTY_END_MINUTE' => ($CalcMin >= 30) ? 1 : 0,
'PARTY_END_HOUR' => $CalcHour
]
\HMExtended\ClimacontrolRegulator::MODE_TEMPERATUR_REGULATOR => 3,
\HMExtended\ClimacontrolRegulator::PARTY_END_DAY => $days->format('%a'),
\HMExtended\ClimacontrolRegulator::PARTY_END_MINUTE => ($CalcMin >= 30) ? 1 : 0,
\HMExtended\ClimacontrolRegulator::PARTY_END_HOUR => $CalcHour
],
true
)) {
$this->SetValue('MODE_TEMPERATUR_REGULATOR', 3);
$this->SetValue('PARTY_END_TIME', $d->getTimestamp());
return true;
$this->SetValue(\HMExtended\ClimacontrolRegulator::MODE_TEMPERATUR_REGULATOR, 3);
$this->SetValue(\HMExtended\ClimacontrolRegulator::PARTY_END_TIME, $d->getTimestamp());
}
return;
}
if ($this->PutParamSet([$Ident=>$Value])) {
if ($this->PutParamSet([$Ident => $SendValue], true)) {
$this->SetValue($Ident, $Value);
return true;
}
return;
}
trigger_error('Invalid Ident.', E_USER_NOTICE);
return false;
trigger_error($this->Translate('Invalid Ident.'), E_USER_NOTICE);
return;
}

protected function SetParamVariable(array $Params)
{
$d = new DateTime();
$d->setTime($Params['DECALCIFICATION_HOUR'], $Params['DECALCIFICATION_MINUTE'], 0, 0);
$Params['DECALCIFICATION_TIME'] = $d->getTimestamp();
$d->setTime(
$Params[\HMExtended\ClimacontrolRegulator::DECALCIFICATION_HOUR],
$Params[\HMExtended\ClimacontrolRegulator::DECALCIFICATION_MINUTE],
0,
0
);
$Params[\HMExtended\ClimacontrolRegulator::DECALCIFICATION_TIME] = $d->getTimestamp();
$d = new DateTime();
$d->setTime($Params['PARTY_END_HOUR'], ($Params['PARTY_END_MINUTE'] == 0 ? 0 : 30), 0, 0);
$i = new DateInterval('P' . $Params['PARTY_END_DAY'] . 'D');
$Params['PARTY_END_TIME'] = $d->add($i)->getTimestamp();
$d->setTime(
$Params[\HMExtended\ClimacontrolRegulator::PARTY_END_HOUR],
($Params[\HMExtended\ClimacontrolRegulator::PARTY_END_MINUTE] == 0 ? 0 : 30),
0,
0
);
$i = new DateInterval('P' . $Params[\HMExtended\ClimacontrolRegulator::PARTY_END_DAY] . 'D');
$Params[\HMExtended\ClimacontrolRegulator::PARTY_END_TIME] = $d->add($i)->getTimestamp();
foreach ($Params as $Ident => $Value) {
@$this->SetValue($Ident, $Value);
}
}

protected function SetVariable(string $Ident, $Value)
{
@$this->SetValue($Ident, $Value);
switch ($Ident) {
case \HMExtended\ClimacontrolRegulator\SETPOINT:
if ($Value == 0) {
$Value = 4.5;
}
if ($Value == 100) {
$Value = 30.5;
}
@$this->SetValue($Ident, $Value);
case \HMExtended\ClimacontrolRegulator::SETPOINT:
IPS_RunScriptText('IPS_RequestAction(' . $this->InstanceID . ',"getParam",0);');
break;
default:
@$this->SetValue($Ident, $Value);
break;
}
}
//################# PRIVATE
Expand Down
5 changes: 5 additions & 0 deletions ExtendedConfigurator/module.php
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,7 @@ public function Test(string $MethodName, int $Protocol, array $Data)
{
return $this->SendRPC($MethodName, $Protocol, $Data);
}

/**
* Interne Funktion des SDK.
*/
Expand Down Expand Up @@ -188,6 +189,7 @@ protected function GetConfigParam(&$item1, $InstanceID, $ConfigParam)
{
$item1 = IPS_GetProperty($InstanceID, $ConfigParam);
}

private function GetConfigRows(int $Protocol, string $GUID)
{
$CreateParams = [
Expand Down Expand Up @@ -231,6 +233,7 @@ private function GetConfigRows(int $Protocol, string $GUID)
}
return $Devices;
}

private function GetDeviceData(int $Protocol, array &$Device)
{
$InterfaceString = \HMExtended\CCU::$Interfaces[$Protocol];
Expand All @@ -249,6 +252,7 @@ private function GetDeviceData(int $Protocol, array &$Device)
$Device['name'] = $Device['type'];
}
}

private function GetDevices(int $Protocol, string $Type)
{
$Result = $this->SendRPC('listDevices', $Protocol, []);
Expand Down Expand Up @@ -301,6 +305,7 @@ private function LoadDeviceData()
}
return $Values;
}

private function SendRPC(string $MethodName, int $Protocol, array $Data)
{
if (!$this->HasActiveParent()) {
Expand Down
Loading

0 comments on commit 36d0f03

Please sign in to comment.