1
0
mirror of https://github.com/beestat/app.git synced 2025-07-09 03:04:07 -04:00

Added API call for cron job to be able to generate thermostat profiles weekly

This commit is contained in:
Jon Ziebell 2021-01-29 20:55:26 -05:00
parent 9ef6773440
commit fc41e7c2fc

View File

@ -15,6 +15,7 @@ class thermostat extends cora\crud {
'restore_alert',
'set_reported_system_types',
'generate_profile',
'generate_profiles',
'get_metrics'
],
'public' => []
@ -217,6 +218,25 @@ class thermostat extends cora\crud {
);
}
/**
* Generate profiles for all thermostats. This pretty much only exists for
* the cron job.
*/
public function generate_profiles() {
$thermostats = $this->read();
foreach($thermostats as $thermostat) {
$this->generate_profile(
$thermostat['thermostat_id']
);
}
$this->api(
'user',
'update_sync_status',
['key' => 'thermostat.generate_profiles']
);
}
/**
* Generate a new profile for this thermostat.
*