Laravel Philips Hue package to control your lights with remote support

Overview

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

  • 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

Comments
  • Undefined function array_first

    Undefined function array_first

    Hi,

    I've got an error inside HueUser.php on line 33. Is array_first a valid function? I searched already the Laravel and PHP docs but couldn't find any helper or something.

    opened by justkidding96 5
  • Missing Guzzle requirement in composer

    Missing Guzzle requirement in composer

    The Guzzle package is missing from the composer file which will throw an error if the lib is used without installing guzzle. The solution would be to add the requirement to the composer.json.

    I can open a PR with these changes if you would like? I would also be open to help developing the lib further if you would like some help?

    opened by allentje 4
  • Update php doc

    Update php doc

    What does this PR do?

    This is just a small PR to define the phpdoc in the HueClient to enable IDE's to auto suggest the return type

    What should happen on deployment? (check all that apply)

    • [x] The usual steps.
    opened by allentje 2
  • Package not found

    Package not found

    Hi, thanks for this package. However, the 'composer require dennissmink/laravel-philips-hue' command (as stated in the docs) is not working. Composer returns a not found notice. Running 'composer require cannonb4ll/laravel-philips-hue' does the trick.

    It would be too bad to miss this package ;)

    Thanks!

    opened by StephanDisberg 1
  • added guzzle dependency for issue #4

    added guzzle dependency for issue #4

    What does this PR do?

    This adds the guzzle requirement so that the lib can be installed without extra maintenance needed

    Where should the reviewer start?

    composer install

    How should this be manually tested?

    • [ ] composer install

    What should happen on deployment? (check all that apply)

    • [x] The usual steps.
    opened by allentje 0
  • 1.6 removed support for Laravel 5?

    1.6 removed support for Laravel 5?

    I need to upgrade to version 1.6 since i'm having trouble with the cached config for Hue when running this in an Job. This has been fixed in 1.6, but I don't see the reason why support for Laravel 5 has been dropped?

    It will save me a lot of time if you can still support this version or make an 1.5.x release with this changes included, it is to much work for now to upgrade to newer Laravel.

    opened by dejury 1
  • ErrorCode: invalid_request - api.meethue.com

    ErrorCode: invalid_request - api.meethue.com

    Hello, Thanks for the great work. I have been attempting to utilize laravel-philips-hue however I'm having some odd experiences, listed out some things I've noticed in case these help identify the issue. My core issue is that when I http://{app-url}/hue/auth I receive a standard {"ErrorCode" : "invalid_request", "Error" :"The request is missing required parameters."}. Below is some areas where the issue might be occurring.

    1. composer require cannonb4ll/laravel-philips-hue is grabbing version 1.5 (Oct 5th) instead of using the current dev-master (Oct 9th - 62aaa30). Not sure if anything needs to be changed on the packagist.org site. To solve this I've been using composer require cannonb4ll/laravel-philips-hue:dev-master to force using the current master.

    2. Within HueClient.php & HueUser.php the below changes were made recently - should the "README.md" config area need to be update as well? The readme still directs that the config/services.php should use env('PHILIPS_HUE_CLIENT_ID') and env('PHILIPS_HUE_CLIENT_SECRET').... The example of the changes I'm referencing can be seen here REMOVED: env('PHILIPS_HUE_APP_ID') ADDED: config('services.philips-hue.app_id')

    3. I'm receiving the following message once completing the services.php file and using http://{app-url}/hue/auth ERROR CODE: {"ErrorCode" : "invalid_request", "Error" :"The request is missing required parameters."} This sadly is a very common / standard error code by Hue so I can't learn much from it. This is my main problem.

    4. As a side/bonus question: do you know of a clean and simple way to monitor the outbound post/get etc from Laravel so I can see the message it's sending when http://{app-url}/hue/auth is actioned? That way I could check the message I'm sending

    Thanks again, I hope the above helps solve this issue (if it exists in the repo) or if I'm doing something wrong please point me in the better direction.

    opened by flamnitka 7
Owner
Dennis Smink
Laravel enthusiast. Founder of @ploi-deploy, @documentator-io and @LaraBug
Dennis Smink
Convert remote api response data into laravel model

laravel remote model Create remote driver to convert remote api request into laravel model. 中文文档 日本語文書 overview Install the version between laravel5.5

张子彬 15 Aug 11, 2022
Easily validate data attributes through a remote request

Laravel Remote Rule Easily validate data attributes through a remote request. This package allows you to define a subset of custom rules to validate a

H-FARM Innovation 27 Nov 20, 2022
Easily interact and control your feature flags from Filament

Easily interact and control your feature flags from Filament

Ryan Chandler 32 Nov 29, 2022
With dadjokes every time you load your control panel you'll be greeted by an epic dad joke on the dashboard.

Filament Dad Jokes Widget With DadJokes every time you load your control panel you'll be greeted by an epic dad joke on the dashboard. Installation Yo

Craig Smith 15 Jan 7, 2023
This package provides extended support for our spatie/enum package in Laravel.

Laravel support for spatie/enum This package provides extended support for our spatie/enum package in Laravel. Installation You can install the packag

Spatie 264 Dec 23, 2022
Control frontend access to properties/methods in Livewire using PHP 8 attributes.

This package adds PHP 8.0 attribute support to Livewire. In specific, the attributes are used for flagging component properties and methods as frontend-accessible.

ARCHTECH 83 Dec 17, 2022
pagina de control de inversiones para practicar

inversion pagina de control de inversiones para practicar. Esta pagina esta hecho con codeigniter utilizando bootstrap. Esta mas que nada hecha en php

null 1 Nov 21, 2021
Aplicación Web para control de registros de participantes y eventos

About Laravel Laravel is a web application framework with expressive, elegant syntax. We believe development must be an enjoyable and creative experie

Flisol Paraguay 2 Apr 6, 2022
Laravel package to generate and to validate a UUID according to the RFC 4122 standard. Only support for version 1, 3, 4 and 5 UUID are built-in.

Laravel Uuid Laravel package to generate and to validate a universally unique identifier (UUID) according to the RFC 4122 standard. Support for versio

Christoph Kempen 1.7k Dec 28, 2022
View themes is a simple package to provide themed view support to Laravel.

Laravel View Themes View themes is a simple package to provide themed view support to Laravel. Installation Add alexwhitman/view-themes to the require

Alex Whitman 15 Nov 29, 2022
An opinionated support package for Laravel, that provides flexible and reusable helper methods and traits for commonly used functionality.

Support An opinionated support package for Laravel, that provides flexible and reusable helper methods and traits for commonly used functionality. Ins

Ian Olson 3 Apr 14, 2021
Package with small support traits and classes for the Laravel Eloquent models

Contains a set of traits for the eloquent model. In future can contain more set of classes/traits for the eloquent database.

Martin Kluska 3 Feb 10, 2022
Easily set up a sync endpoint to support Watermelon DB in your Laravel projects.

Laravel Watermelon This package provides a Watermelon DB backend sync implementation for Laravel. Watermelon DB is a robust local database synchroniza

Nathan Heffley 18 Dec 21, 2022
Bring multi themes support to your Laravel application with a full-featured Themes Manager

Introduction hexadog/laravel-themes-manager is a Laravel package which was created to let you developing multi-themes Laravel application. Installatio

hexadog 86 Dec 15, 2022
Composer package which adds support for HTML5 elements using Laravels Form interface (e.g. Form::date())

Laravel HTML 5 Inputs Composer package which adds support for HTML5 elements by extending Laravel's Form interface (e.g. Form::date()) Adds support fo

Small Dog Studios 11 Oct 13, 2020
This package adds support for verifying new email addresses: when a user updates its email address, it won't replace the old one until the new one is verified.

Laravel Verify New Email Laravel supports verifying email addresses out of the box. This package adds support for verifying new email addresses. When

Protone Media 300 Dec 30, 2022
Jetstrap is a lightweight laravel 8 package that focuses on the VIEW side of Jetstream / Breeze package installed in your Laravel application

A Laravel 8 package to easily switch TailwindCSS resources generated by Laravel Jetstream and Breeze to Bootstrap 4.

null 686 Dec 28, 2022
A simple drop-in solution for providing UUID support for the IDs of your Eloquent models.

Introduction A simple drop-in solution for providing UUID support for the IDs of your Eloquent models. Both v1 and v4 IDs are supported out of the box

GoldSpec Digital 501 Jan 4, 2023
Live Helper Chat - live support for your website. Featuring web and mobile apps, Voice & Video & ScreenShare. Supports Telegram, Twilio (whatsapp), Facebook messenger including building a bot.

Live helper chat It's an open-source powered application, which brings simplicity and usability in one place. With live helper chat you can bring live

Live Helper Chat 1.7k Dec 29, 2022