diff --git a/models.py b/models.py index c7fe00f..bf39777 100644 --- a/models.py +++ b/models.py @@ -156,6 +156,12 @@ class LightStrip(Device): def __init__(self): super().__init__() self.type = "LightStrip" + self.state = "solid" + self.animation = "static", + rainbow_params = [0.3, 0.3, 0.3, 0, 2, 4, 127, 128], + america_params = 8, + animation_rotate_count = 1, + animation_delay = 200, async def mqtt_callback(self, app, msg): topic = msg.topic.split('/') diff --git a/static/juice.css b/static/juice.css index ad5355b..6826310 100644 --- a/static/juice.css +++ b/static/juice.css @@ -86,6 +86,11 @@ nav span:hover { margin: 0.2em; } +.light_controls { + display: grid; + grid-template-columns: 1fr 1fr; +} + .sub_devices { display: flex; } diff --git a/static/juice.js b/static/juice.js index 2c2811d..198d82e 100644 --- a/static/juice.js +++ b/static/juice.js @@ -4,11 +4,11 @@ function load() { socket = init_websocket(); // initialize RelayOutlet SVG color - Object.entries(init_state).forEach(([device_id, sub_devs]) => { + Object.entries(init_state).forEach(([device_id, sub_devices]) => { let device = document.querySelector('#' + device_id); - Object.entries(sub_devs).forEach(([sub_device_id, state]) => { - let sub_dev = device.querySelector('.' + sub_device_id); - let svg = sub_dev.querySelector('object').getSVGDocument().firstElementChild; + Object.entries(sub_devices).forEach(([sub_device_id, state]) => { + let sub_device = device.querySelector('.' + sub_device_id); + let svg = sub_device.querySelector('object').getSVGDocument().firstElementChild; if (state) { svg.classList.remove('off'); svg.classList.add('on'); @@ -271,3 +271,37 @@ function get_object_from_svg(svg) { function sleep(ms) { return new Promise(resolve => setTimeout(resolve, ms)); } + +function state_solid_amount(radio) { + let device = radio.parentElement.parentElement.parentElement.parentElement; + let sub_devices = device.querySelector('.sub_devices'); + for (let sub_device of sub_devices.children) { + let input = sub_device.firstElementChild.firstElementChild; + if (radio.value === 'all') { + input.disabled = true; + } else if (radio.value === 'single') { + input.disabled = false; + } + } + if (radio.value === 'all') { + device.querySelector('#state_solid_all_color_' + device.id).disabled = false; + } else if (radio.value === 'single') { + device.querySelector('#state_solid_all_color_' + device.id).disabled = true; + } +} + +function state_select(select) { + if (select.value === 'solid') { + select.parentElement.querySelector('.state_solid').style.display = 'block'; + select.parentElement.querySelector('.state_rainbow').style.display = 'none'; + select.parentElement.querySelector('.state_america').style.display = 'none'; + } else if (select.value === 'rainbow') { + select.parentElement.querySelector('.state_solid').style.display = 'none'; + select.parentElement.querySelector('.state_rainbow').style.display = 'block'; + select.parentElement.querySelector('.state_america').style.display = 'none'; + } else if (select.value === 'america') { + select.parentElement.querySelector('.state_solid').style.display = 'none'; + select.parentElement.querySelector('.state_rainbow').style.display = 'none'; + select.parentElement.querySelector('.state_america').style.display = 'block'; + } +} diff --git a/templates/index.html b/templates/index.html index 97312de..a27cff4 100644 --- a/templates/index.html +++ b/templates/index.html @@ -39,6 +39,81 @@
{{ device.ip_address }}{% if not device.locked %}{% endif %}
{% elif device.type == 'LightStrip' %}
{{ device.ip_address }}{% if not device.locked %}{% endif %}
+
+
+ State
+ +
+ +
+ +
+ + +
+
+ + + + + + + + + + + + + + + + + + + + + + + + +
Red + + + + + +
Green + + + + + +
Blue + + + + + +
+
+
+ + +
+
+
+ Animation
+ +
+
{% endif %}
{% for sub_device in device.sub_devices %} @@ -49,7 +124,7 @@
{{ sub_device.description }}{% if not device.locked %}{% endif %}
{% elif device.type == 'LightStrip' %} {% endif %}