check for non-existent temperature

This commit is contained in:
mischa 2019-11-17 13:06:10 +01:00
parent 8742d1e32a
commit a50be9a2ff
1 changed files with 4 additions and 1 deletions

View File

@ -62,7 +62,10 @@ for key in sensors:
name = json_data.get(i)['name']
if json_data.get(i)['type'] == 'ZLLTemperature':
updated = json_data.get(i)['state']['lastupdated'][-8:]
temperature = round((json_data.get(i)['state']['temperature'] / 100), 1)
if json_data.get(i)['state']['temperature']:
temperature = round((json_data.get(i)['state']['temperature'] / 100), 1)
else:
temperature = 0
if verbose:
print (f"{name:<32s} - {temperature:>4}C (updated: {updated} UTC)")
elif debug: