question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Dimmable light accessory doesn't turn on

See original GitHub issue

I’m not sure if this is just weirdness in the way my light works, but the dimmable light sends brightness values or off. But if my light is in the off state, it won’t turn on and set the brightness values. It needs to receive an on code and then the brightness code. Here’s the code I changed to make it work:

async setBrightness (hexData) { const { data, host, log } = this; const { off } = data const { on } = data

if (this.brightness > 0) {

  const allHexKeys = Object.keys(data);

  // Create an array of value specified in the data config
  const foundValues = [];

  allHexKeys.forEach((key) => {
    const parts = key.split('brightness');

    if (parts.length !== 2) return;

    foundValues.push(parts[1])
  })

  // Find brightness closest to the one requested
  const closest = foundValues.reduce((prev, curr) => Math.abs(curr - this.brightness) < Math.abs(prev - this.brightness) ? curr : prev);
  log(`setBrightness: (closest: ${closest})`);

  // Get the closest brightness's hex data
  hexData = on;
  sendData({ host, hexData, log });
  hexData = data[`brightness${closest}`];
} else {
  log(`setLightState: off`);

  hexData = off;
}

sendData({ host, hexData, log });

}

Issue Analytics

  • State:closed
  • Created 6 years ago
  • Comments:21 (9 by maintainers)

github_iconTop GitHub Comments

1reaction
Nixontiracommented, Jun 15, 2017

Yes im with Dids! Because there is almost just light accessories with increase and decrease buttons and no specific ones for 25%/50%?and so on. Isn’t there a way to define how many steps the module/controller can go up and down. For example the controller can go 5 stepson different brightness. Then you configure that the Lights turn on to 100%(it sends when you say turn on, one time the turn on code and at least the amount of steps the controller can go up, to make sure its on 100%) and then If you tell the device to dim about 20 percent, it goes down one step(by sending the decrease code). if you tell it to dim 60 % it goes down 3 steps. If you want it to go up it sends the other code(that many times as needed).

I don’t know how hard it is to program that, but would be cool to realize that. And isn’t there a way to choose a specific color? so you can make atleast 4 preprogrammed colors to choose from under the slider of the brightness?

1reaction
Didscommented, Jun 15, 2017

Thought I’d comment here instead of opening a new issue, but what about lights that have a single signal for on/off, while also having 25%/50%/100% brightness levels and having a brightness up/down feature as well? Should I be using both “on” and “off” data, or only one or the other? Or would this not fit my scenario since there’s no way to ensure that the light is on/off?

Also any chance of expanding the light accessory to support increasing/decreasing the brightness?

EDIT: In my case there are 9 steps when adjusting the brightness up/down, 1 being around 1% brightness and 9 being 100% brightness. Technically adding a required stepCount attribute should allow the accessory to set the brightness level based on the current step, right?

Read more comments on GitHub >

github_iconTop Results From Across the Web

Here's an overview of common LED dimming issues and how ...
A common issue with LED dimmability is sudden turn on or turn off when you try to adjust light levels with your dimmer...
Read more >
Dimmer Switch Turns On But Doesn't Dim - LED & Lighting Info
The next most common cause of a dimmer switch failing to work correctly is when it is overloaded.
Read more >
7 Reasons LED Strip Lights May Not Turn On
Another common reason that LED strip light won't turn on is because the wires leading to it are damaged or loose. There's a...
Read more >
My dimmer was working but suddenly stopped working and ...
"My dimmer was working, but suddenly stopped one day. The green indicator lights on the dimmer no longer light up and the dimmer...
Read more >
Fix Dimming LED Lights That Flicker or Wont Turn Off
A fix is to add resistance with a “dummy load” to increase the power consumption. Fibaro sells a “dimmer bypass” which appears to...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found