thermferm/thermferm.c

changeset 582
ba340e00aab2
parent 578
d694abd9d809
child 583
9795a16de807
equal deleted inserted replaced
581:b56988cc516b 582:ba340e00aab2
413 syslog(LOG_NOTICE, "Mode from %s to %s via panel interface", UNITMODE[current_unit->mode], UNITMODE[mode]); 413 syslog(LOG_NOTICE, "Mode from %s to %s via panel interface", UNITMODE[current_unit->mode], UNITMODE[mode]);
414 current_unit->mode = mode; 414 current_unit->mode = mode;
415 /* Allways turn everything off after a mode change */ 415 /* Allways turn everything off after a mode change */
416 current_unit->PID_cool->OutP = current_unit->PID_heat->OutP = 0.0; 416 current_unit->PID_cool->OutP = current_unit->PID_heat->OutP = 0.0;
417 current_unit->PID_cool->Mode = current_unit->PID_heat->Mode = PID_MODE_NONE; 417 current_unit->PID_cool->Mode = current_unit->PID_heat->Mode = PID_MODE_NONE;
418 current_unit->heater_state = current_unit->cooler_state = current_unit->fan_state = current_unit->light_state = 0; 418 current_unit->heater_state = current_unit->cooler_state = current_unit->fan_state = current_unit->light_state = current_unit->light_timer = 0;
419 current_unit->heater_wait = current_unit->cooler_wait = current_unit->fan_wait = current_unit->light_wait = 0; 419 current_unit->heater_wait = current_unit->cooler_wait = current_unit->fan_wait = current_unit->light_wait = 0;
420 device_out(current_unit->heater_address, current_unit->heater_state); 420 device_out(current_unit->heater_address, current_unit->heater_state);
421 device_out(current_unit->cooler_address, current_unit->cooler_state); 421 device_out(current_unit->cooler_address, current_unit->cooler_state);
422 device_out(current_unit->fan_address, current_unit->fan_state); 422 device_out(current_unit->fan_address, current_unit->fan_state);
423 device_out(current_unit->light_address, current_unit->light_state); 423 device_out(current_unit->light_address, current_unit->light_state);
1103 for (unit = Config.units; unit; unit = unit->next) { 1103 for (unit = Config.units; unit; unit = unit->next) {
1104 /* 1104 /*
1105 * Safety, turn everything off 1105 * Safety, turn everything off
1106 */ 1106 */
1107 unit->mqtt_flag = unit->alarm_flag = unit->alarm_last = 0; 1107 unit->mqtt_flag = unit->alarm_flag = unit->alarm_last = 0;
1108 unit->heater_state = unit->cooler_state = unit->fan_state = unit->door_state = unit->light_state = 0; 1108 unit->heater_state = unit->cooler_state = unit->fan_state = unit->door_state = unit->light_state = unit->light_timer = 0;
1109 unit->heater_wait = unit->cooler_wait = unit->fan_wait = unit->light_wait = 0; 1109 unit->heater_wait = unit->cooler_wait = unit->fan_wait = unit->light_wait = 0;
1110 if (unit->mode == UNITMODE_PROFILE) { 1110 if (unit->mode == UNITMODE_PROFILE) {
1111 if (!unit->profile_uuid) 1111 if (!unit->profile_uuid)
1112 syslog(LOG_NOTICE, "Starting unit `%s' in profile mode, no profile defined.", unit->alias); 1112 syslog(LOG_NOTICE, "Starting unit `%s' in profile mode, no profile defined.", unit->alias);
1113 else { 1113 else {
1635 1635
1636 /* 1636 /*
1637 * Interior lights 1637 * Interior lights
1638 */ 1638 */
1639 if (unit->light_address) { 1639 if (unit->light_address) {
1640 if (unit->door_state && (unit->mode == UNITMODE_NONE) && unit->light_state) { 1640 if (unit->light_timer) {
1641 unit->light_timer--;
1642 }
1643 if (unit->door_state && !unit->light_timer && unit->light_state) {
1641 if (unit->light_wait > 0) { 1644 if (unit->light_wait > 0) {
1642 unit->light_wait--; 1645 unit->light_wait--;
1643 } else { 1646 } else {
1644 unit->light_state = 0; 1647 unit->light_state = 0;
1645 syslog(LOG_NOTICE, "Unit `%s' lights On => Off", unit->alias); 1648 syslog(LOG_NOTICE, "Unit `%s' lights On => Off", unit->alias);
1646 unit->mqtt_flag |= MQTT_FLAG_DATA; 1649 unit->mqtt_flag |= MQTT_FLAG_DATA;
1647 } 1650 }
1648 } 1651 }
1649 if ((!unit->door_state || (unit->mode != UNITMODE_NONE)) && !unit->light_state) { 1652 if ((!unit->door_state || unit->light_timer) && !unit->light_state) {
1650 unit->light_wait = unit->light_delay; /* No delay to turn lights on */ 1653 unit->light_wait = unit->light_delay; /* No delay to turn lights on */
1651 unit->light_state = 1; 1654 unit->light_state = 1;
1652 unit->mqtt_flag |= MQTT_FLAG_DATA; 1655 unit->mqtt_flag |= MQTT_FLAG_DATA;
1653 syslog(LOG_NOTICE, "Unit `%s' lights Off => On", unit->alias); 1656 syslog(LOG_NOTICE, "Unit `%s' lights Off => On", unit->alias);
1654 } 1657 }
2058 */ 2061 */
2059 for (unit = Config.units; unit; unit = unit->next) { 2062 for (unit = Config.units; unit; unit = unit->next) {
2060 /* 2063 /*
2061 * Turn everything off 2064 * Turn everything off
2062 */ 2065 */
2063 unit->heater_state = unit->cooler_state = unit->fan_state = unit->door_state = unit->light_state = 0; 2066 unit->heater_state = unit->cooler_state = unit->fan_state = unit->door_state = unit->light_state = unit->light_timer = 0;
2064 unit->heater_wait = unit->cooler_wait = unit->fan_wait = unit->light_wait = 0; 2067 unit->heater_wait = unit->cooler_wait = unit->fan_wait = unit->light_wait = 0;
2065 device_out(unit->heater_address, unit->heater_state); 2068 device_out(unit->heater_address, unit->heater_state);
2066 pub_domoticz_output(unit->heater_idx, unit->heater_state); 2069 pub_domoticz_output(unit->heater_idx, unit->heater_state);
2067 device_out(unit->cooler_address, unit->cooler_state); 2070 device_out(unit->cooler_address, unit->cooler_state);
2068 pub_domoticz_output(unit->cooler_idx, unit->cooler_state); 2071 pub_domoticz_output(unit->cooler_idx, unit->cooler_state);

mercurial