Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

Awesome Lists | Featured Topics | Projects

https://github.com/juangesino/photon

Meteor app to control Photon-connected lights.
https://github.com/juangesino/photon

android iot iot-application meteor meteorjs mobile particle-io particle-photon photon smart-home smart-lights smart-switch smartswitch

Last synced: 1 day ago
JSON representation

Meteor app to control Photon-connected lights.

Awesome Lists containing this project

README

        

Photon Logo

Β Β Photon


Photon Screenshot

Meteor app to control Photon-connected lights.

### About

This project contains the source code for my personal Android application for controlling my lights. The lights are controlled using a Photon device and a relay. My lights are connected to the relay and this app triggers a function in the Photon to turn on/off the relay.

The app is built with Meteor which allows me to compile an APK for my Android phone.

πŸ‘‰πŸ» For the Photon-side of things checkout the project here: [github.com/juangesino/lux](https://github.com/juangesino/lux).

## Setup

1. **Install Meteor**

On Linux & Mac:

```sh
> curl https://install.meteor.com/ | sh
```

This will setup [Meteor](http://github.com/meteor/meteor) (including [Node](https://github.com/nodejs/node) and [Mongo](https://github.com/mongodb/mongo) if necessary).

> _Note:_ Windows users must [download installer](https://www.meteor.com/install).

2. **Clone Repository**

```sh
> git clone https://github.com/juangesino/photon.git
> cd photon
```

3. **Install Dependencies**

If you have npm installed:

```sh
> npm install
```

If you only have meteor:

```sh
> meteor npm install
```

4. **Setup Keys**

In order for the application to connect with the Photon, we need to provide some auth key (the device ID and an access token).

Rename the file `/server/keys.js.example` to `/server/keys.js`.

Open the file and replace `` and `` with the device ID and an access token.

For info on how to get these variables see these docs.

5. **Run**

While in repository directory run:

```sh
> meteor run
```

Load browser and go to [http://localhost:3000/](http://localhost:3000/)

Alternatively, you can run:

```sh
> meteor run android-device
```

With an Android phone connected to your computer and with USB debugging enabled to run the server on your computer and install the APK on your phone (connected to the same network). More info about running Meteor on Android here and more info on debugging here.

## Deploy

### Hardware

This project requires my Lux project. Go check it out here: github.com/juangesino/lux.

### Server

The meteor application requires a server. We can do this by deploying the server to Heroku for free.

Follow these steps to deploy the Meteor app on Heroku.

After that we need to setup our two environment variables: `deviceId` and `accessToken`. To do so, we need to add the following Config Var to our Heroku application:

```
METEOR_SETTINGS = {"secrets": {"deviceId":"", "accessToken": ""} }
```

Where `` and `` are the device ID and access token for the Photon device.

πŸ‘‰πŸ» For info on how to get these variables see github.com/juangesino/lux.

πŸ‘‰πŸ» For info on how to set these variables in Heroku see these docs.

**Note**: You will need to deploy this server for the Android app to work.

**Note 2**: The name of the config variable is `METEOR_SETTINGS` and the value for it is everything to the right of the `=` sign.

### Android

To build for Android run:

```sh
> meteor build ..//photon --debug --server=https://.herokuapp.com/
```

Replace `` with the actual path where you want your build to be generated.
Replace `` with the name of the Heroku app for your server. If you are not using Heroku, replace the entire `--server` argument with your server's URL.

## Contributing

1. Fork it ( https://github.com/juangesino/photon/fork )
2. Create your feature branch (`git checkout -b my-new-feature`)
3. Commit your changes (`git commit -am 'Add some feature'`)
4. Push to the branch (`git push origin my-new-feature`)
5. Create a new Pull Request

## License

See [MIT-LICENSE](https://github.com/juangesino/photon/blob/master/LICENSE).