@link http://blog.idleman.fr @licence CC by nc sa @version 1.0.0 @description Permet la programmation d'évenements yana client (parole,commande,son...) selon un horaire fixé */ function eventmanager_action(){ global $_,$conf,$myUser; switch($_['action']){ case 'eventmanager_save_event': if($myUser->can('event','c') || $myUser->can('event','u')){ $event = new Event(); $event =($_['eventId']!=''?$event->getById($_['eventId']):$event); $event->setName($_['eventName']); $event->setYear($_['eventYear']); $event->setMonth($_['eventMonth']); $event->setDay($_['eventDay']); $event->setHour($_['eventHour']); $event->setMinut($_['eventMinut']); $event->setRepeat('0'); $content = array(); //Todo, prendre en compte le multi action ([1],[2]...) $event->setRecipients(array()); $event->addRecipient($_['eventTarget']); $content[0]['type'] = $_['eventType']; $event->setState($_['eventState']); switch($content[0]['type']){ case 'talk': $content[0]['sentence'] = $_['eventContent']; break; case 'sound': $content[0]['file'] = $_['eventContent']; break; case 'command': $content[0]['program'] = $_['eventContent']; break; case 'gpio': $content[0]['gpios'] = $_['eventContent']; break; } $event->setContent($content[0]); //$event->setRecipients('all'); //@TODO $event->save(); header('location:index.php?module=eventmanager'); }else{ header('location:index.php?module=eventmanager&error=Vous n\'avez pas le droit de faire ça!'); } break; case 'eventmanager_delete_event': if($myUser->can('event','d')){ $event = new Event(); $event->delete(array('id'=>$_['id'])); header('location:index.php?module=eventmanager'); }else{ header('location:index.php?module=eventmanager&error=Vous n\'avez pas le droit de faire ça!'); } break; } } function eventmanager_plugin_menu(&$menuItems){ global $_; $menuItems[] = array('sort'=>1,'content'=>' Événements'); } function eventmanager_plugin_page($_){ if(isset($_['module']) && $_['module']=='eventmanager'){ $eventManager = new Event(); $currentEvent = new Event(); $currentEvent->setYear('*'); $currentEvent->setMonth('*'); $currentEvent->setDay('*'); $currentEvent->setHour('*'); $currentEvent->setMinut('*'); $currentEvent = (isset($_['id'])?$eventManager->getById($_['id']):$currentEvent); ?>
coté serveur
, vous devez ajouter une tâche
planifiée sur le raspberry PI, pour cela tapez :
sudo crontab -e
puis ajoutez la ligne
*/1 * * * * wget '.$url.' -O /dev/null 2>&1'; ?>
puis sauvegardez (ctrl
+x
puis O
puis Entrée
)