diff --git a/api/thermostat.php b/api/thermostat.php index 08f0387..111c2b9 100644 --- a/api/thermostat.php +++ b/api/thermostat.php @@ -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. *