mirror of
https://github.com/xoseperez/espurna.git
synced 2026-03-21 07:37:06 +01:00
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
@@ -807,6 +807,10 @@ private:
|
||||
|
||||
LightTemperature _light_temperature;
|
||||
|
||||
#if RELAY_SUPPORT
|
||||
auto _light_state_relay_id = RelaysMax;
|
||||
#endif
|
||||
|
||||
bool _light_state_changed = false;
|
||||
LightStateListener _light_state_listener = nullptr;
|
||||
|
||||
@@ -2568,9 +2572,9 @@ void _lightApiSetup() {
|
||||
namespace {
|
||||
|
||||
bool _lightWebSocketOnKeyCheck(espurna::StringView key, const JsonVariant&) {
|
||||
return espurna::settings::query::samePrefix(key, STRING_VIEW("light"))
|
||||
|| espurna::settings::query::samePrefix(key, STRING_VIEW("use"))
|
||||
|| espurna::settings::query::samePrefix(key, STRING_VIEW("lt"));
|
||||
return key.startsWith(STRING_VIEW("light"))
|
||||
|| key.startsWith(STRING_VIEW("use"))
|
||||
|| key.startsWith(STRING_VIEW("lt"));
|
||||
}
|
||||
|
||||
void _lightWebSocketStatus(JsonObject& root) {
|
||||
@@ -2604,6 +2608,9 @@ void _lightWebSocketOnVisible(JsonObject& root) {
|
||||
wsPayloadModule(root, PSTR("light"));
|
||||
|
||||
JsonObject& light = root.createNestedObject("light");
|
||||
#if RELAY_SUPPORT
|
||||
light["state_relay_id"] = _light_state_relay_id;
|
||||
#endif
|
||||
|
||||
JsonArray& channels = light.createNestedArray("channels");
|
||||
|
||||
@@ -3589,6 +3596,7 @@ void _lightSettingsMigrate(int version) {
|
||||
RelayProviderBasePtr lightMakeStateRelayProvider(size_t id) {
|
||||
#if RELAY_SUPPORT
|
||||
if (!_light_state_listener) {
|
||||
_light_state_relay_id = id;
|
||||
_light_state_listener = [id](bool state) {
|
||||
relayStatus(id, state);
|
||||
};
|
||||
|
||||
4606
code/espurna/static/index.all.html.gz.h
generated
4606
code/espurna/static/index.all.html.gz.h
generated
File diff suppressed because it is too large
Load Diff
1392
code/espurna/static/index.curtain.html.gz.h
generated
1392
code/espurna/static/index.curtain.html.gz.h
generated
File diff suppressed because it is too large
Load Diff
1313
code/espurna/static/index.garland.html.gz.h
generated
1313
code/espurna/static/index.garland.html.gz.h
generated
File diff suppressed because it is too large
Load Diff
2504
code/espurna/static/index.light.html.gz.h
generated
2504
code/espurna/static/index.light.html.gz.h
generated
File diff suppressed because it is too large
Load Diff
1319
code/espurna/static/index.lightfox.html.gz.h
generated
1319
code/espurna/static/index.lightfox.html.gz.h
generated
File diff suppressed because it is too large
Load Diff
1383
code/espurna/static/index.rfbridge.html.gz.h
generated
1383
code/espurna/static/index.rfbridge.html.gz.h
generated
File diff suppressed because it is too large
Load Diff
2880
code/espurna/static/index.rfm69.html.gz.h
generated
2880
code/espurna/static/index.rfm69.html.gz.h
generated
File diff suppressed because it is too large
Load Diff
1559
code/espurna/static/index.sensor.html.gz.h
generated
1559
code/espurna/static/index.sensor.html.gz.h
generated
File diff suppressed because it is too large
Load Diff
1287
code/espurna/static/index.small.html.gz.h
generated
1287
code/espurna/static/index.small.html.gz.h
generated
File diff suppressed because it is too large
Load Diff
1357
code/espurna/static/index.thermostat.html.gz.h
generated
1357
code/espurna/static/index.thermostat.html.gz.h
generated
File diff suppressed because it is too large
Load Diff
@@ -1681,6 +1681,9 @@ function relayToggle(event) {
|
||||
function initRelayToggle(id, cfg) {
|
||||
let line = loadConfigTemplate("relay-control");
|
||||
|
||||
let root = line.querySelector("div");
|
||||
root.classList.add(`relay-control-${id}`);
|
||||
|
||||
let name = line.querySelector("span[data-key='relayName']");
|
||||
name.textContent = cfg.relayName;
|
||||
name.dataset["id"] = id;
|
||||
@@ -2170,6 +2173,12 @@ function colorUpdate(mode, value) {
|
||||
}
|
||||
}
|
||||
|
||||
function lightStateHideRelay(id) {
|
||||
styleInject([
|
||||
styleVisible(`.relay-control-${id}`, false)
|
||||
]);
|
||||
}
|
||||
|
||||
function initLightState() {
|
||||
const toggle = document.getElementById("light-state-value");
|
||||
toggle.addEventListener("change", (event) => {
|
||||
@@ -2290,6 +2299,10 @@ function updateLight(data) {
|
||||
updateLightState(value);
|
||||
break;
|
||||
|
||||
case "state_relay_id":
|
||||
lightStateHideRelay(value);
|
||||
break;
|
||||
|
||||
case "channels":
|
||||
initLightState();
|
||||
initBrightness();
|
||||
|
||||
Reference in New Issue
Block a user