56 lines
1.8 KiB
PHP
56 lines
1.8 KiB
PHP
<?php
|
|
require_once("./phpMQTT.php");
|
|
require_once("../helper.php");
|
|
|
|
|
|
if (checkLogin()) {
|
|
$close = 0;
|
|
$hostname = "192.168.179.169";
|
|
$server = 'localhost'; // change if necessary
|
|
$port = 1883; // change if necessary
|
|
$username = ''; // set your username
|
|
$password = ''; // set your password
|
|
$client_id = 'RoomtempSetter'; // make sure this is unique for connecting to sever - you could use uniqid()
|
|
|
|
if (isset($_POST["setTemp"]) && isset($_GET["heater"])) {
|
|
$topic = "Raumtemp/".str_replace("_","/",$_GET["heater"])."/changeSetTemp";
|
|
$mqtt = new Bluerhinos\phpMQTT($server, $port, $client_id);
|
|
//send new value
|
|
$temp = intval($_POST["setTemp"]);
|
|
if($temp > 9 && $temp < 31){
|
|
if ($mqtt->connect(true, NULL, $username, $password)) {
|
|
$mqtt->publish($topic, $temp, 0, false);
|
|
$mqtt->close();
|
|
}
|
|
}
|
|
$close = 1;
|
|
}
|
|
} else {
|
|
$close = 1;
|
|
}
|
|
if (!$close) {
|
|
echo <<<ENDE
|
|
<style>
|
|
input[type='range']::-webkit-slider-runnable-track {
|
|
background: linear-gradient(to right, #00788F, #00788F), #D7D7D7;
|
|
background-size: var(--background-size, 0%) 100%;
|
|
background-repeat: no-repeat;
|
|
}
|
|
</style>
|
|
<!--begin::Form-->
|
|
<form id="heater_form">
|
|
<div class="col-sm-11">
|
|
<div class="form-check">
|
|
<label class="form-label" for="addedCharge">Temperatur: </label>
|
|
<div style="font-size: 15px;color: #297195;display: inline-block;" id="modal-slider-label">0</div>
|
|
<input type="range" id="modal-slider" name="setTemp" class="form-range range-color-track" min="10" max="30" />
|
|
<div class="d-flex justify-content-between">
|
|
<span class="max-amount f-16 font-weight-normal darkGray-color text-right mt-1">10 °C</span>
|
|
<span class="max-amount f-16 font-weight-normal darkGray-color text-right mt-1">30 °C</span>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</form>
|
|
ENDE;
|
|
}
|