bugfix remember state

This commit is contained in:
iou1name 2019-11-22 07:36:10 -05:00
parent 761683a046
commit 853a3cce53
2 changed files with 14 additions and 11 deletions

View File

@ -174,6 +174,7 @@ class LightStrip(Device):
if topic[1] == 'state': if topic[1] == 'state':
if topic[2] == 'solid': if topic[2] == 'solid':
self.state = topic[2]
data['type'] = topic[2] data['type'] = topic[2]
payload = payload.split(',') payload = payload.split(',')
payload = [int(num) for num in payload] payload = [int(num) for num in payload]
@ -189,12 +190,14 @@ class LightStrip(Device):
sub_device.color = payload sub_device.color = payload
data['color'] = tools.to_html_color(payload) data['color'] = tools.to_html_color(payload)
elif topic[2] == 'rainbow': elif topic[2] == 'rainbow':
self.state = topic[2]
data['type'] = topic[2] data['type'] = topic[2]
payload = payload.split(',') payload = payload.split(',')
self.rainbow_params = [float(p) for p in payload[:3]] self.rainbow_params = [float(p) for p in payload[:3]]
self.rainbow_params += [int(p) for p in payload[3:]] self.rainbow_params += [int(p) for p in payload[3:]]
data['rainbow_params'] = self.rainbow_params data['rainbow_params'] = self.rainbow_params
elif topic[2] == 'america': elif topic[2] == 'america':
self.state = topic[2]
data['type'] = topic[2] data['type'] = topic[2]
payload = payload.split(',') payload = payload.split(',')
self.america_params = [int(n) for n in payload] self.america_params = [int(n) for n in payload]
@ -203,22 +206,22 @@ class LightStrip(Device):
if topic[2] == 'mode': if topic[2] == 'mode':
data['property_type'] = topic[2] data['property_type'] = topic[2]
if topic[3] == 'static': if topic[3] == 'static':
data['type'] = topic[3]
self.animation = topic[3] self.animation = topic[3]
elif topic[3] == 'rotate_left':
data['type'] = topic[3] data['type'] = topic[3]
data['rotate_count'] = payload elif topic[3] == 'rotate_left':
self.animation = topic[3] self.animation = topic[3]
self.animation_rotate_count = int(payload) self.animation_rotate_count = int(payload)
data['type'] = topic[3]
data['rotate_count'] = payload
elif topic[3] == 'rotate_right': elif topic[3] == 'rotate_right':
data['type'] = topic[3] data['type'] = topic[3]
data['rotate_count'] = payload data['rotate_count'] = payload
self.animation = topic[3] self.animation = topic[3]
self.animation_rotate_count = int(payload) self.animation_rotate_count = int(payload)
elif topic[2] == 'delay': elif topic[2] == 'delay':
self.animation_delay = int(payload)
data['property_type'] = topic[2] data['property_type'] = topic[2]
data['delay'] = payload data['delay'] = payload
self.animation_delay = int(payload)
elif topic[1] == 'strip': elif topic[1] == 'strip':
data['amount'] = topic[2] data['amount'] = topic[2]
if topic[2] == 'full': if topic[2] == 'full':

View File

@ -43,11 +43,11 @@
<div class="state"> <div class="state">
<span>State</span><br> <span>State</span><br>
<select class="state_select" onchange="state_select(this)"> <select class="state_select" onchange="state_select(this)">
<option{% if device.state == 'solid' %} checked{% endif %} value="solid">Solid</option> <option{% if device.state == 'solid' %} selected{% endif %} value="solid">Solid</option>
<option{% if device.state == 'rainbow' %} checked{% endif %} value="rainbow">Rainbow</option> <option{% if device.state == 'rainbow' %} selected{% endif %} value="rainbow">Rainbow</option>
<option{% if device.state == 'america' %} checked{% endif %} value="america">America</option> <option{% if device.state == 'america' %} selected{% endif %} value="america">America</option>
</select> </select>
<div class="state_solid" style="display: {% if device.state == 'solid' %}block{% else %}hidden{% endif %}"> <div class="state_solid" style="display: {% if device.state == 'solid' %}block{% else %}none{% endif %}">
<input type="radio" id="state_solid_all_{{ device.id }}" name="state_solid_{{ device.id }}" value="all" onchange="state_solid_amount(this)" checked> <input type="radio" id="state_solid_all_{{ device.id }}" name="state_solid_{{ device.id }}" value="all" onchange="state_solid_amount(this)" checked>
<label for="state_solid_all_{{ device.id }}">All</label><br> <label for="state_solid_all_{{ device.id }}">All</label><br>
<input type="radio" id="state_solid_single_{{ device.id }}" name="state_solid_{{ device.id }}" value="single" onchange="state_solid_amount(this)"> <input type="radio" id="state_solid_single_{{ device.id }}" name="state_solid_{{ device.id }}" value="single" onchange="state_solid_amount(this)">
@ -116,9 +116,9 @@
<div class="animation"> <div class="animation">
<span>Animation</span><br> <span>Animation</span><br>
<select class="animation_select" onchange="animation_select(this)"> <select class="animation_select" onchange="animation_select(this)">
<option{% if device.animation == 'static' %} checked{% endif %} value="static">Static</option> <option{% if device.animation == 'static' %} selected{% endif %} value="static">Static</option>
<option{% if device.animation == 'rotate_left' %} checked{% endif %} value="rotate_left">Rotate Left</option> <option{% if device.animation == 'rotate_left' %} selected{% endif %} value="rotate_left">Rotate Left</option>
<option{% if device.animation == 'rotate_right' %} checked{% endif %} value="rotate_right">Rotate Right</option> <option{% if device.animation == 'rotate_right' %} selected{% endif %} value="rotate_right">Rotate Right</option>
</select> </select>
<div class="animation_static" style="display: {% if device.animation == 'static' %}block{% else %}none{% endif %}"> <div class="animation_static" style="display: {% if device.animation == 'static' %}block{% else %}none{% endif %}">
</div> </div>