Fake accelerometer and handle hasMainSwitch
This commit is contained in:
parent
5233aa38af
commit
d97d90cf95
11 changed files with 3692 additions and 549 deletions
|
|
@ -33,7 +33,7 @@ exports.install = function(instance) {
|
|||
|
||||
logger.debug(exports.title, "installed");
|
||||
|
||||
instance.on("close", function(){
|
||||
instance.on("close", function() {
|
||||
clearInterval(startRead);
|
||||
})
|
||||
|
||||
|
|
@ -42,24 +42,25 @@ exports.install = function(instance) {
|
|||
|
||||
try {
|
||||
|
||||
if(temperatureAddress === "") throw "Thermometer: temperatureAddress is not defined";
|
||||
if (temperatureAddress === "") throw "Thermometer: temperatureAddress is not defined";
|
||||
|
||||
exec(`owread -C ${temperatureAddress}/temperature`, (error, stdout, stderr) => {
|
||||
|
||||
if(!error)
|
||||
{
|
||||
if (!error) {
|
||||
parseData(stdout)
|
||||
return;
|
||||
}
|
||||
|
||||
counter++;
|
||||
if(counter == NUMBER_OF_FAILURES_TO_SEND_ERROR) sendNotification("Thermometer_main", rvoTbName, "thermometer_is_not_responding", {}, {"Error": error}, SEND_TO.tb, instance, "thermometer");
|
||||
monitor.info("Thermometer is not responding", error);
|
||||
instance.send(SEND_TO.dido_controller, {status: "NOK-thermometer"});
|
||||
if (counter == NUMBER_OF_FAILURES_TO_SEND_ERROR) {
|
||||
sendNotification("Thermometer_main", rvoTbName, "thermometer_is_not_responding", {}, { "Error": error }, SEND_TO.tb, instance, "thermometer");
|
||||
monitor.info("Thermometer is not responding", error);
|
||||
}
|
||||
instance.send(SEND_TO.dido_controller, { status: "NOK-thermometer" });
|
||||
});
|
||||
|
||||
}
|
||||
catch(err) {
|
||||
catch (err) {
|
||||
errLogger.error(exports.title, err);
|
||||
clearInterval(startRead);
|
||||
}
|
||||
|
|
@ -70,12 +71,12 @@ exports.install = function(instance) {
|
|||
data = parseFloat(data);
|
||||
//logger.debug("Thermometer", data);
|
||||
|
||||
if(isNaN(data)) {
|
||||
if (isNaN(data)) {
|
||||
errLogger.error("Thermometer sends invalid data");
|
||||
return;
|
||||
}
|
||||
|
||||
if(counter > NUMBER_OF_FAILURES_TO_SEND_ERROR) //1 hour
|
||||
if (counter > NUMBER_OF_FAILURES_TO_SEND_ERROR) //1 hour
|
||||
{
|
||||
instance.send(SEND_TO.debug, "Thermometer - temperature data are comming again");
|
||||
sendNotification("Thermometer_parseData", rvoTbName, "thermometer_is_responding_again", {}, "", SEND_TO.tb, instance, "thermometer");
|
||||
|
|
@ -85,7 +86,7 @@ exports.install = function(instance) {
|
|||
"temperature": Number(data.toFixed(2)),
|
||||
}
|
||||
|
||||
instance.send(SEND_TO.dido_controller, {values: values});
|
||||
instance.send(SEND_TO.dido_controller, { values: values });
|
||||
counter = 0;
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue