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

[WIP] New Vue Web UI #1933

Draft
wants to merge 84 commits into
base: dev
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from 9 commits
Commits
Show all changes
84 commits
Select commit Hold shift + click to select a range
6b172e8
[WIP] Create a new web ui with vue
Tofandel Oct 7, 2019
230f627
Configured webpack compilation (outputs image in dist/index.html.gz)
Tofandel Oct 11, 2019
a8672f3
Move each tab to its own component
Tofandel Oct 11, 2019
e139e42
Add environment conditional compilation
Tofandel Oct 11, 2019
907b7c7
Make Form and Input components
Tofandel Oct 11, 2019
0e7335e
New favicon
Tofandel Oct 12, 2019
81cdc76
New favicon
Tofandel Oct 12, 2019
c14f03f
Added compile mode for dev +
Tofandel Oct 17, 2019
101c152
Harmonize ws api
Tofandel Oct 17, 2019
7e455b0
Merge branch 'dev' into dev
Tofandel Oct 17, 2019
8e57f4f
Continue template conversion + some styling
Tofandel Oct 17, 2019
3d7189c
Merge remote-tracking branch 'origin/dev' into dev
Tofandel Oct 17, 2019
99400a7
Convert OOP to schema arrays
Tofandel Oct 21, 2019
6e7f90f
Restore start parameter
Tofandel Oct 21, 2019
221bb37
First test unit
Tofandel Oct 21, 2019
bb822f7
Add test unit for input
Tofandel Oct 21, 2019
1a6878a
Form unit tests
Tofandel Oct 21, 2019
5c9a717
Designing menu + start grid conversion
Tofandel Oct 21, 2019
b15ba1e
Moving alexa integration to it's own tab + Add hint component
Tofandel Oct 22, 2019
15b1ef0
Populating websocket data
Tofandel Oct 23, 2019
4cdcc69
Implement module visibility
Tofandel Oct 25, 2019
15c2dc6
New switch styling + repeater improvements
Tofandel Oct 25, 2019
ae997d5
More ws schema refactor
Tofandel Oct 25, 2019
d28cb84
Merge branch 'dev' into dev
Tofandel Oct 25, 2019
2c90d11
Added multiselect support
Tofandel Oct 25, 2019
a8a0394
Finished all common tabs except sensor
Tofandel Oct 26, 2019
9e9521a
PWA initial setup
Tofandel Oct 26, 2019
5266284
PWA initial setup
Tofandel Oct 26, 2019
508af01
Fix pwa compilation (npm run build:pwa)
Tofandel Oct 30, 2019
066e527
Fix typos
Tofandel Oct 30, 2019
a4cadb6
Fix compile errors
Tofandel Oct 30, 2019
c5947a4
Fix compile errors
Tofandel Oct 30, 2019
88a29e1
Fix compile errors
Tofandel Oct 30, 2019
9263b1f
Add codeowners
Tofandel Oct 30, 2019
769be42
Add codeowners
Tofandel Oct 30, 2019
f3b6565
More ws refactor
Tofandel Oct 30, 2019
60cb976
More ws refactor
Tofandel Oct 30, 2019
6222903
Add favicons + generate pwa icons automatically
Tofandel Nov 5, 2019
3f6e9b3
Add favicons + generate pwa icons automatically
Tofandel Nov 5, 2019
b8d00e6
Add favicons + generate pwa icons automatically
Tofandel Nov 5, 2019
2cb0059
Fix conditional loading of pwa
Tofandel Nov 5, 2019
41a2ecf
Replace gif loader by css
Tofandel Nov 5, 2019
c4500a3
Add package info for pwa
Tofandel Nov 5, 2019
0e7a486
Refactor integrations
Tofandel Nov 10, 2019
bb54a26
Refactor integrations
Tofandel Nov 10, 2019
3f88649
Refactor features
Tofandel Nov 10, 2019
75849f9
Make a vue data table component and code diff analysis to send the data
Tofandel Nov 10, 2019
8e250b0
Multiple fixes + finish features refactor
Tofandel Nov 15, 2019
65e06b9
Merge branch 'dev' into dev
Tofandel Nov 19, 2019
e77d0bb
Merge branch 'dev' into dev
Tofandel Dec 3, 2019
7f5e3ea
Work on the PWA
Tofandel Dec 3, 2019
c875953
Merge remote-tracking branch 'origin/dev' into dev
Tofandel Dec 3, 2019
ae0172d
Move from webpack-conditional-loader to webpack-preprocessor-loader
Tofandel Dec 8, 2019
4045365
Working device scanner
Tofandel Dec 9, 2019
751d621
Style pwa with element-ui
Tofandel Dec 9, 2019
58e1ec5
Add authentication modal
Tofandel Dec 9, 2019
e68de35
Add wifi status + refresh info
Tofandel Dec 10, 2019
d38b5e8
Add uploader
Tofandel Dec 10, 2019
03f2b03
Add uploader
Tofandel Dec 10, 2019
d7f68e3
Add pwa mocking device for 127.0.0.1
Tofandel Dec 23, 2019
74022d8
Improve uploader
Tofandel Dec 25, 2019
3efd905
Update dependencies + optimizations
Tofandel Jan 27, 2020
830761c
Merge branch 'dev' into dev
Tofandel Feb 13, 2020
dc202a5
Implement changes of 13.6 to 14.2 in vue ui
Tofandel Feb 13, 2020
f7c62f3
Restore scheduler visible and fix rfm69 visible
Tofandel Feb 13, 2020
39ff17b
Fix wifi schema
Tofandel Feb 13, 2020
9dbf4be
Fix relay schema
Tofandel Feb 13, 2020
4af5993
Add ws disconnection dialog
Tofandel Feb 13, 2020
2708706
Various bug fixes
Tofandel Feb 13, 2020
2b1c8f1
Cleanup debug messages
Tofandel Feb 13, 2020
ddc7215
Cleanup debug logs
Tofandel Feb 13, 2020
7ac8ae8
Restore debug line break
Tofandel Feb 14, 2020
fa8e609
Restore debug line break
Tofandel Feb 14, 2020
4054100
Added hardcode check for wifi
Tofandel Feb 14, 2020
3694b16
New underscore notation for non settings in api
Tofandel Feb 16, 2020
7c16335
Improve schema + fixes
Tofandel Feb 16, 2020
b352284
Add options for button + fix build error
Tofandel Feb 18, 2020
17d0bc9
Move options to button + fixes
Tofandel Feb 18, 2020
7c0ac08
Add codacity lint rules + implements websocket callback
Tofandel Feb 19, 2020
cf0e786
WIP refactor json buffer alloc + ws action callback
Tofandel Feb 20, 2020
ecc04d3
More api and ui rework + test of better allocation
Tofandel Apr 22, 2020
0376955
Merge branch 'dev' of https://github.com/xoseperez/espurna into dev
Tofandel Apr 22, 2020
6e18585
Remove some useless diff
Tofandel Apr 22, 2020
9c9caf0
Fix some merge errors
Tofandel Apr 22, 2020
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
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -15,3 +15,4 @@ custom.h
.env
.DS_Store
.vscode
.idea
5 changes: 3 additions & 2 deletions code/espurna/alexa.ino
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,9 @@ bool _alexaWebSocketOnKeyCheck(const char * key, JsonVariant& value) {
}

void _alexaWebSocketOnConnected(JsonObject& root) {
root["alexaEnabled"] = alexaEnabled();
root["alexaName"] = getSetting("alexaName");
JsonObject& alexa = root.createNestedObject("alexa");
alexa["enabled"] = alexaEnabled();
alexa["name"] = getSetting("alexaName");
}

void _alexaConfigure() {
Expand Down
9 changes: 5 additions & 4 deletions code/espurna/api.ino
Original file line number Diff line number Diff line change
Expand Up @@ -27,10 +27,11 @@ bool _apiWebSocketOnKeyCheck(const char * key, JsonVariant& value) {
}

void _apiWebSocketOnConnected(JsonObject& root) {
root["apiEnabled"] = getSetting("apiEnabled", API_ENABLED).toInt() == 1;
root["apiKey"] = getSetting("apiKey");
root["apiRealTime"] = getSetting("apiRealTime", API_REAL_TIME_VALUES).toInt() == 1;
root["apiRestFul"] = getSetting("apiRestFul", API_RESTFUL).toInt() == 1;
JsonObject& api = root.createNestedObject("api");
api["enabled"] = getSetting("apiEnabled", API_ENABLED).toInt() == 1;
api["key"] = getSetting("apiKey");
api["realTime"] = getSetting("apiRealTime", API_REAL_TIME_VALUES).toInt() == 1;
api["restFul"] = getSetting("apiRestFul", API_RESTFUL).toInt() == 1;
}

void _apiConfigure() {
Expand Down
2 changes: 1 addition & 1 deletion code/espurna/config/general.h
Original file line number Diff line number Diff line change
Expand Up @@ -625,7 +625,7 @@
// there are no special requirements. Any static web server will do (NGinx, Apache, Lighttpd,...).
// The only requirement is that the resource must be available under this domain.
#ifndef WEB_REMOTE_DOMAIN
#define WEB_REMOTE_DOMAIN "http://espurna.io"
#define WEB_REMOTE_DOMAIN "*"
#endif

// -----------------------------------------------------------------------------
Expand Down
11 changes: 6 additions & 5 deletions code/espurna/domoticz.ino
Original file line number Diff line number Diff line change
Expand Up @@ -188,18 +188,19 @@ void _domoticzWebSocketOnVisible(JsonObject& root) {
}

void _domoticzWebSocketOnConnected(JsonObject& root) {
JsonObject& dcz = root.createNestedObject("dcz");

root["dczEnabled"] = getSetting("dczEnabled", DOMOTICZ_ENABLED).toInt() == 1;
root["dczTopicIn"] = getSetting("dczTopicIn", DOMOTICZ_IN_TOPIC);
root["dczTopicOut"] = getSetting("dczTopicOut", DOMOTICZ_OUT_TOPIC);
dcz["enabled"] = getSetting("dczEnabled", DOMOTICZ_ENABLED).toInt() == 1;
dcz["topicIn"] = getSetting("dczTopicIn", DOMOTICZ_IN_TOPIC);
dcz["topicOut"] = getSetting("dczTopicOut", DOMOTICZ_OUT_TOPIC);

JsonArray& relays = root.createNestedArray("dczRelays");
JsonArray& relays = dcz.createNestedArray("relays");
for (unsigned char i=0; i<relayCount(); i++) {
relays.add(domoticzIdx(i));
}

#if SENSOR_SUPPORT
_sensorWebSocketMagnitudes(root, "dcz");
_sensorWebSocketMagnitudes(dcz);
#endif

}
Expand Down
8 changes: 5 additions & 3 deletions code/espurna/homeassistant.ino
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ void _haSendMagnitude(unsigned char i, JsonObject& config) {
unsigned char type = magnitudeType(i);
config["name"] = _haFixName(getSetting("hostname") + String(" ") + magnitudeTopic(type));
config["state_topic"] = mqttTopic(magnitudeTopicIndex(i).c_str(), false);
config["unit_of_measurement"] = magnitudeUnits(type);
config["unit_of_measurement"] = magnitudeUnit(type);
}

void _haSendMagnitudes(ha_config_t& config) {
Expand Down Expand Up @@ -328,8 +328,10 @@ void _haWebSocketOnVisible(JsonObject& root) {
}

void _haWebSocketOnConnected(JsonObject& root) {
root["haPrefix"] = getSetting("haPrefix", HOMEASSISTANT_PREFIX);
root["haEnabled"] = getSetting("haEnabled", HOMEASSISTANT_ENABLED).toInt() == 1;
JsonObject& ha = root.createNestedObject("ha");

ha["enabled"] = getSetting("haEnabled", HOMEASSISTANT_ENABLED).toInt() == 1;
ha["prefix"] = getSetting("haPrefix", HOMEASSISTANT_PREFIX);
}

void _haWebSocketOnAction(uint32_t client_id, const char * action, JsonObject& data) {
Expand Down
14 changes: 8 additions & 6 deletions code/espurna/influxdb.ino
Original file line number Diff line number Diff line change
Expand Up @@ -26,12 +26,14 @@ void _idbWebSocketOnVisible(JsonObject& root) {
}

void _idbWebSocketOnConnected(JsonObject& root) {
root["idbEnabled"] = getSetting("idbEnabled", INFLUXDB_ENABLED).toInt() == 1;
root["idbHost"] = getSetting("idbHost", INFLUXDB_HOST);
root["idbPort"] = getSetting("idbPort", INFLUXDB_PORT).toInt();
root["idbDatabase"] = getSetting("idbDatabase", INFLUXDB_DATABASE);
root["idbUsername"] = getSetting("idbUsername", INFLUXDB_USERNAME);
root["idbPassword"] = getSetting("idbPassword", INFLUXDB_PASSWORD);
JsonObject& idb = root.createNestedObject("idb");

idb["enabled"] = getSetting("idbEnabled", INFLUXDB_ENABLED).toInt() == 1;
idb["host"] = getSetting("idbHost", INFLUXDB_HOST);
idb["port"] = getSetting("idbPort", INFLUXDB_PORT).toInt();
idb["database"] = getSetting("idbDatabase", INFLUXDB_DATABASE);
idb["username"] = getSetting("idbUsername", INFLUXDB_USERNAME);
idb["password"] = getSetting("idbPassword", INFLUXDB_PASSWORD);
}

void _idbConfigure() {
Expand Down
2 changes: 1 addition & 1 deletion code/espurna/led.ino
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ void _ledWebSocketOnVisible(JsonObject& root) {

void _ledWebSocketOnConnected(JsonObject& root) {
if (_ledCount() == 0) return;
JsonArray& leds = root.createNestedArray("ledConfig");
JsonArray& leds = root.createNestedArray("leds");
for (byte i=0; i<_ledCount(); i++) {
JsonObject& led = leds.createNestedObject();
led["mode"] = getSetting("ledMode", i, "").toInt();
Expand Down
12 changes: 7 additions & 5 deletions code/espurna/lightfox.ino
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ void lightfoxLearn() {
Serial.write(LIGHTFOX_CODE_STOP);
Serial.println();
Serial.flush();
DEBUG_MSG_P(PSTR("[LIGHTFOX] Learn comman sent\n"));
DEBUG_MSG_P(PSTR("[LIGHTFOX] Learn command sent\n"));
}

void lightfoxClear() {
Expand All @@ -38,7 +38,7 @@ void lightfoxClear() {
Serial.write(LIGHTFOX_CODE_STOP);
Serial.println();
Serial.flush();
DEBUG_MSG_P(PSTR("[LIGHTFOX] Clear comman sent\n"));
DEBUG_MSG_P(PSTR("[LIGHTFOX] Clear command sent\n"));
}

// -----------------------------------------------------------------------------
Expand All @@ -48,10 +48,12 @@ void lightfoxClear() {
#if WEB_SUPPORT

void _lightfoxWebSocketOnConnected(JsonObject& root) {
root["lightfoxVisible"] = 1;
JsonObject& lightfox = root.createNestedObject("lightfox");

lightfox["enabled"] = 1;

uint8_t buttonsCount = _buttons.size();
root["lightfoxRelayCount"] = relayCount();
JsonArray& rfb = root.createNestedArray("lightfoxButtons");
JsonArray& rfb = root.createNestedArray("buttons");
for (byte id=0; id<buttonsCount; id++) {
JsonObject& node = rfb.createNestedObject();
node["id"] = id;
Expand Down
28 changes: 15 additions & 13 deletions code/espurna/mqtt.ino
Original file line number Diff line number Diff line change
Expand Up @@ -438,21 +438,23 @@ void _mqttWebSocketOnData(JsonObject& root) {
}

void _mqttWebSocketOnConnected(JsonObject& root) {
root["mqttEnabled"] = mqttEnabled();
root["mqttServer"] = getSetting("mqttServer", MQTT_SERVER);
root["mqttPort"] = getSetting("mqttPort", MQTT_PORT);
root["mqttUser"] = getSetting("mqttUser", MQTT_USER);
root["mqttClientID"] = getSetting("mqttClientID");
root["mqttPassword"] = getSetting("mqttPassword", MQTT_PASS);
root["mqttKeep"] = _mqtt_keepalive;
root["mqttRetain"] = _mqtt_retain;
root["mqttQoS"] = _mqtt_qos;
JsonObject& mqtt = root.createNestedObject("mqtt");

mqtt["enabled"] = mqttEnabled();
mqtt["server"] = getSetting("mqttServer", MQTT_SERVER);
mqtt["port"] = getSetting("mqttPort", MQTT_PORT);
mqtt["user"] = getSetting("mqttUser", MQTT_USER);
mqtt["clientID"] = getSetting("mqttClientID");
mqtt["password"] = getSetting("mqttPassword", MQTT_PASS);
mqtt["keep"] = _mqtt_keepalive;
mqtt["retain"] = _mqtt_retain;
mqtt["qoS"] = _mqtt_qos;
#if SECURE_CLIENT != SECURE_CLIENT_NONE
root["mqttUseSSL"] = getSetting("mqttUseSSL", MQTT_SSL_ENABLED).toInt() == 1;
root["mqttFP"] = getSetting("mqttFP", MQTT_SSL_FINGERPRINT);
mqtt["useSSL"] = getSetting("mqttUseSSL", MQTT_SSL_ENABLED).toInt() == 1;
mqtt["FP"] = getSetting("mqttFP", MQTT_SSL_FINGERPRINT);
#endif
root["mqttTopic"] = getSetting("mqttTopic", MQTT_TOPIC);
root["mqttUseJson"] = getSetting("mqttUseJson", MQTT_USE_JSON).toInt() == 1;
mqtt["topic"] = getSetting("mqttTopic", MQTT_TOPIC);
mqtt["useJson"] = getSetting("mqttUseJson", MQTT_USE_JSON).toInt() == 1;
}

#endif
Expand Down
6 changes: 4 additions & 2 deletions code/espurna/nofuss.ino
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,10 @@ void _nofussWebSocketOnVisible(JsonObject& root) {
}

void _nofussWebSocketOnConnected(JsonObject& root) {
root["nofussEnabled"] = getSetting("nofussEnabled", NOFUSS_ENABLED).toInt() == 1;
root["nofussServer"] = getSetting("nofussServer", NOFUSS_SERVER);
JsonObject& nofuss = root.createNestedObject("nofuss");

nofuss["enabled"] = getSetting("nofussEnabled", NOFUSS_ENABLED).toInt() == 1;
nofuss["server"] = getSetting("nofussServer", NOFUSS_SERVER);
}

#endif
Expand Down
10 changes: 6 additions & 4 deletions code/espurna/ntp.ino
Original file line number Diff line number Diff line change
Expand Up @@ -39,10 +39,12 @@ void _ntpWebSocketOnData(JsonObject& root) {
}

void _ntpWebSocketOnConnected(JsonObject& root) {
root["ntpServer"] = getSetting("ntpServer", NTP_SERVER);
root["ntpOffset"] = getSetting("ntpOffset", NTP_TIME_OFFSET).toInt();
root["ntpDST"] = getSetting("ntpDST", NTP_DAY_LIGHT).toInt() == 1;
root["ntpRegion"] = getSetting("ntpRegion", NTP_DST_REGION).toInt();
JsonObject& ntp = root.createNestedObject("ntp");

ntp["server"] = getSetting("ntpServer", NTP_SERVER);
ntp["offset"] = getSetting("ntpOffset", NTP_TIME_OFFSET).toInt();
ntp["DST"] = getSetting("ntpDST", NTP_DAY_LIGHT).toInt() == 1;
ntp["region"] = getSetting("ntpRegion", NTP_DST_REGION).toInt();
}

#endif
Expand Down
40 changes: 12 additions & 28 deletions code/espurna/relay.ino
Original file line number Diff line number Diff line change
Expand Up @@ -719,39 +719,23 @@ String _relayFriendlyName(unsigned char i) {
return res;
}

void _relayWebSocketSendRelays(JsonObject& root) {
JsonObject& relays = root.createNestedObject("relayConfig");

relays["size"] = relayCount();
relays["start"] = 0;

JsonArray& gpio = relays.createNestedArray("gpio");
JsonArray& type = relays.createNestedArray("type");
JsonArray& reset = relays.createNestedArray("reset");
JsonArray& boot = relays.createNestedArray("boot");
JsonArray& pulse = relays.createNestedArray("pulse");
JsonArray& pulse_time = relays.createNestedArray("pulse_time");

#if MQTT_SUPPORT
JsonArray& group = relays.createNestedArray("group");
JsonArray& group_sync = relays.createNestedArray("group_sync");
JsonArray& on_disconnect = relays.createNestedArray("on_disc");
#endif
void _relayWebSocketSendRelays(JsonObject& root) {
JsonArray& relays = root.createNestedArray("relays");
Tofandel marked this conversation as resolved.
Show resolved Hide resolved

for (unsigned char i=0; i<relayCount(); i++) {
gpio.add(_relayFriendlyName(i));

type.add(_relays[i].type);
reset.add(_relays[i].reset_pin);
boot.add(getSetting("relayBoot", i, RELAY_BOOT_MODE).toInt());

pulse.add(_relays[i].pulse);
pulse_time.add(_relays[i].pulse_ms / 1000.0);
JsonObject& relay = relays.createNestedObject()
relay["gpio"] = _relayFriendlyName(i);
relay["type"] = _relays[i].type;
relay["reset"] = _relays[i].reset_pin;
relay["boot"] = getSetting("relayBoot", i, RELAY_BOOT_MODE).toInt();
relay["pulse"] = _relays[i].pulse;
relay["pulse_time"] = _relays[i].pulse_ms / 1000.0;

#if MQTT_SUPPORT
group.add(getSetting("mqttGroup", i, ""));
group_sync.add(getSetting("mqttGroupSync", i, 0).toInt());
on_disconnect.add(getSetting("relayOnDisc", i, 0).toInt());
relay["group"] = getSetting("mqttGroup", i, "");
relay["group_sync"] = getSetting("mqttGroupSync", i, 0).toInt();
relay["on_disc"] = getSetting("relayOnDisc", i, 0).toInt();
#endif
}
}
Expand Down
12 changes: 7 additions & 5 deletions code/espurna/rfbridge.ino
Original file line number Diff line number Diff line change
Expand Up @@ -104,12 +104,14 @@ void _rfbWebSocketOnVisible(JsonObject& root) {
}

void _rfbWebSocketOnConnected(JsonObject& root) {
root["rfbRepeat"] = getSetting("rfbRepeat", RF_SEND_TIMES).toInt();
root["rfbCount"] = relayCount();
JsonObject& rfb = root.createNestedObject("rfb");

rfb["repeat"] = getSetting("rfbRepeat", RF_SEND_TIMES).toInt();
rfb["count"] = relayCount();
#if RFB_DIRECT
root["rfbdirectVisible"] = 1;
root["rfbRX"] = getSetting("rfbRX", RFB_RX_PIN).toInt();
root["rfbTX"] = getSetting("rfbTX", RFB_TX_PIN).toInt();
rfb["directVisible"] = 1;
rfb["RX"] = getSetting("rfbRX", RFB_RX_PIN).toInt();
rfb["TX"] = getSetting("rfbTX", RFB_TX_PIN).toInt();
#endif
}

Expand Down
11 changes: 6 additions & 5 deletions code/espurna/rfm69.ino
Original file line number Diff line number Diff line change
Expand Up @@ -36,12 +36,13 @@ unsigned long _rfm69_packet_count;
#if WEB_SUPPORT

void _rfm69WebSocketOnConnected(JsonObject& root) {
JsonObject& rfm69 = root.createNestedObject("rfm69");

root["rfm69Visible"] = 1;
root["rfm69Topic"] = getSetting("rfm69Topic", RFM69_DEFAULT_TOPIC);
root["packetCount"] = _rfm69_packet_count;
root["nodeCount"] = _rfm69_node_count;
JsonArray& mappings = root.createNestedArray("mapping");
rfm69["visible"] = 1;
rfm69["topic"] = getSetting("rfm69Topic", RFM69_DEFAULT_TOPIC);
rfm69["packetCount"] = _rfm69_packet_count;
rfm69["nodeCount"] = _rfm69_node_count;
JsonArray& mappings = rfm69.createNestedArray("mapping");
for (unsigned char i=0; i<RFM69_MAX_TOPICS; i++) {
unsigned char node = getSetting("node", i, 0).toInt();
if (0 == node) break;
Expand Down
37 changes: 13 additions & 24 deletions code/espurna/scheduler.ino
Original file line number Diff line number Diff line change
Expand Up @@ -25,41 +25,30 @@ void _schWebSocketOnVisible(JsonObject& root) {
}

void _schWebSocketOnConnected(JsonObject &root){

if (!relayCount()) return;

JsonArray& schedules = root.createNestedArray("schedules");

root["maxSchedules"] = SCHEDULER_MAX_SCHEDULES;

JsonObject &schedules = root.createNestedObject("schedules");
uint8_t size = 0;

JsonArray& enabled = schedules.createNestedArray("schEnabled");
JsonArray& switch_ = schedules.createNestedArray("schSwitch");
JsonArray& action = schedules.createNestedArray("schAction");
JsonArray& type = schedules.createNestedArray("schType");
JsonArray& hour = schedules.createNestedArray("schHour");
JsonArray& minute = schedules.createNestedArray("schMinute");
JsonArray& utc = schedules.createNestedArray("schUTC");
JsonArray& weekdays = schedules.createNestedArray("schWDs");

for (byte i = 0; i < SCHEDULER_MAX_SCHEDULES; i++) {
if (!hasSetting("schSwitch", i)) break;
++size;

enabled.add<uint8_t>(getSetting("schEnabled", i, 1).toInt() == 1);
utc.add<uint8_t>(getSetting("schUTC", i, 0).toInt() == 1);

switch_.add(getSetting("schSwitch", i, 0).toInt());
action.add(getSetting("schAction", i, 0).toInt());
type.add(getSetting("schType", i, 0).toInt());
hour.add(getSetting("schHour", i, 0).toInt());
minute.add(getSetting("schMinute", i, 0).toInt());
weekdays.add(getSetting("schWDs", i, ""));

JsonObject& schedule = schedules.createNestedObject();

schedule["enabled"] = getSetting("schEnabled", i, 1).toInt() == 1;
schedule["UTC"] = getSetting("schUTC", i, 0).toInt() == 1;
schedule["switch"] = getSetting("schSwitch", i, 0).toInt();
schedule["action"] = getSetting("schAction", i, 0).toInt();
schedule["type"] = getSetting("schType", i, 0).toInt();
schedule["hour"] = getSetting("schHour", i, 0).toInt();
schedule["minute"] = getSetting("schMinute", i, 0).toInt();
schedule["weekdays"] = getSetting("schWDs", i, "");
}

schedules["size"] = size;
schedules["start"] = 0;

}

#endif // WEB_SUPPORT
Expand Down
Loading