Skip to content

Commit

Permalink
Initial commit
Browse files Browse the repository at this point in the history
  • Loading branch information
mnorlin committed Nov 23, 2020
0 parents commit e5279fa
Show file tree
Hide file tree
Showing 63 changed files with 43,134 additions and 0 deletions.
28 changes: 28 additions & 0 deletions .dockerignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
**/__pycache__
**/.classpath
**/.dockerignore
**/.DS_Store
**/.env
**/.git
**/.gitignore
**/.gitmodules
**/.project
**/.settings
**/.toolstarget
**/.vs
**/.vscode
**/*.*proj.user
**/*.dbmdl
**/*.jfm
**/azds.yaml
**/bin
**/charts
**/docker-compose*
**/Dockerfile*
**/node_modules
**/npm-debug.log
**/obj
**/secrets.dev.yaml
**/values.dev.yaml
README.md
Makefile
18 changes: 18 additions & 0 deletions .eslintrc.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
{
"env": {
"browser": true,
"es2021": true
},
"extends": ["plugin:react/recommended", "plugin:react-hooks/recommended"],
"parserOptions": {
"ecmaFeatures": {
"jsx": true
},
"ecmaVersion": 12,
"sourceType": "module"
},
"plugins": ["react", "react-hooks"],
"rules": {
"react/prop-types": 0
}
}
23 changes: 23 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
# dependencies
/node_modules
.pnp
/react-hue.pnp.js

# testing
/coverage

# production
/build

# misc
/.vscode
/.nova
.DS_Store
.env.local
.env.development.local
.env.test.local
.env.production.local

npm-debug.log*
yarn-debug.log*
yarn-error.log*
3 changes: 3 additions & 0 deletions .gitmodules
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
[submodule "public/weather-icons"]
path = public/weather-icons
url = https://github.com/erikflowers/weather-icons.git
13 changes: 13 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
FROM node:latest as installation
WORKDIR /app
COPY package*.json /app/
RUN npm install


FROM installation as build
COPY ./ /app/
RUN npm run build


FROM nginx as publish
COPY --from=build /app/build /usr/share/nginx/html
674 changes: 674 additions & 0 deletions LICENSE

Large diffs are not rendered by default.

89 changes: 89 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,89 @@
# Homecontrol

Set up a dashboard to control your Philips Hue lights using an old tablet or phone. You get a simple weather forecast and you can control your lights through a floor map.

![Screenshot](public/screenshot.png "Screenshot")

**Features:**

- Generate a floor map from coordinates.
- Get instant overview of which rooms have lights on.
- Click on a room to toggle all its lights.
- Weather forecast from OpenWeatherMap.
- Scheduling of light temperature throughout the day.
- Set the scheduled time for 5 different light temperatures, from energizing blue light, to relaxed red light.
- Even if the lights are turned off, the light temperature will apply when you turn them on.
- The current light temperature even applies if you turn on the lights in another app.
- Get the current temperature from Philips hue sensors.
- Get an estimate of the current power consumption of the lights.
- Turn individual lights on or off.

## How to run

### Download the release and run locally in your browser

Download the latest release, and open `index.html` in your browser.

### Build it yourself

Edit `package.json`, and add the line `"homepage": ".",` at the root of the json file. Execute `npm run build`, when finished, you can open up `./build/index.html` in your browser.

### Run as a docker container

`docker-compose build`

`docker-compose up -d`

The app is now available at `http://localhost:3000`.

### Run as an npm development server

`npm install`

`npm start`

The app is now available at `http://localhost:3000`.

## Generate a floor map

The floor plan for each room can be configured in the settings. It is generated by an array of objects with x- and y-coordinates representing points on the browser Canvas API. On the canvas, point zero is in the upper left corner.
A line is drawn between each coordinate in the array. If you want to make space for a door in a room, you can add the property `"transparent": true`, and the line drawn to that point will be transparent. See example code below, which was used for generating the rooms used in the app screenshot.

**Room 1**

```json
[
{ "x": 0, "y": 0 },
{ "x": 8, "y": 0 },
{ "x": 8, "y": 5 },
{ "x": 8, "y": 7, "transparent": true },
{ "x": 8, "y": 10 },
{ "x": 0, "y": 10 },
{ "x": 0, "y": 0 }
]
```

![Canvas room 1](public/canvas.png "Canvas room 1")

**Room 2**

```json
[
{ "x": 8, "y": 0 },
{ "x": 16, "y": 0 },
{ "x": 16, "y": 7 },
{ "x": 8, "y": 7 },
{ "x": 8, "y": 5, "transparent": true },
{ "x": 8, "y": 0 }
]
```

## Known issues

1. **The turned off lights flicker when changing light scene** - Philips Hue can't change the color of a light when it is turned off, so to enable that all lights have the same state when turned on, they will briefly need to be turned on and off to get their new state.

2. **The power consumption is just an estimate** - The estimate is based on the dimming percentage for the default light color for sultan, candle and light-strip models. If the model is of another type, it falls back to the sultan bulbs power consumption.

3. **The power consumption is never zero** - This is not a bug. The Hue bridge draws power, as well as the lights, even when turned off, so it will never show 0 Watt.

4. **Control section with light switches can't collapse** - This seems to be a bug in Bootstrap 5 alpha.
11 changes: 11 additions & 0 deletions docker-compose.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
version: "3"

services:
homecontrol:
container_name: homecontrol
build:
context: .
dockerfile: Dockerfile
ports:
- "3000:80"
restart: unless-stopped
Loading

0 comments on commit e5279fa

Please sign in to comment.