bugfix remember state
This commit is contained in:
parent
761683a046
commit
853a3cce53
11
models.py
11
models.py
|
@ -174,6 +174,7 @@ class LightStrip(Device):
|
|||
|
||||
if topic[1] == 'state':
|
||||
if topic[2] == 'solid':
|
||||
self.state = topic[2]
|
||||
data['type'] = topic[2]
|
||||
payload = payload.split(',')
|
||||
payload = [int(num) for num in payload]
|
||||
|
@ -189,12 +190,14 @@ class LightStrip(Device):
|
|||
sub_device.color = payload
|
||||
data['color'] = tools.to_html_color(payload)
|
||||
elif topic[2] == 'rainbow':
|
||||
self.state = topic[2]
|
||||
data['type'] = topic[2]
|
||||
payload = payload.split(',')
|
||||
self.rainbow_params = [float(p) for p in payload[:3]]
|
||||
self.rainbow_params += [int(p) for p in payload[3:]]
|
||||
data['rainbow_params'] = self.rainbow_params
|
||||
elif topic[2] == 'america':
|
||||
self.state = topic[2]
|
||||
data['type'] = topic[2]
|
||||
payload = payload.split(',')
|
||||
self.america_params = [int(n) for n in payload]
|
||||
|
@ -203,22 +206,22 @@ class LightStrip(Device):
|
|||
if topic[2] == 'mode':
|
||||
data['property_type'] = topic[2]
|
||||
if topic[3] == 'static':
|
||||
data['type'] = topic[3]
|
||||
self.animation = topic[3]
|
||||
elif topic[3] == 'rotate_left':
|
||||
data['type'] = topic[3]
|
||||
data['rotate_count'] = payload
|
||||
elif topic[3] == 'rotate_left':
|
||||
self.animation = topic[3]
|
||||
self.animation_rotate_count = int(payload)
|
||||
data['type'] = topic[3]
|
||||
data['rotate_count'] = payload
|
||||
elif topic[3] == 'rotate_right':
|
||||
data['type'] = topic[3]
|
||||
data['rotate_count'] = payload
|
||||
self.animation = topic[3]
|
||||
self.animation_rotate_count = int(payload)
|
||||
elif topic[2] == 'delay':
|
||||
self.animation_delay = int(payload)
|
||||
data['property_type'] = topic[2]
|
||||
data['delay'] = payload
|
||||
self.animation_delay = int(payload)
|
||||
elif topic[1] == 'strip':
|
||||
data['amount'] = topic[2]
|
||||
if topic[2] == 'full':
|
||||
|
|
|
@ -43,11 +43,11 @@
|
|||
<div class="state">
|
||||
<span>State</span><br>
|
||||
<select class="state_select" onchange="state_select(this)">
|
||||
<option{% if device.state == 'solid' %} checked{% endif %} value="solid">Solid</option>
|
||||
<option{% if device.state == 'rainbow' %} checked{% endif %} value="rainbow">Rainbow</option>
|
||||
<option{% if device.state == 'america' %} checked{% endif %} value="america">America</option>
|
||||
<option{% if device.state == 'solid' %} selected{% endif %} value="solid">Solid</option>
|
||||
<option{% if device.state == 'rainbow' %} selected{% endif %} value="rainbow">Rainbow</option>
|
||||
<option{% if device.state == 'america' %} selected{% endif %} value="america">America</option>
|
||||
</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>
|
||||
<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)">
|
||||
|
@ -116,9 +116,9 @@
|
|||
<div class="animation">
|
||||
<span>Animation</span><br>
|
||||
<select class="animation_select" onchange="animation_select(this)">
|
||||
<option{% if device.animation == 'static' %} checked{% endif %} value="static">Static</option>
|
||||
<option{% if device.animation == 'rotate_left' %} checked{% 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 == 'static' %} selected{% endif %} value="static">Static</option>
|
||||
<option{% if device.animation == 'rotate_left' %} selected{% endif %} value="rotate_left">Rotate Left</option>
|
||||
<option{% if device.animation == 'rotate_right' %} selected{% endif %} value="rotate_right">Rotate Right</option>
|
||||
</select>
|
||||
<div class="animation_static" style="display: {% if device.animation == 'static' %}block{% else %}none{% endif %}">
|
||||
</div>
|
||||
|
|
Loading…
Reference in New Issue
Block a user