One of the last missing functions for me to switch completely to Node-RED is the ability to gradually increase or decrease color temperature (CT). I make use of this extensively in the CT bulbs in my nightstand lamp - gradually increasing the CT from 2000-4000K makes it easier for me to wakeup; conversely, a gradual decrease from 3500-2000K makes me feel sleepy.
Thanks to @stephen_nutt pointing out the range node, I was able to create a sequence that can be used to gradually increase or decrease CT (or anything else that is desired).
Here's an example of a sequence that does exactly that - gradually raising a lamp from 2000K to 4000K over 450 secs
In addition to the standard palette, this sequence uses a loop-timer (node-red-contrib-looptimer or node-red-contrib-looptimer2 - either work) and a counter (node-red-contrib-counter).
In this sequence, I've used the range node to map the values of 0-99 to 2000-4000, which are passed along as color temperature arguments to the bulb. The loop timer causes this value to increase every 5 seconds.
In the event others should find this useful, here's the sequence:
Sequentially increase/decrease color temperature (or any other value)
[
{
"id": "eec02883.a6e538",
"type": "range",
"z": "1e432849.642ac",
"minin": "1",
"maxin": "99",
"minout": "2000",
"maxout": "4000",
"action": "roll",
"round": true,
"property": "count",
"name": "",
"x": 959,
"y": 1360,
"wires": [
[
"d6ae1dde.3d1b"
]
]
},
{
"id": "b8ceb483.bc902",
"type": "counter",
"z": "1e432849.642ac",
"name": "0-99",
"init": "0",
"step": "1",
"lower": "0",
"upper": "99",
"mode": "increment",
"outputs": "1",
"x": 810,
"y": 1360,
"wires": [
[
"eec02883.a6e538"
]
]
},
{
"id": "d6ae1dde.3d1b",
"type": "change",
"z": "1e432849.642ac",
"name": "msg.arguments",
"rules": [
{
"t": "set",
"p": "arguments",
"pt": "msg",
"to": "count",
"tot": "msg"
}
],
"action": "",
"property": "",
"from": "",
"to": "",
"reg": false,
"x": 1140,
"y": 1360,
"wires": [
[
"11292ede.45cd51"
]
]
},
{
"id": "567b3b.06123cc4",
"type": "change",
"z": "1e432849.642ac",
"name": "increment (1)",
"rules": [
{
"t": "set",
"p": "increment",
"pt": "msg",
"to": "1",
"tot": "num"
}
],
"action": "",
"property": "",
"from": "",
"to": "",
"reg": false,
"x": 650,
"y": 1320,
"wires": [
[
"b8ceb483.bc902"
]
]
},
{
"id": "399dcb19.3a8e3c",
"type": "change",
"z": "1e432849.642ac",
"name": "reset (0)",
"rules": [
{
"t": "set",
"p": "reset",
"pt": "msg",
"to": "0",
"tot": "str"
}
],
"action": "",
"property": "",
"from": "",
"to": "",
"reg": false,
"x": 651,
"y": 1400,
"wires": [
[
"b8ceb483.bc902"
]
]
},
{
"id": "11292ede.45cd51",
"type": "hubitat command",
"z": "1e432849.642ac",
"name": "Cat Light",
"server": "a22e0ea9.276dc8",
"deviceId": "1478",
"command": "setColorTemperature",
"commandArgs": "msg.arguments",
"x": 1180,
"y": 1420,
"wires": [
[]
]
},
{
"id": "22b963e2.d3a73c",
"type": "looptimer2",
"z": "1e432849.642ac",
"duration": "5",
"units": "Second",
"maxloops": "90",
"maxtimeout": "1",
"maxtimeoutunits": "Hour",
"name": "90 loops (5s)",
"x": 450,
"y": 1360,
"wires": [
[
"567b3b.06123cc4"
],
[
"399dcb19.3a8e3c"
]
]
},
{
"id": "bf0e54d4.034eb8",
"type": "change",
"z": "1e432849.642ac",
"name": "msg.count = 0",
"rules": [
{
"t": "delete",
"p": "payload",
"pt": "msg"
},
{
"t": "set",
"p": "count",
"pt": "msg",
"to": "0",
"tot": "str"
}
],
"action": "",
"property": "",
"from": "",
"to": "",
"reg": false,
"x": 260,
"y": 1360,
"wires": [
[
"22b963e2.d3a73c"
]
]
},
{
"id": "4089ffa7.50a578",
"type": "switch",
"z": "1e432849.642ac",
"name": "on",
"property": "payload.value",
"propertyType": "msg",
"rules": [
{
"t": "eq",
"v": "on",
"vt": "str"
}
],
"checkall": "true",
"repair": false,
"outputs": 1,
"x": 230,
"y": 1420,
"wires": [
[
"bf0e54d4.034eb8"
]
]
},
{
"id": "401896a.ad99568",
"type": "hubitat device",
"z": "1e432849.642ac",
"name": "Cat Light",
"server": "a22e0ea9.276dc8",
"deviceId": "1478",
"attribute": "switch",
"sendEvent": true,
"x": 80,
"y": 1420,
"wires": [
[
"4089ffa7.50a578"
]
]
},
{
"id": "a22e0ea9.276dc8",
"type": "hubitat config",
"z": "",
"name": "HubitatM",
"usetls": false,
"host": "192.168.1.46",
"port": "80",
"token": "496f7f11-256d-44c9-99c6-4ed460d3efb0",
"appId": "1522",
"nodeRedServer": "http://192.168.1.4:1880",
"webhookPath": "/hubitat/webhook"
}
]
Edit: for s & g, here's a single sequence that simultaneously adjusts the CT and the level:
Adjust CT and level
[
{
"id": "22b963e2.d3a73c",
"type": "looptimer2",
"z": "1e432849.642ac",
"duration": "5",
"units": "Second",
"maxloops": "90",
"maxtimeout": "1",
"maxtimeoutunits": "Hour",
"name": "90 loops (5s)",
"x": 450,
"y": 1420,
"wires": [
[
"567b3b.06123cc4"
],
[
"399dcb19.3a8e3c"
]
]
},
{
"id": "567b3b.06123cc4",
"type": "change",
"z": "1e432849.642ac",
"name": "increment (1)",
"rules": [
{
"t": "set",
"p": "increment",
"pt": "msg",
"to": "1",
"tot": "num"
}
],
"action": "",
"property": "",
"from": "",
"to": "",
"reg": false,
"x": 650,
"y": 1380,
"wires": [
[
"b8ceb483.bc902"
]
]
},
{
"id": "399dcb19.3a8e3c",
"type": "change",
"z": "1e432849.642ac",
"name": "reset (0)",
"rules": [
{
"t": "set",
"p": "reset",
"pt": "msg",
"to": "0",
"tot": "str"
}
],
"action": "",
"property": "",
"from": "",
"to": "",
"reg": false,
"x": 651,
"y": 1460,
"wires": [
[
"b8ceb483.bc902"
]
]
},
{
"id": "bf0e54d4.034eb8",
"type": "change",
"z": "1e432849.642ac",
"name": "msg.count = 0",
"rules": [
{
"t": "delete",
"p": "payload",
"pt": "msg"
},
{
"t": "set",
"p": "count",
"pt": "msg",
"to": "0",
"tot": "str"
}
],
"action": "",
"property": "",
"from": "",
"to": "",
"reg": false,
"x": 260,
"y": 1420,
"wires": [
[
"22b963e2.d3a73c"
]
]
},
{
"id": "b8ceb483.bc902",
"type": "counter",
"z": "1e432849.642ac",
"name": "0-99",
"init": "0",
"step": "1",
"lower": "0",
"upper": "99",
"mode": "increment",
"outputs": "1",
"x": 810,
"y": 1420,
"wires": [
[
"eec02883.a6e538",
"9ad48a0e.d99d68"
]
]
},
{
"id": "4089ffa7.50a578",
"type": "switch",
"z": "1e432849.642ac",
"name": "on",
"property": "payload.value",
"propertyType": "msg",
"rules": [
{
"t": "eq",
"v": "on",
"vt": "str"
}
],
"checkall": "true",
"repair": false,
"outputs": 1,
"x": 230,
"y": 1480,
"wires": [
[
"bf0e54d4.034eb8"
]
]
},
{
"id": "eec02883.a6e538",
"type": "range",
"z": "1e432849.642ac",
"minin": "1",
"maxin": "99",
"minout": "2000",
"maxout": "4000",
"action": "roll",
"round": true,
"property": "count",
"name": "",
"x": 959,
"y": 1380,
"wires": [
[
"d6ae1dde.3d1b"
]
]
},
{
"id": "9ad48a0e.d99d68",
"type": "range",
"z": "1e432849.642ac",
"minin": "1",
"maxin": "99",
"minout": "1",
"maxout": "100",
"action": "roll",
"round": true,
"property": "count",
"name": "",
"x": 949,
"y": 1460,
"wires": [
[
"802bd5c5.97bbd"
]
]
},
{
"id": "401896a.ad99568",
"type": "hubitat device",
"z": "1e432849.642ac",
"name": "Cat Light",
"server": "a22e0ea9.276dc8",
"deviceId": "1478",
"attribute": "switch",
"sendEvent": true,
"x": 80,
"y": 1480,
"wires": [
[
"4089ffa7.50a578"
]
]
},
{
"id": "d6ae1dde.3d1b",
"type": "change",
"z": "1e432849.642ac",
"name": "msg.arguments",
"rules": [
{
"t": "set",
"p": "arguments",
"pt": "msg",
"to": "count",
"tot": "msg"
}
],
"action": "",
"property": "",
"from": "",
"to": "",
"reg": false,
"x": 1140,
"y": 1380,
"wires": [
[
"11292ede.45cd51"
]
]
},
{
"id": "802bd5c5.97bbd",
"type": "change",
"z": "1e432849.642ac",
"name": "msg.arguments",
"rules": [
{
"t": "set",
"p": "arguments",
"pt": "msg",
"to": "count",
"tot": "msg"
}
],
"action": "",
"property": "",
"from": "",
"to": "",
"reg": false,
"x": 1140,
"y": 1460,
"wires": [
[
"687a0c3e.1c29ac"
]
]
},
{
"id": "11292ede.45cd51",
"type": "hubitat command",
"z": "1e432849.642ac",
"name": "Cat Light CT",
"server": "a22e0ea9.276dc8",
"deviceId": "1478",
"command": "setColorTemperature",
"commandArgs": "msg.arguments",
"x": 1190,
"y": 1320,
"wires": [
[]
]
},
{
"id": "687a0c3e.1c29ac",
"type": "hubitat command",
"z": "1e432849.642ac",
"name": "Cat Light LVL",
"server": "a22e0ea9.276dc8",
"deviceId": "1478",
"command": "setLevel",
"commandArgs": "msg.arguments",
"x": 1200,
"y": 1520,
"wires": [
[]
]
},
{
"id": "a22e0ea9.276dc8",
"type": "hubitat config",
"z": "",
"name": "HubitatM",
"usetls": false,
"host": "192.168.1.46",
"port": "80",
"token": "496f7f11-256d-44c9-99c6-4ed460d3efb0",
"appId": "1522",
"nodeRedServer": "http://192.168.1.4:1880",
"webhookPath": "/hubitat/webhook"
}
]