Skip to content

Commit

Permalink
readme and cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
AYapejian committed Feb 17, 2018
1 parent b87a7b2 commit 581aa44
Show file tree
Hide file tree
Showing 5 changed files with 1,831 additions and 25 deletions.
40 changes: 21 additions & 19 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ Various nodes to assist in setting up automation using [node-red](https://nodere

## Project status

Project is going through active development and as such will probably have a few 'growing pain' bugs as well as node type, input, output and functionality changes. At this stage backwards compatibility between versions is not a main concern and a new version may mean you'll have to recreate certain nodes.
Project is going through active development and as such will probably have a few 'growing pain' bugs as well as node type, input, output and functionality changes. At this stage backwards compatibility between versions is not a main concern and a new version __may mean you'll have to recreate certain nodes.__

## Getting Started

Expand All @@ -19,46 +19,49 @@ $ npm install node-red-contrib-home-assistant
## Included Nodes
The installed nodes have more detailed information in the node-red info pane shown when the node is selected. Below is a quick summary

### events: all
### All Events
Listens for all types of events from home assistant

### events: state
### State Changed Event
Listens for only `state_changed` events from home assistant

### call service
### State Trigger
Much like the `State Changed Ndoe` however provides some advanced functionality around common automation use cases.

### Poll State
Outputs the state of an entity at regular intervals, optionally also at startup and every time the entity changes if desired

### Call Service
Sends a request to home assistant for any domain and service available ( `light/turn_on`, `input_select/select_option`, etc..)

### get state
### Get Current State
Fetches the last known state for any entity on input

### get history
### Get History
Fetches HomeAssistant history on input

### get template
### Get Template
Allows rendering of templates on input

---
## Development
An entire environment with Home Assistant/MQTT/Node Red can be easily spun up using docker and docker-compose along with built in VSCode debug enabled.
An environment with Home Assistant/Node Red can be easily spun up using docker and docker-compose along with built in VSCode debug enabled.

1. Clone this repository: `git clone https://github.com/AYapejian/node-red-contrib-home-assistant.git`
2. Install node dependencies as usual: `cd node-red-contrib-home-assistant && npm install`
3. Start the docker dev environment: `npm run dev`
2. Install node dependencies as usual: `cd node-red-contrib-home-assistant && yarn`
3. Start the docker dev environment: `yarn run dev`
a. _Note: First run will take a bit to download the images ( home-assistants image is over 1gb (yikes!) after that launch is much quicker)_
b. _Note: Also first run load of HomeAssistant web interface seems very slow, but after first time it's also much faster_
4. The `npm run dev` command will leave you with a terminal spitting out logs, `ctrl+c` out of this and it kills all the servers by design, just run `npm run dev` again to pick back up. The following services and ports are launched in the `dev` script
4. The `yarn run dev` command will leave you with a terminal spitting out logs, `ctrl+c` out of this and it kills all the servers by design, just run `yarn run dev` again to pick back up. The following services and ports are launched in the `dev` script


| service | port mappings | info |
|------------------------|--------------------------|---------------------------------------------------------------------------------------------------------------------------------|
| home-assistant | `8123:8123`, `8300:8300` | exposed for local access via browser |
| node-red | `1880:1880`, `9123:9229` | exposed for local access via browser, `9123` is used for debugging. Includes default flow example connected to `home-assistant` |
| mqtt | `1883:1883`, `9001:9001` | exposed for experimenting, however shouldn't be needed as compose handles mappings internally |
| mqtt-listener | | debug listener subscribed to topic `dev/#` of `mqtt` broker for log output |
| mqtt-dev-sensor | | publishes every 10 seconds to a topic home assistant has a `sensor` platform for |
| mqtt-dev-binary-sensor | | publishes every 30 seconds to a topic home assistant has a `binary_sensor` for |
| node-red | `1880:1880`, `9123:9229` | exposed for local access via browser, `9123` is used for debugging. Includes default flow example connected to `home-assistant` | |

### Docker Tips
1. If you run into environment issues running `npm run dev:clean` should remove all docker data and get you back to a clean state
1. If you run into environment issues running `yarn run dev:clean` should remove all docker data and get you back to a clean state
2. All data will be discarded when the docker container is removed. You can map volumes locally to persist data. Create and copy as directed below then modify `docker-compose.yaml` to map the container directories to the created host dirs below. _See: `./_docker/docker-compose.mapped.yaml` for an example or just use that file to launch manually_

```
Expand All @@ -68,13 +71,12 @@ cp _docker/home-assistant/root-fs/config/* _docker-volumes/home-assistant/config
cp _docker/node-red/root-fs/data/* _docker-volumes/node-red/data
```


### Node Debugger via VSCode
Optional but it's pretty nice if you have VSCode installed.
- Open the project directory in VSCode
- Go to the debug tab ( or `cmd/ctrl+shift+d`)
- In the debug tab you should see an target for "Attach: Docker", run that guy and you can place debug breakpoints and changes will be reloaded within docker automatically
- Open [http://localhost:8123](http://localhost:8123) for HomeAssistant (password is `password` by default). There is a default config which includes mqtt with a couple mqtt sensors that autopublish every 10 and 30 seconds by default. MQTT broker is also launched via docker, checkout the `docker` dir for more details if interested.
- Open [http://localhost:8123](http://localhost:8123) for HomeAssistant (password is `password` by default).
- For node-red either open up via the HomeAssistant web link or left hand menu or just open a browser tab to [http://localhost:1880](http://localhost:1880)

### Other Dev Tips
Expand Down
1 change: 1 addition & 0 deletions _docker/node-red/root-fs/app/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
},
"dependencies": {
"node-red": "0.18.2",
"node-red-contrib-contextbrowser": "*",
"nodemon": "1.14.11"
},
"engines": {
Expand Down
Loading

0 comments on commit 581aa44

Please sign in to comment.