andig / fritzapi

Home automation API for Fritz!Box, Fritz!DECT and FRITZ!Powerline devices
MIT License
140 stars 27 forks source link

Add LED status API #7

Closed chrmoritz closed 4 years ago

chrmoritz commented 6 years ago

This PR adds support for getting and setting the LED status of a Fritz!Box. It also includes a documentation for this new feature.

This PR is a preparation for the corresponding homebridge-fritz PR, which will add these status LEDs as a lightbulb to homebridge: https://github.com/andig/homebridge-fritz/pull/40

A little background on this feature.

A while ago AVM added support for deactivating the status LEDs from withing the LED settings page as a feature in Fritz!OS, but later decided to hide this feature again from all Fritz!Boxes (but not from the repeaters I think) for unknown reasons. But they didn't actual remove this feature as the POST endpoint is still working. It's just not accessible from the official web settings ui anymore. Nonetheless I think this is a very useful feature and everyone who has to sleep in the same room as their Fritz!Box will likely agree with me on this.

Tested with a Fritz!Box 6490 and FRITZ!OS 6.87.

andig commented 6 years ago

ping @chrmoritz do you still want to pursue this? Apart from the comments sofar I'd also suggest using:

what do you think?

chrmoritz commented 6 years ago

Sure, I'm just a little short on time right now.

The values I've used are the one used by AVM. While I agree that this is bad API design, I'm not sure if it is worth the effort to translate on every API call between our values the one used by AVM. Maybe we could use some sort of enum to hide the ugliness, like exporting LED_STATUS = {ON: 0, AUTO: 1, OFF: 2}, so that you could use something like this:

var fritz = require('./index.js');
fritz.setLEDStatus(sid, fritz.LED_STATUS.ON);

What do you think?

andig commented 6 years ago

Sounds good though a simple (but intuitive :) number should do as well

lavolp3 commented 4 years ago

I tried to use this code but the html request returns an empty html element for me. Can you confirm it still works? Fritz OS v 7.12 FRITZ Box 7490

chrmoritz commented 4 years ago

I don't think this code works in FritzOS v7+ anymore. But at least AVM did bring back the ability to choose between the always on and on demand option for their LEDs in their officially web GUI.

One could try to bind to that, but this isn't that important (at least for me) anymore, since it's available in the GUI again. So I'm closing this PR.