pihome-shc / pihome

PiHome - Smart Heating, Ventilation and Air Conditioning (HVAC)
http://www.pihome.eu
Other
52 stars 25 forks source link

Add/edit schedule max temp #408

Closed sandreialexandru closed 3 years ago

sandreialexandru commented 3 years ago

Upper limit of the slider for setting schedule temperature should be the maximum temperature of the zone (DB zone_sensors > max_c)

sandreialexandru commented 3 years ago

In scheduling.php, after line 327 insert this

$query = "SELECT * FROM zone_sensors WHERE id = {$row['zone_id']} LIMIT 1";
$result = $conn->query($query);
$zs_temp = mysqli_fetch_array($result);
$zs_max = $zs_temp['max_c'];

then change $max = xx to $max = $zs_max

This solution rezolves the problem only when editing schedule or night schedule, but when trying to add a schedule, the slider goes up to 100

twa127 commented 3 years ago

Hi,

To be honest I don't think max_c was intended to be used to determine the upper limit of the slider, these vales are hardcoded at line 330 onwards. I think the idea for max_c was that it is is used in boiler.php as part of the boiler control

sandreialexandru commented 3 years ago

Hello, I think it is a bit weird that we can set the slider up to 30, but the maximum allowed temperature of the zone is 25 (numbers are hypothetical). My solution to this, was to get max_c from database into a variable called zs_max and replace the values of $max at lines 332, 335, 338, 341 with $zs_max

twa127 commented 3 years ago

@pihome-shc how do you want to handle this issue ?

sandreialexandru commented 3 years ago

What is your opinion on this matter @pihome-shc ?

pihome-shc commented 3 years ago

@sandreialexandru right now we have max value of slider hard coded taking this value from zone max value ould work as well, dont mind if you want to set this, also change text on zone creation to notify user about this.

sandreialexandru commented 3 years ago

I am aware of the fixed value for the $max , but changing the value to zone's max temperature would improve the logic. Is it just me that thinks it is strange seeing the slider go higher than the maximum allowed temperature for the zone?

pihome-shc commented 3 years ago

i agree, it will make more sense if we set the slider's limit to zone max temperature, having hard coded slider max value just overlooked.

sandreialexandru commented 3 years ago

Maybe @twa127 could help. I'm not an expert at php/sql . My only solution to this is : _In scheduling.php, after line 327 insert this

$query = "SELECT * FROM zone_sensors WHERE id = {$row['zone_id']} LIMIT 1"; $result = $conn->query($query); $zs_temp = mysqli_fetch_array($result); $zs_max = $zs_temp['max_c'];

then change $max = xx to $max = $zs_max

This solution rezolves the problem only when editing schedule or night schedule, but when trying to add a schedule, the slider goes up to 100_

twa127 commented 3 years ago

Okay leave it with me and I'll see what I can come up with

twa127 commented 3 years ago

I've committed an update, the max temperature is now set to the zone value for max_c, the minimum slider value is still hardcoded in scheduling.php. Note: Requires the Views to be updated.

sandreialexandru commented 3 years ago

@twa127 please have a look, if you can, at EDITING an existing holiday schedule. The slider goes to 100. When ADDING holiday schedule the slider works ok. Also, for me, deleting holidays doesn't work. Night climate is the same.(slider to 100)

twa127 commented 3 years ago

The holidays scheduling uses the same schedule_daily_time_zone_view so should work the same. Please post a dump of your database and I'll have a look

sandreialexandru commented 3 years ago

pihome_db.zip this is my database, no alterations

twa127 commented 3 years ago

Hi,

Looks like you have not updated views schedule_daily_time_zone_view and schedule_night_climat_zone_view

twa127 commented 3 years ago

Attached the sql for the 2 changed views

views.zip

sandreialexandru commented 3 years ago

Great! Thank you! The sliders work.

twa127 commented 3 years ago

No problem, glad its working okay