From af2365213818eaf496eddf256ef64ae6d0fada20 Mon Sep 17 00:00:00 2001 From: Karsten Thiele Date: Sun, 20 Dec 2020 20:55:57 +0100 Subject: [PATCH] 1.1.4 test impr. --- README.md | 2 + test/lib/fritzserver.js | 20 +++++ test/light_hkr_group.json | 156 +++++++++++++++++++++++++++++++++++++ test/testAdapter.js | 74 ++++++++++++++++++ test/test_api_response.xml | 29 +++++++ 5 files changed, 281 insertions(+) create mode 100644 test/light_hkr_group.json diff --git a/README.md b/README.md index dbd42a5d..a41fbd2a 100644 --- a/README.md +++ b/README.md @@ -176,12 +176,14 @@ Not all FW-versions of fritz.box support all objects. ## TODO: * universal object names and structures -> breaking change * groups inside a device e.g. DECT440 -> breaking change +* groups for DECT500 * usage of predefined colors * improvement of thermostat mode to text representation (auto, off, boost, comfort, night), comfort and night are also auto mode, but preset to the parametrized value ## Changelog ### 1.1.4 * blinds control +* update testing ### 1.1.3 (npm) * setcolor cmd correction diff --git a/test/lib/fritzserver.js b/test/lib/fritzserver.js index f01ab877..a558a83b 100644 --- a/test/lib/fritzserver.js +++ b/test/lib/fritzserver.js @@ -56,6 +56,15 @@ function handleHttpRequest(request, response) { '0' ); response.end(); + } else if (request.url == '/login_sid.lua?version=2') { + //check the URL of the current request + response.writeHead(200, { 'Content-Type': 'application/xml' }); + response.write( + '0000000000000000' + + challenge + + '0' + ); + response.end(); } else if (request.url == '/login_sid.lua?username=admin') { //check the URL of the current request response.writeHead(200, { 'Content-Type': 'application/xml' }); @@ -76,6 +85,17 @@ function handleHttpRequest(request, response) { '0Dial2App2HomeAuto2BoxAdmin2Phone2NAS2' ); response.end(); + } else if (request.url == '/login_sid.lua?version=2?username=admin&response=' + challengeResponse) { + //check the URL of the current request + response.writeHead(200, { 'Content-Type': 'application/xml' }); + response.write( + '' + + sid + + '' + + challenge2 + + '0Dial2App2HomeAuto2BoxAdmin2Phone2NAS2' + ); + response.end(); } else if (request.url == '/webservices/homeautoswitch.lua?0=0&sid=' + sid + '&switchcmd=getswitchlist') { //check the URL of the current request response.writeHead(200, { 'Content-Type': 'application/json' }); diff --git a/test/light_hkr_group.json b/test/light_hkr_group.json new file mode 100644 index 00000000..d43cafc7 --- /dev/null +++ b/test/light_hkr_group.json @@ -0,0 +1,156 @@ +[ + { + "synchronized": "0", + "identifier": "grp9CEFB6-3BDCFFC80", + "id": "901", + "functionbitmask": "233476", + "fwversion": "1.0", + "manufacturer": "AVM", + "present": "1", + "txbusy": "0", + "name": "Stehlampe", + "simpleonoff": { "state": "1" }, + "levelcontrol": { "level": "26", "levelpercentage": "10" }, + "colorcontrol": { + "supported_modes": "5", + "current_mode": "4", + "hue": "", + "saturation": "", + "temperature": "3000" + }, + "groupinfo": { "masterdeviceid": "0", "members": "2010,2011" } + }, + { + "synchronized": "0", + "identifier": "grp9CEFB6-3BB5C647F", + "id": "900", + "functionbitmask": "233476", + "fwversion": "1.0", + "manufacturer": "AVM", + "present": "1", + "txbusy": "0", + "name": "Licht Kinderzimmer", + "simpleonoff": { "state": "1" }, + "levelcontrol": { "level": "0", "levelpercentage": "0" }, + "colorcontrol": { + "supported_modes": "5", + "current_mode": "4", + "hue": "", + "saturation": "", + "temperature": "3000" + }, + "groupinfo": { "masterdeviceid": "0", "members": "2009,2012" } + }, + { + "synchronized": "1", + "identifier": "grp9CEFB6-3BB5C8228", + "id": "905", + "functionbitmask": "4160", + "fwversion": "1.0", + "manufacturer": "AVM", + "present": "1", + "txbusy": "0", + "name": "Heizung Bäder", + "hkr": { + "tist": "", + "tsoll": "44", + "absenk": "40", + "komfort": "44", + "lock": "0", + "devicelock": "0", + "errorcode": "0", + "windowopenactiv": "0", + "windowopenactiveendtime": "0", + "boostactive": "0", + "boostactiveendtime": "0", + "nextchange": { "endperiod": "1608498000", "tchange": "40" }, + "summeractive": "0", + "holidayactive": "0" + }, + "groupinfo": { "masterdeviceid": "0", "members": "20,16" } + }, + { + "synchronized": "1", + "identifier": "grp9CEFB6-3BB5C5FBE", + "id": "904", + "functionbitmask": "4160", + "fwversion": "1.0", + "manufacturer": "AVM", + "present": "1", + "txbusy": "0", + "name": "Heizung Wohnzimmer", + "hkr": { + "tist": "", + "tsoll": "42", + "absenk": "36", + "komfort": "42", + "lock": "0", + "devicelock": "0", + "errorcode": "0", + "windowopenactiv": "0", + "windowopenactiveendtime": "0", + "boostactive": "0", + "boostactiveendtime": "0", + "nextchange": { "endperiod": "1608501600", "tchange": "36" }, + "summeractive": "0", + "holidayactive": "0" + }, + "groupinfo": { "masterdeviceid": "0", "members": "24,25" } + }, + { + "synchronized": "1", + "identifier": "grp9CEFB6-3BB5C6313", + "id": "903", + "functionbitmask": "4160", + "fwversion": "1.0", + "manufacturer": "AVM", + "present": "1", + "txbusy": "0", + "name": "Heizung Kinderzimmer", + "hkr": { + "tist": "", + "tsoll": "253", + "absenk": "38", + "komfort": "42", + "lock": "0", + "devicelock": "0", + "errorcode": "0", + "windowopenactiv": "0", + "windowopenactiveendtime": "0", + "boostactive": "0", + "boostactiveendtime": "0", + "nextchange": { "endperiod": "1608490800", "tchange": "38" }, + "summeractive": "0", + "holidayactive": "0" + }, + "groupinfo": { "masterdeviceid": "0", "members": "23,21" } + }, + { + "synchronized": "1", + "identifier": "grp9CEFB6-3BB5C6181", + "id": "902", + "functionbitmask": "4160", + "fwversion": "1.0", + "manufacturer": "AVM", + "present": "1", + "txbusy": "0", + "name": "Heizung Schlafzimmer", + "hkr": { + "tist": "", + "tsoll": "42", + "absenk": "38", + "komfort": "42", + "lock": "0", + "devicelock": "0", + "errorcode": "0", + "windowopenactiv": "0", + "windowopenactiveendtime": "0", + "boostactive": "0", + "boostactiveendtime": "0", + "nextchange": { "endperiod": "1608490800", "tchange": "38" }, + "summeractive": "0", + "holidayactive": "0" + }, + "groupinfo": { "masterdeviceid": "0", "members": "18,19" } + } +] diff --git a/test/testAdapter.js b/test/testAdapter.js index 802f6df9..4edd3452 100644 --- a/test/testAdapter.js +++ b/test/testAdapter.js @@ -2141,6 +2141,80 @@ describe('Test ' + adapterShortName + ' adapter', function() { }); }, 1000); }); + it('Test ' + adapterShortName + ' adapter: Check values of Blinds', function(done) { + this.timeout(30000); + setTimeout(function() { + states.getState('fritzdect.0.Blinds_119340395779-1.name', function(err, state) { + if (err) console.error(err); + expect(state).to.exist; + if (!state) { + console.error('state "fritzdect.0.Blinds_119340395779-1.name" not set'); + } else { + console.log('fritzdect.0.Blinds_119340395779-1.name ... ' + state.val); + } + expect(state.val).to.exist; + expect(state.val).to.be.equal('test Rollladen'); + states.getState('fritzdect.0.Blinds_119340395779-1.present', function(err, state) { + if (err) console.error(err); + expect(state).to.exist; + if (!state) { + console.error('state "fritzdect.0.Blinds_119340395779-1.present" not set'); + } else { + console.log('fritzdect.0.Blinds_119340395779-1.present ... ' + state.val); + } + expect(state.val).to.exist; + expect(state.val).to.be.equal(true); + states.getState('fritzdect.0.Blinds_119340395779-1.id', function(err, state) { + if (err) console.error(err); + expect(state).to.exist; + if (!state) { + console.error('state "fritzdect.0.Blinds_119340395779-1.id" not set'); + } else { + console.log('fritzdect.0.Blinds_119340395779-1.id ... ' + state.val); + } + expect(state.val).to.exist; + expect(state.val).to.be.equal('2000'); + states.getState('fritzdect.0.Blinds_119340395779-1.fwversion', function(err, state) { + if (err) console.error(err); + expect(state).to.exist; + if (!state) { + console.error('state "fritzdect.0.Blinds_119340395779-1.fwversion" not set'); + } else { + console.log('fritzdect.0.Blinds_119340395779-1.fwversion ... ' + state.val); + } + expect(state.val).to.exist; + expect(state.val).to.be.equal('0.0'); + states.getState('fritzdect.0.Blinds_119340395779-1.manufacturer', function(err, state) { + if (err) console.error(err); + expect(state).to.exist; + if (!state) { + console.error('state "fritzdect.0.Blinds_119340395779-1.manufacturer" not set'); + } else { + console.log('fritzdect.0.Blinds_119340395779-1.manufacturer ... ' + state.val); + } + expect(state.val).to.exist; + expect(state.val).to.be.equal('0x0feb'); + states.getState('fritzdect.0.Blinds_119340395779-1.level', function(err, state) { + if (err) console.error(err); + expect(state).to.exist; + if (!state) { + console.error('state "fritzdect.0.Blinds_119340395779-1.level" not set'); + } else { + console.log('fritzdect.0.Blinds_119340395779-1.temp ... ' + state.val); + expect(state.val).to.exist; + expect(state.val).to.be.equal(77); + done(); + // to be added levelpercentage, alert state, alert lastalertchgtimestamp + } + }); + }); + }); + }); + }); + }); + }, 1000); + }); + // templates it('Test ' + adapterShortName + ' adapter: Objects must exist for template_tmp6F0093-39091EED0', (done) => { setTimeout(function() { objects.getObject(adapterShortName + '.0.template_tmp6F0093-39091EED0.name', (err, obj) => { diff --git a/test/test_api_response.xml b/test/test_api_response.xml index 77eae1e9..a33f50a0 100644 --- a/test/test_api_response.xml +++ b/test/test_api_response.xml @@ -349,6 +349,35 @@ 19,20 + + 0 + grp9CEFB6-3BDCFFC80 + 901 + 233476 + 1.0 + AVM + 1 + 0 + Stehlampe + + 1 + + + 26 + 10 + + + 5 + 4 + + + 3000 + + + 0 + 2010,2011 + + 099950403922 56