Skip to content

add try/except to cheerlights demo #13

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Dec 27, 2018
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 8 additions & 5 deletions examples/espatcontrol_cheerlights.py
Original file line number Diff line number Diff line change
Expand Up @@ -83,12 +83,15 @@ def get_value(response, location):
print('-'*40)
# For mystery reasons, there's two numbers before and after the json data
lines = body.split(b'\r\n') # so split into lines
value = get_value(lines[1], DATA_LOCATION) # an get the middle chunk
builtin[0] = (100, 100, 100)
if not value:
try:
value = get_value(lines[1], DATA_LOCATION) # an get the middle chunk
builtin[0] = (100, 100, 100)
if not value:
continue
print(times, the_time, "value:", value)
except IndexError as e:
print("IndexError processing Body, retrying\n", e)
continue
print(times, the_time, "value:", value)

if last_value != value:
color = int(value[1:],16)
red = color >> 16 & 0xFF
Expand Down