mjwwit / node-red-contrib-ikea-tradfri

Node-RED nodes to get updates from and control devices connected to an IKEA TRADFRI gateway
3 stars 3 forks source link

brightness with decimal point not accepted #26

Closed Jan21493 closed 1 year ago

Jan21493 commented 2 years ago

Hi again, when I get brightness from a lamp via tradfri-monitor, I get something like {...,"colorTemperature":95.6,"dimmer":0.4, ...} but I have to send brightness as an integer value back to the lamp. This may restrict the range from 254 values (0..254) used by IKEA lights internally to only 100 values (0..100%) in tradfri-light-control node, see types.ts line 15 and tradfri-light-control.ts, line 15 as well.

Without further correction, rounding of 0.4 (brightness/dimmer for IKEA lights internally when fully dimmed down after converting 1/254*100) would be 0 and then the lights are out. I propose to modify the code to allow a "float" instead of an integer. For colorTemperature, decimal points are allowed and don't throw an error during validation.

mjwwit commented 2 years ago

You're right. There's 2 possible solutions here:

  1. I can check if the library I use also accepts floating point numbers
  2. The library has an option to use raw values only, but this also has consequences for other values (such as color temperature). This allows you to specify the the raw brightness, 0..254.

I'll first build a test version for the first solution, since it's the easiest to implement and doesn't affect anything else. Would you be willing to test this version?

mjwwit commented 2 years ago

I've just released 0.6.1-beta.1 under the beta tag. I think you'll have to install it manually.

mjwwit commented 1 year ago

Closing due to inactivity