Announcement

Collapse
No announcement yet.

Control Ikea Tradfri LED light

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

    Control Ikea Tradfri LED light

    I can control the on off state, but how do I control the dim value?

    I think the command is {"state":"ON","brightness":100} to set it to dim level 100. (can be set from 0 to 255)
    I found this information:
    https://www.zigbee2mqtt.io/devices/LED1649C5.html
    I also want to know how I can control the transition.
    Peter

    http://ohh.pcgsm.nl

    #2
    Do you have homeassistant enabled in zigbee2mqtt conf file? If you do then mcsMQTT will know how to setup HS devices for it. If you have not and want to do it, then first obsolete the topics related to this device from either the Association tab O column or General tab Obsolete row in Inbound Management.

    To do it without homeassistant discovery then I expect zigbee2mqtt to have provided a JSON payload that contained brightness and state. Each of these would be Associated to HS devices. The publish topic will be the same as the subscribed topic with a /set suffixed. You likley want a slider for the brightness so use Edit tab to select it to be a slider. Sliders in mcsMQTT have a range of 0 to 100. You will want to use edit tab expression to of $$PAYLOAD:/2.55 and the publish payload template of <<$$VALUE:*2.55>> to get the scaling. Furthermore the payload template will be JSON formatted so it will be {"brightness":<<$$VALUE:*2.55>>}

    If you provide a little more information I can be more specific for your situation.

    Comment


      #3
      I started all over.
      Enabled homeassistant and deleted all HS devices for the led bulb.
      I now have 3 devices (parent, dim level and ON/OFF) and I can set the dim level and control the state.
      Perfect!
      But how can I control the transition?
      Peter

      http://ohh.pcgsm.nl

      Comment


        #4
        That will need to be something that I add such as I did for Hubitat and Shelly control. I found that the Shelly RGBW2 ramped nicely. The Shelly Bulb did not like incremental commands very well. It will be implemented as a ramp rate device and the plugin use this rate to update a calculated value of the next brightness increment.

        For testing to assure this bulb will work as you desire, are you able to setup a HS event that runs every second to increment the brightness device by 1 every second?

        Comment


          #5
          I think the Ikea LED bulb already suports transition:

          Device type specific configuration #


          How to use device type specific configuration
          • transition: Controls the transition time (in seconds) of on/off, brightness, color temperature (if applicable) and color (if applicable) changes. Defaults to 0 (no transition). Note that this value is overridden if a transition value is present in the MQTT command payload.
          see:
          https://www.zigbee2mqtt.io/devices/LED1649C5.html
          Peter

          http://ohh.pcgsm.nl

          Comment


            #6
            This is a preferred method. I have also implemented a transition device in mcsMQTT but have not tested it.

            I am guessing that the JSON key is transition. What you will want to do is add it to the payload template. I do not recall exactly what is in the template now, but assuming it is
            Code:
            {"brightness":$$VALUE:}
            then if you want it to always transition at a given rate of 30 then you would change it to

            Code:
            {"brightness":$$VALUE:,"transition":30}
            I have no insight into the units for the transition so don't know if 30 would be 30 seconds full scale or 30%/minute or ...

            Comment


              #7
              In the payload template is: {"brightness":<<Round(255*$$VALUE:/100,0)>>}
              I changed it to: {"brightness":<<Round(255*$$VALUE:/100,0)>>,"transition":600}
              Transition is in1/10th of a second from 0 to 9000.
              But the transition does not show in zigbee2mqtt:
              zigbee2mqtt:info 2020-06-19 09:20:45: MQTT publish: topic 'zigbee2mqtt/0x14b457fffe49fc5d', payload '{"update_available":false,"state":"ON","brightness":120}'
              Is it possible to make a new device that will only send the transition value of the device to the light?
              The light should stay on the last transition value it has received.
              Peter

              http://ohh.pcgsm.nl

              Comment


                #8
                You can also use the Publist tab and create a publist file with the content as below then use the Execute Publish button.
                Code:
                zigbee2mqtt/0x14b457fffe49fc5d={"transition":600}
                You could also follow the following two steps. Change your template for the topic to below, set the brightness to something from HS.
                Code:
                {"transition":600}
                Change the template back to
                Code:
                {"brightness":<<Round(255*$$VALUE:/100,0)>>}
                Change brightness and see if the transition works.


                Comment


                  #9
                  I have it working!
                  Problem was, that the transition command does not show in the zigbee2mqtt: info window.
                  I use MQTT Explorer now to see the results.
                  The command has to be send with all commands to let it work, no transition command defaults to 0 transition.
                  This is working for the dim command: {"brightness":<<Round(255*$$VALUE:/100,0)>>,"transition":60}
                  This is working for the ON/OFF command: {"state":"$$LABEL:","transition":60}
                  Is it possible to replace the 60 with the value of a device that has the transition value?
                  I made a device with values from 0 to 900, but I don't know how to put the device value in the publish Payload Template.
                  I tried:
                  Code:
                   {"brightness":<<Round(255*$$VALUE:/100,0)>>,"transition": “$$DVR:(9856):”}
                  Where 9856 is the ref of that device, but the result is:
                  {"brightness":82,"transition": “(9856):”}
                  Peter

                  http://ohh.pcgsm.nl

                  Comment


                    #10
                    $$DVR): was only setup for event actions. I do not see any reason why the general substitution could not include these. This would make it easy then for using multiple HS devices in expressions. I will update the plugin to do it.

                    With the version you have now you can create an event on the brightness device changing and then in the event action of send mqtt message you can use the $$DVRxxx): rather than $$VALUE: for the payload you show in post #9. I believe the syntax for the mqtt send message action is topic=payload. Since you do not want to send from both the device change and the event action you would change the publish topic in the Edit tab to some dummy that would not be recognized by the bulb. It will get sent, but not affect anything.

                    Comment


                      #11
                      I added the $$DVR and other event action substitution variables to those that are available for payload and inline expressions. What you posted in #9 should work with http://mcsSprinklers.com/mcsMQTT_5_3_0_0.zip.

                      While you do not need it, I did complete the addition of the Ramp Control/Status UI to this same version. It creates two HS devices where one is the the brightness control and the other is the transition rate specification. The plugin will send out 1% increments at the rate specified.

                      Click image for larger version

Name:	Capture.PNG
Views:	63
Size:	84.2 KB
ID:	1395428

                      Comment


                        #12
                        Installed the update,but output is now:
                        Code:
                         {"brightness":125,"transition":"0DVR:(9856)"}
                        Peter

                        http://ohh.pcgsm.nl

                        Comment


                          #13
                          I did not look close enough at you original expression. No quotes around the DVR element since the result is a number and inline expression less-than and greater-than is needed. Not certain if 100.0 or 100,0 is needed, but starting the expression with a digit will cause the plugin to not get confused with the comma being a separator or a decimal character.
                          Code:
                          {"brightness":<<Round(255*$$VALUE:/100,0)>>,"transition":<<$$DVR:(9856):>>}

                          Comment


                            #14
                            Don't know why it will not work.
                            I use:
                            Code:
                            {"brightness":<<Round(255*$$VALUE:/100,0)>>,"transition":<<$$DVC:(z212):>>}
                            or
                            Code:
                            {"brightness":<<Round(255*$$VALUE:/100,0)>>,"transition":<<$$DVR:(9863):>>}
                            But both give now:
                            Code:
                            {"brightness":61,"transition":}
                            If I try:
                            Code:
                            {"brightness":<<$$DVR:(9863):>>
                            }
                            I get:
                            Code:
                            {"brightness":30}
                            The value of device 9863, so that is ok.
                            Code:
                            {"brightness":<<Round(255*$$VALUE:/100,0)>>,"transition":60}
                            is also still working.
                            Peter

                            http://ohh.pcgsm.nl

                            Comment


                              #15
                              I see the issue. I need to do all substitutions before I do any expressions. The second inline replacement has not yet been substituted when the first inline substitution occurs and evaluation performed.

                              Comment

                              Working...
                              X