コード例 #1
0
function radioRelay_vocal_command(&$response, $actionUrl)
{
    global $conf;
    $radioRelayManager = new RadioRelay();
    $radioRelays = $radioRelayManager->populate();
    foreach ($radioRelays as $radioRelay) {
        $response['commands'][] = array('command' => $conf->get('VOCAL_ENTITY_NAME') . ', allume ' . $radioRelay->getName(), 'url' => $actionUrl . '?action=radioRelay_change_state&engine=' . $radioRelay->getId() . '&state=on&webservice=true', 'confidence' => '0.9');
        $response['commands'][] = array('command' => $conf->get('VOCAL_ENTITY_NAME') . ', eteint ' . $radioRelay->getName(), 'url' => $actionUrl . '?action=radioRelay_change_state&engine=' . $radioRelay->getId() . '&state=off&webservice=true', 'confidence' => '0.9');
    }
}
コード例 #2
0
function radioRelay_plugin_setting_page()
{
    global $_, $myUser, $conf;
    if (isset($_['section']) && $_['section'] == 'radioRelay') {
        if (!$myUser) {
            throw new Exception('Vous devez être connecté pour effectuer cette action');
        }
        $radioRelayManager = new RadioRelay();
        $radioRelays = $radioRelayManager->populate();
        $roomManager = new Room();
        $rooms = $roomManager->populate();
        $selected = new RadioRelay();
        $selected->pulse = 0;
        $selected->icon = 'fa fa-flash';
        //Si on est en mode modification
        if (isset($_['id'])) {
            $selected = $radioRelayManager->getById($_['id']);
        }
        $icons = array('fa fa-lightbulb-o', 'fa fa-power-off', 'fa fa-flash', 'fa fa-gears', 'fa fa-align-justify', 'fa fa-adjust', 'fa fa-arrow-circle-o-right', 'fa fa-desktop', 'fa fa-music', 'fa fa-bell-o', 'fa fa-beer', 'fa fa-bullseye', 'fa fa-automobile', 'fa fa-book', 'fa fa-bomb', 'fa fa-clock-o', 'fa fa-cutlery', 'fa fa-microphone', 'fa fa-tint');
        ?>

		<div class="span9 userBloc">

			<h1>Relais</h1>
			<p>Gestion des relais radios</p>  

			<fieldset>
			    <legend>Ajouter/Modifier un relais radio</legend>

			    <div class="left">

				    <label for="nameRadioRelay">Nom</label>
				    <input type="hidden" id="id" value="<?php 
        echo $selected->id;
        ?>
">
				    <input type="text" id="nameRadioRelay" value="<?php 
        echo $selected->name;
        ?>
" placeholder="Lumiere Canapé…"/>
				    
				    <label for="descriptionRadioRelay">Description</label>
				    <input type="text"  value="<?php 
        echo $selected->description;
        ?>
" id="descriptionRadioRelay" placeholder="Relais sous le canapé…" />

					<label for="iconRadioRelay">Icone</label>
				    <input type="hidden"  value="<?php 
        echo $selected->icon;
        ?>
" id="iconRadioRelay"  />
					
					<div>
						<div style='margin:5px;'>
						<?php 
        foreach ($icons as $i => $icon) {
            if ($i % 6 == 0) {
                echo '</div><div style="margin:5px;">';
            }
            ?>
							<i style="width:25px;" onclick="plugin_radiorelay_set_icon(this,'<?php 
            echo $icon;
            ?>
');" class="<?php 
            echo $icon;
            ?>
 btn <?php 
            echo $selected->icon == $icon ? 'btn-success' : '';
            ?>
"></i>
						<?php 
        }
        ?>
 
						</div>
					</div>

					<label for="radioCodeRadioRelay">Code radio</label>
					<input type="text" value="<?php 
        echo $selected->radiocode;
        ?>
" name="radioCodeRadioRelay" id="radioCodeRadioRelay" placeholder="1234,1111,0022..." />

				    <label for="onRadioRelay">Commande vocale "ON" associée</label>
				    <?php 
        echo $conf->get('VOCAL_ENTITY_NAME');
        ?>
, <input type="text" id="onRadioRelay" value="<?php 
        echo $selected->onCommand;
        ?>
" placeholder="Allume la lumière, Ouvre le volet…"/>
				   
				    
				    <label for="offRadioRelay">Commande vocale "OFF" associée</label>
				    <?php 
        echo $conf->get('VOCAL_ENTITY_NAME');
        ?>
, <input type="text" id="offRadioRelay" value="<?php 
        echo $selected->offCommand;
        ?>
" placeholder="Eteinds la lumière, Ferme le volet…"/>
				    
				    
				    <label for="roomRadioRelay">Pièce de la maison</label>
				    <select id="roomRadioRelay">
				    	<?php 
        foreach ($rooms as $room) {
            ?>
				    	<option <?php 
            if ($selected->room == $room->getId()) {
                echo "selected";
            }
            ?>
 value="<?php 
            echo $room->getId();
            ?>
"><?php 
            echo $room->getName();
            ?>
</option>
				    	<?php 
        }
        ?>
				    </select>
				   <label for="pinRadioRelay">Mode impulsion (micro secondes)</label>
				   <input type="number" value="<?php 
        echo $selected->pulse;
        ?>
" id="pulseRadioRelay" placeholder="0" />
				   <small>laisser à zéro pour désactiver le mode impulsion</small>
				</div>

	  			<div class="clear"></div>
			    <br/><button onclick="plugin_radiorelay_save(this)" class="btn">Enregistrer</button>
		  	</fieldset>
			<br/>


			<fieldset>
				<legend>Consulter les relais radios existants</legend>
				<table class="table table-striped table-bordered table-hover">
				    <thead>
					    <tr>
					    	<th>Nom</th>
						    <th>Description</th>
						    <th>Code</th>
						    
						    <th>Pièce</th>
						    <th colspan="2">Impulsion</th>
						    
					    </tr>
				    </thead>
			    
			    	<?php 
        foreach ($radioRelays as $radioRelay) {
            $room = $roomManager->load(array('id' => $radioRelay->room));
            ?>
					<tr>
				    	<td><?php 
            echo $radioRelay->name;
            ?>
</td>
					    <td><?php 
            echo $radioRelay->description;
            ?>
</td>
					    <td><?php 
            echo $radioRelay->radiocode;
            ?>
</td>
					    
					    <td><?php 
            echo $room->getName();
            ?>
</td>
					    <td><?php 
            echo $radioRelay->pulse;
            ?>
</td>
					    <td>
					    	<a class="btn" href="setting.php?section=radioRelay&id=<?php 
            echo $radioRelay->id;
            ?>
"><i class="fa fa-pencil"></i></a>
					    	<div class="btn" onclick="plugin_radiorelay_delete(<?php 
            echo $radioRelay->id;
            ?>
,this);"><i class="fa fa-times"></i></div>
					    </td>
					    </td>
			    	</tr>
			    <?php 
        }
        ?>
			    </table>
			</fieldset>
		</div>

<?php 
    }
}