diff --git a/server/ControlScripts/Common.php b/server/ControlScripts/Common.php index c923c90..dfd76f8 100644 --- a/server/ControlScripts/Common.php +++ b/server/ControlScripts/Common.php @@ -12,7 +12,7 @@ } } - $this -> helper() -> sync_btn_channels($this -> sync_map, $btns_block -> alias); + $this -> helper() -> sync_btn_channels($this -> sync_map(), $btns_block -> alias); }); } } \ No newline at end of file diff --git a/server/ControlScripts/Scopes/LightHubScope.php b/server/ControlScripts/Scopes/LightHubScope.php index 449960e..845139e 100644 --- a/server/ControlScripts/Scopes/LightHubScope.php +++ b/server/ControlScripts/Scopes/LightHubScope.php @@ -72,7 +72,7 @@ $result = false; if($relay_api instanceof \SHServ\Tools\DeviceAPI\Relay) { $result = $relay_api -> toggle_channel($channel); - $this -> helper() -> sync_relay_to_btns($this -> sync_map, $relay_alias); + $this -> helper() -> sync_relay_to_btns($this -> sync_map(), $relay_alias); } return [ @@ -82,7 +82,7 @@ protected function btns_click_handlers($alias): void { $self = $this; - $buttons = $this -> helper() -> prepare_sync_map_by_alias($this -> sync_map, $alias); + $buttons = $this -> helper() -> prepare_sync_map_by_alias($this -> sync_map(), $alias); foreach($buttons as $btn_channel => $entry) { if($entry[0]["type"] != "relay") { continue; @@ -97,7 +97,7 @@ if($relay_api instanceof \SHServ\Tools\DeviceAPI\Relay and $btns_block_api instanceof \SHServ\Tools\DeviceAPI\Button) { $relay_api -> toggle_channel($relay_channel); - $this -> helper() -> sync_relay_to_btns($this -> sync_map, $relay_alias); + $this -> helper() -> sync_relay_to_btns($this -> sync_map(), $relay_alias); } }); } diff --git a/server/ControlScripts/Scopes/OfficeRoomScope.php b/server/ControlScripts/Scopes/OfficeRoomScope.php index 3524f30..b6484d1 100644 --- a/server/ControlScripts/Scopes/OfficeRoomScope.php +++ b/server/ControlScripts/Scopes/OfficeRoomScope.php @@ -78,7 +78,7 @@ $result = false; if($relay_api instanceof \SHServ\Tools\DeviceAPI\Relay) { $result = $relay_api -> toggle_channel($channel); - $this -> helper() -> sync_relay_to_btns($this -> sync_map, $relay_alias); + $this -> helper() -> sync_relay_to_btns($this -> sync_map(), $relay_alias); } return [ @@ -89,16 +89,12 @@ protected function btns_online(String $button_alias): void { $this -> add_event_handler("button@{$button_alias}.online", function(Device $btns_block, Array $data) { $btns_block_api = $btns_block -> device_api(); - // if($btns_block_api instanceof \SHServ\Tools\DeviceAPI\Button) { - // $btns_block_api -> set_channel_state("mute", 0); - // } - - $this -> helper() -> sync_btn_channels($this -> sync_map, $btns_block -> alias); + $this -> helper() -> sync_btn_channels($this -> sync_map(), $btns_block -> alias); }); } protected function btns_handlers(String $button_alias): void { - $buttons_channels = $this -> helper() -> prepare_sync_map_by_alias($this -> sync_map, $button_alias); + $buttons_channels = $this -> helper() -> prepare_sync_map_by_alias($this -> sync_map(), $button_alias); foreach($buttons_channels as $btn_channel => $entry) { if($entry[0]["type"] != "relay") { continue; diff --git a/server/ControlScripts/Scopes/SpotlightsScope.php b/server/ControlScripts/Scopes/SpotlightsScope.php index 57e14d9..90de4e3 100644 --- a/server/ControlScripts/Scopes/SpotlightsScope.php +++ b/server/ControlScripts/Scopes/SpotlightsScope.php @@ -96,13 +96,13 @@ // ACTIONS protected function spotlight_switch(String $relay_alias, Bool $state = false) { - $device_entries = $this -> helper() -> get_sync_entries_by_type($this -> sync_map, "relay"); + $device_entries = $this -> helper() -> get_sync_entries_by_type($this -> sync_map(), "relay"); $relay_api = $this -> devices() -> by_alias($relay_alias) -> device_api(); $result = false; if($relay_api instanceof \SHServ\Tools\DeviceAPI\Relay) { $result = $relay_api -> set_state($state); - $this -> helper() -> sync_relay_to_btns($this -> sync_map, $relay_alias); + $this -> helper() -> sync_relay_to_btns($this -> sync_map(), $relay_alias); } return [ @@ -112,7 +112,7 @@ protected function all_spotlight_switch(Bool $state = false): Array { $results = []; - $device_entries = $this -> helper() -> get_sync_entries_by_type($this -> sync_map, "relay"); + $device_entries = $this -> helper() -> get_sync_entries_by_type($this -> sync_map(), "relay"); foreach($device_entries as $device_entry) { $relay_api = $this -> devices() -> by_alias($device_entry["alias"]) -> device_api(); @@ -128,7 +128,7 @@ } $results[$device_entry["alias"]] = $result; - $this -> helper() -> sync_relay_to_btns($this -> sync_map, $device_entry["alias"]); + $this -> helper() -> sync_relay_to_btns($this -> sync_map(), $device_entry["alias"]); } diff --git a/server/SHServ/Middleware/ControlScripts.php b/server/SHServ/Middleware/ControlScripts.php index f047f5a..a078190 100644 --- a/server/SHServ/Middleware/ControlScripts.php +++ b/server/SHServ/Middleware/ControlScripts.php @@ -162,4 +162,8 @@ protected function add_sync_connection(Array $sync_connection) { $this -> sync_map["connection"][] = $sync_connection; } + + public function sync_map() { + return $this -> sync_map; + } } \ No newline at end of file