Instantiate FHEM object only in case of valid typ

This commit is contained in:
Marco Schotthöfer 2020-07-11 16:39:07 +02:00
parent 9fb4e5fbe9
commit f18e47334e

View file

@ -89,8 +89,6 @@ def run(typ,freq,data):
logging.debug("password: %s", password)
########## User Plugin CODE ##########
fh = fhem.Fhem(server=server, protocol=protocol, port=port, username=username, password=password)
if typ == "FMS":
fhemCommand = globalVars.config.get("fhemCmd", "commandFMS")
elif typ == "ZVEI":
@ -104,6 +102,8 @@ def run(typ,freq,data):
fhemCommand = wildcardHandler.replaceWildcards(fhemCommand, data)
logging.debug("fhemCommand: %s", fhemCommand)
fh = fhem.Fhem(server=server, protocol=protocol, port=port, username=username, password=password)
fh.send_cmd(fhemCommand)
del fh
########## User Plugin CODE ##########