Skip to content

Commit

Permalink
update language translations, add offsets for temperature control hys…
Browse files Browse the repository at this point in the history
…teresis, fix bug in setup_pi-ager.sh so that WLAN can connect after first boot.
  • Loading branch information
phylax2020 committed Feb 19, 2024
1 parent b8f3441 commit c46080b
Show file tree
Hide file tree
Showing 17 changed files with 693 additions and 574 deletions.
46 changes: 27 additions & 19 deletions opt/pi-ager/pi_ager_loop.py
Original file line number Diff line number Diff line change
Expand Up @@ -1050,29 +1050,31 @@ def generate_status_change_event(logstring):
pass

def simple_cooler_temperature_control():
# simple 2-point temperature control for cooler
# simple 2-point temperature control for cooler, always use primary temperature control hysteresis
global sensor_temperature
global setpoint_temperature
global switch_on_cooling_compressor
global switch_off_cooling_compressor
global cooling_hysteresis_offset # should be positiv

# check if cooler must be set on or off
if sensor_temperature >= setpoint_temperature + switch_on_cooling_compressor:
if sensor_temperature >= setpoint_temperature + switch_on_cooling_compressor + cooling_hysteresis_offset:
delay_cooling_compressor( pi_ager_names.relay_on) # Kuehlung ein
if sensor_temperature <= setpoint_temperature + switch_off_cooling_compressor:
if sensor_temperature <= setpoint_temperature + switch_off_cooling_compressor + cooling_hysteresis_offset:
delay_cooling_compressor( pi_ager_names.relay_off) # Kuehlung aus

def simple_heater_temperature_control():
# simple 2-point temperature control for heater
def simple_heater_temperature_control():
# simple 2-point temperature control for heater, always use primary hysteresis for heater, but use heating hysteresis offset
global sensor_temperature
global setpoint_temperature
global switch_on_cooling_compressor
global switch_off_cooling_compressor
global heating_hysteresis_offset # should be negativ

# check if heater must be set on or off
if sensor_temperature <= setpoint_temperature - switch_on_cooling_compressor:
if sensor_temperature <= setpoint_temperature - switch_on_cooling_compressor + heating_hysteresis_offset:
control_heater(pi_ager_names.relay_on)
if sensor_temperature >= setpoint_temperature - switch_off_cooling_compressor:
if sensor_temperature >= setpoint_temperature - switch_off_cooling_compressor + heating_hysteresis_offset:
control_heater(pi_ager_names.relay_off)

def auto_temperature_control():
Expand All @@ -1081,36 +1083,38 @@ def auto_temperature_control():
global sensor_temperature
global setpoint_temperature
global second_sensor_temperature

cooling_hysteresis = pi_ager_database.get_table_value(pi_ager_names.config_settings_table, pi_ager_names.cooling_hysteresis_key)
heating_hysteresis = pi_ager_database.get_table_value(pi_ager_names.config_settings_table, pi_ager_names.heating_hysteresis_key)
global cooling_hysteresis_offset
global heating_hysteresis_offset

cooling_hysteresis = pi_ager_database.get_table_value(pi_ager_names.config_settings_table, pi_ager_names.cooling_hysteresis_key) # primary hysteresis
heating_hysteresis = pi_ager_database.get_table_value(pi_ager_names.config_settings_table, pi_ager_names.heating_hysteresis_key) # secondary hysteresis

# check if an external sensor exists and if so check if external temperature is greater than setpoint temperature:
# then activate cooling algorithm
if (second_sensor_temperature == None or second_sensor_temperature > setpoint_temperature):
# then activate cooling algorithm. If no external sensor is available, assume cooling cabinet as default
if (second_sensor_temperature == None or second_sensor_temperature > setpoint_temperature): # take primary hysteresis value for cooler
switch_on_cooling_compressor = cooling_hysteresis/2
switch_off_cooling_compressor = -cooling_hysteresis/2
switch_on_heater = heating_hysteresis/2
switch_off_heater = -heating_hysteresis/2
else: # activate heating alhorithm by exchanging primary and secondary hysteresis values
else: # activate heating alhorithm by exchanging primary and secondary hysteresis values so that heater operates with primary hysteresis
switch_on_cooling_compressor = heating_hysteresis/2
switch_off_cooling_compressor = -heating_hysteresis/2
switch_on_heater = cooling_hysteresis/2
switch_off_heater = -cooling_hysteresis/2

# check if cooler or heater must be set on or off
if (sensor_temperature <= setpoint_temperature + switch_off_cooling_compressor) or (sensor_temperature <= setpoint_temperature + switch_off_heater):
if (sensor_temperature <= setpoint_temperature + switch_off_cooling_compressor + cooling_hysteresis_offset) or (sensor_temperature <= setpoint_temperature + heating_hysteresis_offset + switch_off_heater):
delay_cooling_compressor( pi_ager_names.relay_off) # Kuehlung aus
if (sensor_temperature >= setpoint_temperature - switch_off_heater) or (sensor_temperature >= setpoint_temperature - switch_off_cooling_compressor ):
if (sensor_temperature >= setpoint_temperature - switch_off_heater + heating_hysteresis_offset) or (sensor_temperature >= setpoint_temperature - switch_off_cooling_compressor + cooling_hysteresis_offset):
control_heater(pi_ager_names.relay_off) # Heizung aus

if (sensor_temperature >= setpoint_temperature + switch_on_cooling_compressor): # or (sensor_temperature >= setpoint_temperature + switch_on_heater):
if (sensor_temperature >= setpoint_temperature + switch_on_cooling_compressor + cooling_hysteresis_offset): # or (sensor_temperature >= setpoint_temperature + switch_on_heater):
delay_cooling_compressor( pi_ager_names.relay_on) # Kuehlung ein
if gpio.input(pi_ager_gpio_config.gpio_heater) == False: # only if heater is on, turn off heater
control_heater(pi_ager_names.relay_off)

if (sensor_temperature <= setpoint_temperature - switch_on_heater): # or (sensor_temperature <= setpoint_temperature - switch_on_cooling_compressor ):
control_heater(pi_ager_names.relay_on) # turn on heater
if (sensor_temperature <= setpoint_temperature - switch_on_heater + heating_hysteresis_offset): # or (sensor_temperature <= setpoint_temperature - switch_on_cooling_compressor ):
control_heater(pi_ager_names.relay_on) # Heizung ein
if gpio.input(pi_ager_gpio_config.gpio_cooling_compressor) == False: # only if cooler is on, turn off cooler
delay_cooling_compressor( pi_ager_names.relay_off) # Kuehlung aus

Expand Down Expand Up @@ -1213,7 +1217,9 @@ def doMainLoop():
global saturation_point # sensor saturation point
global switch_on_cooling_compressor
global switch_off_cooling_compressor

global cooling_hysteresis_offset
global heating_hysteresis_offset

global settings
global status_circulating_air # Umluft
global status_exhaust_air # (Abluft-)Luftaustausch
Expand Down Expand Up @@ -1470,6 +1476,8 @@ def doMainLoop():

cooling_hysteresis = pi_ager_database.get_table_value(pi_ager_names.config_settings_table, pi_ager_names.cooling_hysteresis_key)
heating_hysteresis = pi_ager_database.get_table_value(pi_ager_names.config_settings_table, pi_ager_names.heating_hysteresis_key)
cooling_hysteresis_offset = pi_ager_database.get_table_value(pi_ager_names.config_settings_table, pi_ager_names.cooling_hysteresis_offset_key)
heating_hysteresis_offset = pi_ager_database.get_table_value(pi_ager_names.config_settings_table, pi_ager_names.heating_hysteresis_offset_key)
switch_on_cooling_compressor = cooling_hysteresis/2
switch_off_cooling_compressor = -cooling_hysteresis/2
switch_on_heater = heating_hysteresis/2
Expand Down
3 changes: 3 additions & 0 deletions opt/pi-ager/pi_ager_names.py
Original file line number Diff line number Diff line change
Expand Up @@ -175,6 +175,9 @@
tolerance_monitoring_humidifier_key = 'tolerance_monitoring_humidifier'
check_monitoring_humidifier_key = 'check_monitoring_humidifier'

cooling_hysteresis_offset_key = 'cooling_hysteresis_offset'
heating_hysteresis_offset_key = 'heating_hysteresis_offset'

# table fields
key_field = 'key'
value_field = 'value'
Expand Down
3 changes: 3 additions & 0 deletions usr/local/bin/setup_pi-ager.sh
Original file line number Diff line number Diff line change
Expand Up @@ -144,6 +144,9 @@ EOF
else
echo "Fehler $? : WLAN SSID und Passphrase konnten nicht gesetzt werden"
fi
# restart network manager to activate
echo "restart NetworkManager"
systemctl restart NetworkManager
fi
fi

Expand Down
14 changes: 12 additions & 2 deletions var/www/config.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
<!----------------------------------------------------------------------------------------Temperatur-->
<table style="width: 100%;table-layout: fixed;">
<tr>
<td rowspan="3" class="td_png_icon"><h3><?php echo _('temperature control'); ?></h3><img src="images/icons/heating_cooling_42x42.png" alt=""><br><button class="art-button" type="button" onclick="help_temperature_config_blockFunction()"><?php echo _('help'); ?></button></td>
<td rowspan="5" class="td_png_icon"><h3><?php echo _('temperature control'); ?></h3><img src="images/icons/heating_cooling_42x42.png" alt=""><br><button class="art-button" type="button" onclick="help_temperature_config_blockFunction()"><?php echo _('help'); ?></button></td>
<td class="text_left_padding"><?php echo _('primary control hysteresis'); ?>:</td>
<td><input name="cooling_hysteresis_config" type="number" style="width: 30%;" min="0.5" max="7" step="0.1" required value=<?php echo $cooling_hysteresis; ?>>&nbsp;°C
</td>
Expand All @@ -23,6 +23,16 @@
<td><input name="heating_hysteresis_config" type="number" style="width: 30%;" min="0.5" max="7" step="0.1" required value=<?php echo $heating_hysteresis; ?>>&nbsp;°C
</td>
</tr>
<tr>
<td class="text_left_padding"><?php echo _('cooling hysteresis offset'); ?>:</td>
<td><input name="cooling_hysteresis_offset_config" type="number" style="width: 30%;" min="-5" max="5" step="0.1" required value=<?php echo $cooling_hysteresis_offset; ?>>&nbsp;°C
</td>
</tr>
<tr>
<td class="text_left_padding"><?php echo _('heating hysteresis offset'); ?>:</td>
<td><input name="heating_hysteresis_offset_config" type="number" style="width: 30%;" min="-5" max="5" step="0.1" required value=<?php echo $heating_hysteresis_offset; ?>>&nbsp;°C
</td>
</tr>
<tr>
<td class="text_left_padding"><?php echo _('cooler delay'); ?>:</td>
<td><input name="delay_cooler_config" type="number" style="width: 30%;" min="0" max="120" step="1" required value=<?php echo $delay_cooler; ?>>&nbsp;<?php echo _('seconds'); ?><span style="font-size: xx-small"> (0 <?php echo _('to'); ?> 120)</span></td>
Expand Down Expand Up @@ -51,7 +61,7 @@ function help_temperature_config_noneFunction() {
</tr>
<tr>
<td class="text_left_padding"><?php echo _('dehumidifier hysteresis').':'; ?></td>
<td><input name="dehumidifier hysteresis_config" type="number" style="width: 30%;" min="2" max="30" required value=<?php echo $dehumidifier_hysteresis; ?>>&nbsp;%<span style="font-size: xx-small"> (2 <?php echo _('to'); ?> 30)</span></td>
<td><input name="dehumidifier_hysteresis_config" type="number" style="width: 30%;" min="2" max="30" required value=<?php echo $dehumidifier_hysteresis; ?>>&nbsp;%<span style="font-size: xx-small"> (2 <?php echo _('to'); ?> 30)</span></td>
</tr>
<tr>
<td class="text_left_padding"><?php echo _('humidifier hysteresis offset').':'; ?></td>
Expand Down
Binary file modified var/www/images/icons/temperature-control.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
24 changes: 14 additions & 10 deletions var/www/index.php
Original file line number Diff line number Diff line change
Expand Up @@ -1176,16 +1176,20 @@ function convert_timestamps_index( timestamps_seconds ) {
$internal_temperature = get_table_value($current_values_table, $sensor_temperature_key);
$external_temperature = get_table_value($current_values_table, $sensor_extern_temperature_key);
if ($external_temperature !== null && $internal_temperature !== null && $external_temperature < $setpoint_temperature && ($modus == 3 || $modus == 4)) {
$cooler_on = number_format(floatval($setpoint_temperature + $heating_hysteresis/2), 2, '.', '');
$cooler_off = number_format(floatval($setpoint_temperature - $heating_hysteresis/2), 2, '.', '');
$heater_on = number_format(floatval($setpoint_temperature - $cooling_hysteresis/2), 2, '.', '');
$heater_off = number_format(floatval($setpoint_temperature + $cooling_hysteresis/2), 2, '.', '');
$cooler_on = number_format(floatval($setpoint_temperature + $heating_hysteresis/2 + $heating_hysteresis_offset), 2, '.', '');
$cooler_off = number_format(floatval($setpoint_temperature - $heating_hysteresis/2 + $heating_hysteresis_offset), 2, '.', '');
$heater_on = number_format(floatval($setpoint_temperature - $cooling_hysteresis/2 + $cooling_hysteresis_offset), 2, '.', '');
$heater_off = number_format(floatval($setpoint_temperature + $cooling_hysteresis/2 + $cooling_hysteresis_offset), 2, '.', '');
}
else if ($modus == 2) { // heater only
$heater_on = number_format(floatval($setpoint_temperature - $cooling_hysteresis/2 + $heating_hysteresis_offset), 2, '.', '');
$heater_off = number_format(floatval($setpoint_temperature + $cooling_hysteresis/2 + $heating_hysteresis_offset), 2, '.', '');
}
else {
$cooler_on = number_format(floatval($setpoint_temperature + $cooling_hysteresis/2), 2, '.', '');
$cooler_off = number_format(floatval($setpoint_temperature - $cooling_hysteresis/2), 2, '.', '');
$heater_on = number_format(floatval($setpoint_temperature - $heating_hysteresis/2), 2, '.', '');
$heater_off = number_format(floatval($setpoint_temperature + $heating_hysteresis/2), 2, '.', '');
$cooler_on = number_format(floatval($setpoint_temperature + $cooling_hysteresis/2 + $cooling_hysteresis_offset), 2, '.', '');
$cooler_off = number_format(floatval($setpoint_temperature - $cooling_hysteresis/2 + $cooling_hysteresis_offset), 2, '.', '');
$heater_on = number_format(floatval($setpoint_temperature - $heating_hysteresis/2 + $heating_hysteresis_offset), 2, '.', '');
$heater_off = number_format(floatval($setpoint_temperature + $heating_hysteresis/2 + $heating_hysteresis_offset), 2, '.', '');
}
if ($modus == 0 || $modus == 1){
echo '<td><img id="mod_type_line1_id" src="images/icons/cooling_42x42.png" alt=""></td>
Expand All @@ -1207,8 +1211,8 @@ function convert_timestamps_index( timestamps_seconds ) {
echo '</td>
<td id="mod_current_line1_id">'.$sensor_temperature.' °C</td>
<td id="mod_setpoint_line1_id">'.$setpoint_temperature.' °C</td>
<td id="mod_on_line1_id">'.$cooler_on.' °C</td>
<td id="mod_off_line1_id">'.$cooler_off.' °C</td>';
<td id="mod_on_line1_id">'.$heater_on.' °C</td>
<td id="mod_off_line1_id">'.$heater_off.' °C</td>';
}
else {
echo '<td><img id="mod_type_line1_id" src="images/icons/cooling_42x42.png" alt=""></td>
Expand Down
Binary file modified var/www/locale/de_DE/LC_MESSAGES/pi-ager.mo
Binary file not shown.
Loading

0 comments on commit c46080b

Please sign in to comment.