bmsd/fermenters.c

changeset 698
c7b4cb53b37c
parent 686
ca1fbb3bd3db
child 705
d77b723f7b35
--- 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();

mercurial