thermferm/thermferm.c

changeset 503
003c20125212
parent 502
0e2c58f8eb78
child 504
862de87f9f89
equal deleted inserted replaced
502:0e2c58f8eb78 503:003c20125212
1280 } 1280 }
1281 1281
1282 /* 1282 /*
1283 * Unit door state, default is closed. 1283 * Unit door state, default is closed.
1284 */ 1284 */
1285 unit->door_state = 1;
1286 if (unit->door_address) { 1285 if (unit->door_address) {
1287 rc = device_in(unit->door_address, &temp); 1286 rc = device_in(unit->door_address, &temp);
1288 if (rc == DEVPRESENT_YES) { 1287 if (rc == DEVPRESENT_YES) {
1289 if (temp) { 1288 if (temp) {
1290 if (unit->door_state == 0) { 1289 if (unit->door_state == 0) {
1297 syslog(LOG_NOTICE, "Unit `%s' door opened", unit->name); 1296 syslog(LOG_NOTICE, "Unit `%s' door opened", unit->name);
1298 unit->door_state = 0; 1297 unit->door_state = 0;
1299 mqtt_publish_str(unit->alias, (char *)"door", (char *)"open"); 1298 mqtt_publish_str(unit->alias, (char *)"door", (char *)"open");
1300 } 1299 }
1301 } 1300 }
1301 } else {
1302 unit->door_state = 1;
1302 } 1303 }
1304 } else {
1305 unit->door_state = 1;
1303 } 1306 }
1304 1307
1305 /* 1308 /*
1306 * Unit PSU state, default power is ok 1309 * Unit PSU state
1307 */ 1310 */
1308 unit->psu_state = 1;
1309 if (unit->psu_address) { 1311 if (unit->psu_address) {
1310 rc = device_in(unit->psu_address, &temp); 1312 rc = device_in(unit->psu_address, &temp);
1311 if (rc == DEVPRESENT_YES) { 1313 if (rc == DEVPRESENT_YES) {
1312 if (temp) { 1314 if (temp) {
1313 if (unit->psu_state == 0) { 1315 if (unit->psu_state == 0) {
1320 syslog(LOG_NOTICE, "Unit `%s' PSU (12 volt) is off", unit->name); 1322 syslog(LOG_NOTICE, "Unit `%s' PSU (12 volt) is off", unit->name);
1321 unit->psu_state = 0; 1323 unit->psu_state = 0;
1322 mqtt_publish_str(unit->alias, (char *)"12volt", (char *)"off"); 1324 mqtt_publish_str(unit->alias, (char *)"12volt", (char *)"off");
1323 } 1325 }
1324 } 1326 }
1327 } else {
1328 unit->psu_state = 1;
1325 } 1329 }
1330 } else {
1331 /*
1332 * No state available, assume Ok.
1333 */
1334 unit->psu_state = 1;
1326 } 1335 }
1327 1336
1328 /* 1337 /*
1329 * Handle profile 1338 * Handle profile
1330 */ 1339 */

mercurial