2828if __name__ == '__main__' :
2929 builtins .SDP_standalone = True
3030
31- class SmartPlugin () :
31+ class SmartPlugin :
3232 pass
3333
34- class SmartPluginWebIf () :
34+ class SmartPluginWebIf :
3535 pass
3636
3737 BASE = os .path .sep .join (os .path .realpath (__file__ ).split (os .path .sep )[:- 3 ])
@@ -46,30 +46,31 @@ class SmartPluginWebIf():
4646from lib .model .smartdeviceplugin import SDPResultError , SmartDevicePlugin , Standalone
4747
4848
49- if not SDP_standalone :
49+ if not SDP_standalone : # noqa: F821
5050 from .webif import WebInterface
5151
5252
5353class viessmann (SmartDevicePlugin ):
54- """ Device class for Viessmann heating systems.
54+ """Device class for Viessmann heating systems.
5555
5656 Standalone mode is automatic device type discovery
5757 """
58+
5859 PLUGIN_VERSION = '2.0.0'
5960
6061 def _set_device_defaults (self ):
6162
62- if not SDP_standalone :
63+ if not SDP_standalone : # noqa: F821
6364 self ._webif = WebInterface
6465
6566 self ._parameters [PLUGIN_ATTR_PROTOCOL ] = SDPProtocolViessmann
6667
6768 # use callbacks to enable schedulers
6869 self ._use_callbacks = True
6970
70- #
71- # methods for standalone mode
72- #
71+ #
72+ # methods for standalone mode
73+ #
7374
7475 def run_standalone (self ):
7576 """
@@ -81,23 +82,23 @@ def run_standalone(self):
8182 devs = {}
8283
8384 for proto in ('P300' , 'KW' ):
84-
8585 res = self .get_device_type (proto )
8686
8787 if res is None :
88-
8988 # None means no connection, no further tries
90- print (f'Connection could not be established to { self ._parameters [PLUGIN_ATTR_SERIAL_PORT ]} . Please check connection.' )
89+ print (
90+ f'Connection could not be established to { self ._parameters [PLUGIN_ATTR_SERIAL_PORT ]} . Please check connection.'
91+ )
9192 break
9293
9394 if res is False :
94-
9595 # False means no comm init (only P300), go on
9696 print (f'Communication could not be established using protocol { proto } .' )
9797 else :
98-
9998 # anything else should be the devices answer, try to decode and quit
100- print (f'Device ID is { res } , device type is { devs .get (res .upper (), "unknown" )} supporting protocol { proto } ' )
99+ print (
100+ f'Device ID is { res } , device type is { devs .get (res .upper (), "unknown" )} supporting protocol { proto } '
101+ )
101102 # break
102103
103104 def read_addr (self , addr ):
@@ -139,16 +140,16 @@ def read_temp_addr(self, addr, length=1, mult=0, signed=False):
139140 # as we have no reference whatever concerning the supplied data, we do a few sanity checks...
140141
141142 addr = addr .lower ()
142- if len (addr ) != 4 : # addresses are 2 bytes
143+ if len (addr ) != 4 : # addresses are 2 bytes
143144 self .logger .warning (f'temp address: address not 4 digits long: { addr } ' )
144145 return
145146
146- for c in addr : # addresses are hex strings
147+ for c in addr : # addresses are hex strings
147148 if c not in '0123456789abcdef' :
148149 self .logger .warning (f'temp address: address digit "{ c } " is not hex char' )
149150 return
150151
151- if length < 1 or length > 32 : # empiritistical choice
152+ if length < 1 or length > 32 : # empiritistical choice
152153 self .logger .warning (f'temp address: len is not > 0 and < 33: { len } ' )
153154 return
154155
@@ -159,7 +160,16 @@ def read_temp_addr(self, addr, length=1, mult=0, signed=False):
159160 else :
160161 # create temp commandset
161162 cmd = 'temp_cmd'
162- cmdconf = {'read' : True , 'write' : False , 'opcode' : addr , 'reply_token' : addr , 'item_type' : 'str' , 'dev_datatype' : 'H' , 'params' : ['value' , 'mult' , 'signed' , 'len' ], 'param_values' : ['VAL' , mult , signed , length ]}
163+ cmdconf = {
164+ 'read' : True ,
165+ 'write' : False ,
166+ 'opcode' : addr ,
167+ 'reply_token' : addr ,
168+ 'item_type' : 'str' ,
169+ 'dev_datatype' : 'H' ,
170+ 'params' : ['value' , 'mult' , 'signed' , 'len' ],
171+ 'param_values' : ['VAL' , mult , signed , length ],
172+ }
163173 self .logger .debug (f'Adding temporary command config { cmdconf } for command temp_cmd' )
164174 self ._commands ._parse_commands (self .device_id , {cmd : cmdconf }, [cmd ])
165175
0 commit comments