/** * Execute the console command. * * @return mixed */ public function handle() { $lights = new HouseLight(); $all_lights = $lights->get_lights_on_network(); foreach ($all_lights as $light) { HouseLight::save_from_phue_light($light); } }
/** * Execute the console command. * * @return mixed */ public function handle() { $lights = HouseLight::all(); foreach ($lights as $light) { $job = new TurnLightOff($light->light_id); $this->dispatch($job); } }
private function turnLightOff() { $this->initialise(); $light = HouseLight::where('light_id', 1)->first(); $this->assertInstanceOf('App\\HouseLight', $light); $job = new TurnLightOff($light->light_id); $this->dispatch($job); }
/** * Turn off all lights after test. * TODO: It'd be nice to save a pre-test state and return to that. */ public function tearDown() { $lights = HouseLight::all(); foreach ($lights as $light) { $job = new TurnLightOff($light->light_id); } $this->dispatch($job); parent::tearDown(); }
/** * Execute the job. * * @return void */ public function handle() { $houselight = HouseLight::where('light_id', '=', $this->light_id)->firstOrFail(); $light = $this->client->getLights()[$this->light_id]; $light->setOn(true); if ($light->isOn()) { $houselight->state = true; $houselight->save(); } }
/** * Define your route model bindings, pattern filters, etc. * * @param \Illuminate\Routing\Router $router * @return void */ public function boot(Router $router) { // parent::boot($router); $router->bind('houselight', function ($id) { return \App\HouseLight::findOrFail($id); }); $router->bind('lightsettings', function ($id) { return \App\LightSetting::findOrFail($id); }); }
public static function save_from_phue_light(Light $light) { $db_light = HouseLight::firstOrNew(['uniqueid' => $light->getUniqueid()]); $db_light->name = $light->getName(); $db_light->light_id = $light->getId(); $db_light->type = $light->getType(); $db_light->uniqueid = $light->getUniqueId(); $db_light->state = $light->isOn(); $db_light->reachable = $light->isReachable(); $db_light->brightness = $light->getBrightness(); $db_light->hue = $light->getHue(); $db_light->saturation = $light->getSaturation(); $db_light->effect = $light->getEffect(); $db_light->alert = $light->getAlert(); $db_light->colormode = $light->getColorMode(); $db_light->xy = $light->getXY()['x'] . ',' . $light->getXY()['y']; $db_light->x = $light->getXY()['x']; $db_light->y = $light->getXY()['y']; $db_light->save(); }
/** * Execute the job. * * @return void */ public function handle() { $houselight = HouseLight::where('light_id', '=', $this->light_id)->firstOrFail(); $light = $this->client->getLights()[$this->light_id]; $off_after = false; if (!$light->isOn()) { $off_after = true; } $light->setOn(true); $light->setXY($this->x, $this->y); $light->setBrightness($this->brightness); if ($off_after) { $job = new TurnLightOff($this->light_id); $this->dispatch($job); } $houselight->x = $this->x; $houselight->y = $this->y; $houselight->xy = $this->x . ',' . $this->y; $houselight->brightness = $this->brightness; $houselight->save(); }
/** * Display a listing of the resource. * * @return Response */ public function index() { $lights = HouseLight::all(); $settings = LightSetting::all(); return view('home', compact('lights', 'settings')); }