Commit a3378560 authored by nextime's avatar nextime

Fix statusActionRequest return value when 0

parent 03118838
...@@ -1337,7 +1337,7 @@ class domotikaService(service.Service): ...@@ -1337,7 +1337,7 @@ class domotikaService(service.Service):
@defer.inlineCallbacks @defer.inlineCallbacks
def manageStatusAction(self, status, res): def manageStatusAction(self, status, res):
changed=False changed=False
if status: if status or (type(status).__name__=='str' and status=''):
# detect if changed # detect if changed
oldstatus=yield dmdb.getStatusRealtime(res.status_name) oldstatus=yield dmdb.getStatusRealtime(res.status_name)
# NOTE: we have a changed status only if oldstatus exists # NOTE: we have a changed status only if oldstatus exists
......
...@@ -64,17 +64,31 @@ def statusParser(trigger, sun, restype='string'): ...@@ -64,17 +64,31 @@ def statusParser(trigger, sun, restype='string'):
qr=str(qres) qr=str(qres)
else: else:
qr=False qr=False
if qr: if qr or restype=='string':
if restype in ['int','bool']: if restype in ['int','bool']:
if qr in ["1",1,'true','y','si','yes']: if qr in ["1",1,'true','y','si','yes',True]:
if restype=='int': if restype=='int':
if reverse: return 0 if reverse: return 0
return 1 return 1
else: # restype=='bool': else: # restype=='bool':
if reverse: return False if reverse: return False
return True return True
else:
if restype=='int':
try:
return int(qr)
except:
return 0
else
if qr in ['','false','0',0,'n','no',False,None]:
return False
return True
else: else:
return qr try:
return str(qr)
except:
return ''
if restype=='int': if restype=='int':
if reverse: return 1 if reverse: return 1
return 0 return 0
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment