diff --git a/server/ControlScripts/SpotlightsScope.php b/server/ControlScripts/SpotlightsScope.php index 84548c1..fad7347 100644 --- a/server/ControlScripts/SpotlightsScope.php +++ b/server/ControlScripts/SpotlightsScope.php @@ -94,10 +94,7 @@ } $results[$device_entry["alias"]] = $result; - $this -> helper() -> sync_relay_to_btns( - $this -> helper() -> prepare_sync_map_by_alias($this -> sync_map, $device_entry["alias"]), - $device_entry["alias"] - ); + $this -> helper() -> sync_relay_to_btns($this -> sync_map, $device_entry["alias"]); } @@ -114,13 +111,15 @@ if($btns_block_api instanceof \SHServ\Tools\DeviceAPI\Button) { $btns_block_api -> set_channel_state("mute", 3); - foreach($this -> aliases as $btn_channel => $relay_alias) { - $relay_api = $this -> devices() -> by_alias($relay_alias) -> device_api(); - if($relay_api instanceof \SHServ\Tools\DeviceAPI\Relay) { - $this -> helper() -> sync_relay_to_btn_channel($relay_api, $btns_block_api, 0, $btn_channel); - } - } + // foreach($this -> aliases as $btn_channel => $relay_alias) { + // $relay_api = $this -> devices() -> by_alias($relay_alias) -> device_api(); + // if($relay_api instanceof \SHServ\Tools\DeviceAPI\Relay) { + // $this -> helper() -> sync_relay_to_btn_channel($relay_api, $btns_block_api, 0, $btn_channel); + // } + // } } + + $this -> helper() -> sync_btn_channels($this -> sync_map, $btns_block -> alias); }); } diff --git a/server/SHServ/Helpers/DeviceScriptsHelper.php b/server/SHServ/Helpers/DeviceScriptsHelper.php index 0486e1a..7e97f24 100644 --- a/server/SHServ/Helpers/DeviceScriptsHelper.php +++ b/server/SHServ/Helpers/DeviceScriptsHelper.php @@ -47,6 +47,10 @@ * @return Bool */ public function sync_relay_to_btns(Array $sync_map, String $relay_alias): Bool { + if(isset($sync_map["connections"])) { + $sync_map = $this -> prepare_sync_map_by_alias($sync_map, $relay_alias); + } + $relay = $this -> devices() -> by_alias($relay_alias); if(!$relay) { return false; @@ -89,6 +93,10 @@ * @return Bool */ public function sync_btn_channels(Array $sync_map, String $btn_alias): Bool { + if(isset($sync_map["connections"])) { + $sync_map = $this -> prepare_sync_map_by_alias($sync_map, $btn_alias); + } + $btn = $this -> devices() -> by_alias($btn_alias); if(!$btn) { return false;