# node-red-contrib-time-controller

> time controller node

Latest version **0.0.17** (published 2021-07-27) · MIT license · 0 weekly downloads

## Install

```sh
npm install node-red-contrib-time-controller
pnpm add node-red-contrib-time-controller
yarn add node-red-contrib-time-controller
bun add node-red-contrib-time-controller
```

## Health

**Score 15/100 (F)** — status: abandoned.

Positive: no vulnerabilities.

Warnings: low downloads; no types; no esm support; pre 1.0.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 0.0.17 |
| Published | 2021-07-27 |
| First published | 2019-09-10 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 3 |
| Unpacked size | 73.3 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 3 |
| Author | @koslo |
| Maintainers | koslo |
| Keywords | node-red, time controller, schedule, scheduler, timer, sun events, fade |

## Links

- npm: https://www.npmjs.com/package/node-red-contrib-time-controller
- Repository: https://github.com/koslo/node-red-contrib-time-controller
- Homepage: https://github.com/koslo/node-red-contrib-time-controller#readme
- Issues: https://github.com/koslo/node-red-contrib-time-controller/issues
- npm.io page: https://npm.io/package/node-red-contrib-time-controller

## Dependencies (3)

- [lodash](https://npm.io/package/lodash.md) ^4.17.21
- [moment](https://npm.io/package/moment.md) ^2.29.1
- [suncalc](https://npm.io/package/suncalc.md) ^1.8.0

## Alternatives

- [async-exit-hook](https://npm.io/package/async-exit-hook.md) — 3.7M weekly downloads
- [evnty](https://npm.io/package/evnty.md) — 7.2K weekly downloads
- [eleventy-plugin-asciidoc](https://npm.io/package/eleventy-plugin-asciidoc.md) — 3.5K weekly downloads
- [@jswork/next-get2get](https://npm.io/package/@jswork/next-get2get.md) — 945 weekly downloads
- [@dashersw/axon](https://npm.io/package/@dashersw/axon.md) — 934 weekly downloads

## Recent versions

- 0.0.17 (latest) — 2021-07-27
- 0.0.16 — 2021-07-26
- 0.0.15 — 2021-07-21
- 0.0.14 — 2021-07-06
- 0.0.12 — 2021-06-28
- 0.0.11 — 2021-06-18
- 0.0.10 — 2021-06-17
- 0.0.9 — 2021-06-16
- 0.0.8 — 2021-06-15
- 0.0.7 — 2021-06-14
- 0.0.5 — 2020-06-20
- 0.0.4 — 2020-04-13
- 0.0.3 — 2019-09-11
- 0.0.2 — 2019-09-10
- 0.0.1 — 2019-09-10

## README

# Time Controller

Time Controller is a node-red node for light controller (or other devices) that can fade the light or color channels in
a specified time range. It is possible to control each channel separately or in rgb mode. It calculates the values
depending on the start and end value and time.   
The input values can be an integer or an array. The range doesn't matter, so it is possible to use percentages or rgb
values or what ever you'd like.

## Configuration

### Data

At the moment Data is defined as an array of objects including the start time and value, the end time and value and the
topic. The values can be an integer or an array of integers. It doesn't matter whether they are percentages or color
values.    
See `example.json` for a full set of a RGBWW controller.

Each object has the following format:

     {
        "start": {
            "time": "06:00:10",
            "value": 0
        },
        "end": {
            "time": "solarNoon",
            "offset": 10,
            "value": 78
        },
        "topic": "rgbw/cmnd/channel1"
    },
    {
       "start": {
           "time": "06:00",
           "value": [80, 50, 10, 100, 100]
       },
       "end": {
           "time": "solarNoon",
           "offset": 10,
           "value": [500, 50, 10, 1, 255]
       },
       "topic": "light-entity"
    }

Example for the home-assistant call service node if the input is defined as array

Data:

    {
        "rgbw_color": [
            "{{payload.0}}",
            "{{payload.1}}",
            "{{payload.2}}",
            "{{payload.3}}"
        ],
        "brightness": "{{payload.4}}"
    }

Or:

    {
        "brightness_pct": "{{payload.0}}",
        "color_temp": "{{payload.1}}"
    }

Entity id:

    {{topic}}

---

| data object    | description                                                                      |
| -------------- | ---------------------------------------------------------------------------------|
| `start.time`   | start time, begin fading, `"hh:mm:ss" or "suncalc event"`                           |
| `start.offset` | start offset in minutes, `integer`                                               |
| `start.value`  | start value, `integer` or `array [red, green, blue, brigthness, ...]`      |
| `end.time`     | end time, stop fading, `"hh:mm:ss" or "suncalc event"`                              |
| `end.offset`   | end offset in minutes, `integer`                                                 |
| `end.value`    | end value, `integer` or `array [red, green, blue, brigthness, ...]`        |
| `topic`        | topic, e.q. a MQTT topic/ command like a channel or the light entity             |

### Interval

The interval in seconds to refresh the topics. Default: `1`

### Latitude and Longitude

The coordinates of the location to calculate the correct sun events.

### Use previous state of event on reload

If enabled then the Time Controller will emit the state of the previous event. Default: `false`

### Output type

If enabled then the input values must be in percentage and will be returned as color value (0 - 255).

### possible suncalc events

https://github.com/mourner/suncalc

| sunclac event    | datetime                 |
| ---------------- | ------------------------ |
| `nadir`          | 2020-04-13T01:14:05.769Z |
| `nightEnd`       | 2020-04-13T04:14:23.086Z |
| `nauticalDawn`   | 2020-04-13T05:02:54.596Z |
| `dawn`           | 2020-04-13T05:46:23.778Z |
| `sunrise`        | 2020-04-13T06:21:37.913Z |
| `sunriseEnd`     | 2020-04-13T06:25:11.302Z |
| `goldenHourEnd`  | 2020-04-13T07:06:30.077Z |
| `solarNoon`      | 2020-04-13T13:14:05.769Z |
| `goldenHour`     | 2020-04-13T19:21:41.462Z |
| `sunsetStart`    | 2020-04-13T20:03:00.236Z |
| `sunset`         | 2020-04-13T20:06:33.626Z |
| `dusk`           | 2020-04-13T20:41:47.761Z |
| `nauticalDusk`   | 2020-04-13T21:25:16.942Z |
| `night`          | 2020-04-13T22:13:48.453Z |

## Inputs

| msg.payload       | description                                       |
| ----------------- | ------------------------------------------------- |
| `"on"`            | start the timecontroller interval                 |
| `"off"`           | stop the timecontroller interval                  |
| `"hh:mm:ss"`      | emit events at given time once without interval   |
| `"suncalc event"` | emit events at given time once without interval   | 

## Programmatic Control

todo

# Coming soon/ Todo

- fullcalendar to define the time events in the frontend
- programmatic control
- instant on/ off events

---
_Source: https://npm.io/package/node-red-contrib-time-controller · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
