Fixed some MQTT messages. Added more profile MQTT messages. Version 0.5.7

Wed, 11 May 2016 14:47:27 +0200

author
Michiel Broek <mbroek@mbse.eu>
date
Wed, 11 May 2016 14:47:27 +0200
changeset 502
0e2c58f8eb78
parent 501
52bb55ba0b01
child 503
003c20125212

Fixed some MQTT messages. Added more profile MQTT messages. Version 0.5.7

configure file | annotate | diff | comparison | revisions
configure.ac file | annotate | diff | comparison | revisions
thermferm/server.c file | annotate | diff | comparison | revisions
thermferm/thermferm.c file | annotate | diff | comparison | revisions
--- a/configure	Mon May 09 21:37:25 2016 +0200
+++ b/configure	Wed May 11 14:47:27 2016 +0200
@@ -2035,7 +2035,7 @@
 
 
 PACKAGE="mbsePi-apps"
-VERSION="0.5.6"
+VERSION="0.5.7"
 COPYRIGHT="Copyright (C) 2014-2016 Michiel Broek, All Rights Reserved"
 CYEARS="2014-2016"
 
--- a/configure.ac	Mon May 09 21:37:25 2016 +0200
+++ b/configure.ac	Wed May 11 14:47:27 2016 +0200
@@ -8,7 +8,7 @@
 dnl General settings
 dnl After changeing the version number, run autoconf!
 PACKAGE="mbsePi-apps"
-VERSION="0.5.6"
+VERSION="0.5.7"
 COPYRIGHT="Copyright (C) 2014-2016 Michiel Broek, All Rights Reserved"
 CYEARS="2014-2016"
 AC_SUBST(PACKAGE)
--- a/thermferm/server.c	Mon May 09 21:37:25 2016 +0200
+++ b/thermferm/server.c	Wed May 11 14:47:27 2016 +0200
@@ -2189,7 +2189,7 @@
 				if (unit->name) {
 				    if (strcmp(unit->name, val)) {
 					syslog(LOG_NOTICE, "Fermenter unit %s name `%s' to `%s'", unit->uuid, unit->name, val);
-					mqtt_publish_str(unit->uuid, (char *)"name", val);
+					mqtt_publish_str(unit->alias, (char *)"name", val);
 				    }
 				    free(unit->name);
 				}
@@ -2393,11 +2393,11 @@
 					    }
 					}
 					if (unit->heater_address)
-					    mqtt_publish_int(unit->uuid, (char *)"heater", 0);
+					    mqtt_publish_int(unit->alias, (char *)"heater", 0);
 					if (unit->cooler_address)
-					    mqtt_publish_int(unit->uuid, (char *)"cooler", 0);
+					    mqtt_publish_int(unit->alias, (char *)"cooler", 0);
 					if (unit->fan_address)
-					    mqtt_publish_int(unit->uuid, (char *)"fan", 0);
+					    mqtt_publish_int(unit->alias, (char *)"fan", 0);
 					break;
 				    }
 				}
@@ -2514,11 +2514,11 @@
 				    device_out(unit->fan_address, unit->fan_state);
 				    device_out(unit->light_address, unit->light_state);
 				    if (unit->heater_address)
-					mqtt_publish_int(unit->uuid, (char *)"heater", 0);
+					mqtt_publish_int(unit->alias, (char *)"heater", 0);
 				    if (unit->cooler_address)
-					mqtt_publish_int(unit->uuid, (char *)"cooler", 0);
+					mqtt_publish_int(unit->alias, (char *)"cooler", 0);
 				    if (unit->fan_address)
-					mqtt_publish_int(unit->uuid, (char *)"fan", 0);
+					mqtt_publish_int(unit->alias, (char *)"fan", 0);
 				    unit->mqtt_flag |= (MQTT_FLAG_PROFILE | MQTT_FLAG_SP);
 				}
 
@@ -2529,17 +2529,17 @@
 						case PROFILE_OFF:	if (unit->prof_state == PROFILE_DONE) {
 									    unit->prof_state = PROFILE_OFF;
 									    syslog(LOG_NOTICE, "Fermenter unit %s profile to OFF", unit->uuid);
-									    mqtt_publish_str(unit->uuid, (char *)"profile/state", (char *)PROFSTATE[i]);
+									    mqtt_publish_str(unit->alias, (char *)"profile/state", (char *)PROFSTATE[i]);
 									}
 									break;
 						case PROFILE_PAUSE:	if (unit->prof_state == PROFILE_RUN) {
 									    unit->prof_state = PROFILE_PAUSE;
 									    syslog(LOG_NOTICE, "Fermenter unit %s profile PAUSE", unit->uuid);
-									    mqtt_publish_str(unit->uuid, (char *)"profile/state", (char *)PROFSTATE[i]);
+									    mqtt_publish_str(unit->alias, (char *)"profile/state", (char *)PROFSTATE[i]);
 									} else if (unit->prof_state == PROFILE_PAUSE) {
 									    unit->prof_state = PROFILE_RUN;
 									    syslog(LOG_NOTICE, "Fermenter unit %s profile RESUME", unit->uuid);
-									    mqtt_publish_str(unit->uuid, (char *)"profile/state", (char *)PROFSTATE[PROFILE_RUN]);
+									    mqtt_publish_str(unit->alias, (char *)"profile/state", (char *)PROFSTATE[PROFILE_RUN]);
 									}
 									break;
 						case PROFILE_RUN:	if (unit->prof_state == PROFILE_OFF) {
@@ -2548,7 +2548,7 @@
 									    unit->prof_paused = unit->prof_primary_done = 0;
 									    unit->prof_peak_abs = unit->prof_peak_rel = 0.0;
 									    syslog(LOG_NOTICE, "Fermenter unit %s profile to RUN", unit->uuid);
-									    mqtt_publish_str(unit->uuid, (char *)"profile/state", (char *)PROFSTATE[i]);
+									    mqtt_publish_str(unit->alias, (char *)"profile/state", (char *)PROFSTATE[i]);
 									}
 									break;
 						case PROFILE_DONE:	break;	/* Command is illegal */
@@ -2556,7 +2556,7 @@
 									    unit->prof_state = PROFILE_OFF;
 									    unit->prof_started = 0;
 									    syslog(LOG_NOTICE, "Fermenter unit %s profile ABORT", unit->uuid);
-									    mqtt_publish_str(unit->uuid, (char *)"profile/state", (char *)PROFSTATE[i]);
+									    mqtt_publish_str(unit->alias, (char *)"profile/state", (char *)PROFSTATE[i]);
 									}
 									break;
 					}
--- a/thermferm/thermferm.c	Mon May 09 21:37:25 2016 +0200
+++ b/thermferm/thermferm.c	Wed May 11 14:47:27 2016 +0200
@@ -1808,6 +1808,12 @@
 		if (unit->mqtt_flag & MQTT_FLAG_PROFILE) {
 		    mqtt_publish_str(unit->alias, (char *)"profile/uuid", unit->profile);
 		    mqtt_publish_str(unit->alias, (char *)"profile/state", (char *)PROFSTATE[unit->prof_state]);
+		    for (profile = Config.profiles; profile; profile = profile->next) {
+			if (strcmp(unit->profile, profile->uuid) == 0) {
+			    mqtt_publish_str(unit->alias, (char *)"profile/name", profile->name);
+			    mqtt_publish_int(unit->alias, (char *)"profile/fridgemode", profile->fridge_mode);
+			}
+		    }
 		}
 		if (unit->mqtt_flag & MQTT_FLAG_PERCENT) {
 		    mqtt_publish_int(unit->alias, (char *)"profile/percent", unit->prof_percent);

mercurial