Coder Social home page Coder Social logo

environment-sensitive-lighting's Introduction

Environment Sensitive Lighting - Lights that adjust based on cloudiness.

The purpose of this repository is to demo the making of a SmartThings SmartApp. The demo will adjust lighting brightness based on the cloudiness outside and the time of day. The user will be able to determine the greatest brightness level.

Use cases

  • Hallway lighting.
  • Kitchen lighting.
  • Outdoor lighting.
  • Adjust the lighting for seasonal affective disorder.

Setup

Prerequisites

  • A SmartThings compatible color light.
  • An OpenWeather account. The free tier will be enough.
  • A Samsung account
  • The SmartThings mobile application, Android or iOS.
  • A SmartThings Developer Workspace account. You can use your Samsung account login for the Developer Workspace.
  • A Heroku account if you want to host this project.
  • Node.js installed.
  • npm installed.
  • ngrok installed. Ngrok will create a secure tunnel to the local node server.

Getting started

Local setup

  • Get an API key from your OpenWeather account.
  • Copy the .env.example file to .env in this project's root directory. You can use this command in the root directory of this project: cp .env.example .env. Replace YOUR_API_KEY_HERE with your open weather API key.
  • Run npm install to install the project dependencies.
  • Start the Node.js server npm run start.
  • Start ngrok ngrok http 3000. Once started, copy and save the "Forwarding" HTTPS URL. This is the URL used in the Developer Workspace.

SmartApp creation

  • Log in to the Developer Workspace.
  • In the Developer Workspace, create a new project.
  • Select "Automation for the SmartThings App" as the project type.
  • Give the project the desired name.
  • Select "Register App" in the created project.
  • Choose "WebHook Endpoint" and enter your ngrok HTTPS URL.
  • Give your SmartApp a name and description.
  • Enable the following OAuth2 scopes under "Permissions required by your connector app."
    • r:devices:*
    • x:devices:*
  • Save the APP.
  • You will not need the Client ID or Secret for this, but you can save it anyways.
  • Click on "VERIFY APP REGISTRATION"; this will send a post to your application with a URL in your logs. Copy this URL and visit it in your browser to verify the connection.
  • After you have verified your app registration, then click on the "Deploy to Test" button.

More information on:

Testing SmartApp on your phone

  • Sign in to the SmartThings app on your smartphone.
  • Make sure you have a SmartLight added in the SmartThings app.
  • IMPORTANT: Enable developer mode in the SmartThings app. Go to the settings menu and hold down on "About SmartThings" for five seconds. After this, you should see an option to enable developer mode. The SmartThings app will need to restart.
  • Open the menu in the SmartThings app and go to SmartApps. Click on the plus sign to add a new SmartApp. If you scroll to the bottom, you should see this app listed under the "Custom" section.
  • Fill in the information in the prompt, then click "done > allow" and you should be able to see this project in action.

More information on:

Deploying as a service

  • Heroku can host this project.
  • Make sure you add the environment variable for the weather API key.
  • Use the URL in your Heroku app for your SmartThings SmartApp. The URL is in the Heroku app settings.
  • To verify your SmartThings SmartApp with Heroku, follow the logs heroku logs --tail.

More information on:

Inspiration

This SmartApp got inspiration from weather-color-light-smartapp-nodejs. A fantastic SmartApp that adjusts lighting color based on the current weather.

environment-sensitive-lighting's People

Watchers

James Cloos avatar nicholas diesslin avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.