fritzapi icon indicating copy to clipboard operation
fritzapi copied to clipboard

getWindowOpen and FritzOS 7

Open delta2308151984 opened this issue 7 years ago • 7 comments

I´ve updated my FritzBox 7490 to OS 7.01 and the getWindowOpen function don´t work anymore. It´s just getting false.

In the example.js Raw devices section it is getting the correct windowopenactiv: 1 state

delta2308151984 avatar Sep 12 '18 20:09 delta2308151984

That looks like either a UI bug or a functionality change. The table is no longer displaying the window open icon:

screen shot 2018-09-13 at 15 05 31

The raw device output has also changed:

[ { identifier: '119340326786-1',
    id: '2000',
    functionbitmask: '8208',
    fwversion: '0.0',
    manufacturer: '0x0feb',
    productname: 'HAN-FUN',
    present: '1',
    name: 'no name',
    etsiunitinfo: { etsideviceid: '406', unittype: '514', interfaces: '256' },
    alert: { state: '1' } },
  { identifier: '119340326786',
    id: '406',
    functionbitmask: '1',
    fwversion: '00.00',
    manufacturer: '0x0feb',
    productname: 'HAN-FUN',
    present: '1',
    name: 'HAN-FUN #1' } ]

Instead of the HANFUN device there is now device plus one entry per function.

I'm wondering if this complexity should be hidden in terms of supporting multiple FritzOS versions:

  • try AIN as HAN function first?
  • find window sensor for matching AIN?
  • use UI fallback as last resort?

I'll see if I can draft something.

andig avatar Sep 13 '18 13:09 andig

The icon is still shown in the UI. smarthome

smarthome_icon

delta2308151984 avatar Sep 13 '18 15:09 delta2308151984

So, without adding another API and utilizing lodash you could do something like:

getDevice(sid, ain).then(device => +_.get(device, ['alert', 'state']));

Would that work for you?

andig avatar Sep 13 '18 15:09 andig

Sorry, meine Java Kenntnisse sind nur rudimentär ;-) Muss ich das in eine neue function einbauen? Am 13. Sep. 2018, 17:41 +0200 schrieb andig [email protected]:

So, without adding another API and utilizing lodash you could do something like: getDevice(sid, ain).then(device => +_.get(device, ['alert', 'state'])); Would that work for you? — You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub, or mute the thread.

delta2308151984 avatar Sep 13 '18 16:09 delta2308151984

Gegenfrage- wo hast Du es denn überhaupt eingebaut und wie? Dann zeige ich Dir der Einfachheit halber wie das zu verändern wäre.

andig avatar Sep 13 '18 16:09 andig

Autsch ;) Das müsste dann so aussehen:

fritz.getDevice(sid, '099950013169').then(function(device) {
	var status = +device.alert.state ? "auf" : "zu";
	console.log("Fenster " + status);
});

andig avatar Sep 14 '18 07:09 andig

Leider bekomme ich folgende Fehlermeldung:

Unhandled rejection TypeError: Cannot read property 'state' of undefined at /home/pi/node_modules/fritzapi/window-open-bad.js:709:34 at tryCatcher (/home/pi/node_modules/fritzapi/node_modules/bluebird/js/release/util.js:16:23) at Promise._settlePromiseFromHandler (/home/pi/node_modules/fritzapi/node_modules/bluebird/js/release/promise.js:512:31) at Promise._settlePromise (/home/pi/node_modules/fritzapi/node_modules/bluebird/js/release/promise.js:569:18) at Promise._settlePromise0 (/home/pi/node_modules/fritzapi/node_modules/bluebird/js/release/promise.js:614:10) at Promise._settlePromises (/home/pi/node_modules/fritzapi/node_modules/bluebird/js/release/promise.js:694:18) at _drainQueueStep (/home/pi/node_modules/fritzapi/node_modules/bluebird/js/release/async.js:138:12) at _drainQueue (/home/pi/node_modules/fritzapi/node_modules/bluebird/js/release/async.js:131:9) at Async._drainQueues (/home/pi/node_modules/fritzapi/node_modules/bluebird/js/release/async.js:147:5) at Immediate.Async.drainQueues [as _onImmediate] (/home/pi/node_modules/fritzapi/node_modules/bluebird/js/release/async.js:17:14) at processImmediate [as _immediateCallback] (timers.js:396:17)

delta2308151984 avatar Sep 14 '18 15:09 delta2308151984