soft reboot node

Moderator: leecollings

Post Reply
Sevift
Posts: 31
Joined: Monday 21 September 2015 16:02
Target OS: Raspberry Pi / ODroid
Domoticz version: Latest
Contact:

soft reboot node

Post by Sevift »

is it possible to from domoticz send a command reboot?
Снимок экрана 2015-12-29 в 14.59.49.png
Снимок экрана 2015-12-29 в 14.59.49.png (7.51 KiB) Viewed 1780 times
jannl
Posts: 673
Joined: Thursday 02 October 2014 6:36
Target OS: Raspberry Pi / ODroid
Domoticz version: 2022.2
Location: Geleen
Contact:

Re: soft reboot node

Post by jannl »

Set this as code in the On-action of a virtual switch:

http://192.168.1.2:8080/json.htm?type=c ... tem_reboot
(replace the ip-address with your own)

Edit: I use this on a Pi.
Sevift
Posts: 31
Joined: Monday 21 September 2015 16:02
Target OS: Raspberry Pi / ODroid
Domoticz version: Latest
Contact:

Re: soft reboot node

Post by Sevift »

This restart domoticz.
Is necessary to reboot the devices mysensors.
How does MYSController
jannl
Posts: 673
Joined: Thursday 02 October 2014 6:36
Target OS: Raspberry Pi / ODroid
Domoticz version: 2022.2
Location: Geleen
Contact:

Re: soft reboot node

Post by jannl »

That actually reboots the Pi, not just Domoticz, see https://www.domoticz.com/wiki/Domoticz_API/JSON_URL's
Sevift
Posts: 31
Joined: Monday 21 September 2015 16:02
Target OS: Raspberry Pi / ODroid
Domoticz version: Latest
Contact:

Re: soft reboot node

Post by Sevift »

I mean, this is:
I_REBOOT 13 Used by OTA firmware updates. Request for node to reboot.
http://www.mysensors.org/download/serial_api_15
Sevift
Posts: 31
Joined: Monday 21 September 2015 16:02
Target OS: Raspberry Pi / ODroid
Domoticz version: Latest
Contact:

Re: soft reboot node

Post by Sevift »

Used by OTA firmware updates. Request for node to reboot.
I tried to implement it.
Снимок экрана 2016-01-23 в 23.17.43.png
Снимок экрана 2016-01-23 в 23.17.43.png (70.28 KiB) Viewed 1609 times
I have not used even once git pull request (It would be nice to receive instructions)

add in MySensorsBase.cpp
after void MySensorsBase::RemoveNode(const int nodeID)

Code: Select all

void MySensorsBase::RebootNode(const int nodeID) 
{
	SendNodeCommand(nodeID, 0, MT_Internal, I_REBOOT, "");
}
after
void CWebServer::Cmd_MySensorsRemoveNode(WebEmSession & session, const request& req, Json::Value &root)
add

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);
		}
add in MySensorsBase.h
after
void RemoveNode(const int nodeID);

Code: Select all

void RebootNode(const int nodeID);
add in WebServer.h
after
void Cmd_MySensorsRemoveNode(WebEmSession & session, const request& req, Json::Value &root);

Code: Select all

void Cmd_MySensorsRebootNode(WebEmSession & session, const request& req, Json::Value &root);
add in WebServer.cpp
after
RegisterCommandCode("mysensorsremovenode", boost::bind(&CWebServer::Cmd_MySensorsRemoveNode, this, _1, _2, _3));

Code: Select all

RegisterCommandCode("mysensorsrebootnode", boost::bind(&CWebServer::Cmd_MySensorsRebootNode, this, _1, _2, _3));
add in HardwareController.js
after MySensorsDeleteNode = function(nodeid)

Code: Select all

MySensorsRebootNode = function (nodeid) { 
            if ($('#updelclr #nodereboot').attr("class") == "btnstyle3-dis") {
                return;
            }
            $.ajax({
                url: "json.htm?type=command&param=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);
                }
            });
        }
After these lines
/* Add a click handler to the rows - this could be used as a callback */
$("#mysensorsnodestable tbody").off();
$("#mysensorsnodestable tbody").on( 'click', 'tr', function () {
$('#updelclr #nodedelete').attr("class", "btnstyle3-dis");
$('#updelclr #nodeupdate').attr("class", "btnstyle3-dis");
add

Code: Select all

$('#updelclr #nodereboot').attr("class", "btnstyle3-dis"); 
ibid after this line
$('#updelclr #nodeupdate').attr("class", "btnstyle3");
add

Code: Select all

$('#updelclr #nodereboot').attr("class", "btnstyle3");
ibid after this line
$("#updelclr #nodedelete").attr("href", "javascript:MySensorsDeleteNode(" + idx + ")");
add

Code: Select all

$("#updelclr #nodereboot").attr("href", "javascript:MySensorsRebootNode(" + idx + ")");
in hardware.html
it

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>&nbsp;&nbsp;&nbsp;
				<a class="btnstyle3-dis" id="nodedelete" data-i18n="Delete">Delete</a> 
replace by

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>&nbsp;&nbsp;&nbsp;
				<a class="btnstyle3-dis" id="nodedelete" data-i18n="Delete">Delete</a>&nbsp;&nbsp;&nbsp;
                <a class="btnstyle3-dis" id="nodereboot" data-i18n="Reboot">Reboot</a>
p.s.
I do not know C ++ and Java, and web. I do not know the architecture Domoticz. But it works. Strongly do not scold.


You have to have a bootloader with watchdogs enabled like optiboot or the MySensors bootloader
Post Reply

Who is online

Users browsing this forum: No registered users and 1 guest