diff --git a/server/ControlScripts/SpotlightsScope.php b/server/ControlScripts/SpotlightsScope.php index ec5d421..f439091 100644 --- a/server/ControlScripts/SpotlightsScope.php +++ b/server/ControlScripts/SpotlightsScope.php @@ -6,7 +6,7 @@ class SpotlightsScope extends \SHServ\Middleware\ControlScripts implements \SHServ\Implements\ControlScriptsInterface { public function register_events_handlers(): void { - + $this -> backdoor_btns_handlers(); } public function register_actions_scripts(): void { @@ -80,5 +80,22 @@ // EVENTS HANDLERS - + protected function backdoor_btns_handlers() { + $this -> add_event_handler("button@buttons_backdoor(0).press", function(Device $btns_block, Array $data) { + $relay_api = $this -> devices() -> by_alias("spotlight_main_front_1") -> device_api(); + + if($relay_api instanceof \SHServ\Tools\DeviceAPI\Relay) { + $relay_api -> toggle_channel(0); + $relay_channels = ($relay_api -> get_status())["channels"]; + + $btns_block_api = $btns_block -> device_api(); + if($btns_block_api instanceof \SHServ\Tools\DeviceAPI\Button) { + $btns_block_api -> set_channel_state( + $relay_channels[0]["state"] == "on" ? "enabled" : "disabled", + $data["channel"] + ); + } + } + }); + } } \ No newline at end of file