f.lux f.lux forum
    • Recent
    • Popular
    • Register
    • Login

    Feature Request: MQTT Support

    Smart Lighting
    4
    6
    3.4k
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • Jensen FongJ
      Jensen Fong
      last edited by

      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

      1 Reply Last reply Reply Quote 2
      • Rafal TrzewikowskiR
        Rafal Trzewikowski
        last edited by

        Awesome suggestion! +1

        1 Reply Last reply Reply Quote 0
        • S
          SubOrbit
          last edited by

          Hey Jensen. Would you be willing to share your PHP code?

          Thanks!

          1 Reply Last reply Reply Quote 0
          • Jensen FongJ
            Jensen Fong
            last edited by

            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

            download linky

            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

            1 Reply Last reply Reply Quote 0
            • A
              alex.
              last edited by

              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".

              A 1 Reply Last reply Reply Quote 0
              • A
                alex. @alex.
                last edited by

                @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.

                1 Reply Last reply Reply Quote 0
                • First post
                  Last post
                Copyright © 2014 NodeBB Forums | Contributors