Skip to content

Commit

Permalink
Merge pull request #5 from biddster/develop
Browse files Browse the repository at this point in the history
0.4.2
  • Loading branch information
biddster committed Mar 12, 2016
2 parents 1efca1a + 35e3252 commit c4ac862
Show file tree
Hide file tree
Showing 4 changed files with 154 additions and 8 deletions.
53 changes: 50 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,10 +1,57 @@
# node-red-contrib-schedex

Scheduler for node-red which allows you to enter on/off times as 24hr clock (e.g. 01:10) or suncalc events (e.g. goldenHour).
It also allows you to offset times and randomise the time within the offset.

Inspired by Pete Scargill's [BigTimer](http://tech.scargill.net/big-timer/)

TODO:
- [x] Fuzzy on and off times (e.g. turn my light on at a random time each day within +-60 minutes of goldenHour).
- [ ] Initial scheduling should show off or on next, depending on which is next.


### Installation

Change directory to your node red installation:

$ npm install node-red-contrib-schedex

### Configuration

#### Times

The times can be a 24 hour time or a [suncalc](https://github.com/mourner/suncalc) event:


| Time | Description |
| --------------- | ------------------------------------------------------------------------ |
| `00:00 ... 23:59` | 24hr time |
| `sunrise` | sunrise (top edge of the sun appears on the horizon) |
| `sunriseEnd` | sunrise ends (bottom edge of the sun touches the horizon) |
| `goldenHourEnd` | morning golden hour (soft light, best time for photography) ends |
| `solarNoon` | solar noon (sun is in the highest position) |
| `goldenHour` | evening golden hour starts |
| `sunsetStart` | sunset starts (bottom edge of the sun touches the horizon) |
| `sunset` | sunset (sun disappears below the horizon, evening civil twilight starts) |
| `dusk` | dusk (evening nautical twilight starts) |
| `nauticalDusk` | nautical dusk (evening astronomical twilight starts) |
| `night` | night starts (dark enough for astronomical observations) |
| `nadir` | nadir (darkest moment of the night, sun is in the lowest position) |
| `nightEnd` | night ends (morning astronomical twilight starts) |
| `nauticalDawn` | nautical dawn (morning nautical twilight starts) |
| `dawn` | dawn (morning nautical twilight ends, morning civil twilight starts) |


#### Offsets

The on and off time can have an offset. This is specified in minutes:

- -ve number brings the time forward. E.g. if the time is dusk and offset is -60, a message will be generated 60 minutes before dusk.
- +ve number delays the time by the specified number of minutes

#### Ramdomisation of times

Both on and off times can be randomised by ticking "Use random time within offset period". For example, if you specify dusk with
and offset of -60 minutes, every day a message will be generated at a random time in a 60 minute window before dusk.

#### Inputs

You can wire inject nodes to the input of this node. To turn on manually, simply send a payload of 'on'. To turn off manually,
send a payload of 'off'. Injecting on or off causes this node emit the configured topic and payload. The manual mode is reset when the next on or off time is reached.
100 changes: 99 additions & 1 deletion index.html
Original file line number Diff line number Diff line change
Expand Up @@ -128,5 +128,103 @@

<script type="text/x-red" data-help-name="schedex">
<h1>SCHEDEX</h1>
<p>Write me</p>
<p>
Scheduler for node-red which allows you to enter on/off times as 24hr clock (e.g. 01:10) or suncalc events (e.g. goldenHour).
It also allows you to offset times and randomise the time within the offset.

Inspired by Pete Scargill's <a href="http://tech.scargill.net/big-timer/">BigTimer</a>
<h2>Times</h2>
</p>
<p>The times can be a 24 hour time or a <a href="https://github.com/mourner/suncalc" target="newWindow">suncalc</a> event:<p>
<table>
<thead>
<tr>
<th>Time</th>
<th>Description</th>
</tr>
</thead>
<tbody>
<tr>
<td><code>00:00 ... 23:59</code></td>
<td>a 24h time</td>
</tr>
<tr>
<td><code>sunrise</code></td>
<td>sunrise (top edge of the sun appears on the horizon)</td>
</tr>
<tr>
<td><code>sunriseEnd</code></td>
<td>sunrise ends (bottom edge of the sun touches the horizon)</td>
</tr>
<tr>
<td><code>goldenHourEnd</code></td>
<td>morning golden hour (soft light, best time for photography) ends</td>
</tr>
<tr>
<td><code>solarNoon</code></td>
<td>solar noon (sun is in the highest position)</td>
</tr>
<tr>
<td><code>goldenHour</code></td>
<td>evening golden hour starts</td>
</tr>
<tr>
<td><code>sunsetStart</code></td>
<td>sunset starts (bottom edge of the sun touches the horizon)</td>
</tr>
<tr>
<td><code>sunset</code></td>
<td>sunset (sun disappears below the horizon, evening civil twilight starts)</td>
</tr>
<tr>
<td><code>dusk</code></td>
<td>dusk (evening nautical twilight starts)</td>
</tr>
<tr>
<td><code>nauticalDusk</code></td>
<td>nautical dusk (evening astronomical twilight starts)</td>
</tr>
<tr>
<td><code>night</code></td>
<td>night starts (dark enough for astronomical observations)</td>
</tr>
<tr>
<td><code>nadir</code></td>
<td>nadir (darkest moment of the night, sun is in the lowest position)</td>
</tr>
<tr>
<td><code>nightEnd</code></td>
<td>night ends (morning astronomical twilight starts)</td>
</tr>
<tr>
<td><code>nauticalDawn</code></td>
<td>nautical dawn (morning nautical twilight starts)</td>
</tr>
<tr>
<td><code>dawn</code></td>
<td>dawn (morning nautical twilight ends, morning civil twilight starts)</td>
</tr>
</tbody>
</table>
<h2>Offsets</h2>
The on and off time can have an offset. This is specified in minutes:
<ul>
<li>-ve number brings the time forward. E.g. if the time is dusk and offset is -60, a message will be generated 60 minutes before dusk.</li>
<li>+ve number delays the time by the specified number of minutes</li>
</ul>
<h2>Randomisation of times</h2>
<p>Both on and off times can be randomised by ticking "Use random time within offset period". For example, if you specify dusk with
and offset of -60 minutes, every day a message will be generated at a random time in a 60 minute window before dusk. </p>
<h2>Inputs</h2>
You can wire inject nodes to the input of this node. To turn on manually, simply send a payload of 'on'. To turn off manually,
send a payload of 'off'. Injecting on or off causes this node emit the configured topic and payload. The manual mode is reset when the next on or off time is reached.

</script>
4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
{
"name": "node-red-contrib-schedex",
"version": "0.4.0",
"version": "0.4.2",
"description": "",
"main": "index.js",
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1"
"test": "mocha -R spec ./tests/test.js"
},
"author": "@biddster",
"license": "MIT",
Expand Down
5 changes: 3 additions & 2 deletions tests/test.js
Original file line number Diff line number Diff line change
Expand Up @@ -75,17 +75,18 @@ var nodeRedModule = require('../index.js');
describe('schedex', function () {
it('should schedule initially', function () {
var node = loadNode({
on: '11:45',
onTime: '11:45',
onTopic: 'on',
onPayload: 'on payload',
off: '11:48',
offTime: '11:48',
offTopic: 'off',
offPayload: 'off payload',
lat: 51.33411,
lon: -0.83716,
unitTest: true
}, nodeRedModule);

// TODO - actually do something here.

// assert.strictEqual(2881, node.messages().length);
});
Expand Down

0 comments on commit c4ac862

Please sign in to comment.