Fixed replacement of some placeholder. Added a timezone string to the config.
This commit is contained in:
parent
3dc7ebf263
commit
3cbdf20e79
7 changed files with 36 additions and 30 deletions
|
@ -2,8 +2,10 @@
|
|||
#define USE_STATIC_IP //! uncomment to enable Static IP Adress
|
||||
|
||||
#define SERIAL_BAUD_RATE 115200
|
||||
|
||||
#define LOCAL_TIMEZONE_STRING "CET-1CEST-2,M3.5.0/02:00:00,M10.5.0/03:00:00" // Berlin, Germany - https://sites.google.com/a/usapiens.com/opnode/time-zones
|
||||
|
||||
#define light_name "Dimmable Hue Light" //default light name
|
||||
#define light_name "Dimmable Hue Light (DEV)" // default light name
|
||||
|
||||
#define LIGHTS_COUNT 4 // do not modify because luminie p30 only has 4 channel, never set above 80
|
||||
|
||||
|
|
|
@ -45,19 +45,19 @@ String getConfigHTML()
|
|||
"</div>"
|
||||
"<div class=\"pure-control-group\">"
|
||||
"<label for=\"ip\">IP</label>"
|
||||
"<input id=\"ip\" name=\"ip\" type=\"text\" value=\"{{WIFI_IP}}\">"
|
||||
"<input id=\"ip\" name=\"ip\" type=\"text\" value=\"{{WIFI_CFG_IP}}\">"
|
||||
"</div>"
|
||||
"<div class=\"pure-control-group\">"
|
||||
"<label for=\"gwip\">Gateway IP</label>"
|
||||
"<input id=\"gwip\" name=\"gwip\" type=\"text\" value=\"{{WIFI_GW}}\">"
|
||||
"<input id=\"gwip\" name=\"gwip\" type=\"text\" value=\"{{WIFI_CFG_GW}}\">"
|
||||
"</div>"
|
||||
"<div class=\"pure-control-group\">"
|
||||
"<label for=\"ip\">Netmask</label>"
|
||||
"<input id=\"netmask\" name=\"netmas\" type=\"text\" value=\"{{WIFI_NM}}\">"
|
||||
"<input id=\"netmask\" name=\"netmas\" type=\"text\" value=\"{{WIFI_CFG_NM}}\">"
|
||||
"</div>"
|
||||
"<div class=\"pure-control-group\">"
|
||||
"<label for=\"ip\">DNS</label>"
|
||||
"<input id=\"netmask\" name=\"dns\" type=\"text\" value=\"{{WIFI_DNS}}\">"
|
||||
"<input id=\"netmask\" name=\"dns\" type=\"text\" value=\"{{WIFI_CFG_DNS}}\">"
|
||||
"</div>"
|
||||
"<div class=\"pure-controls\">"
|
||||
"<button type=\"submit\" class=\"pure-button pure-button-primary\">Save</button>"
|
||||
|
|
|
@ -41,19 +41,19 @@
|
|||
</div>
|
||||
<div class="pure-control-group">
|
||||
<label for="ip">IP</label>
|
||||
<input id="ip" name="ip" type="text" value="{{WIFI_IP}}">
|
||||
<input id="ip" name="ip" type="text" value="{{WIFI_CFG_IP}}">
|
||||
</div>
|
||||
<div class="pure-control-group">
|
||||
<label for="gwip">Gateway IP</label>
|
||||
<input id="gwip" name="gwip" type="text" value="{{WIFI_GW}}">
|
||||
<input id="gwip" name="gwip" type="text" value="{{WIFI_CFG_GW}}">
|
||||
</div>
|
||||
<div class="pure-control-group">
|
||||
<label for="ip">Netmask</label>
|
||||
<input id="netmask" name="netmas" type="text" value="{{WIFI_NM}}">
|
||||
<input id="netmask" name="netmas" type="text" value="{{WIFI_CFG_NM}}">
|
||||
</div>
|
||||
<div class="pure-control-group">
|
||||
<label for="ip">DNS</label>
|
||||
<input id="netmask" name="dns" type="text" value="{{WIFI_DNS}}">
|
||||
<input id="netmask" name="dns" type="text" value="{{WIFI_CFG_DNS}}">
|
||||
</div>
|
||||
<div class="pure-controls">
|
||||
<button type="submit" class="pure-button pure-button-primary">Save</button>
|
||||
|
|
|
@ -80,12 +80,16 @@ uint32_t last_lightengine_activity = 0;
|
|||
|
||||
//********************************//
|
||||
|
||||
void apply_scene(uint8_t new_scene, uint8_t light) {
|
||||
if (new_scene == SCENE_RELEAX) {
|
||||
void apply_scene(uint8_t new_scene, uint8_t light)
|
||||
{
|
||||
if (new_scene == SCENE_RELEAX)
|
||||
{
|
||||
bri[light] = 144;
|
||||
} else if (new_scene == SCENE_BRIGHT) {
|
||||
} else if (new_scene == SCENE_BRIGHT)
|
||||
{
|
||||
bri[light] = 254;
|
||||
} else if (new_scene == SCENE_NIGHTLY) {
|
||||
} else if (new_scene == SCENE_NIGHTLY)
|
||||
{
|
||||
bri[0] = 25;
|
||||
bri[1] = 0;
|
||||
bri[2] = 0;
|
||||
|
@ -619,6 +623,8 @@ void init_webserver()
|
|||
|
||||
http_content.replace("{{LIGHT_NAME}}", (String)light_name);
|
||||
|
||||
http_content.replace("{{LIGHT_COUNT}}", (String)LIGHTS_COUNT);
|
||||
|
||||
int tc_val = EEPROM.read(EEPROM_TIMING_CONTROL_ENABLED_ADDRESS);
|
||||
if (tc_val == TIMING_CONTROL_ENABLED)
|
||||
{
|
||||
|
@ -700,7 +706,7 @@ void init_webserver()
|
|||
String config_content = getConfigHTML();
|
||||
|
||||
// Wifi settings
|
||||
config_content.replace("{{WIFI_SSIF}}", WiFi.SSID());
|
||||
config_content.replace("{{WIFI_SSID}}", WiFi.SSID());
|
||||
|
||||
// Network settings
|
||||
uint8_t dip = EEPROM.read(EEPROM_DYNAMIC_IP_ADDRESS);
|
||||
|
@ -714,16 +720,15 @@ void init_webserver()
|
|||
}
|
||||
|
||||
// ip config
|
||||
if (dip == 0)
|
||||
{
|
||||
config_content.replace("{{WIFI_IP}}", WiFi.localIP().toString());
|
||||
config_content.replace("{{WIFI_GW}}", WiFi.gatewayIP().toString());
|
||||
config_content.replace("{{WIFI_NM}}", WiFi.subnetMask().toString());
|
||||
config_content.replace("{{WIFI_DNS}}", WiFi.dnsIP().toString());
|
||||
}
|
||||
config_content.replace("{{WIFI_CFG_IP}}", WiFi.localIP().toString());
|
||||
config_content.replace("{{WIFI_CFG_GW}}", WiFi.gatewayIP().toString());
|
||||
config_content.replace("{{WIFI_CFG_NM}}", WiFi.subnetMask().toString());
|
||||
config_content.replace("{{WIFI_CFG_DNS}}", WiFi.dnsIP().toString());
|
||||
|
||||
http_content.replace("{{CONFIG_PAGE}}", config_content);
|
||||
|
||||
http_content.replace("{{IP_ADDRESS}}", WiFi.localIP().toString());
|
||||
|
||||
// set the pwm values
|
||||
http_content.replace("{{PWM_MIN}}", (String)PWM_MIN);
|
||||
http_content.replace("{{PWM_MAX}}", (String)PWM_MAX);
|
||||
|
|
|
@ -36,7 +36,7 @@ String getIndexHTML()
|
|||
"<strong>Timing control</strong>"
|
||||
"</label>"
|
||||
"<a id=\"tc_on\" class=\"pure-button {{TC_LINK_PRIMARY_ON}}\" href=\"#\">ON</a>"
|
||||
"<a id=\"tc_off\" class=\"pure-button {{TC_LINK_PRIMARY_OFF\" href=\"#\">OFF</a>"
|
||||
"<a id=\"tc_off\" class=\"pure-button {{TC_LINK_PRIMARY_OFF}}\" href=\"#\">OFF</a>"
|
||||
"</div>"
|
||||
"<script>"
|
||||
"var links = document.querySelectorAll('[id^=\"tc_on\"]');"
|
||||
|
@ -94,7 +94,6 @@ String getIndexHTML()
|
|||
"<tr>"
|
||||
"<td>"
|
||||
"{{LIGHTS_CONTROL}}"
|
||||
""
|
||||
"</td>"
|
||||
"<td>"
|
||||
"<div id=\"plot_chart\"></div>"
|
||||
|
@ -228,7 +227,7 @@ String getIndexHTML()
|
|||
""
|
||||
"function updateLightState() {"
|
||||
"console.log('----> setting bri and power switch <----');"
|
||||
"for (let i = 1; i <= {{LIGHT_NUM}}; i++) {"
|
||||
"for (let i = 1; i <= {{LIGHT_COUNT}}; i++) {"
|
||||
"const lightURL = `http://{{IP_ADDRESS}}/state?light=${i}`;"
|
||||
"fetch(lightURL).then(response => response.json()).then(data => {"
|
||||
"const briSlider = document.getElementById(`bri${i - 1}`);"
|
||||
|
@ -253,7 +252,7 @@ String getIndexHTML()
|
|||
""
|
||||
"function updatePWMValues() {"
|
||||
"console.log('----> setting pwm data <----');"
|
||||
"for (let i = 0; i < {{LIGHT_NUM}}; i++) {"
|
||||
"for (let i = 0; i < {{LIGHT_COUNT}}; i++) {"
|
||||
"const lightID = i + 1;"
|
||||
"const pwmElement = document.getElementById(`light${i}_pwm`);"
|
||||
"const pwmElementTxt = document.getElementById(`light${i}_pwm_txt`);"
|
||||
|
|
|
@ -32,7 +32,7 @@
|
|||
<strong>Timing control</strong>
|
||||
</label>
|
||||
<a id="tc_on" class="pure-button {{TC_LINK_PRIMARY_ON}}" href="#">ON</a>
|
||||
<a id="tc_off" class="pure-button {{TC_LINK_PRIMARY_OFF" href="#">OFF</a>
|
||||
<a id="tc_off" class="pure-button {{TC_LINK_PRIMARY_OFF}}" href="#">OFF</a>
|
||||
</div>
|
||||
<script>
|
||||
var links = document.querySelectorAll('[id^="tc_on"]');
|
||||
|
@ -224,7 +224,7 @@
|
|||
|
||||
function updateLightState() {
|
||||
console.log('----> setting bri and power switch <----');
|
||||
for (let i = 1; i <= {{LIGHT_NUM}}; i++) {
|
||||
for (let i = 1; i <= {{LIGHT_COUNT}}; i++) {
|
||||
const lightURL = `http://{{IP_ADDRESS}}/state?light=${i}`;
|
||||
fetch(lightURL).then(response => response.json()).then(data => {
|
||||
const briSlider = document.getElementById(`bri${i - 1}`);
|
||||
|
@ -249,7 +249,7 @@
|
|||
|
||||
function updatePWMValues() {
|
||||
console.log('----> setting pwm data <----');
|
||||
for (let i = 0; i < {{LIGHT_NUM}}; i++) {
|
||||
for (let i = 0; i < {{LIGHT_COUNT}}; i++) {
|
||||
const lightID = i + 1;
|
||||
const pwmElement = document.getElementById(`light${i}_pwm`);
|
||||
const pwmElementTxt = document.getElementById(`light${i}_pwm_txt`);
|
||||
|
@ -271,4 +271,4 @@
|
|||
</div>
|
||||
</fieldset>
|
||||
</body>
|
||||
</html>
|
||||
</html>
|
||||
|
|
|
@ -87,7 +87,7 @@ void tc_init()
|
|||
tc_last_check = millis();
|
||||
|
||||
// Set the timezone to Europe/Berlin
|
||||
setenv("TZ", "CET-1CEST,M3.5.0,M10.5.0/3", 1);
|
||||
setenv("TZ", LOCAL_TIMEZONE_STRING, 1);
|
||||
tzset();
|
||||
|
||||
timeClient.begin();
|
||||
|
|
Loading…
Reference in a new issue