mirror of
https://github.com/beestat/app.git
synced 2025-05-24 02:14:03 -04:00
Added ability to manually manage thermostats
This commit is contained in:
parent
969b6ada12
commit
425c73c7eb
@ -144,9 +144,8 @@ class ecobee_thermostat extends cora\crud {
|
|||||||
);
|
);
|
||||||
|
|
||||||
// For each of the manually added ones, check and see if ecobee gives a
|
// For each of the manually added ones, check and see if ecobee gives a
|
||||||
// result. If so, store that identifier as good. If not, inactivate the
|
// result. If so, do nothing. If not, inactivate the manually added
|
||||||
// manually added ecobee_thermostat row.
|
// ecobee_thermostat row.
|
||||||
$manual_identifiers = [];
|
|
||||||
foreach($manual_ecobee_thermostats as $manual_ecobee_thermostat) {
|
foreach($manual_ecobee_thermostats as $manual_ecobee_thermostat) {
|
||||||
try {
|
try {
|
||||||
$response = $this->api(
|
$response = $this->api(
|
||||||
@ -168,10 +167,6 @@ class ecobee_thermostat extends cora\crud {
|
|||||||
]
|
]
|
||||||
]
|
]
|
||||||
);
|
);
|
||||||
|
|
||||||
foreach($response['thermostatList'] as $api_thermostat) {
|
|
||||||
$manual_identifiers[] = $api_thermostat['identifier'];
|
|
||||||
}
|
|
||||||
} catch(\Exception $e) {
|
} catch(\Exception $e) {
|
||||||
$this->api(
|
$this->api(
|
||||||
'ecobee_thermostat',
|
'ecobee_thermostat',
|
||||||
@ -186,6 +181,24 @@ class ecobee_thermostat extends cora\crud {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Now get everything from the database. This will get already registered
|
||||||
|
// thermostats if they have been synced before, newly manually added
|
||||||
|
// thermostats, and existing manually added thermostats.
|
||||||
|
$ecobee_thermostats = $this->api(
|
||||||
|
'ecobee_thermostat',
|
||||||
|
'read',
|
||||||
|
[
|
||||||
|
'attributes' => [
|
||||||
|
'inactive' => 0
|
||||||
|
]
|
||||||
|
]
|
||||||
|
);
|
||||||
|
|
||||||
|
$manual_identifiers = [];
|
||||||
|
foreach($ecobee_thermostats as $ecobee_thermostat) {
|
||||||
|
$manual_identifiers[] = $ecobee_thermostat['identifier'];
|
||||||
|
}
|
||||||
|
|
||||||
// Get a unique list of identifiers.
|
// Get a unique list of identifiers.
|
||||||
$identifiers = array_unique(array_merge($registered_identifiers, $manual_identifiers));
|
$identifiers = array_unique(array_merge($registered_identifiers, $manual_identifiers));
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user