hthiery/python-fritzhome

View on GitHub

Showing 19 of 19 total issues

Fritzhome has 57 functions (exceeds 30 allowed). Consider refactoring.
Open

class Fritzhome(object):
"""Fritzhome object to communicate with the device."""
 
_sid = None
_session = None
Severity: Major
Found in pyfritzhome/fritzhome.py - About 6 hrs to fix

    File fritzhome.py has 410 lines of code (exceeds 250 allowed). Consider refactoring.
    Open

    """The main fritzhome handling class."""
    # -*- coding: utf-8 -*-
     
    from __future__ import print_function
     
     
    Severity: Minor
    Found in pyfritzhome/fritzhome.py - About 5 hrs to fix

      Function list_all has a Cognitive Complexity of 28 (exceeds 13 allowed). Consider refactoring.
      Open

      def list_all(fritz, args):
      """Command that prints all device information."""
      devices = fritz.get_devices()
       
      for device in devices:
      Severity: Minor
      Found in pyfritzhome/cli.py - About 2 hrs to fix

      Similar blocks of code found in 2 locations. Consider refactoring.
      Open

      if device.has_blind:
      print(" Blind:")
      print(" level=%s" % device.level)
      print(" levelpercentage=%s" % device.levelpercentage)
      print(" endpositionset=%s" % device.endpositionsset)
      Severity: Major
      Found in pyfritzhome/cli.py and 1 other location - About 2 hrs to fix
      pyfritzhome/cli.py on lines 38..42

      Similar blocks of code found in 2 locations. Consider refactoring.
      Open

      if device.has_powermeter:
      print(" Powermeter:")
      print(" power=%s" % device.power)
      print(" energy=%s" % device.energy)
      print(" voltage=%s" % device.voltage)
      Severity: Major
      Found in pyfritzhome/cli.py and 1 other location - About 2 hrs to fix
      pyfritzhome/cli.py on lines 73..77

      File cli.py has 265 lines of code (exceeds 250 allowed). Consider refactoring.
      Open

      #!/usr/bin/env python
      """A simple CLI tool."""
      # -*- coding: utf-8 -*-
       
      from __future__ import print_function
      Severity: Minor
      Found in pyfritzhome/cli.py - About 2 hrs to fix

        Function main has 74 lines of code (exceeds 45 allowed). Consider refactoring.
        Open

        def main(args=None):
        """Enter the main function of the CLI tool."""
        parser = argparse.ArgumentParser(description="Fritz!Box Smarthome CLI tool.")
        parser.add_argument(
        "-v", action="store_true", dest="verbose", help="be more verbose"
        Severity: Major
        Found in pyfritzhome/cli.py - About 2 hrs to fix

          Similar blocks of code found in 2 locations. Consider refactoring.
          Open

          def _update_blind_from_node(self, node):
          _LOGGER.debug("update blind device")
          blind_element = node.find("blind")
          try:
          self.endpositionsset = self.get_node_value_as_int_as_bool(
          Severity: Major
          Found in pyfritzhome/devicetypes/fritzhomedeviceblind.py and 1 other location - About 1 hr to fix
          pyfritzhome/devicetypes/fritzhomedevicehumidity.py on lines 31..38

          Similar blocks of code found in 2 locations. Consider refactoring.
          Open

          def _update_humidity_from_node(self, node):
          _LOGGER.debug("update humidity device")
          humidity_element = node.find("humidity")
          try:
          self.rel_humidity = self.get_node_value_as_int(
          Severity: Major
          Found in pyfritzhome/devicetypes/fritzhomedevicehumidity.py and 1 other location - About 1 hr to fix
          pyfritzhome/devicetypes/fritzhomedeviceblind.py on lines 31..38

          Similar blocks of code found in 8 locations. Consider refactoring.
          Open

          def _update_from_node(self, node):
          super()._update_from_node(node)
          if self.present is False:
          return
           
           
          Severity: Major
          Found in pyfritzhome/devicetypes/fritzhomedevicepowermeter.py and 7 other locations - About 1 hr to fix
          pyfritzhome/devicetypes/fritzhomedevicealarm.py on lines 17..23
          pyfritzhome/devicetypes/fritzhomedeviceblind.py on lines 17..23
          pyfritzhome/devicetypes/fritzhomedevicehumidity.py on lines 17..23
          pyfritzhome/devicetypes/fritzhomedevicelevel.py on lines 18..24
          pyfritzhome/devicetypes/fritzhomedeviceswitch.py on lines 19..25
          pyfritzhome/devicetypes/fritzhomedevicetemperature.py on lines 18..24
          pyfritzhome/devicetypes/fritzhomedevicethermostat.py on lines 34..40

          Similar blocks of code found in 8 locations. Consider refactoring.
          Open

          def _update_from_node(self, node):
          super()._update_from_node(node)
          if self.present is False:
          return
           
           
          Severity: Major
          Found in pyfritzhome/devicetypes/fritzhomedevicethermostat.py and 7 other locations - About 1 hr to fix
          pyfritzhome/devicetypes/fritzhomedevicealarm.py on lines 17..23
          pyfritzhome/devicetypes/fritzhomedeviceblind.py on lines 17..23
          pyfritzhome/devicetypes/fritzhomedevicehumidity.py on lines 17..23
          pyfritzhome/devicetypes/fritzhomedevicelevel.py on lines 18..24
          pyfritzhome/devicetypes/fritzhomedevicepowermeter.py on lines 20..26
          pyfritzhome/devicetypes/fritzhomedeviceswitch.py on lines 19..25
          pyfritzhome/devicetypes/fritzhomedevicetemperature.py on lines 18..24

          Similar blocks of code found in 8 locations. Consider refactoring.
          Open

          def _update_from_node(self, node):
          super()._update_from_node(node)
          if self.present is False:
          return
           
           
          Severity: Major
          Found in pyfritzhome/devicetypes/fritzhomedevicelevel.py and 7 other locations - About 1 hr to fix
          pyfritzhome/devicetypes/fritzhomedevicealarm.py on lines 17..23
          pyfritzhome/devicetypes/fritzhomedeviceblind.py on lines 17..23
          pyfritzhome/devicetypes/fritzhomedevicehumidity.py on lines 17..23
          pyfritzhome/devicetypes/fritzhomedevicepowermeter.py on lines 20..26
          pyfritzhome/devicetypes/fritzhomedeviceswitch.py on lines 19..25
          pyfritzhome/devicetypes/fritzhomedevicetemperature.py on lines 18..24
          pyfritzhome/devicetypes/fritzhomedevicethermostat.py on lines 34..40

          Similar blocks of code found in 8 locations. Consider refactoring.
          Open

          def _update_from_node(self, node):
          super()._update_from_node(node)
          if self.present is False:
          return
           
           
          Severity: Major
          Found in pyfritzhome/devicetypes/fritzhomedevicetemperature.py and 7 other locations - About 1 hr to fix
          pyfritzhome/devicetypes/fritzhomedevicealarm.py on lines 17..23
          pyfritzhome/devicetypes/fritzhomedeviceblind.py on lines 17..23
          pyfritzhome/devicetypes/fritzhomedevicehumidity.py on lines 17..23
          pyfritzhome/devicetypes/fritzhomedevicelevel.py on lines 18..24
          pyfritzhome/devicetypes/fritzhomedevicepowermeter.py on lines 20..26
          pyfritzhome/devicetypes/fritzhomedeviceswitch.py on lines 19..25
          pyfritzhome/devicetypes/fritzhomedevicethermostat.py on lines 34..40

          Similar blocks of code found in 8 locations. Consider refactoring.
          Open

          def _update_from_node(self, node):
          super()._update_from_node(node)
          if self.present is False:
          return
           
           
          Severity: Major
          Found in pyfritzhome/devicetypes/fritzhomedevicealarm.py and 7 other locations - About 1 hr to fix
          pyfritzhome/devicetypes/fritzhomedeviceblind.py on lines 17..23
          pyfritzhome/devicetypes/fritzhomedevicehumidity.py on lines 17..23
          pyfritzhome/devicetypes/fritzhomedevicelevel.py on lines 18..24
          pyfritzhome/devicetypes/fritzhomedevicepowermeter.py on lines 20..26
          pyfritzhome/devicetypes/fritzhomedeviceswitch.py on lines 19..25
          pyfritzhome/devicetypes/fritzhomedevicetemperature.py on lines 18..24
          pyfritzhome/devicetypes/fritzhomedevicethermostat.py on lines 34..40

          Similar blocks of code found in 8 locations. Consider refactoring.
          Open

          def _update_from_node(self, node):
          super()._update_from_node(node)
          if self.present is False:
          return
           
           
          Severity: Major
          Found in pyfritzhome/devicetypes/fritzhomedevicehumidity.py and 7 other locations - About 1 hr to fix
          pyfritzhome/devicetypes/fritzhomedevicealarm.py on lines 17..23
          pyfritzhome/devicetypes/fritzhomedeviceblind.py on lines 17..23
          pyfritzhome/devicetypes/fritzhomedevicelevel.py on lines 18..24
          pyfritzhome/devicetypes/fritzhomedevicepowermeter.py on lines 20..26
          pyfritzhome/devicetypes/fritzhomedeviceswitch.py on lines 19..25
          pyfritzhome/devicetypes/fritzhomedevicetemperature.py on lines 18..24
          pyfritzhome/devicetypes/fritzhomedevicethermostat.py on lines 34..40

          Similar blocks of code found in 8 locations. Consider refactoring.
          Open

          def _update_from_node(self, node):
          super()._update_from_node(node)
          if self.present is False:
          return
           
           
          Severity: Major
          Found in pyfritzhome/devicetypes/fritzhomedeviceblind.py and 7 other locations - About 1 hr to fix
          pyfritzhome/devicetypes/fritzhomedevicealarm.py on lines 17..23
          pyfritzhome/devicetypes/fritzhomedevicehumidity.py on lines 17..23
          pyfritzhome/devicetypes/fritzhomedevicelevel.py on lines 18..24
          pyfritzhome/devicetypes/fritzhomedevicepowermeter.py on lines 20..26
          pyfritzhome/devicetypes/fritzhomedeviceswitch.py on lines 19..25
          pyfritzhome/devicetypes/fritzhomedevicetemperature.py on lines 18..24
          pyfritzhome/devicetypes/fritzhomedevicethermostat.py on lines 34..40

          Similar blocks of code found in 8 locations. Consider refactoring.
          Open

          def _update_from_node(self, node):
          super()._update_from_node(node)
          if self.present is False:
          return
           
           
          Severity: Major
          Found in pyfritzhome/devicetypes/fritzhomedeviceswitch.py and 7 other locations - About 1 hr to fix
          pyfritzhome/devicetypes/fritzhomedevicealarm.py on lines 17..23
          pyfritzhome/devicetypes/fritzhomedeviceblind.py on lines 17..23
          pyfritzhome/devicetypes/fritzhomedevicehumidity.py on lines 17..23
          pyfritzhome/devicetypes/fritzhomedevicelevel.py on lines 18..24
          pyfritzhome/devicetypes/fritzhomedevicepowermeter.py on lines 20..26
          pyfritzhome/devicetypes/fritzhomedevicetemperature.py on lines 18..24
          pyfritzhome/devicetypes/fritzhomedevicethermostat.py on lines 34..40

          Similar blocks of code found in 2 locations. Consider refactoring.
          Open

          if hkr_element.find("batterylow") is not None:
          self.battery_low = self.get_node_value_as_int_as_bool(
          hkr_element, "batterylow"
          )
          self.battery_level = int(
          Severity: Minor
          Found in pyfritzhome/devicetypes/fritzhomedevicethermostat.py and 1 other location - About 35 mins to fix
          pyfritzhome/devicetypes/fritzhomedevicebase.py on lines 63..65

          Similar blocks of code found in 2 locations. Consider refactoring.
          Open

          try:
          self.battery_low = self.get_node_value_as_int_as_bool(node, "batterylow")
          self.battery_level = int(self.get_node_value_as_int(node, "battery"))
          Severity: Minor
          Found in pyfritzhome/devicetypes/fritzhomedevicebase.py and 1 other location - About 35 mins to fix
          pyfritzhome/devicetypes/fritzhomedevicethermostat.py on lines 74..79
          Severity
          Category
          Status
          Source
          Language