All Projects → Cannonb4ll → Laravel Philips Hue

Cannonb4ll / Laravel Philips Hue

Licence: mit
Laravel Philips Hue package to control your lights with remote support

Projects that are alternatives of or similar to Laravel Philips Hue

Laravel Boilerplate
Laravel Boilerplate / Starter Kit with Gentelella Admin Theme
Stars: ✭ 704 (+950.75%)
Mutual labels:  hacktoberfest, laravel
Laravel Adminpanel
A Laravel Admin Panel (Laravel Version : 6.0)
Stars: ✭ 774 (+1055.22%)
Mutual labels:  hacktoberfest, laravel
Artisan View
👀 Manage your views in Laravel projects through artisan
Stars: ✭ 708 (+956.72%)
Mutual labels:  hacktoberfest, laravel
Laravel Mediable
Laravel-Mediable is a package for easily uploading and attaching media files to models with Laravel 5.
Stars: ✭ 541 (+707.46%)
Mutual labels:  hacktoberfest, laravel
Laravel Guided Image
Simplified and ready image manipulation for Laravel through intervention image.
Stars: ✭ 32 (-52.24%)
Mutual labels:  hacktoberfest, laravel
Core
Simple forum software for building great communities.
Stars: ✭ 5,372 (+7917.91%)
Mutual labels:  hacktoberfest, laravel
Platform
A modular multilingual CMS built with Laravel 5.
Stars: ✭ 719 (+973.13%)
Mutual labels:  hacktoberfest, laravel
Telegram
✈️ Telegram Notifications Channel for Laravel
Stars: ✭ 450 (+571.64%)
Mutual labels:  hacktoberfest, laravel
Sentry Laravel
Laravel SDK for Sentry
Stars: ✭ 927 (+1283.58%)
Mutual labels:  hacktoberfest, laravel
Laravel Sri
Subresource Integrity hash generator for laravel
Stars: ✭ 23 (-65.67%)
Mutual labels:  hacktoberfest, laravel
Tenanti
[Package] Multi-tenant Database Schema Manager for Laravel
Stars: ✭ 525 (+683.58%)
Mutual labels:  hacktoberfest, laravel
Laravel Packager
A cli tool for creating Laravel packages
Stars: ✭ 1,049 (+1465.67%)
Mutual labels:  hacktoberfest, laravel
Laravel Dompdf
A DOMPDF Wrapper for Laravel
Stars: ✭ 4,978 (+7329.85%)
Mutual labels:  hacktoberfest, laravel
Laravel Translatable
A Laravel package for multilingual models
Stars: ✭ 624 (+831.34%)
Mutual labels:  hacktoberfest, laravel
Laravel Medialibrary
Associate files with Eloquent models
Stars: ✭ 4,743 (+6979.1%)
Mutual labels:  hacktoberfest, laravel
Orm
A drop-in Doctrine ORM 2 implementation for Laravel 5+ and Lumen
Stars: ✭ 712 (+962.69%)
Mutual labels:  hacktoberfest, laravel
Freek.dev
The sourcecode of freek.dev
Stars: ✭ 407 (+507.46%)
Mutual labels:  hacktoberfest, laravel
Laravel 8 Simple Cms
Laravel 8 content management system for starters.
Stars: ✭ 444 (+562.69%)
Mutual labels:  hacktoberfest, laravel
Tenancy
Run multiple websites using the same Laravel installation while keeping tenant specific data separated for fully independent multi-domain setups.
Stars: ✭ 916 (+1267.16%)
Mutual labels:  hacktoberfest, laravel
Laravel Weather
🌤️ A wrapper around Open Weather Map API (Current weather)
Stars: ✭ 36 (-46.27%)
Mutual labels:  hacktoberfest, laravel

Laravel Philips Hue 💡

Introduction

I created this package for my company Ploi (https://ploi.io) to control our office lights. For example, when we receive a support ticket, our lights briefly light up green (Ploi's green color), fade out and in a bit.

This package makes it possible to easily manage your lights. Easily trigger your lights whenever a support ticket comes in, or if a new user signs up.

Syntax is as easy as this;

(new HueClient)->lights()->on(1)

Installation

Require the package first:

$ composer require cannonb4ll/laravel-philips-hue

Add this to the config/services.php file:

...

'philips-hue' => [
    'client_id' => env('PHILIPS_HUE_CLIENT_ID'),
    'client_secret' => env('PHILIPS_HUE_CLIENT_SECRET'),
    'app_id' => env('PHILIPS_HUE_APP_ID'),
    'device_id' => env('PHILIPS_HUE_DEVICE_ID'),
    'user' => env('PHILIPS_HUE_USERNAME')
]

...

Sign up (or login) to Philips Hue developer:

https://developers.meethue.com/register/

Next create a new Philips Hue App:

https://developers.meethue.com/add-new-hue-remote-api-app/

Fill in the fields accordingly to their form.

Callback URL: You will have to fill in a valid callback URL (certainly in testing enviroment, or you'd have to do this in production). This is because we will get the access and refresh tokens right away and store these in your application. In case if you are using valet, run valet share in your terminal to get an ngrok URL. Use this URL as callback in that case: {NGROK_HOST}/hue/auth/receive (Example: http://aa0515c9.ngrok.io/hue/auth/receive)

After that, note these variables:

  • AppId
  • ClientId
  • ClientSecret

We still need 2 variables, the device ID and username we will be using for your bridge.

Visit this URL and note the device ID: https://discovery.meethue.com/ (or visit https://account.meethue.com/bridge, you will see the bridge ID there too)

Fill in the details accordingly:

PHILIPS_HUE_CLIENT_ID=
PHILIPS_HUE_CLIENT_SECRET=
PHILIPS_HUE_APP_ID=
PHILIPS_HUE_DEVICE_ID=
PHILIPS_HUE_USERNAME= <-- We will get this in below step

Next we will have to create a user to be able to authenticate with your bridge.

The package will register 2 routes for you:

http://{app-url}/hue/auth

http://{app-url}/hue/auth/receive

Visit /hue/auth first to start creating a user.

You will be prompted to allow your own application permissions, accept this, you will be redirected to your own application. This is the point when you redirect that you will receive the username in the view from the package.

Grab this username (this is saved in your bridge), and also enter this in your .env file:

PHILIPS_HUE_USERNAME=

This is it! Now you should be able to execute the methods which we describe below.

You can also disable the default routes from the package by adding routes => false to your services.php file:

'philips-hue' => [
    'client_id' => env('PHILIPS_HUE_CLIENT_ID'),
    'client_secret' => env('PHILIPS_HUE_CLIENT_SECRET'),
    'app_id' => env('PHILIPS_HUE_APP_ID'),
    'device_id' => env('PHILIPS_HUE_DEVICE_ID'),
    'user' => env('PHILIPS_HUE_USERNAME'),
    'routes' => false
]

All the access data is saved in the storage/app/hue.json file, this contains the keys to access Philips Hue API.

Methods

    $hue = new HueClient();

    $hue->groups()->all();
    $hue->lights()->all();
    $hue->lights()->get(1);
    $hue->lights()->on(1);
    $hue->lights()->off(1);
    $hue->lights()->customState(1, [
        "hue" => 25500,
        "bri" =>200,
        "alert" => 'select'
    ]);

TODO

  • [X] Ability to use without physically pressing the link button
  • [ ] Add scenes resource
  • [ ] Add schedules resource
  • [ ] Add sensors resource
  • [ ] Add rules resource
  • [ ] Add capabilities resource
  • [ ] Add exceptions
  • [ ] Add testing
  • [ ] Fix refresh token refreshing automatically
  • [ ] Update readme methods

Helpful links

https://discovery.meethue.com/

https://developers.meethue.com/develop/hue-api/

https://developers.meethue.com/my-apps/

https://account.meethue.com/apps

https://account.meethue.com/bridge

This is not an official package by Philips

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].