Scrounger / ioBroker.linkeddevices

Create linked objects (datapoints) of your devices with a self-defined structure. This makes it possible to create a structure in ioBroker, where all objects are centralized, e.g. to be used in the vis or scripts.
https://forum.iobroker.net/topic/22301/neuer-adapter-linkeddevices
MIT License
17 stars 11 forks source link

Number conversion for hue lights doesn't work as expected #60

Closed cored0wn closed 3 years ago

cored0wn commented 3 years ago

Describe the bug
I created a linked device for my hue lights as described in your documentation. When I change the value of an hue light bulb in the hue adapter it works fine, but when I change the value of the brightness in your adapter to 45 for example the conversion (*100/255) produces 114.75. But this value won't be accepted by bulb because of its decimal places.

To Reproduce
Steps to reproduce the behavior:

  1. Go to 'linkeddevices.0.Licht.Wohnzimmer.Kugel_Licht', which is my linkeddevices node for my light bulb
  2. Change value to '45'
  3. Scroll down to 'hue-extended.0.lights.045-kugel_weis_wohnzimmer.action.brightness'
  4. See error (value '114.75')

Expected behavior
The adapter should remove the decimal places on both sides, as far as it is configured. Additionally an option "Convert according to function" would be useful.

Versions:

cored0wn commented 3 years ago

I found the relevant code line: https://github.com/Scrounger/ioBroker.linkeddevices/blob/ad3f593cfd2c5a43ca8df3de69a8ef18876fd290/main.js#L1469

I'm not sure why you check if its the parent object value which will be changed. But if there's no reason for this you could easily remove this part from the condition and fix the issue.

Scrounger commented 3 years ago

But this value won't be accepted by bulb because of its decimal places.

Which Adapter sends the values to the bulb? At my point of view, this should be handled by the adapter it self. If the user input is not correct for exampl decimal places are wrong, the adapter should convert this value to a value that can handled by the devices. So please write an issue for the corresponding adapter.

I found the relevant code line:

https://github.com/Scrounger/ioBroker.linkeddevices/blob/ad3f593cfd2c5a43ca8df3de69a8ef18876fd290/main.js#L1469

I'm not sure why you check if its the parent object value which will be changed. But if there's no reason for this you could easily remove this part from the condition and fix the issue.

Reason is that the max decimal plaes only applies to the linked object. All settings are only for the linked objects. Parent objects will never be affected by the adapter - this is the concept.