{"id":15490522,"url":"https://github.com/sammarks/photon-lightswitch","last_synced_at":"2025-03-28T16:27:48.889Z","repository":{"id":147095029,"uuid":"44075965","full_name":"sammarks/photon-lightswitch","owner":"sammarks","description":"A simple light switch API for my Particle (Spark) Photon.","archived":false,"fork":false,"pushed_at":"2016-08-07T19:25:29.000Z","size":26,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":3,"default_branch":"master","last_synced_at":"2024-10-19T09:18:33.549Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/sammarks.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2015-10-12T00:51:58.000Z","updated_at":"2016-08-07T19:25:30.000Z","dependencies_parsed_at":null,"dependency_job_id":"a61fa9d9-9b6e-488b-8b80-ab5f104a7d88","html_url":"https://github.com/sammarks/photon-lightswitch","commit_stats":{"total_commits":59,"total_committers":2,"mean_commits":29.5,"dds":"0.22033898305084743","last_synced_commit":"d4ef66411f33a3db26ad412c241442b87e158eb0"},"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sammarks%2Fphoton-lightswitch","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sammarks%2Fphoton-lightswitch/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sammarks%2Fphoton-lightswitch/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sammarks%2Fphoton-lightswitch/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/sammarks","download_url":"https://codeload.github.com/sammarks/photon-lightswitch/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":246061828,"owners_count":20717511,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-10-02T07:21:52.022Z","updated_at":"2025-03-28T16:27:48.863Z","avatar_url":"https://github.com/sammarks.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Photon Lightswitch\n\nThis is a simple API that uses my current location to determine whether or not\na lightswitch should be turned on or off.\n\nI offload the logic to this API to keep the script running on the photon as simple\nas possible.\n\n## Installation\n\nTo install the Firmware, you'll need to load it into your Particle Build IDE, and then flash it to your\nParticle Photon. Be sure to update the comments marked as `TODO` with your connection details.\n\nTo install the web service, you'll need to install and configure Docker and Docker Compose. Once that's done, copy\nthe `.env.example` file to `.env` and fill in the values (the latitude, longitude, timezone and Forecast.IO API key).\nSave that file in the same directory as the `.env.example` file.\n\nWhen you're ready to get the web service up and running, just run `docker-compose build` to build the container, and\nthen `docker-compose up -d` to run the service as a daemon. To view the logs, you can use `docker-compose logs`.\n\nOnce the firmware and web service are working, the two should automatically attempt to establish a connection.\n\n### Alarm Feature\n\nIf you're going to use the alarm feature, it is very important that you set the `TZ` (timezone)\nenvironment variable correctly. If you do not set this, the alarm will go off at a different\ntime than you're expecting!\n\n## Ideas\n\nPossible ideas I have for expansion:\n\n- [x] Send a ping to the websocket connection every 10 seconds to verify that the connection is still alive.\n- [x] Check cloud conditions in the area (turn the lights on when it's cloudy or\n\tstormy).\n- [ ] Check to see if my phone is connected to the same wireless network as the lights\n\t(on device, turns the lights out when my phone is not in the area).\n- [x] Update the application to use WebSockets [using this repository](https://github.com/hpssjellis/Particle-Spark-Core-Photon-Websocket-Hack).\n- [x] Create an Amazon Echo app to support turning the lights on and off by speaking to the Echo.\n- [x] Create an alarm feature that toggles the lights when I'm supposed to wake up in the morning.\n\n## Device Codes\n\n- *Y*: Lights on (submissive)\n- *N*: Lights off (submissive)\n- *F*: Lights on (forceful)\n- *O*: Lights off (forceful)\n- *P*: Ping (should be sent every 10 seconds from the server)\n\n## Device Firmware\n\nI have added the firmware to this repository (`firmware.ino`). The firmware was written\nfor a Particle Photon with the following configuration:\n\n- Pin 3 is connected to a button, with the ground going to ground (it's a pullup resistor).\n- Pin 5 is connected to a solid state relay, which controls the lights. The positive\n\tend of the solid state relay goes into this data port, with the ground going to the\n\tground connection on the photon.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsammarks%2Fphoton-lightswitch","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fsammarks%2Fphoton-lightswitch","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsammarks%2Fphoton-lightswitch/lists"}