soft reboot node
Posted: Tuesday 29 December 2015 15:02
is it possible to from domoticz send a command reboot?
Code: Select all
void MySensorsBase::RebootNode(const int nodeID)
{
SendNodeCommand(nodeID, 0, MT_Internal, I_REBOOT, "");
}
Code: Select all
void CWebServer::Cmd_MySensorsRebootNode(WebEmSession & session, const request& req, Json::Value &root)
{
if (session.rights != 2)
{
//No admin user, and not allowed to be here
return;
}
std::string hwid = request::findValue(&req, "idx");
std::string nodeid = request::findValue(&req, "nodeid");
if (
(hwid == "") ||
(nodeid == "")
)
return;
int iHardwareID = atoi(hwid.c_str());
CDomoticzHardwareBase *pBaseHardware = m_mainworker.GetHardware(iHardwareID);
if (pBaseHardware == NULL)
return;
if (
(pBaseHardware->HwdType != HTYPE_MySensorsUSB) &&
(pBaseHardware->HwdType != HTYPE_MySensorsTCP)
)
return;
MySensorsBase *pMySensorsHardware = (MySensorsBase*)pBaseHardware;
int NodeID = atoi(nodeid.c_str());
root["status"] = "OK";
root["title"] = "MySensorsRebootNode";
pMySensorsHardware->RebootNode(NodeID);
}
Code: Select all
void RebootNode(const int nodeID);
Code: Select all
void Cmd_MySensorsRebootNode(WebEmSession & session, const request& req, Json::Value &root);
Code: Select all
RegisterCommandCode("mysensorsrebootnode", boost::bind(&CWebServer::Cmd_MySensorsRebootNode, this, _1, _2, _3));
Code: Select all
MySensorsRebootNode = function (nodeid) {
if ($('#updelclr #nodereboot').attr("class") == "btnstyle3-dis") {
return;
}
$.ajax({
url: "json.htm?type=command¶m=mysensorsrebootnode" +
"&idx=" + $.devIdx +
"&nodeid=" + nodeid +
"&name=" + encodeURIComponent(name),
async: false,
dataType: 'json',
success: function (data) {
RefreshMySensorsNodeTable();
},
error: function () {
ShowNotify($.t('Problem Updating Node!'), 2500, true);
}
});
}
Code: Select all
$('#updelclr #nodereboot').attr("class", "btnstyle3-dis");
Code: Select all
$('#updelclr #nodereboot').attr("class", "btnstyle3");
Code: Select all
$("#updelclr #nodereboot").attr("href", "javascript:MySensorsRebootNode(" + idx + ")");
Code: Select all
<div id="mysensors" style="display:none;">
<div class="page-header-small">
<table border="0" cellpadding="0" cellspacing="0" width="100%">
<tr>
<td>
<h1 data-i18n="Nodes">Nodes</h1>
</td>
</tr>
</table>
</div>
<table class="display" id="mysensorsnodestable" border="0" cellpadding="0" cellspacing="0" width="100%">
<thead>
<tr>
<th width="80" align="center" data-i18n="NodeID">NodeID</th>
<th align="left" data-i18n="Name">Name</th>
<th align="left" data-i18n="Sketch Name">Sketch Name</th>
<th width="60" align="left" data-i18n="Version">Version</th>
<th width="60" align="left" data-i18n="Childs">Childs</th>
<th width="160" align="left" data-i18n="Last Seen">Last Seen</th>
</tr>
</thead>
</table>
<table id="updelclr" border="0" cellpadding="0" cellspacing="0" width="100%">
<tr>
<td>
<a class="btnstyle3-dis" id="nodeupdate" data-i18n="Update">Update</a>
<a class="btnstyle3-dis" id="nodedelete" data-i18n="Delete">Delete</a>
Code: Select all
<div id="mysensors" style="display:none;">
<div class="page-header-small">
<table border="0" cellpadding="0" cellspacing="0" width="100%">
<tr>
<td>
<h1 data-i18n="Nodes">Nodes</h1>
</td>
</tr>
</table>
</div>
<table class="display" id="mysensorsnodestable" border="0" cellpadding="0" cellspacing="0" width="100%">
<thead>
<tr>
<th width="80" align="center" data-i18n="NodeID">NodeID</th>
<th align="left" data-i18n="Name">Name</th>
<th align="left" data-i18n="Sketch Name">Sketch Name</th>
<th width="60" align="left" data-i18n="Version">Version</th>
<th width="60" align="left" data-i18n="Childs">Childs</th>
<th width="160" align="left" data-i18n="Last Seen">Last Seen</th>
</tr>
</thead>
</table>
<table id="updelclr" border="0" cellpadding="0" cellspacing="0" width="100%">
<tr>
<td>
<a class="btnstyle3-dis" id="nodeupdate" data-i18n="Update">Update</a>
<a class="btnstyle3-dis" id="nodedelete" data-i18n="Delete">Delete</a>
<a class="btnstyle3-dis" id="nodereboot" data-i18n="Reboot">Reboot</a>