Feature Request: MQTT Support
-
It would be great if F.lux can publish color temp and brightness to a MQTT broker/topic so it can be used with pretty much every open home automation platforms current available.
I am currently running Home Assistant to control the Yeelight Ceiling light in my room. Since F.lux can't control this light directly, I customized a php page hosted on an instance of Apache to translate the http posts from f.lux to MQTT messages so Home Assistant can pick it up and change the color temp and brightness accordingly.
Thanks
-
Awesome suggestion! +1
-
Hey Jensen. Would you be willing to share your PHP code?
Thanks!
-
its pretty hacky but it works for me (i tried it on xampp for windows but its currently running on a ubuntu apache + php 7)
you will need to fine tune the variables to the maximum values that your light will support or you can send the raw values from flux to mqtt and handle it from homeassistant or whatever it is you are using...
and you need the phpMQTT library
sensor setup for homeassistant
sensor:- platform: mqtt
state_topic: 'flux/data'
name: 'Flux Status'
value_template: '{{ value_json.fluxstate }}' - platform: mqtt
state_topic: 'flux/data'
name: 'Flux Color Temperature'
value_template: '{{ value_json.colortemp | round(0) }}' - platform: mqtt
state_topic: 'flux/data'
name: 'Flux Brightness'
value_template: '{{ value_json.brightness | round(0) }}' - platform: mqtt
state_topic: 'flux/data'
name: 'Flux Timestamp'
value_template: '{{ value_json.timestamp | timestamp_local }}
input_boolean:
enable_flux:
name: Change Light to Flux Data
initial: on - platform: mqtt
-
Bit late to the party, but I've only just got started with MQTT and automation.
If you're using Node-RED, you can use it to receive the data from f.lux with the built-in nodes.
I was inspired by this reddit thread - https://www.reddit.com/r/tasker/comments/a6q8vl/looking_for_better_mqtt_integration/ejrgl2l/ - which discusses Tasker, but the pertinent information is the post which describes using Node-RED and the "http in" node.
f.lux uses HTTP POST to send "?ct=xxxx&bri=x.xxxxxx" (replacing "x" with appropriate values). For example, "Working Late" sends "?ct=6500&bri=0.800000", while "Cave Painting" sends "?ct=2300&bri=0.800000".
The appropriate Node-RED objects for them are "msg.req.query.ct" and "msg.req.query.bri".
-
@alex said in Feature Request: MQTT Support:
Bit late to the party, but I've only just got started with MQTT and automation.
If you're using Node-RED, you can use it to receive the data from f.lux with the built-in nodes.
I was inspired by this reddit thread - https://www.reddit.com/r/tasker/comments/a6q8vl/looking_for_better_mqtt_integration/ejrgl2l/ - which discusses Tasker, but the pertinent information is the post which describes using Node-RED and the "http in" node.
f.lux uses HTTP POST to send "?ct=xxxx&bri=x.xxxxxx" (replacing "x" with appropriate values). For example, "Working Late" sends "?ct=6500&bri=0.800000", while "Cave Painting" sends "?ct=2300&bri=0.800000".
The appropriate Node-RED objects for them are "msg.req.query.ct" and "msg.req.query.bri".
Looks like the "bri" values are computer-dependent. One of my computers sends "0.800000", but the one next to it sends "0.275000". Still, Node-RED captures both quite happily.