Minor modif to moha.php\nDebug\nAdded script rdc_temperature_int_ext
This commit is contained in:
parent
d0489c7353
commit
4e04dfdfd6
@ -8,6 +8,7 @@
|
|||||||
array(RDC_SDB_TEMP_HUM, "temperature"),
|
array(RDC_SDB_TEMP_HUM, "temperature"),
|
||||||
array(RDC_SDB_RADIATEUR, "current_heating_setpoint"),
|
array(RDC_SDB_RADIATEUR, "current_heating_setpoint"),
|
||||||
array(METEO, "tempc"),
|
array(METEO, "tempc"),
|
||||||
|
array(METEO, "indoortempc"),
|
||||||
array(METEO, "humidity"),
|
array(METEO, "humidity"),
|
||||||
array(METEO, "winddir"),
|
array(METEO, "winddir"),
|
||||||
array(METEO, "windspeedkmh"),
|
array(METEO, "windspeedkmh"),
|
||||||
|
@ -52,6 +52,7 @@ class rdc_sdb_eclairage extends hook
|
|||||||
{
|
{
|
||||||
logger(DEBUG, _("Actionneurs are all false"), __FILE__ . ":" . __LINE__);
|
logger(DEBUG, _("Actionneurs are all false"), __FILE__ . ":" . __LINE__);
|
||||||
//setDelay($deviceTarget, $this->delay, $this->timeUnit, "state_l1", "OFF", true, IDLE);
|
//setDelay($deviceTarget, $this->delay, $this->timeUnit, "state_l1", "OFF", true, IDLE);
|
||||||
|
$this->send("OFF", IDLE);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case "state_l1":
|
case "state_l1":
|
||||||
|
28
hooks/scripts/rdc_temperature_int_ext.php
Normal file
28
hooks/scripts/rdc_temperature_int_ext.php
Normal file
@ -0,0 +1,28 @@
|
|||||||
|
<?php
|
||||||
|
// script to prevent when exterior temperature become inferior or superior to interior one
|
||||||
|
class rdc_temperature_int_ext extends hook
|
||||||
|
{
|
||||||
|
public $hookName = "rdc_wc_eclairage";
|
||||||
|
public $active = true; //enable/disable hook (true => enabled)
|
||||||
|
|
||||||
|
protected $devicelist = array(
|
||||||
|
METEO=> "tempc",
|
||||||
|
);
|
||||||
|
|
||||||
|
// callback fonction. Is called with these 4 parameters
|
||||||
|
public function callBack(&$device, $property, $value)
|
||||||
|
{
|
||||||
|
global $indexDevices;
|
||||||
|
if ($device->properties["indoortempc"]["value"] > $value)
|
||||||
|
{
|
||||||
|
logger(ALERT, _("Indoor temperature is superior to outdoor one"))
|
||||||
|
}elseif ($device->properties["indoortempc"]["value"] < $value)
|
||||||
|
{
|
||||||
|
logger(ALERT, _("Indoor temperature is inferior to outdoor one"))
|
||||||
|
}
|
||||||
|
logger (INFO, sprintf(_("%s: notification received from MQTT from %s => parameter: %s value: %s"), $this->hookName, $device->friendlyName, $property, bool2string($value)), __FILE__ . ":" . __LINE__);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
$hooks["rdc_temperature_int_ext"] = new rdc_temperature_int_ext();
|
||||||
|
?>
|
@ -46,11 +46,13 @@ class rdc_wc_eclairage extends hook
|
|||||||
{
|
{
|
||||||
//$targetDevice->properties["state_l2"]["method"] = AUTO;
|
//$targetDevice->properties["state_l2"]["method"] = AUTO;
|
||||||
$this->send($targetDevice, "ON", AUTO);
|
$this->send($targetDevice, "ON", AUTO);
|
||||||
|
removeEvent($targetDevice, "state_l2", "OFF");
|
||||||
}elseif ($value === false and $targetDevice->properties["state_l2"]["method"] == AUTO)
|
}elseif ($value === false and $targetDevice->properties["state_l2"]["method"] == AUTO)
|
||||||
{
|
{
|
||||||
//$targetDevice->properties["state_l2"]["method"] = IDLE;
|
//$targetDevice->properties["state_l2"]["method"] = IDLE;
|
||||||
//$this->send($targetDevice, "OFF");
|
//$this->send($targetDevice, "OFF");
|
||||||
setDelay($targetDevice, $this->delay, $this->timeUnit, "state_l2", "OFF", true, IDLE);
|
//setDelay($targetDevice, $this->delay, $this->timeUnit, "state_l2", "OFF", true, IDLE);
|
||||||
|
$this->send($targetDevice, "OFF", IDLE);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
logger (INFO, sprintf(_("%s: notification received from MQTT from %s => parameter: %s value: %s"), $this->hookName, $device->friendlyName, $property, bool2string($value)), __FILE__ . ":" . __LINE__);
|
logger (INFO, sprintf(_("%s: notification received from MQTT from %s => parameter: %s value: %s"), $this->hookName, $device->friendlyName, $property, bool2string($value)), __FILE__ . ":" . __LINE__);
|
||||||
|
@ -10,7 +10,7 @@ class rdc_wc_eclairage extends hook
|
|||||||
RDC_WC_MVMT => "occupancy"
|
RDC_WC_MVMT => "occupancy"
|
||||||
);
|
);
|
||||||
|
|
||||||
public $delay = 1; // amount of time in $timeunit
|
public $delay = 3; // amount of time in $timeunit
|
||||||
public $delayManual = 10; // amount of time in $timeunit for manual mode
|
public $delayManual = 10; // amount of time in $timeunit for manual mode
|
||||||
public $timeUnit = "minute"; // unit of time for delay, second, minute, day, week, month, year
|
public $timeUnit = "minute"; // unit of time for delay, second, minute, day, week, month, year
|
||||||
|
|
||||||
@ -31,26 +31,28 @@ class rdc_wc_eclairage extends hook
|
|||||||
if ($targetDevice->properties["state_l2"]["method"] == IDLE)
|
if ($targetDevice->properties["state_l2"]["method"] == IDLE)
|
||||||
{
|
{
|
||||||
$targetDevice->properties["state_l2"]["method"] = MANUAL;
|
$targetDevice->properties["state_l2"]["method"] = MANUAL;
|
||||||
setDelay($device, $this->delayManual, $this->timeUnit, "state_l2", "OFF", true);
|
setDelay($targetDevice, $this->delayManual, $this->timeUnit, "state_l2", "OFF", true);
|
||||||
}
|
}
|
||||||
}elseif ($value == "OFF")
|
}elseif ($value == "OFF")
|
||||||
{
|
{
|
||||||
$targetDevice->properties["state_l2"]["method"] = IDLE;
|
$targetDevice->properties["state_l2"]["method"] = IDLE;
|
||||||
removeEvent($device, "state_l2", "OFF");
|
removeEvent($targetDevice, "state_l2", "OFF");
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case "occupancy":
|
case "occupancy":
|
||||||
logger(DEBUG, "CASE: occupancy", __FILE__ . ":" . __LINE__);
|
logger(DEBUG, "CASE: WC occupancy", __FILE__ . ":" . __LINE__);
|
||||||
logger(DEBUG, "method =" . $targetDevice->properties["state_l2"]["method"], __FILE__ . ":" . __LINE__);
|
logger(DEBUG, "method =" . $targetDevice->properties["state_l2"]["method"], __FILE__ . ":" . __LINE__);
|
||||||
if ($value === true and $targetDevice->properties["state_l2"]["method"] == IDLE)
|
if ($value === true and $targetDevice->properties["state_l2"]["method"] == IDLE)
|
||||||
{
|
{
|
||||||
//$targetDevice->properties["state_l2"]["method"] = AUTO;
|
//$targetDevice->properties["state_l2"]["method"] = AUTO;
|
||||||
$this->send($targetDevice, "ON", AUTO);
|
$this->send($targetDevice, "ON", AUTO);
|
||||||
|
removeEvent($targetDevice, "state_l2", "OFF");
|
||||||
}elseif ($value === false and $targetDevice->properties["state_l2"]["method"] == AUTO)
|
}elseif ($value === false and $targetDevice->properties["state_l2"]["method"] == AUTO)
|
||||||
{
|
{
|
||||||
//$targetDevice->properties["state_l2"]["method"] = IDLE;
|
//$targetDevice->properties["state_l2"]["method"] = IDLE;
|
||||||
//$this->send($targetDevice, "OFF");
|
//$this->send($targetDevice, "OFF");
|
||||||
setDelay($device, $this->delay, $this->timeUnit, "state_l2", "OFF", true, IDLE);
|
//setDelay($targetDevice, $this->delay, $this->timeUnit, "state_l2", "OFF", true, IDLE);
|
||||||
|
$this->send($targetDevice, "OFF", IDLE);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
logger (INFO, sprintf(_("%s: notification received from MQTT from %s => parameter: %s value: %s"), $this->hookName, $device->friendlyName, $property, bool2string($value)), __FILE__ . ":" . __LINE__);
|
logger (INFO, sprintf(_("%s: notification received from MQTT from %s => parameter: %s value: %s"), $this->hookName, $device->friendlyName, $property, bool2string($value)), __FILE__ . ":" . __LINE__);
|
||||||
|
3
moha.php
3
moha.php
@ -176,7 +176,7 @@ function connect2mqttServer()
|
|||||||
global $client;
|
global $client;
|
||||||
$client->onConnect('connectResponse');
|
$client->onConnect('connectResponse');
|
||||||
}
|
}
|
||||||
logger(WARNING, _("starting moha"), __FILE__ . ":" . __LINE__);
|
logger(ALERT, _("starting moha"), __FILE__ . ":" . __LINE__);
|
||||||
|
|
||||||
|
|
||||||
logger(DEBUG, _("requiring config files -> devices_constants.php"), __FILE__ . ":" . __LINE__);
|
logger(DEBUG, _("requiring config files -> devices_constants.php"), __FILE__ . ":" . __LINE__);
|
||||||
@ -312,6 +312,7 @@ foreach($topics as $name => &$topic)
|
|||||||
// starting main loop
|
// starting main loop
|
||||||
logger(INFO, _("Starting loop"), __FILE__ . ":" . __LINE__, false);
|
logger(INFO, _("Starting loop"), __FILE__ . ":" . __LINE__, false);
|
||||||
$oneshot = false;
|
$oneshot = false;
|
||||||
|
logger(ALERT, _("Moha started"), __FILE__ . ":" . __LINE__);
|
||||||
|
|
||||||
while (true)
|
while (true)
|
||||||
{
|
{
|
||||||
|
Loading…
Reference in New Issue
Block a user