1
0
mirror of https://github.com/beestat/app.git synced 2025-05-24 02:14:03 -04:00
beestat/api/sensor.php
Jon Ziebell eaee95736d Fixed #157 - Re-evaluate converged columns
Removed "json_" prefixes from all columns and converted columns to actual JSON types. Also removed all converged columns and converted contents to regular columns.
2019-10-28 21:18:43 -04:00

50 lines
955 B
PHP

<?php
/**
* Sensor for any thermostat type.
*
* @author Jon Ziebell
*/
class sensor extends cora\crud {
public static $exposed = [
'private' => [
'read_id',
'sync'
],
'public' => []
];
public static $cache = [
'sync' => 300 // 5 Minutes
];
/**
* Sync all sensors connected to this account. Once Nest support is
* added this will need to check for all connected accounts and run the
* appropriate ones.
*/
public function sync() {
// Skip this for the demo
if($this->setting->is_demo() === true) {
return;
}
$lock_name = 'sensor->sync(' . $this->session->get_user_id() . ')';
$this->database->get_lock($lock_name);
$this->api('ecobee_sensor', 'sync');
$this->api(
'user',
'update_sync_status',
[
'key' => 'sensor'
]
);
$this->database->release_lock($lock_name);
}
}