diff --git a/server/ControlScripts/SpotlightsScope.php b/server/ControlScripts/SpotlightsScope.php index c3aebf4..8de1338 100644 --- a/server/ControlScripts/SpotlightsScope.php +++ b/server/ControlScripts/SpotlightsScope.php @@ -49,6 +49,26 @@ ], function($params) { return $this -> all_spotlight_switch(false); }); + + $this -> add_action_script([ + "alias" => "front_spotlight_on", + "name" => "ВКЛ фронтальный прожектор", + "icon" => '', + "description" => "Включить только фронтальный прожектор на главном входе", + "author" => "Eugene Sukhodolskiy" + ], function($params) { + return $this -> spotlight_switch("spotlight_main_front_1", true); + }); + + $this -> add_action_script([ + "alias" => "front_spotlight_off", + "name" => "ВЫКЛ фронтальный прожектор", + "icon" => '', + "description" => "Выключить только фронтальный прожектор на главном входе", + "author" => "Eugene Sukhodolskiy" + ], function($params) { + return $this -> spotlight_switch("spotlight_main_front_1", false); + }); } public function register_regular_scripts(): void { @@ -71,6 +91,22 @@ } // ACTIONS + + protected function spotlight_switch(String $relay_alias, Bool $state = false) { + $btns_block_api = $this -> devices() -> by_alias("buttons_backdoor") -> device_api(); + $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); + } + + return [ + "result" => $result + ]; + } protected function all_spotlight_switch(Bool $state = false): Array { $results = []; @@ -133,4 +169,4 @@ }); } } -} \ No newline at end of file +}