# HG changeset patch # User Michiel Broek # Date 1591210977 -7200 # Node ID c7b4cb53b37cd08765cdedb0d22b372c0c2d397f # Parent 367ae7ff52f0e1a6a1266fcb59a0a8455c02ab9d Fixed missing light_state commands for the webcam. diff -r 367ae7ff52f0 -r c7b4cb53b37c bmsd/fermenters.c --- a/bmsd/fermenters.c Sun May 31 12:23:01 2020 +0200 +++ b/bmsd/fermenters.c Wed Jun 03 21:02:57 2020 +0200 @@ -185,7 +185,7 @@ char *mode = NULL, *stage = NULL, *profile = NULL, *profile_uuid = NULL, *profile_name = NULL, *profile_steps = NULL; char *topic = NULL, *pay = NULL, buf[75], *profile_command = NULL; float setpoint_low = 0, setpoint_high = 0, yeast_lo = 0, yeast_hi = 0, inittemp_lo = 0, inittemp_hi = 0; - int heater_state = -1, cooler_state = -1, fan_state = -1, profile_fridgemode = -1; + int heater_state = -1, cooler_state = -1, fan_state = -1, light_state = -1, profile_fridgemode = -1; syslog(LOG_NOTICE, "fermenter_ws_receive(%s)", payload); @@ -221,6 +221,8 @@ cooler_state = json_object_get_int(val); if (json_object_object_get_ex(jobj, "fan_state", &val)) fan_state = json_object_get_int(val); + if (json_object_object_get_ex(jobj, "light_state", &val)) + light_state = json_object_get_int(val); if (json_object_object_get_ex(jobj, "profile", &pobj)) { profile = xstrcpy((char *)json_object_get_string(pobj)); if (profile == NULL) { // clear profile request @@ -332,6 +334,18 @@ pay = NULL; } + if (light_state >= 0) { + syslog(LOG_NOTICE, "Set fermenter %s/%s light %d", node, alias, light_state); + pay = fermenter_paybase(); + pay = xstrcat(pay, (char *)"{\"light\":{\"state\":"); + snprintf(buf, 64, "%d", light_state); + pay = xstrcat(pay, buf); + pay = xstrcat(pay, (char *)"}}}"); + mqtt_publish(topic, pay); + free(pay); + pay = NULL; + } + if (beeruuid && beercode && beername && (yeast_hi > yeast_lo) && (yeast_lo > 0)) { syslog(LOG_NOTICE, "Set fermenter %s/%s beer %s %s", node, alias, beercode, beername); pay = fermenter_paybase(); diff -r 367ae7ff52f0 -r c7b4cb53b37c www/js/mon_fermenter.js --- a/www/js/mon_fermenter.js Sun May 31 12:23:01 2020 +0200 +++ b/www/js/mon_fermenter.js Wed Jun 03 21:02:57 2020 +0200 @@ -602,7 +602,8 @@ }); $('#Camera').jqxButton({ template: 'primary', width: '150px', theme: theme }); $('#Camera').click(function() { - record.light_state = 100; +// record.light_state = 100; + websocket.send('{"device":"fermenters","node":"' + record.node + '","unit":"' + record.alias + '","light_state":100}'); window.open(record.webcam_url); }); createAbortElements();