Flow help needed with Ikea trådfri devices

Hi, guys (and gals)

I have the following flow in my kitchen. As Homey doesn’t support my Ikea dimmer I wanted to make something that would do the job for a while. Everything seems to work fine (I use the notification to check the variable), but the Ikea lights don’t dim to the set value. Any ideas on what to do? It seems they just turn on, but don’t dim to the set value. They don’t even dim to the previous value (which would indicate some sort of delay somewhere), but always to the last used value.

I’ve also tried setting the device dim level directly, but with the same [lack of] result.

Bug? User fault?

“Dim to” is set in % so I think you need to use 1/100 in Logic.
1% = 0.01
50% = 0.5
100% = 1

1 Like

Thanks, that was it. HOWEVER, now there’s another problem.

I’ve tried “less than 1” (stopped one short), “less than 1.01” (went to 100%) and “not larger than 1” etc. Except for the first, this is what happens when I increment by 0.2.

  • 20%, output “Led set to 0.2”
  • 40%, output “Led set to 0.4”
  • 60%, output “Led set to 0.6”
  • 80%, output “Led set to 0.8”
  • 100%, output “Led set to 1”
  • Turned off, output “Led turned off (1.2)”
  • Still turned off, output “Led set to 0”
  • 20% etc etc

The first statement in the “else” clause is to set the variable to 0.

Turned off, output “Led turned off (1.2)”

This is indeed strange. Could you attach exact flow which produced this output? I suppose the screenshot in the original post is outdated, and I’m pretty sure there are some cards which were not visible during taking a screenshot (maybe https://flow.homey.app/ would be easier to screenshot)

1 Like

image
When you Set Dim to, you don’t have to Turn ON, this are two commands for ON at the same time, this could influence each other. Same for OFF, better remove:
image
and use only:
image

1 Like

I did the turn on, then dim as a test. I’ll post the current flow tabs underneath.

Ok, so I’m checking my variable to see if it’s 1 or higher (which should trigger the ‘turn off’ clause). While it’s from 0.0 to 0.8, this should be true.

The expected result would be, if true the variable is incremented to 0.2-1.0, dimming is done and the variable is output. If false (the variable is already 1), the variable should be set to 0 and the lights turned off. The notification should then tell me that the variable is reset. Next click should be 0, in which the true clause is met again.

This is the output. Note that it’s turning off while the variable is 1, then the true clause is met but the variable doesn’t increment before the next round. It’s almost as if the increment is delayed somehow.

The expected output would be “Led turned off (0)” followed by “Led set to 0.2”. Or am I crazy?

Multiple action cards in a flow are executed in parallel (all at the same time), while you’re assuming that they are executed sequentially (one after the other).

So while the action to increment the variable is started, the action to log the value of the variable is also started. And because the variable hasn’t been incremented yet, it will log the “previous” value.

1 Like

Please read this topic: Concurrency in flows

Generally you cannot assume flow cards will be executed in the order you defined them - if you want a sequence, add a delay between cards.

1 Like

Ok, thanks. I wasn’t aware of that. Guess my inner programmer got the best of me :wink: Thanks, all! :slight_smile:

1 Like

image
You can round the variable to 2 decimals with logic calculate:
image
a setting with more than 2 decimals does mostly not work.
(use your own variable names :wink: )

1 Like

Do you recommend using using Logic over Better Logic? Logic doesn’t seem to be able to get to my variables defined in BL…

round((Set volume-0.01),2) can be used in BetterLogic
Personally don’t use BetterLogic because I don’t need it, so it saves another App.

1 Like