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

WC: implementing tilting feature including UI #1033

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
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
9 changes: 9 additions & 0 deletions fs_src/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -674,6 +674,7 @@ <h1 id="head">Window</h1>
<label>Status:</label>
<span id="state"></span> pos
<span id="pos"></span>
<span id="tilt"></span>
</div>
<div class="button-container" id="pos_ctl">
<button id="open_btn">
Expand All @@ -683,6 +684,14 @@ <h1 id="head">Window</h1>
<label><span id="close_spinner"></span>Close</label>
</button>
</div>
<div class="form-control">
<label>Slat movement:</label>
<input type="text" id="tilt_time_ms" style="width: 3em; min-width: 3em;"> ms (0 disables feature)
</div>
<div class="form-control" id="tilt_control">
<label>Blind tilt</label>
<input id="tilt_slider" type="range" min="0" max="100">
</div>
<div class="form-control">
<label>Calibration:</label>
<span id="cal"></span>
Expand Down
26 changes: 26 additions & 0 deletions fs_src/script.js
Original file line number Diff line number Diff line change
Expand Up @@ -459,11 +459,23 @@ function wcSetConfig(c, cfg, spinner) {
alert("Name must not be empty");
return;
}
let tiltTimeMs = parseInt(el(c, "tilt_time_ms").value);
if (isNaN(tiltTimeMs) || tiltTimeMs < 500) {
alert(`Invalid tilt move time ${tiltTimeMs}`);
return;
}
let currentTilt = parseFloat(el(c, "tilt_slider").value);
if (isNaN(currentTilt) || currentTilt < 0.0 || currentTilt > 100.0) {
alert(`Invalid tilt angle ${currentTilt}`);
return;
}
cfg = {
name: name,
in_mode: parseInt(el(c, "in_mode").value),
swap_inputs: el(c, "swap_inputs").checked,
swap_outputs: el(c, "swap_outputs").checked,
tilt_time_ms: tiltTimeMs,
current_tilt: currentTilt,
};
}
setComponentConfig(c, cfg, spinner);
Expand Down Expand Up @@ -809,6 +821,20 @@ function updateComponent(cd) {
selectIfNotModified(el(c, "in_mode"), cd.in_mode);
checkIfNotModified(el(c, "swap_inputs"), cd.swap_inputs);
checkIfNotModified(el(c, "swap_outputs"), cd.swap_outputs);
setValueIfNotModified(el(c, "tilt_time_ms"), cd.tilt_time_ms);
if(cd.tilt_time_ms == 0) {
el(c,"tilt_control").style.display = "none";
} else {
el(c,"tilt_control").style.display = "inline";
el(c,"tilt_time_ms").style.display = "inline";
let currentTilt = parseFloat(cd.cur_tilt);
if(isNaN(currentTilt) || currentTilt < 0.0 || currentTilt > 100.0) {
currentTilt = 50.0;
}
let tiltText = `tilt angle ${currentTilt}°`
updateInnerText(el(c, "tilt"), tiltText);
setValueIfNotModified(el(c, "tilt_slider"), currentTilt);
}
let posText, calText;
if (cd.cal_done == 1) {
if (cd.cur_pos != cd.tgt_pos) {
Expand Down
92 changes: 47 additions & 45 deletions mos.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
author: Shelly-HomeKit contributors
description: A HomeKit firmware for Shelly switches
version: 2.11.1
version: 2.11.1.pr707_blindtilt_alpha.01

libs_version: latest
modules_version: latest
Expand Down Expand Up @@ -83,6 +83,8 @@ config_schema:
- ["wc.obstruction_duration_ms", "i", 3000, {title: "How long should the overpower persist for obstruction to be reported?"}]
- ["wc.obstruction_time_coeff", "f", 1.5, {title: "How long is too long (compared to max)?"}]
- ["wc.current_pos", "f", 0.0, {title: "Last position, percent: 0 - fully closed, 100 - fully open."}]
- ["wc.tilt_time_ms", "i", 0, {title: "Time for turn from min to max tilt angle, in milliseconds; 0 to disable slat feature"}]
- ["wc.current_tilt", "f", 0.0, {title: "Last tilt, percent: 0 - fully towards minimum, 100 - fully towards maximum"}]

- ["gdo", "o", {title: "Garage door settings", abstract: true}]
- ["gdo.name", "s", "Garage Door", {title: "Accessory name"}]
Expand Down Expand Up @@ -129,8 +131,8 @@ build_vars:
MGOS_FW_EXTRA_ATTRS: shelly_hk_model=${build_vars.MODEL}

cdefs:
PRODUCT_VENDOR: Allterco
PRODUCT_MODEL: ${build_vars.MODEL}
PRODUCT_VENDOR: '"Allterco"'
PRODUCT_MODEL: '"${build_vars.MODEL}"'
LED_GPIO: -1
LED_ON: 0
BTN_GPIO: -1
Expand Down Expand Up @@ -210,8 +212,8 @@ conds:
BOOT_CONFIG_ADDR: 0x1000 # To be compatible with stock firmware.
MGOS_ROOT_FS_TYPE: SPIFFS
cdefs:
PRODUCT_HW_REV: "1.0"
STOCK_FW_MODEL: SHSW-1
PRODUCT_HW_REV: '"1.0"'
STOCK_FW_MODEL: '"SHSW-1"'
# We don't use SSL, HomeKit uses its own crypto. This saves ~120K.
MG_ENABLE_SSL: 0
config_schema:
Expand Down Expand Up @@ -252,8 +254,8 @@ conds:
LED_ON: 0
BTN_GPIO: 13
BTN_DOWN: 0
PRODUCT_HW_REV: "1.0"
STOCK_FW_MODEL: SHSW-L
PRODUCT_HW_REV: '"1.0"'
STOCK_FW_MODEL: '"SHSW-L"'
# We don't use SSL, HomeKit uses its own crypto. This saves ~120K.
MG_ENABLE_SSL: 0
SHELLY_HAVE_DUAL_INPUT_MODES: 1
Expand Down Expand Up @@ -294,8 +296,8 @@ conds:
LED_ON: 0
BTN_GPIO: 2
BTN_DOWN: 0
PRODUCT_HW_REV: "1.0"
STOCK_FW_MODEL: SHSW-PM
PRODUCT_HW_REV: '"1.0"'
STOCK_FW_MODEL: '"SHSW-PM"'
# We don't use SSL, HomeKit uses its own crypto. This saves ~120K.
MG_ENABLE_SSL: 0
config_schema:
Expand Down Expand Up @@ -334,8 +336,8 @@ conds:
BOOT_CONFIG_ADDR: 0x1000
MGOS_ROOT_FS_TYPE: SPIFFS
cdefs:
PRODUCT_HW_REV: "1.0"
STOCK_FW_MODEL: SHSW-21
PRODUCT_HW_REV: '"1.0"'
STOCK_FW_MODEL: '"SHSW-21"'
MG_ENABLE_SSL: 0
config_schema:
- ["device.id", "shellyswitch21-??????"]
Expand Down Expand Up @@ -380,8 +382,8 @@ conds:
LED_ON: 0
BTN_GPIO: 2
BTN_DOWN: 0
PRODUCT_HW_REV: "2.5"
STOCK_FW_MODEL: SHSW-25
PRODUCT_HW_REV: '"2.5"'
STOCK_FW_MODEL: '"SHSW-25"'
MG_ENABLE_SSL: 0
SHELLY_HAVE_PM: 1
config_schema:
Expand Down Expand Up @@ -422,8 +424,8 @@ conds:
MGOS_ROOT_FS_TYPE: SPIFFS
cdefs:
PWM_SUPPORT: 1
PRODUCT_HW_REV: "1.0"
STOCK_FW_MODEL: SHCB-1
PRODUCT_HW_REV: '"1.0"'
STOCK_FW_MODEL: '"SHCB-1"'
# We don't use SSL, HomeKit uses its own crypto. This saves ~120K.
MG_ENABLE_SSL: 0
config_schema:
Expand All @@ -445,8 +447,8 @@ conds:
FS_SIZE: 262144
MGOS_ROOT_FS_TYPE: SPIFFS
cdefs:
PRODUCT_HW_REV: "1.0"
STOCK_FW_MODEL: SHBDUO-1
PRODUCT_HW_REV: '"1.0"'
STOCK_FW_MODEL: '"SHBDUO-1"'
# We don't use SSL, HomeKit uses its own crypto. This saves ~120K.
MG_ENABLE_SSL: 0
config_schema:
Expand All @@ -468,8 +470,8 @@ conds:
BOOT_CONFIG_ADDR: 0x1000
MGOS_ROOT_FS_TYPE: SPIFFS
cdefs:
PRODUCT_HW_REV: "1.0"
STOCK_FW_MODEL: SHIX3-1
PRODUCT_HW_REV: '"1.0"'
STOCK_FW_MODEL: '"SHIX3-1"'
MG_ENABLE_SSL: 0
LED_GPIO: 5
LED_ON: 0
Expand Down Expand Up @@ -512,8 +514,8 @@ conds:
LED_ON: 0
BTN_GPIO: 12
BTN_DOWN: 1
PRODUCT_HW_REV: "1.0"
STOCK_FW_MODEL: SHPLG2-1
PRODUCT_HW_REV: '"1.0"'
STOCK_FW_MODEL: '"SHPLG2-1"'
MG_ENABLE_SSL: 0
config_schema:
- ["device.id", "shellyplug-??????"]
Expand Down Expand Up @@ -543,8 +545,8 @@ conds:
LED_ON: 0
BTN_GPIO: 13
BTN_DOWN: 0
PRODUCT_HW_REV: "1.0"
STOCK_FW_MODEL: SHPLG-S
PRODUCT_HW_REV: '"1.0"'
STOCK_FW_MODEL: '"SHPLG-S"'
MG_ENABLE_SSL: 0
config_schema:
- ["device.id", "shellyplug-s-??????"]
Expand Down Expand Up @@ -576,8 +578,8 @@ conds:
LED_ON: 0
BTN_GPIO: 25
BTN_DOWN: 0
PRODUCT_HW_REV: "0.1.6"
STOCK_FW_MODEL: Plus1
PRODUCT_HW_REV: '"0.1.6"'
STOCK_FW_MODEL: '"Plus1"'
MAX_NUM_HAP_SESSIONS: 16
config_schema:
- ["device.id", "ShellyPlus1-??????"]
Expand Down Expand Up @@ -612,8 +614,8 @@ conds:
LED_ON: 0
BTN_GPIO: 25
BTN_DOWN: 0
PRODUCT_HW_REV: "0.1.6"
STOCK_FW_MODEL: Plus1PM
PRODUCT_HW_REV: '"0.1.6"'
STOCK_FW_MODEL: '"Plus1PM"'
MAX_NUM_HAP_SESSIONS: 16
config_schema:
- ["device.id", "ShellyPlus1PM-??????"]
Expand Down Expand Up @@ -653,8 +655,8 @@ conds:
LED_ON: 0
BTN_GPIO: 25
BTN_DOWN: 0
PRODUCT_HW_REV: "0.1.6"
STOCK_FW_MODEL: PlusI4
PRODUCT_HW_REV: '"0.1.6"'
STOCK_FW_MODEL: '"PlusI4"'
MAX_NUM_HAP_SESSIONS: 16
config_schema:
- ["device.id", "ShellyPlusI4-??????"]
Expand Down Expand Up @@ -691,8 +693,8 @@ conds:
BTN_DOWN: 0
BTN_NOISY: 0
RST_GPIO_INIT: 15 # reset GPIO 15 to prevent green flash on startup
PRODUCT_HW_REV: "1.0"
STOCK_FW_MODEL: SHRGBW2-color
PRODUCT_HW_REV: '"1.0"'
STOCK_FW_MODEL: '"SHRGBW2-color"'
# We don't use SSL, HomeKit uses its own crypto. This saves ~120K.
MG_ENABLE_SSL: 0
config_schema:
Expand Down Expand Up @@ -728,8 +730,8 @@ conds:
LED_ON: 0
BTN_GPIO: 2
BTN_DOWN: 0
PRODUCT_HW_REV: "1.0"
STOCK_FW_MODEL: SHUNI-1
PRODUCT_HW_REV: '"1.0"'
STOCK_FW_MODEL: '"SHUNI-1"'
MG_ENABLE_SSL: 0
config_schema:
- ["device.id", "shellyuni-????????????"]
Expand Down Expand Up @@ -759,8 +761,8 @@ conds:
FS_SIZE: 262144
MGOS_ROOT_FS_TYPE: SPIFFS
cdefs:
PRODUCT_HW_REV: "1.0"
STOCK_FW_MODEL: SHVIN-1
PRODUCT_HW_REV: '"1.0"'
STOCK_FW_MODEL: '"SHVIN-1"'
# We don't use SSL, HomeKit uses its own crypto. This saves ~120K.
MG_ENABLE_SSL: 0
config_schema:
Expand Down Expand Up @@ -791,8 +793,8 @@ conds:
LED_ON: 1
BTN_GPIO: 34
BTN_DOWN: 0
PRODUCT_HW_REV: "1.0"
STOCK_FW_MODEL: XXX
PRODUCT_HW_REV: '"1.0"'
STOCK_FW_MODEL: '"XXX"'
SHELLY_HAVE_PM: 0
BTN_NOISY: 0
MGOS_CONFIG_DEV_3: '"aux"'
Expand All @@ -819,8 +821,8 @@ conds:
- location: https://github.com/mongoose-os-libs/mongoose
variant: ubuntu-nossl
cdefs:
PRODUCT_HW_REV: "1.0"
STOCK_FW_MODEL: XXX
PRODUCT_HW_REV: '"1.0"'
STOCK_FW_MODEL: '""'
MG_ENABLE_SSL: 0
SHELLY_HAVE_PM: 1
BTN_NOISY: 0
Expand Down Expand Up @@ -848,8 +850,8 @@ conds:
- location: https://github.com/mongoose-os-libs/mongoose
variant: ubuntu-nossl
cdefs:
PRODUCT_HW_REV: "1.0"
STOCK_FW_MODEL: XXX
PRODUCT_HW_REV: '"1.0"'
STOCK_FW_MODEL: '""'
MG_ENABLE_SSL: 0
SHELLY_HAVE_PM: 0
BTN_NOISY: 0
Expand All @@ -870,8 +872,8 @@ conds:
- location: https://github.com/mongoose-os-libs/mongoose
variant: ubuntu-nossl
cdefs:
PRODUCT_HW_REV: "1.0"
STOCK_FW_MODEL: XXX
PRODUCT_HW_REV: '"1.0"'
STOCK_FW_MODEL: '""'
MG_ENABLE_SSL: 0
SHELLY_HAVE_PM: 1
BTN_NOISY: 0
Expand Down Expand Up @@ -904,8 +906,8 @@ conds:
- location: https://github.com/mongoose-os-libs/mongoose
variant: ubuntu-nossl
cdefs:
PRODUCT_HW_REV: "1.0"
STOCK_FW_MODEL: XXX
PRODUCT_HW_REV: '"1.0"'
STOCK_FW_MODEL: '""'
MG_ENABLE_SSL: 0
SHELLY_HAVE_PM: 0
BTN_NOISY: 0
Expand Down
Loading