athombv / homey-apps-sdk-issues

This issue tracker is for Homey Developers using the Apps SDK.
20 stars 4 forks source link

setCapabilityOptions fails to correctly set min #348

Open gslender opened 1 month ago

gslender commented 1 month ago

I'm seeing odd behaviour when setting the min dim value via setCapabilityOptions.

When using that, it seems to allow the lowest value to go negative when you slide down the minimum value. This is in the mobile iOS app.

I'm doing this at device init after interogating the device to confirm what value it should be for min for a light dimmer.

gslender commented 3 weeks ago

For example... I'm seeing this after setting the min/max values and not sure if that's expected or if there is something I'm doing wrong in how this is supposed to work - any example that test/shows it working as designed??

IMG_B24D6B444ABA-1

gslender commented 3 weeks ago

This example is when the following code is set to the device...

await _device.setCapabilityOptions("dim", { min: 0.04, max:1 });

I would expect that this would set the slider to go between 4% and 100%... but I get this instead !??

IMG_63C3F6D0DEFB-1

regnerus commented 3 weeks ago

Hi @gslender thanks for reporting this issue. We've recently made some changes to the slider component, could you verify if this is still an issue in te latest release 8.2.2?

gslender commented 3 weeks ago

These screenshots were using the latest TestFlight version 8.2.2 build 1502

gslender commented 3 weeks ago

Also, what's the expected behaviour in the web app?

gslender commented 3 weeks ago

Another unexpected bug (or perhaps lack of documentation) is that if you use code such as

await _device.setCapabilityOptions("dim", { min: 0.04 });

You end up having other default values assigned (like 100 for max, step of 1 etc) which causes other problems. So the only fully correct way that you seem to be able to pass in the correct setCapabilityOptions is to provide the entire options of everything you anticipate might be needed to be set such as...

await _device.setCapabilityOptions("dim", {
            "min": 0.04,
            "max": 1,
            "decimals": 2,
            "step": 0.01,
            "opts": {
              "duration": true
            }
          });
regnerus commented 2 weeks ago

Thanks for reporting, I will try to reproduce in the mobile app.