pihome-shc / pihome

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

Use Sunset for Cat2 Zone Schedule Start Time #381

Closed twa127 closed 4 years ago

twa127 commented 4 years ago

What do you think about having the option to use the sunset time available from weather as a schedule start time. Thought it might be useful to have lamps scheduled to come on at sunset.

pihome-shc commented 4 years ago

What if users don’t have weather api set?

twa127 commented 4 years ago

Just make it optional, so no weather api then dont select or maybe check for weather api

pihome-shc commented 4 years ago

no doubt it would be good option for sun set/sun rise.

twa127 commented 4 years ago

This what I have -

  1. Add new field to 'enable_sunset' to table 'schedule_daily_time'
  2. In boiler.php and scheduling.php use getWeather() function to return current weather
  3. if returns 0 then functionality remains as before
  4. if returns data the enable new checkbox in scheduling.php to enable sunset override of start time when start time value is set to some value later than sunset ie set the same as stop time. If start time is set to a value before sunset the start event occurs at this time rather than sunset.
  5. in boiler.php if getWeather() returns a valid time earlier than start time then this triggers the schedule start

sched1

twa127 commented 4 years ago

Attached something for you to test. You need to add a new field to the schedule_daily_time table, call it enable_sunset with a type of TINYINT 1

I've changed the validation from using getWeather() to reading the weather table and checking it has been updated in the last hour.

sunset.zip

twa127 commented 4 years ago

Fix for boiler.php query not checking time variable correctly boiler.zip

pihome-shc commented 4 years ago

Gui works as expected, but i have error while creating schedule

Zone Record Add/Update Failed:

Cannot add or update a child row: a foreign key constraint fails (`pihome`.`schedule_daily_time_zone`, CONSTRAINT `FK_schedule_daily_time_zone_schedule_daily_time` FOREIGN KEY (`schedule_daily_time_id`) REFERENCES `schedule_daily_time` (`id`))
pihome-shc commented 4 years ago

ignore my last comments, i was modifying wrong database (enable_sunset ) but after switching to right one it worked :) one suggestion though, can we add sun rise icon in front of the zone name on schedule list.

twa127 commented 4 years ago

How about sched2

pihome-shc commented 4 years ago

I think sunrise just before schedule name would be better same way we have coop icon.

twa127 commented 4 years ago

Can't say I'm keen in this sched3

pihome-shc commented 4 years ago

I wasn’t expecting it look like this, :( also do we have sunrise icon ?

twa127 commented 4 years ago

I think it looks better to keep the zone names in the same position, so icon would look better in the circle or after the name. The icon should really be sunset not sunrise, I'm sure we can find something suitable. This looks slightly better, but still prefer the first attempt

sched4

twa127 commented 4 years ago

Lost my internet for a few hours ;-( how about sched5

pihome-shc commented 4 years ago

@twa127 last one is awesome love it,

twa127 commented 4 years ago

ok happy for me to commit ?

pihome-shc commented 4 years ago

Yes, definitely, update the build number as well.

twa127 commented 4 years ago

I found a bug in boiler.php, I'll test the fix before I commit

twa127 commented 4 years ago

Hi,

After using this feature for a bit I've come up with a revised version -

  1. Allows individual selection of sunset override rather than applying globally to the zone
  2. Enable the use of an offset value, to say turn on x minutes before sunset

What do you think ?

sched6

pihome-shc commented 4 years ago

@twa127 good thinking for individual zone, i think change line from Enable Sunset and set Offset in Minutes change it to Sunset & set Offset in Minutes. it looks very impressive.

twa127 commented 4 years ago

Okay, the basic idea was to make it similar to Coop selection. I guess one shortcoming is that for zones with multiple cat2 devices (which is not yet implemented), the selection will be applied to all the cat2 controllers allocated to that zone.

twa127 commented 4 years ago

Please note the table format for schedule_daily_time and schedule_daily_time_zone has been changed for this update, also view schedule_daily_time_zone_view has been changed