Commit a3378560 authored by nextime's avatar nextime

Fix statusActionRequest return value when 0

parent 03118838
......@@ -1337,7 +1337,7 @@ class domotikaService(service.Service):
@defer.inlineCallbacks
def manageStatusAction(self, status, res):
changed=False
if status:
if status or (type(status).__name__=='str' and status=''):
# detect if changed
oldstatus=yield dmdb.getStatusRealtime(res.status_name)
# NOTE: we have a changed status only if oldstatus exists
......
......@@ -64,17 +64,31 @@ def statusParser(trigger, sun, restype='string'):
qr=str(qres)
else:
qr=False
if qr:
if qr or restype=='string':
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 reverse: return 0
return 1
else: # restype=='bool':
if reverse: return False
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:
return qr
try:
return str(qr)
except:
return ''
if restype=='int':
if reverse: return 1
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