I can give a small summary what I did, maybe it will help you to achieve your goal.
1 - I made a mqtt virtual light device using Node-Red:
- The delete-inject-node is an string with no content (empty).
- The config-function node contains:
var logTimeStamp = global.get('logTimeStamp')||"No Timestamp";
var _topic = "homeassistant/light/circadian";
var _qos = 2;
var _retain = true;
var _payload = {
"name": "Mqtt Circadian",
"unique_id": "mqtt_circadian",
"command_topic": _topic + "/set",
"brightness_command_topic": _topic + "/brightness",
"rgb_command_topic": _topic + "/rgb_color",
"device": {
"name": "Mqtt Circadian",
"manufacturer": "MQTT Hass.io",
"model": "Custom",
"identifiers": ["Mqtt Circadian"],
"sw_version": "20191219"
}
};
if (msg.payload === '' ){
node.status({fill:"red",shape:"dot",text: logTimeStamp + " " + _topic});
_topic = _topic + "/config";
_qos = 0;
_retain = false;
_payload = '';
} else {
node.status({fill:"green",shape:"dot",text: logTimeStamp + " " + _topic});
_topic = _topic + "/config";
}
var message = {
topic: _topic,
qos: _qos,
retain: _retain,
payload: _payload
};
return message;
note: the global “logTimeStamp” is my custom global variable to show the activated timestamp with clock-symbol in front.
2 - Configured Circadian to use this device in the HA yaml files:
added in configuration.yaml:
# 20191219 Circadian Lighting
# https://github.com/claytonjn/hass-circadian_lighting
# https://community.home-assistant.io/t/circadian-lighting-custom-component
circadian_lighting:
#interval: 60
min_colortemp: 1500
max_colortemp: 4500
Added in switch.yaml:
# 20191219 Circadian Lighting
# https://github.com/claytonjn/hass-circadian_lighting
# https://community.home-assistant.io/t/circadian-lighting-custom-component
- platform: circadian_lighting
min_brightness: 25
lights_rgb:
- light.mqtt_circadian
Now you have a virtual light device (light.mqtt_circadian) you can extract values from.
3 - Then I made a Node-Red flow to get the values the way I want:
[{"id":"a54920fd.059e78","type":"debug","z":"c1caafea.2479e8","name":"= on & rgb","active":false,"tosidebar":true,"console":false,"tostatus":false,"complete":"true","targetType":"full","x":650,"y":200,"wires":[]},{"id":"f8dacc2.21831b","type":"server-state-changed","z":"c1caafea.2479e8","name":"mqtt_circadian (on)","server":"2b4c77a9.ef4658","version":1,"exposeToHomeAssistant":false,"haConfig":[{"property":"name","value":""},{"property":"icon","value":""}],"entityidfilter":"light.mqtt_circadian","entityidfiltertype":"substring","outputinitially":false,"state_type":"str","haltifstate":"on","halt_if_type":"str","halt_if_compare":"is","outputs":2,"output_only_on_state_change":false,"x":130,"y":120,"wires":[["138f337b.088965","1cee51b5.ff36ae","94eff5ea.4a4c28"],[]]},{"id":"9c529ec5.e94a68","type":"comment","z":"c1caafea.2479e8","name":"Circadian Light control","info":"","x":140,"y":40,"wires":[]},{"id":"29a1da35.34e5f6","type":"comment","z":"c1caafea.2479e8","name":"Get Circadian values on change","info":"","x":230,"y":80,"wires":[]},{"id":"138f337b.088965","type":"debug","z":"c1caafea.2479e8","name":"= on","active":false,"tosidebar":true,"console":false,"tostatus":false,"complete":"true","targetType":"full","x":670,"y":120,"wires":[]},{"id":"c8a7bc2e.ed474","type":"switch","z":"c1caafea.2479e8","name":"not null","property":"payload","propertyType":"msg","rules":[{"t":"nnull"}],"checkall":"true","repair":false,"outputs":1,"x":460,"y":360,"wires":[["c18d0ad7.2d2c98","39b58418.57e244"]]},{"id":"c18d0ad7.2d2c98","type":"debug","z":"c1caafea.2479e8","name":"= on & brightness","active":false,"tosidebar":true,"console":false,"tostatus":false,"complete":"true","targetType":"full","x":630,"y":320,"wires":[]},{"id":"1cee51b5.ff36ae","type":"rbe","z":"c1caafea.2479e8","name":"on change","func":"rbe","gap":"","start":"","inout":"out","property":"data.new_state.attributes.rgb_color","x":130,"y":240,"wires":[["acc025c7.578b7"]]},{"id":"94eff5ea.4a4c28","type":"rbe","z":"c1caafea.2479e8","name":"on change","func":"rbe","gap":"","start":"","inout":"out","property":"data.new_state.attributes.brightness","x":130,"y":360,"wires":[["1fa91aa6.0c1ad5"]]},{"id":"acc025c7.578b7","type":"change","z":"c1caafea.2479e8","name":"Only RGB","rules":[{"t":"set","p":"payload","pt":"msg","to":"data.new_state.attributes.rgb_color","tot":"msg"}],"action":"","property":"","from":"","to":"","reg":false,"x":280,"y":240,"wires":[["15a6bb4f.90eb7d"]]},{"id":"1fa91aa6.0c1ad5","type":"change","z":"c1caafea.2479e8","name":"Only Brighness","rules":[{"t":"set","p":"payload","pt":"msg","to":"data.new_state.attributes.brightness","tot":"msg"}],"action":"","property":"","from":"","to":"","reg":false,"x":300,"y":360,"wires":[["c8a7bc2e.ed474"]]},{"id":"15a6bb4f.90eb7d","type":"switch","z":"c1caafea.2479e8","name":"not null","property":"payload","propertyType":"msg","rules":[{"t":"nnull"}],"checkall":"true","repair":false,"outputs":1,"x":460,"y":240,"wires":[["a54920fd.059e78","4dc2f54f.04599c"]]},{"id":"4dc2f54f.04599c","type":"link out","z":"c1caafea.2479e8","name":"lightContol - carcadianRGB","links":["e5aab1da.47c5e8","1f73084e.291218","8cf87d51.f3145"],"x":595,"y":240,"wires":[]},{"id":"39b58418.57e244","type":"link out","z":"c1caafea.2479e8","name":"lightContol - carcadianBrightness","links":["6e8ef7da.63df1","d15b5ae1.4ac448","f2cf2119.21b498","ebd785f0.9ded38","ee88905e.b8682"],"x":595,"y":360,"wires":[]},{"id":"392fb5e1.4908d2","type":"comment","z":"c1caafea.2479e8","name":"Set Circadian values to Globals","info":"","x":230,"y":420,"wires":[]},{"id":"e5aab1da.47c5e8","type":"link in","z":"c1caafea.2479e8","name":"lightControl - to_global.circadianRGB","links":["4dc2f54f.04599c"],"x":115,"y":460,"wires":[["557ec9c3.feddc"]]},{"id":"557ec9c3.feddc","type":"change","z":"c1caafea.2479e8","name":"RGB to global.circadianRGB","rules":[{"t":"set","p":"circadianRGB","pt":"global","to":"payload","tot":"msg"}],"action":"","property":"","from":"","to":"","reg":false,"x":320,"y":460,"wires":[[]]},{"id":"6e8ef7da.63df1","type":"link in","z":"c1caafea.2479e8","name":"lightControl - to_global.circadianBrightness","links":["39b58418.57e244"],"x":115,"y":500,"wires":[["32235da8.90f642"]]},{"id":"32235da8.90f642","type":"change","z":"c1caafea.2479e8","name":"brightness to global.circadianBrighness","rules":[{"t":"set","p":"circadianBrighness","pt":"global","to":"payload","tot":"msg"}],"action":"","property":"","from":"","to":"","reg":false,"x":360,"y":500,"wires":[[]]},{"id":"2b4c77a9.ef4658","type":"server","z":"","name":"hassio.myowndomain","legacy":false,"hassio":true,"rejectUnauthorizedCerts":true,"ha_boolean":"y|yes|true|on|home|open","connectionDelay":true}]
P.S. I didn’t use the Brightness- and RGB-level values Node Red global variables, this is for future purpose.
4 I Used the extracted values to control my light(s):
Adjust RGB call service node data:
{"rgb_color": [{{payload}}]}
note: be aware of the square-brackets!
Adjust Brightness call service node data:
{"brightness": {{payload}}}
Note: wait for the values to be updated for the first time, in my example this is 5 minutes!
Edit: Example of Node-Red UI output I used to monitor:
I hope this will help you out to get your config working!