# Getting the device by its id takes a long time

**URL:** <https://community.homey.app/t/getting-the-device-by-its-id-takes-a-long-time/65621>\
**Category:** Developers\
**Created:** [July 6, 2022, 6:06pm UTC](https://community.homey.app/t/getting-the-device-by-its-id-takes-a-long-time/65621 "2022-07-06T18:06:28Z")\
**Posts on this page:** 6\
**Page:** 2

<div class="post-metadata">

**Author:** ![Articate](https://sea1.discourse-cdn.com/flex025/user_avatar/community.homey.app/articate/32/57311_2.png) [@Articate](https://community.homey.app/u/Articate)\
**Post date:** [July 10, 2022, 9:30pm UTC](https://community.homey.app/t/getting-the-device-by-its-id-takes-a-long-time/65621/21 "2022-07-10T21:30:27Z")

</div>

It might be that we’re talking about this issue to further our understanding of HomeyScript, for which I absolutely support that. However, if we’re concretely discussing how to relatively dim some lights based on input, it feels better to just use flow cards?

 ![relative dim](https://us1.discourse-cdn.com/flex025/uploads/athom/original/3X/9/9/998d59768f088eba547f7e856174787f039e1925.png)

---

<div class="post-metadata">

**Author:** ![Roblof](https://sea1.discourse-cdn.com/flex025/user_avatar/community.homey.app/roblof/32/56492_2.png) [@Roblof](https://community.homey.app/u/Roblof)\
**Post date:** [July 10, 2022, 9:46pm UTC](https://community.homey.app/t/getting-the-device-by-its-id-takes-a-long-time/65621/22 "2022-07-10T21:46:42Z")

</div>

Hi Articate,

In normal cases your card would probably be fine. Since this is about two plafonds with three lamps each my dimming ‘algorithm’ needs to do more than a simple fixed value dimming. The 20% I used was more of a testing value and not evident in my test code above.

Good call though.

---

<div class="post-metadata">

**Author:** ![Articate](https://sea1.discourse-cdn.com/flex025/user_avatar/community.homey.app/articate/32/57311_2.png) [@Articate](https://community.homey.app/u/Articate)\
**Post date:** [July 10, 2022, 9:52pm UTC](https://community.homey.app/t/getting-the-device-by-its-id-takes-a-long-time/65621/23 "2022-07-10T21:52:58Z")

</div>

So you’re going to scale a max dim for each individual plafond or something? Like, that some plafond can go to 100%, but others only to 70%? and then if you dim 20% from 100% that’s 80%, but 20% from 70% would be 56% instead of 50%, is that what you want to achieve?

---

<div class="post-metadata">

**Author:** ![Roblof](https://sea1.discourse-cdn.com/flex025/user_avatar/community.homey.app/roblof/32/56492_2.png) [@Roblof](https://community.homey.app/u/Roblof)\
**Post date:** [July 12, 2022, 12:07pm UTC](https://community.homey.app/t/getting-the-device-by-its-id-takes-a-long-time/65621/24 "2022-07-12T12:07:29Z")

</div>

I need to experiment a bit to see where I will land with how the dimming algorithm will work in the end.

Since each plafond has 3 ikea lamps there is lots of room for how to execute the dimming. In my last dimming step only one of the 3 lamps is lit 5% (ikea lamps turns off lower than that) and that is a perfect level for movie nights or similar where only a guide light is necessary. On the other hand the 3 lamps in the plafond at 100% each serves its purpose as well. Everything between those levels and number of lamps will take some time to figure out since I only want to deal with no more than 4-6 levels to work with.

I have two of these plafonds in my living room but only one is ‘smart’ at the moment and since they each cover half of the room I want to come up with something smart in the end. I’m also considering replacing one of the lamps with its rgbw version to get a bit more variety at night. Time will tell…

---

<div class="post-metadata">

**Author:** ![Peter\_Kawa](https://sea1.discourse-cdn.com/flex025/user_avatar/community.homey.app/peter_kawa/32/173848_2.png) [@Peter\_Kawa](https://community.homey.app/u/Peter_Kawa)\
**Post date:** [July 14, 2022, 2:23pm UTC](https://community.homey.app/t/getting-the-device-by-its-id-takes-a-long-time/65621/25 "2022-07-14T14:23:32Z")

</div>

Hi @Joka  
I just thought of the fact the [Papertrails](https://community.homey.app/t/app-pro-papertrails-log-advanced-logging-and-log-management-v0-6-3/40) app, can log time in ms;  
so no stopwatch or timestamp-script-cards are needed for measuring flowcards or scripts 🙃

 ![Screenshot from 2022-07-14 16-27-36](https://us1.discourse-cdn.com/flex025/uploads/athom/original/3X/2/0/20002de209c2b5ea5e41f5d9ae886d2b84988ead.png)

.  
log:

```auto
2022-07-14 16:04.43.430 TurnLightOn start (script-monitor)
2022-07-14 16:04.43.937 TurnLightOn_FilterDevices - runtime (script-monitor )
2022-07-14 16:04.45.053 TurnLightOn_LoopOverDevices - runtime (script-monitor )

```

---

<div class="post-metadata">

**Author:** ![Joka](https://avatars.discourse-cdn.com/v4/letter/j/7feea3/32.png) [@Joka](https://community.homey.app/u/Joka)\
**Post date:** [July 14, 2022, 5:02pm UTC](https://community.homey.app/t/getting-the-device-by-its-id-takes-a-long-time/65621/26 "2022-07-14T17:02:14Z")

</div>

That’s true but especially for this case I like to get a notification directly with the calculated runtime.

[Previous page](https://community.homey.app/t/getting-the-device-by-its-id-takes-a-long-time/65621.md?page=1)
