Outgoing Value Format with JSON string and reference to 2nd item, possible? [IKEA Dimmer/Color]

Hi all,

I just recently converted all my IKEA TRÅDFRI lights to operate with fading (via z2mqtt).
To do so it is necessary to send the following command string to it: {"brightness":%s,"transition":3}

In above string, brightness is the end brightness level, whereas transition defines the “speed” of transitioning (0 = off, 1 = max speed to n = lowest speed).

I did setup this string in my dimmer item as outgoing value transformation, which works great.

  - id: dimmer
    channelTypeUID: mqtt:dimmer
    label: Dimmer
    description: null
    configuration:
      commandTopic: zigbee2mqtt/IKEA_LED_806_6/set
      step: 10
      min: 0
      formatBeforePublish: '{"brightness":%s,"transition":3}'
      stateTopic: zigbee2mqtt/IKEA_LED_806_6/brightness
      max: 255
Screenshot:

The brightness obviously refers to the received value (%s) already.
Now I am wondering if it is possible to connect the transition value somehow to a 2nd (admin) item, without rules. This would enable me to put this selection on an “admin” page and via UI define the transition speeds. It can be done via rules of course (i.e. the dimmer item informs the rule, the rule then sends the actual command via mqtt) but I was wondering if there is any “non-rule” way.

Thanks!

No, you’ll have to use rules. The Channel can only see the one item it’s linked to.

However it might be possible to access other items from a JS transform. I’ve never tried that before but I know other stuff can be got at there like the log actions. However, that’s not really what transformations are for. But that kind of is what rules are for, coordinating between Items.

1 Like

The rule can also build a complex string and command an MQTT linked tring Item with it.

1 Like

Thanks, I thought so, but hoped it would be different :slight_smile:

ok, might look into that.

Thanks, at the end I guess it would end up being the same outcome and I do not really “need” the string item as it would be just a proxy for what the direct MQTT send via rule would accomplish, or do you see any other benefits?

You don’t need the String item if you use a rule and the publish action. I can’t think of a compelling reason to create one but that doesn’t mean there isn’t one.