/** * activate * enables this event * * @access public */ public function activate() { $time = time(); IPS_SetEventCyclicTimeFrom($this->id, intval(date('H', $time)), intval(date('i', $time)), intval(date('s', $time))); //IPS_SetEventCyclicTimeFrom($this->id, 16, 06, 32); return IPS_SetEventActive($this->id, true); }
public function toogleGoodNight() { $goodnightstate = GetValue($this->GetIDForIdent("GoodNight")); $sleeptimerstate = GetValue($this->GetIDForIdent("SleepTimer")); $sleeptimervariableid = @$this->GetIDForIdent("SleepTimer"); $sleeptimercontrolscriptid = @IPS_GetScriptIDByName("SleepTimerControl", $sleeptimervariableid); $sleeptimercontrolscripteventid = @IPS_GetEventIDByName("SleepTimerEvent", $sleeptimercontrolscriptid); if ($goodnightstate == false and $sleeptimerstate == false) { SetValue($this->GetIDForIdent("GoodNight"), true); SetValue($this->GetIDForIdent("VolumeFadeOut"), true); // set event $timenow = time(); $timestamp = strtotime('+900 seconds', $timenow); $nextpowerofftime = strtotime('+1800 seconds', $timenow); $hour = date("H", $timestamp); $minute = date("i", $timestamp); $second = date("s", $timestamp); IPS_SetEventCyclicTimeFrom($sleeptimercontrolscripteventid, $hour, $minute, $second); IPS_SetEventActive($sleeptimercontrolscripteventid, true); // set next power off $day = date("l", $nextpowerofftime); $date = date("d.m.Y", $nextpowerofftime); $time = date("H:i:s", $nextpowerofftime); $nextpoweroff = $day . ", " . $date . ", " . $time; SetValue($this->GetIDForIdent("NextPowerOff"), $nextpoweroff); // calculate cycle time $fadeoutseconds = 900; $actualvolume = GetValue($this->GetIDForIdent("VolumeSlider")); $cycletime = floor(900 / ($actualvolume - 1)); SetValue($this->GetIDForIdent("SleepCycle"), $cycletime); } if ($goodnightstate == true and $sleeptimerstate == false) { IPS_SetEventActive($sleeptimercontrolscripteventid, false); SetValue($this->GetIDForIdent("VolumeFadeOut"), false); SetValue($this->GetIDForIdent("GoodNight"), false); SetValue($this->GetIDForIdent("SleepCycle"), 0); SetValue($this->GetIDForIdent("NextPowerOff"), ""); } }
/** * ModBusMaster_WriteCoil * @param boolean $Value * @return boolean */ public function WriteCoil($Value) { if ($this->ReadPropertyBoolean("ReadOnly")) { trigger_error("Address is marked as read-only!", E_USER_WARNING); return; } if ($this->ReadPropertyInteger("DataType") === 0) { $resultat = $this->SendDataToParent(json_encode(array("DataID" => "{A3419A88-C83B-49D7-8706-D3AFD596DFBB}", "FC" => "5", "Address" => $this->ReadPropertyInteger("Address"), "Data" => $Value))); if ($this->ReadPropertyInteger("SwitchDuration") > 0 and $Value) { $eid = @IPS_GetObjectIDByIdent("SwitchDuration", $this->InstanceID); if ($eid === false) { $eid = 0; } else { if (IPS_GetEvent($eid)['EventType'] != 1) { IPS_DeleteEvent($eid); $eid = 0; } } if ($eid == 0) { $eid = IPS_CreateEvent(1); IPS_SetParent($eid, $this->InstanceID); IPS_SetIdent($eid, "SwitchDuration"); IPS_SetName($eid, "SwitchDuration"); IPS_SetHidden($eid, true); IPS_SetEventScript($eid, "ModBusMaster_WriteCoil(\$_IPS['TARGET'], false);IPS_SetEventActive(\$_IPS['EVENT'],false);"); } IPS_SetEventCyclicTimeFrom($eid, date("H"), date("i"), date("s")); IPS_SetEventCyclic($eid, 0, 0, 0, 0, 1, $this->ReadPropertyInteger("SwitchDuration")); IPS_SetEventActive($eid, true); } return $resultat; } else { trigger_error("Invalid DataType!", E_USER_WARNING); } }
protected function SetTimerByIdent_InSekunden($ident, $Sekunden) { $eid = @IPS_GetObjectIDByIdent($ident, $this->InstanceID); if ($eid === false) { $eid = IPS_CreateEvent(1); IPS_SetParent($eid, $this->InstanceID); IPS_SetName($eid, $ident); IPS_SetIdent($eid, $ident); IPS_SetEventScript($eid, 'HMON_Benachrichtigung($_IPS[\'TARGET\'], false, true);'); IPS_SetInfo($eid, "this timer was created by script #" . $_IPS['SELF']); } if ($Sekunden === false) { IPS_SetEventActive($eid, false); return $eid; } else { IPS_SetEventCyclicTimeFrom($eid, intval(date("H", time() + $Sekunden)), intval(date("i", time() + $Sekunden)), intval(date("s", time() + $Sekunden))); IPS_SetEventActive($eid, true); return $eid; } }
protected function SetTimer($Name, $TargetTime) { $id = @IPS_GetObjectIDByIdent($Name, $this->InstanceID); if ($id === false) { throw new Exception('Timer not present'); } if (!IPS_EventExists($id)) { throw new Exception('Timer not present'); } $Event = IPS_GetEvent($id); if ($TargetTime < time()) { if ($Event['EventActive']) { IPS_SetEventActive($id, false); } } else { IPS_SetEventCyclic($id, 1, 0, 0, 0, 0, 0); IPS_SetEventCyclicDateFrom($id, (int) date("j", $TargetTime), (int) date("n", $TargetTime), (int) date("o", $TargetTime)); IPS_SetEventCyclicDateTo($id, (int) date("j", $TargetTime), (int) date("n", $TargetTime), (int) date("o", $TargetTime)); IPS_SetEventCyclicTimeFrom($id, (int) date("H", $TargetTime), (int) date("i", $TargetTime), (int) date("s", $TargetTime)); IPS_SetEventCyclicTimeTo($id, (int) date("H", $TargetTime), (int) date("i", $TargetTime), (int) date("s", $TargetTime)); if (!$Event['EventActive']) { IPS_SetEventActive($id, true); } } }
protected function SetTimerIntervalTime($Name, $startzeith, $startzeitm, $stopzeith, $stopzeitm) { $id = @IPS_GetObjectIDByIdent($Name, $this->InstanceID); if ($id === false) { throw new Exception('Timer not present', E_USER_WARNING); } if (!IPS_EventExists($id)) { throw new Exception('Timer not present', E_USER_WARNING); } $Event = IPS_GetEvent($id); if ($startzeith > 23) { if ($Event['EventActive']) { IPS_SetEventActive($id, false); } } else { IPS_SetEventCyclicTimeFrom($id, $startzeith, $startzeitm, 0); IPS_SetEventCyclicTimeTo($id, $stopzeith, $stopzeitm, 0); } }