@@ -0,0 +1,1472 @@
+#!/usr/bin/env python%0Aimport sys%0Aimport os.path%0Aimport os%0Aimport subprocess%0Aimport sqlite3%0A%0A%0A%0A%0Adbname='/home/pi/database/centralheating.db'%0A%0A# connection to db. select values from db and hand over variables. %0Aconn=sqlite3.connect(dbname)%0Acurs=conn.cursor()%0Afor row in curs.execute(%22SELECT heating_constant, heating_onehour, heating_schedule FROM control WHERE rowid=1%22):%0A%09heating_constant = row%5B0%5D%0A%09heating_onehour = row%5B1%5D%0A%09heating_schedule = row%5B2%5D%0Aconn.close()%0A%0A# Get what action to take%0Aaction = sys.argv.pop()%0A%0Aif action == %22off%22 :%0A%09if heating_constant == 1:%0A%09%09heating_schedule = 0%0A%09%09if heating_onehour == 1:%0A%09%09%09os.system(%22gcalcli --calendar 'central heating' --title 'Heating extra hour set' --when '%22 + var + %22' --where '.' --duration '60' --description 'end: /usr/bin/python /home/pi/scripts/heating_schedule.py extrahouroff' --reminder '1' add%22)%0A%09else:%0A%09%09heating_schedule = 0%0A%09%09heating_on = 0%0A%09%09%0A      %0Aelif action == %22on%22 :%0A%09heating_schedule = 1%0A%09heating_on = 1%0A%09%0A%09if heating_onehour == 1:%0A%09%09heating_onehour = 0%0A%0Aelif action == %22extrahouroff%22 :%0A%09if heating_schedule == 1:%0A%09%09heating_onehour = 0%0A%09%0A%09else:%0A%09%09heating_onehour = 0%0A%09%09if heating_constant == 0:%0A%09%09%09heating_on = 0%0A%09%09%09%0Aconn=sqlite3.connect(dbname)%0Acurs=conn.cursor()%0Acurs.execute(%22UPDATE control SET heating_on = ?, heating_schedule = ?, heating_onehour = ? WHERE rowid = ?%22, (heating_on, heating_schedule, heating_onehour, 1))%0Aconn.commit()%0Aconn.close()%09%09%09%0Aos.system(%22python /home/pi/scripts/control.py%22)%0A

Create heating_schedule.py