Skip to content
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

Added more button controls. Fixed issue #37 and issue #62 #73

Merged
merged 2 commits into from
Aug 5, 2023
Merged
Show file tree
Hide file tree
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
Binary file modified docker/web/nspanelmanager/firmware.bin
Binary file not shown.
Binary file modified docker/web/nspanelmanager/merged_flash.bin
Binary file not shown.
11 changes: 9 additions & 2 deletions docker/web/nspanelmanager/web/api.py
Original file line number Diff line number Diff line change
Expand Up @@ -289,17 +289,24 @@ def get_nspanel_config(request):
base["screensaver_activation_timeout"] = get_nspanel_setting_with_default(nspanel.id, "screensaver_activation_timeout", get_setting_with_default("screensaver_activation_timeout", 30000))
base["show_screensaver_clock"] = get_nspanel_setting_with_default(nspanel.id, "show_screensaver_clock", get_setting_with_default("show_screensaver_clock", False))
base["clock_us_style"] = get_setting_with_default("clock_us_style", False)
base["button1_mode"] = nspanel.button1_mode
base["use_farenheit"] = get_setting_with_default("use_farenheit", False)
base["lock_to_default_room"] = get_nspanel_setting_with_default(nspanel.id, "lock_to_default_room", "False")
base["reverse_relays"] = get_nspanel_setting_with_default(nspanel.id, "reverse_relays", False)
base["relay1_default_mode"] = get_nspanel_setting_with_default(nspanel.id, "relay1_default_mode", False)
base["relay2_default_mode"] = get_nspanel_setting_with_default(nspanel.id, "relay2_default_mode", False)
base["temperature_calibration"] = float(get_nspanel_setting_with_default(nspanel.id, "temperature_calibration", 0))
base["button1_mode"] = nspanel.button1_mode
base["button1_mqtt_topic"] = get_nspanel_setting_with_default(nspanel.id, "button1_mqtt_topic", "")
base["button1_mqtt_payload"] = get_nspanel_setting_with_default(nspanel.id, "button1_mqtt_payload", "")
base["button2_mode"] = nspanel.button2_mode
base["button2_mqtt_topic"] = get_nspanel_setting_with_default(nspanel.id, "button2_mqtt_topic", "")
base["button2_mqtt_payload"] = get_nspanel_setting_with_default(nspanel.id, "button2_mqtt_payload", "")

if nspanel.button1_detached_mode_light:
base["button1_detached_light"] = nspanel.button1_detached_mode_light.id
else:
base["button1_detached_mode_light"] = -1
base["button2_mode"] = nspanel.button2_mode

if nspanel.button2_detached_mode_light:
base["button2_detached_light"] = nspanel.button2_detached_mode_light.id
else:
Expand Down
24 changes: 22 additions & 2 deletions docker/web/nspanelmanager/web/static/edit_nspanel.js
Original file line number Diff line number Diff line change
Expand Up @@ -97,18 +97,38 @@ function update_shown_elements() {
// Direct mode
$("#button1_detached_mode_light_label").hide();
$("#button1_detached_mode_light_select").hide();
} else {
$("#button1_custom_mqtt_container").hide();
} else if ($("#button1_mode").val() == 1) {
$("#button1_detached_mode_light_label").show();
$("#button1_detached_mode_light_select").show();
$("#button1_custom_mqtt_container").hide();
} else if ($("#button1_mode").val() == 2) {
$("#button1_detached_mode_light_label").hide();
$("#button1_detached_mode_light_select").hide();
$("#button1_custom_mqtt_container").show();
} else if ($("#button1_mode").val() == 3) {
$("#button1_detached_mode_light_label").hide();
$("#button1_detached_mode_light_select").hide();
$("#button1_custom_mqtt_container").hide();
}

if ($("#button2_mode").val() == 0) {
// Direct mode
$("#button2_detached_mode_light_label").hide();
$("#button2_detached_mode_light_select").hide();
} else {
$("#button2_custom_mqtt_container").hide();
} else if ($("#button2_mode").val() == 1) {
$("#button2_detached_mode_light_label").show();
$("#button2_detached_mode_light_select").show();
$("#button2_custom_mqtt_container").hide();
} else if ($("#button2_mode").val() == 2) {
$("#button2_detached_mode_light_label").hide();
$("#button2_detached_mode_light_select").hide();
$("#button2_custom_mqtt_container").show();
} else if ($("#button2_mode").val() == 3) {
$("#button2_detached_mode_light_label").hide();
$("#button2_detached_mode_light_select").hide();
$("#button2_custom_mqtt_container").hide();
}
}

Expand Down
80 changes: 63 additions & 17 deletions docker/web/nspanelmanager/web/templates/edit_nspanel.html
Original file line number Diff line number Diff line change
Expand Up @@ -75,24 +75,44 @@ <h2 class="subtitle is-6">MAC: <span id="nspanel_mac">{{ panel.mac_address }}</s
Lock to default room
<span class="question">
<span class="icon question_icon">
<i class="mdi mdi-help"></i>
<i class="mdi mdi-information has-text-info"></i>
</span>
<div class="question_help_text notification is-info is-light">
Wether this panel control other rooms other than the default room. T setting causes the panel to only load the selected room.
</div>
</span>
</label>
</div>
<div class="field">
<label class="checkbox">
{% if settings.reverse_relays == "True" %}
<input type="checkbox" name="reverse_relays" checked>
{% else %}
<input type="checkbox" name="reverse_relays">
{% endif %}
Reverse relays
<span class="question">
<span class="icon question_icon">
<i class="mdi mdi-information has-text-info"></i>
</span>
<div class="question_help_text notification is-info is-light">
When this box i checked, it is like you have switches places of the cables for the relays on the back of the unit. All options in the web interface named for "relay 1" are applied to relay 2 and vice versa.
</div>
</span>
</label>
</div>
<div class="field">
<label class="label">Button 1 mode<span class="question">
<span class="icon question_icon">
<i class="mdi mdi-help"></i>
<i class="mdi mdi-information has-text-info"></i>
</span>
<div class="question_help_text notification is-info is-light">
Direct mode: The button directly controls the relay.<br>
Detached mode: The button does not directly control the relay but is instead coupled to a light added in the
<b>Direct mode</b>: The button directly controls the relay.<br>
<b>Detached mode</b>: The button does not directly control the relay but is instead coupled to a light added in the
room. In case the lights is removed from the room, the button will will remain in detached mode but will no
longed be coupled to any button.
longed be coupled to any button.<br>
<b>Custom MQTT</b>: Send a custom MQTT payload to a custom MQTT topic.<br>
<b>Follow mode</b>: The relay state will follow the button state. If the button is pressed, the relay is on, if the button is released, the relay is off.<br>
</div>
</span>
</label>
Expand All @@ -101,6 +121,8 @@ <h2 class="subtitle is-6">MAC: <span id="nspanel_mac">{{ panel.mac_address }}</s
<select name="button1_mode" id="button1_mode">
<option value="0" {% if panel.button1_mode == 0 %}selected{% endif %}>Direct mode</option>
<option value="1" {% if panel.button1_mode == 1 %}selected{% endif %}>Detached mode</option>
<option value="2" {% if panel.button1_mode == 2 %}selected{% endif %}>Custom MQTT</option>
<option value="3" {% if panel.button1_mode == 3 %}selected{% endif %}>Follow mode</option>
</select>
</div>
</div>
Expand All @@ -123,17 +145,29 @@ <h2 class="subtitle is-6">MAC: <span id="nspanel_mac">{{ panel.mac_address }}</s
</select>
</div>
</div>
<div id="button1_custom_mqtt_container">
<label class="label">MQTT Topic:</label>
<div class="control" id="">
<input type="text" class="input" name="button1_custom_mqtt_topic" value="{{ settings.button1_custom_mqtt_topic }}">
</div>
<label class="label">MQTT Payload:</label>
<div class="control" id="">
<input type="text" class="input" name="button1_custom_mqtt_payload" value="{{ settings.button1_custom_mqtt_payload }}" maxlength=128>
</div>
</div>
</div>
<div class="field">
<label class="label">Button 2 mode<span class="question">
<span class="icon question_icon">
<i class="mdi mdi-help"></i>
<i class="mdi mdi-information has-text-info"></i>
</span>
<div class="question_help_text notification is-info is-light">
Direct mode: The button directly controls the relay.<br>
Detached mode: The button does not directly control the relay but is instead coupled to a light added in the
<b>Direct mode</b>: The button directly controls the relay.<br>
<b>Detached mode</b>: The button does not directly control the relay but is instead coupled to a light added in the
room. In case the lights is removed from the room, the button will will remain in detached mode but will no
longed be coupled to any button.
longed be coupled to any button.<br>
<b>Custom MQTT</b>: Send a custom MQTT payload to a custom MQTT topic.<br>
<b>Follow mode</b>: The relay state will follow the button state. If the button is pressed, the relay is on, if the button is released, the relay is off.<br>
</div>
</span>
</label>
Expand All @@ -142,6 +176,8 @@ <h2 class="subtitle is-6">MAC: <span id="nspanel_mac">{{ panel.mac_address }}</s
<select name="button2_mode" id="button2_mode">
<option value="0" {% if panel.button2_mode == 0 %}selected{% endif %}>Direct mode</option>
<option value="1" {% if panel.button2_mode == 1 %}selected{% endif %}>Detached mode</option>
<option value="2" {% if panel.button2_mode == 2 %}selected{% endif %}>Custom MQTT</option>
<option value="3" {% if panel.button2_mode == 3 %}selected{% endif %}>Follow mode</option>
</select>
</div>
</div>
Expand All @@ -164,11 +200,21 @@ <h2 class="subtitle is-6">MAC: <span id="nspanel_mac">{{ panel.mac_address }}</s
</select>
</div>
</div>
<div id="button2_custom_mqtt_container">
<label class="label">MQTT Topic:</label>
<div class="control" id="">
<input type="text" class="input" name="button2_custom_mqtt_topic" value="{{ settings.button2_custom_mqtt_topic }}">
</div>
<label class="label">MQTT Payload:</label>
<div class="control" id="">
<input type="text" class="input" name="button2_custom_mqtt_payload" value="{{ settings.button2_custom_mqtt_payload }}" maxlength=128>
</div>
</div>
</div>
<div class="field">
<label class="label">Relay 1 default mode<span class="question">
<span class="icon question_icon">
<i class="mdi mdi-help"></i>
<i class="mdi mdi-information has-text-info"></i>
</span>
<div class="question_help_text notification is-info is-light">
Controls the default power state of relay 1 after power on.<br>
Expand All @@ -189,7 +235,7 @@ <h2 class="subtitle is-6">MAC: <span id="nspanel_mac">{{ panel.mac_address }}</s
<div class="field">
<label class="label">Relay 2 default mode<span class="question">
<span class="icon question_icon">
<i class="mdi mdi-help"></i>
<i class="mdi mdi-information has-text-info"></i>
</span>
<div class="question_help_text notification is-info is-light">
Controls the default power state of relay 2 after power on.<br>
Expand Down Expand Up @@ -217,7 +263,7 @@ <h2 class="subtitle is-6">MAC: <span id="nspanel_mac">{{ panel.mac_address }}</s
Is US panel
<span class="question">
<span class="icon question_icon">
<i class="mdi mdi-help"></i>
<i class="mdi mdi-information has-text-info"></i>
</span>
<div class="question_help_text notification is-info is-light">
Wether this panel is a US version or Europe version. Check for US version.
Expand All @@ -228,7 +274,7 @@ <h2 class="subtitle is-6">MAC: <span id="nspanel_mac">{{ panel.mac_address }}</s
<div class="field">
<label class="label">Screen brightness<span class="question">
<span class="icon question_icon">
<i class="mdi mdi-help"></i>
<i class="mdi mdi-information has-text-info"></i>
</span>
<div class="question_help_text notification is-info is-light">
Brightness when the panel is on. 1-100%. Leave empty to use global setting.
Expand All @@ -244,7 +290,7 @@ <h2 class="subtitle is-6">MAC: <span id="nspanel_mac">{{ panel.mac_address }}</s
<div class="field">
<label class="label">Screensaver brightness<span class="question">
<span class="icon question_icon">
<i class="mdi mdi-help"></i>
<i class="mdi mdi-information has-text-info"></i>
</span>
<div class="question_help_text notification is-info is-light">
Brightness level during screensaver. 0-100%. Leave empty to use global setting.
Expand All @@ -260,7 +306,7 @@ <h2 class="subtitle is-6">MAC: <span id="nspanel_mac">{{ panel.mac_address }}</s
<div class="field">
<label class="label">Screensaver activation timeout<span class="question">
<span class="icon question_icon">
<i class="mdi mdi-help"></i>
<i class="mdi mdi-information has-text-info"></i>
</span>
<div class="question_help_text notification is-info is-light">
The amount of time before the screensaver is activated. Time is in milliseconds. Default: 30000 (30 seconds). Leave empty to use global setting.
Expand All @@ -276,7 +322,7 @@ <h2 class="subtitle is-6">MAC: <span id="nspanel_mac">{{ panel.mac_address }}</s
<div class="field">
<label class="label">Show clock on screensaver<span class="question">
<span class="icon question_icon">
<i class="mdi mdi-help"></i>
<i class="mdi mdi-information has-text-info"></i>
</span>
<div class="question_help_text notification is-info is-light">
True: show clock on screensaver<br>
Expand All @@ -298,7 +344,7 @@ <h2 class="subtitle is-6">MAC: <span id="nspanel_mac">{{ panel.mac_address }}</s
<div class="field">
<label class="label">Temperature calibration<span class="question">
<span class="icon question_icon">
<i class="mdi mdi-help"></i>
<i class="mdi mdi-information has-text-info"></i>
</span>
<div class="question_help_text notification is-info is-light">
Enter the number of degrees to calibrate. Entering a positive number (ex. 5) will add 5 degrees to the read temperature. Entering a negative number (ex. -5) will subtract 5 degrees from the read temperature.
Expand Down
Loading