Skip to content

Commit

Permalink
Update trait.py
Browse files Browse the repository at this point in the history
  • Loading branch information
DewGew authored Feb 10, 2024
1 parent a0b0b90 commit 4358386
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions modules/trait.py
Original file line number Diff line number Diff line change
Expand Up @@ -126,9 +126,9 @@ def query(custom_data, device, user_id):
response["currentArmLevel"] = state['Data']

if 'action.devices.traits.EnergyStorage' in device['traits']:
if state['BatteryLevel'] != 255:
if state['BatteryLevel'] is not None:
battery = state['BatteryLevel']
if battery is not None:
if battery != 255:
if battery == 100:
descriptive_capacity_remaining = "FULL"
elif 50 <= battery < 100:
Expand All @@ -148,7 +148,7 @@ def query(custom_data, device, user_id):


response['online'] = True
if domain not in ['Group', 'Scene'] and state['BatteryLevel'] != 255:
if domain not in ['Group', 'Scene'] and state['BatteryLevel'] is not None and state['BatteryLevel'] != 255:
if state['BatteryLevel'] <= 10: # Report low battery below 10%
response['exceptionCode'] = 'lowBattery'

Expand Down

0 comments on commit 4358386

Please sign in to comment.