Skip to content

Commit

Permalink
Merge pull request #28 from Scrounger/master
Browse files Browse the repository at this point in the history
timerlist bug fix
  • Loading branch information
Matten-Matten authored Nov 17, 2019
2 parents 55ee2e5 + 9d781f4 commit d52d0de
Showing 1 changed file with 56 additions and 1 deletion.
57 changes: 56 additions & 1 deletion enigma2.js
Original file line number Diff line number Diff line change
Expand Up @@ -147,6 +147,8 @@ adapter.on('stateChange', function (id, state) {
getResponse('GETVOLUME', deviceId, PATH['VOLUME'], evaluateCommandResponse);
getResponse('GETCURRENT', deviceId, PATH['GET_CURRENT'], evaluateCommandResponse);
getResponse('ISRECORD', deviceId, PATH['ISRECORD'], ISRECORD);
getResponse('TIMERLIST', deviceId, PATH['TIMERLIST'], evaluateCommandResponse);

//getResponse('STATUSINFO', deviceId, PATH['API'], APIstatusinfo);
adapter.log.debug("E2 States manuell aktualisiert");
adapter.setState('enigma2.Update', {val: state.val, ack: true});
Expand Down Expand Up @@ -653,7 +655,47 @@ function evaluateCommandResponse (command, deviceId, xml) {
case "BOUQUET_DOWN":
case "INFO":
case "MENU":
//setState(boxId, "");
case "TIMERLIST":
let result = [];

if (xml && xml.e2timerlist && xml.e2timerlist.e2timer) {
let timerList = xml.e2timerlist.e2timer;

timerList.forEach(function (timerItem) {
result.push(
{
title: timerItem["e2name"].toString(),
channel: timerItem["e2servicename"].toString(),
serviceRef: timerItem["e2servicereference"].toString(),
serviceRefName: timerItem["e2servicereference"].toString().replace(/:/g, '_').slice(0,-1),
starTime: timerItem["e2timebegin"].toString(),
endTime: timerItem["e2timeend"].toString(),
duration: timerItem["e2duration"].toString(),
subtitle: timerItem["e2description"].toString(),
description: timerItem["e2descriptionextended"].toString(),
}
)
});

// only update if we have a result -> keep on data if box is in deepStandby
result = JSON.stringify(result);

adapter.getState('enigma2.Timer_list', function(err, state) {
// only update if we have new timer
if (state && state.val !== null){
if (result !== state.val){
adapter.setState('enigma2.Timer_list', result, true);
adapter.log.debug("timer_list updated");
} else {
adapter.log.debug("no new timer found -> timer_list need no update");
}
} else {
adapter.setState('enigma2.Timer_list', result, true);
}
});
}
break;

default:
adapter.log.info("received unknown command '"+command+"' @ evaluateCommandResponse");
}
Expand Down Expand Up @@ -723,6 +765,7 @@ function setStatus(status)
getResponse('GETVOLUME', deviceId, PATH['VOLUME'], evaluateCommandResponse);
getResponse('GETCURRENT', deviceId, PATH['GET_CURRENT'], evaluateCommandResponse);
getResponse('ISRECORD', deviceId, PATH['ISRECORD'], ISRECORD);
getResponse('TIMERLIST', deviceId, PATH['TIMERLIST'], evaluateCommandResponse);
//getResponse('STATUSINFO', deviceId, PATH['API'], APIstatusinfo);
getResponse('DEVICEINFO', deviceId, PATH['DEVICEINFO'], evaluateCommandResponse);
} else {
Expand Down Expand Up @@ -1109,6 +1152,7 @@ function main() {
getResponse('GETVOLUME', deviceId, PATH['VOLUME'], evaluateCommandResponse);
getResponse('GETCURRENT', deviceId, PATH['GET_CURRENT'], evaluateCommandResponse);
getResponse('ISRECORD', deviceId, PATH['ISRECORD'], ISRECORD);
getResponse('TIMERLIST', deviceId, PATH['TIMERLIST'], evaluateCommandResponse);
//getResponse('STATUSINFO', deviceId, PATH['API'], APIstatusinfo);
}, adapter.config.PollingInterval);

Expand Down Expand Up @@ -1188,6 +1232,17 @@ function main2() {
write: false
},
native: {}
});
adapter.setObjectNotExists('enigma2.Timer_list', {
type: 'state',
common: {
type: 'string',
role: 'info',
name: 'Timer List',
read: true,
write: false
},
native: {}
});

// in this example all states changes inside the adapters namespace are subscribed
Expand Down

0 comments on commit d52d0de

Please sign in to comment.