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 USE_STATIC_IP //! uncomment to enable Static IP Adress
|
||||||
|
|
||||||
#define SERIAL_BAUD_RATE 115200
|
#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
|
#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>"
|
||||||
"<div class=\"pure-control-group\">"
|
"<div class=\"pure-control-group\">"
|
||||||
"<label for=\"ip\">IP</label>"
|
"<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>"
|
||||||
"<div class=\"pure-control-group\">"
|
"<div class=\"pure-control-group\">"
|
||||||
"<label for=\"gwip\">Gateway IP</label>"
|
"<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>"
|
||||||
"<div class=\"pure-control-group\">"
|
"<div class=\"pure-control-group\">"
|
||||||
"<label for=\"ip\">Netmask</label>"
|
"<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>"
|
||||||
"<div class=\"pure-control-group\">"
|
"<div class=\"pure-control-group\">"
|
||||||
"<label for=\"ip\">DNS</label>"
|
"<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>"
|
||||||
"<div class=\"pure-controls\">"
|
"<div class=\"pure-controls\">"
|
||||||
"<button type=\"submit\" class=\"pure-button pure-button-primary\">Save</button>"
|
"<button type=\"submit\" class=\"pure-button pure-button-primary\">Save</button>"
|
||||||
|
|
|
@ -41,19 +41,19 @@
|
||||||
</div>
|
</div>
|
||||||
<div class="pure-control-group">
|
<div class="pure-control-group">
|
||||||
<label for="ip">IP</label>
|
<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>
|
||||||
<div class="pure-control-group">
|
<div class="pure-control-group">
|
||||||
<label for="gwip">Gateway IP</label>
|
<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>
|
||||||
<div class="pure-control-group">
|
<div class="pure-control-group">
|
||||||
<label for="ip">Netmask</label>
|
<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>
|
||||||
<div class="pure-control-group">
|
<div class="pure-control-group">
|
||||||
<label for="ip">DNS</label>
|
<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>
|
||||||
<div class="pure-controls">
|
<div class="pure-controls">
|
||||||
<button type="submit" class="pure-button pure-button-primary">Save</button>
|
<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) {
|
void apply_scene(uint8_t new_scene, uint8_t light)
|
||||||
if (new_scene == SCENE_RELEAX) {
|
{
|
||||||
|
if (new_scene == SCENE_RELEAX)
|
||||||
|
{
|
||||||
bri[light] = 144;
|
bri[light] = 144;
|
||||||
} else if (new_scene == SCENE_BRIGHT) {
|
} else if (new_scene == SCENE_BRIGHT)
|
||||||
|
{
|
||||||
bri[light] = 254;
|
bri[light] = 254;
|
||||||
} else if (new_scene == SCENE_NIGHTLY) {
|
} else if (new_scene == SCENE_NIGHTLY)
|
||||||
|
{
|
||||||
bri[0] = 25;
|
bri[0] = 25;
|
||||||
bri[1] = 0;
|
bri[1] = 0;
|
||||||
bri[2] = 0;
|
bri[2] = 0;
|
||||||
|
@ -619,6 +623,8 @@ void init_webserver()
|
||||||
|
|
||||||
http_content.replace("{{LIGHT_NAME}}", (String)light_name);
|
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);
|
int tc_val = EEPROM.read(EEPROM_TIMING_CONTROL_ENABLED_ADDRESS);
|
||||||
if (tc_val == TIMING_CONTROL_ENABLED)
|
if (tc_val == TIMING_CONTROL_ENABLED)
|
||||||
{
|
{
|
||||||
|
@ -700,7 +706,7 @@ void init_webserver()
|
||||||
String config_content = getConfigHTML();
|
String config_content = getConfigHTML();
|
||||||
|
|
||||||
// Wifi settings
|
// Wifi settings
|
||||||
config_content.replace("{{WIFI_SSIF}}", WiFi.SSID());
|
config_content.replace("{{WIFI_SSID}}", WiFi.SSID());
|
||||||
|
|
||||||
// Network settings
|
// Network settings
|
||||||
uint8_t dip = EEPROM.read(EEPROM_DYNAMIC_IP_ADDRESS);
|
uint8_t dip = EEPROM.read(EEPROM_DYNAMIC_IP_ADDRESS);
|
||||||
|
@ -714,16 +720,15 @@ void init_webserver()
|
||||||
}
|
}
|
||||||
|
|
||||||
// ip config
|
// ip config
|
||||||
if (dip == 0)
|
config_content.replace("{{WIFI_CFG_IP}}", WiFi.localIP().toString());
|
||||||
{
|
config_content.replace("{{WIFI_CFG_GW}}", WiFi.gatewayIP().toString());
|
||||||
config_content.replace("{{WIFI_IP}}", WiFi.localIP().toString());
|
config_content.replace("{{WIFI_CFG_NM}}", WiFi.subnetMask().toString());
|
||||||
config_content.replace("{{WIFI_GW}}", WiFi.gatewayIP().toString());
|
config_content.replace("{{WIFI_CFG_DNS}}", WiFi.dnsIP().toString());
|
||||||
config_content.replace("{{WIFI_NM}}", WiFi.subnetMask().toString());
|
|
||||||
config_content.replace("{{WIFI_DNS}}", WiFi.dnsIP().toString());
|
|
||||||
}
|
|
||||||
|
|
||||||
http_content.replace("{{CONFIG_PAGE}}", config_content);
|
http_content.replace("{{CONFIG_PAGE}}", config_content);
|
||||||
|
|
||||||
|
http_content.replace("{{IP_ADDRESS}}", WiFi.localIP().toString());
|
||||||
|
|
||||||
// set the pwm values
|
// set the pwm values
|
||||||
http_content.replace("{{PWM_MIN}}", (String)PWM_MIN);
|
http_content.replace("{{PWM_MIN}}", (String)PWM_MIN);
|
||||||
http_content.replace("{{PWM_MAX}}", (String)PWM_MAX);
|
http_content.replace("{{PWM_MAX}}", (String)PWM_MAX);
|
||||||
|
|
|
@ -36,7 +36,7 @@ String getIndexHTML()
|
||||||
"<strong>Timing control</strong>"
|
"<strong>Timing control</strong>"
|
||||||
"</label>"
|
"</label>"
|
||||||
"<a id=\"tc_on\" class=\"pure-button {{TC_LINK_PRIMARY_ON}}\" href=\"#\">ON</a>"
|
"<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>"
|
"</div>"
|
||||||
"<script>"
|
"<script>"
|
||||||
"var links = document.querySelectorAll('[id^=\"tc_on\"]');"
|
"var links = document.querySelectorAll('[id^=\"tc_on\"]');"
|
||||||
|
@ -94,7 +94,6 @@ String getIndexHTML()
|
||||||
"<tr>"
|
"<tr>"
|
||||||
"<td>"
|
"<td>"
|
||||||
"{{LIGHTS_CONTROL}}"
|
"{{LIGHTS_CONTROL}}"
|
||||||
""
|
|
||||||
"</td>"
|
"</td>"
|
||||||
"<td>"
|
"<td>"
|
||||||
"<div id=\"plot_chart\"></div>"
|
"<div id=\"plot_chart\"></div>"
|
||||||
|
@ -228,7 +227,7 @@ String getIndexHTML()
|
||||||
""
|
""
|
||||||
"function updateLightState() {"
|
"function updateLightState() {"
|
||||||
"console.log('----> setting bri and power switch <----');"
|
"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}`;"
|
"const lightURL = `http://{{IP_ADDRESS}}/state?light=${i}`;"
|
||||||
"fetch(lightURL).then(response => response.json()).then(data => {"
|
"fetch(lightURL).then(response => response.json()).then(data => {"
|
||||||
"const briSlider = document.getElementById(`bri${i - 1}`);"
|
"const briSlider = document.getElementById(`bri${i - 1}`);"
|
||||||
|
@ -253,7 +252,7 @@ String getIndexHTML()
|
||||||
""
|
""
|
||||||
"function updatePWMValues() {"
|
"function updatePWMValues() {"
|
||||||
"console.log('----> setting pwm data <----');"
|
"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 lightID = i + 1;"
|
||||||
"const pwmElement = document.getElementById(`light${i}_pwm`);"
|
"const pwmElement = document.getElementById(`light${i}_pwm`);"
|
||||||
"const pwmElementTxt = document.getElementById(`light${i}_pwm_txt`);"
|
"const pwmElementTxt = document.getElementById(`light${i}_pwm_txt`);"
|
||||||
|
|
|
@ -32,7 +32,7 @@
|
||||||
<strong>Timing control</strong>
|
<strong>Timing control</strong>
|
||||||
</label>
|
</label>
|
||||||
<a id="tc_on" class="pure-button {{TC_LINK_PRIMARY_ON}}" href="#">ON</a>
|
<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>
|
</div>
|
||||||
<script>
|
<script>
|
||||||
var links = document.querySelectorAll('[id^="tc_on"]');
|
var links = document.querySelectorAll('[id^="tc_on"]');
|
||||||
|
@ -224,7 +224,7 @@
|
||||||
|
|
||||||
function updateLightState() {
|
function updateLightState() {
|
||||||
console.log('----> setting bri and power switch <----');
|
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}`;
|
const lightURL = `http://{{IP_ADDRESS}}/state?light=${i}`;
|
||||||
fetch(lightURL).then(response => response.json()).then(data => {
|
fetch(lightURL).then(response => response.json()).then(data => {
|
||||||
const briSlider = document.getElementById(`bri${i - 1}`);
|
const briSlider = document.getElementById(`bri${i - 1}`);
|
||||||
|
@ -249,7 +249,7 @@
|
||||||
|
|
||||||
function updatePWMValues() {
|
function updatePWMValues() {
|
||||||
console.log('----> setting pwm data <----');
|
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 lightID = i + 1;
|
||||||
const pwmElement = document.getElementById(`light${i}_pwm`);
|
const pwmElement = document.getElementById(`light${i}_pwm`);
|
||||||
const pwmElementTxt = document.getElementById(`light${i}_pwm_txt`);
|
const pwmElementTxt = document.getElementById(`light${i}_pwm_txt`);
|
||||||
|
@ -271,4 +271,4 @@
|
||||||
</div>
|
</div>
|
||||||
</fieldset>
|
</fieldset>
|
||||||
</body>
|
</body>
|
||||||
</html>
|
</html>
|
||||||
|
|
|
@ -87,7 +87,7 @@ void tc_init()
|
||||||
tc_last_check = millis();
|
tc_last_check = millis();
|
||||||
|
|
||||||
// Set the timezone to Europe/Berlin
|
// 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();
|
tzset();
|
||||||
|
|
||||||
timeClient.begin();
|
timeClient.begin();
|
||||||
|
|
Loading…
Reference in a new issue