# Lux Input mapped to Brightness Output

**URL:** https://community.homey.app/t/lux-input-mapped-to-brightness-output/108186
**Category:** Flows
**Created:** [April 13, 2024, 8:38pm UTC](https://community.homey.app/t/lux-input-mapped-to-brightness-output/108186 "2024-04-13T20:38:39Z")
**Posts on this page:** 6
**Page:** 1

<div class="post-metadata">

### Author: ![Robert\_Persons](https://sea1.discourse-cdn.com/flex025/user_avatar/community.homey.app/robert_persons/32/80106_2.png) [@Robert\_Persons](https://community.homey.app/u/Robert_Persons)
#### Post date: [April 13, 2024, 8:38pm UTC](https://community.homey.app/t/lux-input-mapped-to-brightness-output/108186/1 "2024-04-13T20:38:40Z")

</div>

I’m trying to find the best way to have a light smoothly brighten and dim based on the ambient light in the room, based on specific input and output ranges. I have searched the forum but haven’t found quite what I’m looking for.

I created a basic flow which does a crude job of it, but lacks precision.

 ![Brightness Shift Flow](https://us1.discourse-cdn.com/flex025/uploads/athom/original/3X/a/f/af4a1abd672e5f0cd55286c16fa3b340e5b631dd.jpeg)

The basic formula I have started with is “1-(luminance \*.36)”

My goal is to achieve something like this:

Input: 10-60 Lux  
Output: 100-0% Brightness.

Does anyone know a way to map a specific input range to a specific output range so it tracks smoothly and predictably? Is there a math expression or app which would do the job?

Thank you!

---

<div class="post-metadata">

### Author: ![Andy\_Henderson](https://sea1.discourse-cdn.com/flex025/user_avatar/community.homey.app/andy_henderson/32/80642_2.png) [@Andy\_Henderson](https://community.homey.app/u/Andy_Henderson)
#### Post date: [April 14, 2024, 12:19pm UTC](https://community.homey.app/t/lux-input-mapped-to-brightness-output/108186/2 "2024-04-14T12:19:53Z")

</div>

The Chronograph app has cards explictly for transitions that might help.

> **[Chronograph](https://homey.app/en-us/app/nl.fellownet.chronograph/Chronograph/)**
>
> Adds precise timer, stopwatch and transition functionality to Homey.

Andy

---

<div class="post-metadata">

### Author: ![Rmb](https://sea1.discourse-cdn.com/flex025/user_avatar/community.homey.app/rmb/32/79135_2.png) [@Rmb](https://community.homey.app/u/Rmb)
#### Post date: [April 14, 2024, 10:12pm UTC](https://community.homey.app/t/lux-input-mapped-to-brightness-output/108186/3 "2024-04-14T22:12:19Z")

</div>

(100-((Luminance-10)/(60-10))x100)%  
When luminance = 10 the formula results in 100%  
When luminance = 60 the formula results in 0%  
When luminance = 35 the formula results in 50%

---

<div class="post-metadata">

### Author: ![Robert\_Persons](https://sea1.discourse-cdn.com/flex025/user_avatar/community.homey.app/robert_persons/32/80106_2.png) [@Robert\_Persons](https://community.homey.app/u/Robert_Persons)
#### Post date: [April 15, 2024, 12:08am UTC](https://community.homey.app/t/lux-input-mapped-to-brightness-output/108186/4 "2024-04-15T00:08:21Z")

</div>

Perfect! That is exactly the kind of solution I was looking for!

The original form wasn’t accepted by the Temporary Variables app, so I tweaked it to make it work. I changed the “x” to an asterisk, and also replaced the “%” with “\*.01”. It works great now!

Thank you so very much for your help Rmb!!

---

<div class="post-metadata">

### Author: ![DirkG](https://sea1.discourse-cdn.com/flex025/user_avatar/community.homey.app/dirkg/32/118897_2.png) [@DirkG](https://community.homey.app/u/DirkG)
#### Post date: [April 15, 2024, 8:03am UTC](https://community.homey.app/t/lux-input-mapped-to-brightness-output/108186/5 "2024-04-15T08:03:21Z")

</div>

According to the name of the devices, it seems that the sensor and the lamp are in the same room, right?

So if the brightness in the living room changes, the brightness of the lamp is adjusted according to the formula. This changes the brightness in the living room again, which causes the brightness of the lamp to change again. And so on…  
Doesn’t this lead to an infinite loop?

---

<div class="post-metadata">

### Author: ![Robert\_Persons](https://sea1.discourse-cdn.com/flex025/user_avatar/community.homey.app/robert_persons/32/80106_2.png) [@Robert\_Persons](https://community.homey.app/u/Robert_Persons)
#### Post date: [April 15, 2024, 1:34pm UTC](https://community.homey.app/t/lux-input-mapped-to-brightness-output/108186/6 "2024-04-15T13:34:57Z")

</div>

The sensor and the lamp are in the same room. However I set it up so that the sensor is pointed away from the lamp, so the sensor is looking at the general room brightness. The lamp is an accent lamp behind my TV, so the two don’t interact.
