diff -r f5a00ad53329 -r 7ab5cf2afc0c thermferm/thermferm.c --- a/thermferm/thermferm.c Sat Jun 10 13:00:14 2017 +0200 +++ b/thermferm/thermferm.c Sat Jun 10 23:43:56 2017 +0200 @@ -1233,8 +1233,10 @@ deviation = 40000; if ((unit->air_temperature == 0) || (unit->air_temperature && (temp > (int)unit->air_temperature - deviation) && (temp < ((int)unit->air_temperature + deviation)))) { - if (unit->air_temperature != temp) + if (unit->air_temperature != temp) { unit->mqtt_flag |= MQTT_FLAG_DATA; + pub_domoticz_temp(unit->air_idx, temp); + } unit->air_temperature = temp; unit->air_state = 0; } else { @@ -1253,8 +1255,10 @@ deviation = 40000; if ((unit->beer_temperature == 0) || (unit->beer_temperature && (temp > (int)unit->beer_temperature - deviation) && (temp < ((int)unit->beer_temperature + deviation)))) { - if (unit->beer_temperature != temp) + if (unit->beer_temperature != temp) { unit->mqtt_flag |= MQTT_FLAG_DATA; + pub_domoticz_temp(unit->beer_idx, temp); + } unit->beer_temperature = temp; unit->beer_state = 0; } else { @@ -1277,12 +1281,14 @@ if (unit->door_state == 0) { syslog(LOG_NOTICE, "Unit `%s' door closed", unit->name); unit->door_state = 1; + pub_domoticz_output(unit->door_idx, unit->door_state); unit->mqtt_flag |= MQTT_FLAG_DATA; } } else { if (unit->door_state) { syslog(LOG_NOTICE, "Unit `%s' door opened", unit->name); unit->door_state = 0; + pub_domoticz_output(unit->door_idx, unit->door_state); unit->mqtt_flag |= MQTT_FLAG_DATA; } } @@ -1303,12 +1309,14 @@ if (unit->psu_state == 0) { syslog(LOG_NOTICE, "Unit `%s' PSU (12 volt) is on", unit->name); unit->psu_state = 1; + pub_domoticz_output(unit->psu_idx, unit->psu_state); unit->mqtt_flag |= MQTT_FLAG_DATA; } } else { if (unit->psu_state) { syslog(LOG_NOTICE, "Unit `%s' PSU (12 volt) is off", unit->name); unit->psu_state = 0; + pub_domoticz_output(unit->psu_idx, unit->psu_state); unit->mqtt_flag |= MQTT_FLAG_DATA; } } @@ -1651,6 +1659,7 @@ if (unit->heater_state != power) { syslog(LOG_NOTICE, "Unit `%s' heater %d%% => %d%%", unit->name, unit->heater_state, power); unit->heater_state = power; + pub_domoticz_output(unit->heater_idx, unit->heater_state); if (unit->heater_address) unit->mqtt_flag |= MQTT_FLAG_DATA; } @@ -1662,15 +1671,19 @@ if (unit->heater_state) { syslog(LOG_NOTICE, "Unit `%s' heater On => Off", unit->name); unit->heater_state = 0; + pub_domoticz_output(unit->heater_idx, unit->heater_state); if (unit->heater_address) unit->mqtt_flag |= MQTT_FLAG_DATA; } } } - if (unit->door_state) + if (unit->door_state) { device_out(unit->heater_address, unit->heater_state); - else + pub_domoticz_output(unit->heater_idx, unit->heater_state); + } else { device_out(unit->heater_address, 0); + pub_domoticz_output(unit->heater_idx, 0); + } } if (unit->cooler_address && ! unit->heater_state) { @@ -1682,6 +1695,7 @@ if (unit->cooler_state != power) { syslog(LOG_NOTICE, "Unit `%s' cooler %d%% => %d%%", unit->name, unit->cooler_state, power); unit->cooler_state = power; + pub_domoticz_output(unit->cooler_idx, unit->cooler_state); if (unit->cooler_address) unit->mqtt_flag |= MQTT_FLAG_DATA; } @@ -1693,15 +1707,19 @@ if (unit->cooler_state) { syslog(LOG_NOTICE, "Unit `%s' cooler On => Off", unit->name); unit->cooler_state = 0; + pub_domoticz_output(unit->cooler_idx, unit->cooler_state); if (unit->cooler_address) unit->mqtt_flag |= MQTT_FLAG_DATA; } } } - if (unit->door_state) + if (unit->door_state) { device_out(unit->cooler_address, unit->cooler_state); - else + pub_domoticz_output(unit->cooler_idx, unit->cooler_state); + } else { device_out(unit->cooler_address, 0); + pub_domoticz_output(unit->cooler_idx, 0); + } } if (debug) fprintf(stdout, "Final: PIDheat=%.2f PWRheat=%d PIDcool=%.2f PWRcool=%d\n", @@ -1719,6 +1737,7 @@ if (! unit->fan_state) { syslog(LOG_NOTICE, "Unit `%s' Fan Off => On", unit->name); unit->fan_state = 100; + pub_domoticz_output(unit->fan_idx, unit->fan_state); if (unit->fan_address) unit->mqtt_flag |= MQTT_FLAG_DATA; } @@ -1730,6 +1749,7 @@ if (unit->fan_state) { syslog(LOG_NOTICE, "Unit `%s' Fan On => Off", unit->name); unit->fan_state = 0; + pub_domoticz_output(unit->fan_idx, unit->fan_state); if (unit->fan_address) unit->mqtt_flag |= MQTT_FLAG_DATA; } @@ -1912,8 +1932,11 @@ unit->heater_state = unit->cooler_state = unit->fan_state = unit->door_state = unit->light_state = 0; unit->heater_wait = unit->cooler_wait = unit->fan_wait = unit->light_wait = 0; device_out(unit->heater_address, unit->heater_state); + pub_domoticz_output(unit->heater_idx, unit->heater_state); device_out(unit->cooler_address, unit->cooler_state); + pub_domoticz_output(unit->cooler_idx, unit->cooler_state); device_out(unit->fan_address, unit->fan_state); + pub_domoticz_output(unit->fan_idx, unit->fan_state); device_out(unit->light_address, unit->light_state); unit->mqtt_flag = MQTT_FLAG_DATA; publishDData(unit);