function propise_plugin_setting_page() { global $_, $myUser, $conf; if (isset($_['section']) && $_['section'] == 'propise') { require_once 'Data.class.php'; require_once 'Sensor.class.php'; if (!$myUser) { throw new Exception('Vous devez être connecté pour effectuer cette action'); } $sensorManager = new Sensor(); $sensors = $sensorManager->populate(); $roomManager = new Room(); $rooms = $roomManager->populate(); $selected = new Sensor(); //Si on est en mode modification if (isset($_['id'])) { $selected = $sensorManager->getById($_['id']); } ?> <div class="span9 userBloc"> <h1>Propise</h1> <p>Gestion des multi-sondes</p> <fieldset> <legend>Ajouter/Modifier une sonde</legend> <div class="left"> <label for="labelSensor">Nom</label> <input type="hidden" id="id" value="<?php echo $selected->id; ?> "> <input type="text" id="labelSensor" value="<?php echo $selected->label; ?> " placeholder="Sonde du salon"/> <label for="uidSensor">UID</label> <input type="text" value="<?php echo $selected->uid; ?> " id="uidSensor" placeholder="sonde-1,sonde-2..." /> <label for="locationSensor">Pièce de la maison</label> <select id="locationSensor"> <?php foreach ($rooms as $room) { ?> <option <?php if ($selected->location == $room->getId()) { echo "selected"; } ?> value="<?php echo $room->getId(); ?> "><?php echo $room->getName(); ?> </option> <?php } ?> </select> </div> <div class="clear"></div> <br/><button onclick="plugin_propise_save(this)" class="btn">Enregistrer</button> </fieldset> <br/> <fieldset> <legend>Consulter les sondes existants</legend> <table class="table table-striped table-bordered table-hover"> <thead> <tr> <th>Nom</th> <th>UID</th> <th>Pièce</th> <th colspan="2"></th> </tr> </thead> <?php foreach ($sensors as $sensor) { $room = $roomManager->load(array('id' => $sensor->location)); ?> <tr> <td><?php echo $sensor->label; ?> </td> <td><?php echo $sensor->uid; ?> </td> <td><?php echo $room->getName(); ?> </td> <td> <a class="btn" href="setting.php?section=propise&id=<?php echo $sensor->id; ?> "><i class="fa fa-pencil"></i></a> <div class="btn" onclick="plugin_propise_delete(<?php echo $sensor->id; ?> ,this);"><i class="fa fa-times"></i></div> </td> </td> </tr> <?php } ?> </table> </fieldset> </div> <?php } }
function sensor_vocal_command(&$response, $actionUrl) { global $conf; $sensorManager = new Sensor(); $sensors = $sensorManager->populate(); foreach ($sensors as $sensor) { $response['commands'][] = array('command' => $conf->get('VOCAL_ENTITY_NAME') . ', allume ' . $sensor->getName(), 'url' => $actionUrl . '?action=sensor_change_state&engine=' . $sensor->getId() . '&state=on&webservice=true', 'confidence' => '0.9'); $response['commands'][] = array('command' => $conf->get('VOCAL_ENTITY_NAME') . ', eteint ' . $sensor->getName(), 'url' => $actionUrl . '?action=sensor_change_state&engine=' . $sensor->getId() . '&state=off&webservice=true', 'confidence' => '0.9'); $response['commands'][] = array('command' => $conf->get('VOCAL_ENTITY_NAME') . ', donne ' . $sensor->getName(), 'url' => $actionUrl . '?action=sensor_get_value&engine=' . $sensor->getId() . '&webservice=true', 'confidence' => '0.9'); } }