kbr / fritzconnection

Python-Tool to communicate with the AVM Fritz!Box by the TR-064 protocol and the AHA-HTTP-Interface
MIT License
303 stars 59 forks source link

Device update #156

Closed chemelli74 closed 1 year ago

chemelli74 commented 2 years ago

Add a property to get info about new firmware update.

cc @mib1185

kbr commented 1 year ago

I suggest to rename device_update to update_available and return an empty string (resolves to False) or the new version as a string (resolves to True):

@property
def update_available(self):
    """
    The new version number (as a string) if an update is available or an
    empty string if no update is avilable.
    """
    return self.fc.call_action("UserInterface1", "GetInfo")["NewX_AVM-DE_Version"]

This way an application can use the library like

if version := fs.update_available:
    print(f"new FritzOS version available: {version}")
else:
    print("FritzOS up to date.")

Well, we don't use the Walrus operator in fritzconnection itself, as Python 3.6 and 3.7 are still supported.

chemelli74 commented 1 year ago

Done, should be fine to go now.

Thx,

Simone