set back function loadStates to private add public function loadStatesForSync
This commit is contained in:
@@ -300,7 +300,39 @@ class HassAPI{
|
||||
}
|
||||
}
|
||||
|
||||
public function loadStates() {
|
||||
public function loadStatesForSync() {
|
||||
$ret = false;
|
||||
if($this->states){
|
||||
$ret = true;
|
||||
}else{
|
||||
if($this->isAuthorized()){
|
||||
$loaded = false;
|
||||
$data_age = @(time() - filemtime('states.json'));
|
||||
if($data_age > 100){
|
||||
$this->states_get_cache();
|
||||
}
|
||||
$data = @file_get_contents('states.json');
|
||||
if(isset($data)){
|
||||
$this->states = json_decode($data, true);
|
||||
if($this->states){
|
||||
foreach ($this->states as &$value) {
|
||||
$h = str_split(hash('sha256', $value['entity_id']),12)[0];
|
||||
$val = intval($h, 16);
|
||||
$value['entity_uid_sha256'] = $val;
|
||||
}
|
||||
$loaded = true;
|
||||
$ret = true;
|
||||
}
|
||||
}
|
||||
if($loaded == false){
|
||||
trigger_error("API GET states wrong response", E_USER_ERROR);
|
||||
}
|
||||
}
|
||||
}
|
||||
return $this->states;
|
||||
}
|
||||
|
||||
Private function loadStates() {
|
||||
$ret = false;
|
||||
if($this->states){
|
||||
$ret = true;
|
||||
|
||||
Reference in New Issue
Block a user