Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
  • Loading branch information
empierre committed Nov 11, 2023
1 parent 3b6cf6b commit 0e8c86a
Showing 1 changed file with 14 additions and 10 deletions.
24 changes: 14 additions & 10 deletions mdah.js
Original file line number Diff line number Diff line change
Expand Up @@ -261,7 +261,7 @@ function getLastVersion() {
}
}
function getSettingsSecPassword() {
var url = getURL(req) + "?type=settings";
var url = getURL(req) + "?type=command&param=getsettings";
var res = requester('GET', url);
if (res.statusCode!=200) {return({})};
logger.info(url);
Expand Down Expand Up @@ -1630,7 +1630,9 @@ function DevMultiSwitchHeating(data) {
}

function getDeviceType(deviceId) {
var url = getURL(req) + "?type=devices&rid=" + deviceId;
logger.info("In");
var url = getURL() + "?type=command&param=getdevices&rid=" + deviceId;
logger.info("Out "+url);
var res = requester('GET', url);
if (res.statusCode!=200) {return({})};
logger.info(url);
Expand All @@ -1639,15 +1641,16 @@ function getDeviceType(deviceId) {
};

function getDeviceSubType(deviceId) {
var url = getURL(req) + "?type=devices&rid=" + deviceId;
var url = getURL() + "?type=command&param=devices&rid=" + deviceId;
logger.info(url);
var res = requester('GET', url);
if (res.statusCode!=200) {return({})};
var js = JSON.parse(res.body.toString('utf-8'));
return (js.result[0].SubType);
};

function DevCamera(req) {
var url = getURL(req) + "?type=cameras&rid=";
var url = getURL(req) + "?type=command&param=getcameras&rid=";
var res = requester('GET', url);
if (res.statusCode!=200) {return({})};
var data = JSON.parse(res.body.toString('utf-8'));
Expand Down Expand Up @@ -1722,7 +1725,7 @@ app.get("/rooms", auth, function (req, res) {
//TODO: add hidden rooms
res.type('json');
var options = {
url: getURL(req)+"?type=plans&order=name&used=true",
url: getURL(req)+"?type=command&param=getplans&order=name&used=true",
headers: {
'User-Agent': 'request'
}
Expand Down Expand Up @@ -1940,7 +1943,7 @@ app.get("/devices/:deviceId/action/:actionName/:actionParam?", auth, function (r
case 'setSetPoint':
res.type('json');
var options = {
url: getURL(req) + "?type=setused&idx=" + deviceId + "&used=true&setpoint=" + actionParam +"&passcode="+passcode,
url: getURL(req) + "?type=command&param=setused&idx=" + deviceId + "&used=true&setpoint=" + actionParam +"&passcode="+passcode,
headers: {
'User-Agent': 'request'
}
Expand Down Expand Up @@ -2118,13 +2121,14 @@ app.get("/devices/:deviceId/:paramKey/histo/:startdate/:enddate", auth, function
type='temp';
key='ba';
} else {
type =getDeviceType(deviceId).toLowerCase();
logger.info("P3 "+deviceId);
type=getDeviceType(deviceId).toLowerCase();
logger.info("P3 out");
}
var ptype = type;
var curl = "&method=1";
logger.info(deviceId +"/"+PLine+" "+type+" "+ptype);


if ((type === "lux") || (type === "energy") || (type == "rfxmeter")) {
type = "counter";
curl = "&method=1";
Expand Down Expand Up @@ -2157,7 +2161,7 @@ app.get("/devices/:deviceId/:paramKey/histo/:startdate/:enddate", auth, function
}
res.type('json');
var options = {
url: getURL(req) + "?type=graph&sensor=" + type + curl + "&idx=" + deviceId + "&range=" + range,
url: getURL(req) + "?type=command&param=graph&sensor=" + type + curl + "&idx=" + deviceId + "&range=" + range,
headers: {
'User-Agent': 'request'
}
Expand Down Expand Up @@ -2194,7 +2198,7 @@ app.get("/devices/:deviceId/:paramKey/histo/:startdate/:enddate", auth, function
if ((deviceId)&&((deviceId.match(/_1/)))) {
key='ba';
}
//logger.info('rawkey='+key+" "+type+" "+ptype);
logger.info('rawkey='+key+" "+type+" "+ptype);
if (key === 'tm') {key='te';}
if (paramKey === 'temp') {
key = 'te';
Expand Down

0 comments on commit 0e8c86a

Please sign in to comment.