Jump to content

Welcome to Smart Home Forum by FIBARO

Dear Guest,

 

as you can notice parts of Smart Home Forum by FIBARO is not available for you. You have to register in order to view all content and post in our community. Don't worry! Registration is a simple free process that requires minimal information for you to sign up. Become a part of of Smart Home Forum by FIBARO by creating an account.

 

As a member you can:

  •     Start new topics and reply to others
  •     Follow topics and users to get email updates
  •     Get your own profile page and make new friends
  •     Send personal messages
  •     ... and learn a lot about our system!

 

Regards,

Smart Home Forum by FIBARO Team


  • 0

Problems with Sliders, Specifically "setSlider"


Question

As has been re-iterated many many times on this forum, there are two methods of updating a slider in a virtual device from a scene or another VD:

  1. Using fibaro:call(device, "setProperty", "ui.sliderX,value", value) causes the numerical value of the slider to be updated, but not the length of the slider bar. Neither does it execute the code behind the slider. 
  2. Using fibaro:call(device, "setSlider", X, value) causes the numerical value and the length of the slider to be updated,, and executes the code behind the slider.

In both cases, "device" is the ID number of the VD,  "X" is the slider reverence number and "value" is the new slider value (0-100). Generall, option 2 is preferred because everything is updated. However, there seems to be an issue if the VD has more that nine sliders. Executing a few lines of test code for each of the methods illustrates this.

 

First, method 1. Executing this code:

 

local device = fibaro:getSelfId()
local sliderString1
local sliderString2
local numSliders = 13
 
fibaro:debug('-----------------------------------------------------------')
fibaro:debug('--Set Sliders----------------------------------------------')
for i = 1, numSliders do
    sliderString1 = ('ui.Slider' .. tostring(i) .. '.value')
    fibaro:call(device, "setProperty", sliderString1, tostring(i))
       fibaro:debug('Slider ' .. tostring(i) .. ' = ' .. tostring(i))
end
fibaro:debug('--Read Sliders---------------------------------------------')
for i = 1, numSliders do
    sliderString1 = ('ui.Slider' .. tostring(i) .. '.value')
    sliderString2 = fibaro:getValue(device, sliderString1)
    fibaro:debug(device .. ', ' .. sliderString1 .. ' = ' .. sliderString2)
end

 

Gives:


[DEBUG] 16:21:04: --Set Sliders----------------------------------------------
[DEBUG] 16:21:04: Slider 1 = 1
[DEBUG] 16:21:05: Slider 2 = 2
[DEBUG] 16:21:05: Slider 3 = 3
[DEBUG] 16:21:05: Slider 4 = 4
[DEBUG] 16:21:05: Slider 5 = 5
[DEBUG] 16:21:05: Slider 6 = 6
[DEBUG] 16:21:05: Slider 7 = 7
[DEBUG] 16:21:05: Slider 8 = 8
[DEBUG] 16:21:05: Slider 9 = 9
[DEBUG] 16:21:05: Slider 10 = 10
[DEBUG] 16:21:05: Slider 11 = 11
[DEBUG] 16:21:05: Slider 12 = 12
[DEBUG] 16:21:05: Slider 13 = 13
[DEBUG] 16:21:05: --Read Sliders---------------------------------------------
[DEBUG] 16:21:05: 1044, ui.Slider1.value = 1
[DEBUG] 16:21:05: 1044, ui.Slider2.value = 2
[DEBUG] 16:21:05: 1044, ui.Slider3.value = 3
[DEBUG] 16:21:05: 1044, ui.Slider4.value = 4
[DEBUG] 16:21:05: 1044, ui.Slider5.value = 5
[DEBUG] 16:21:05: 1044, ui.Slider6.value = 6
[DEBUG] 16:21:05: 1044, ui.Slider7.value = 7
[DEBUG] 16:21:05: 1044, ui.Slider8.value = 8
[DEBUG] 16:21:05: 1044, ui.Slider9.value = 9
[DEBUG] 16:21:05: 1044, ui.Slider10.value = 10
[DEBUG] 16:21:05: 1044, ui.Slider11.value = 11
[DEBUG] 16:21:05: 1044, ui.Slider12.value = 12
[DEBUG] 16:21:05: 1044, ui.Slider13.value = 13

 

As would be expected. However executing a code snippet using method 2, like this:

 

local device = fibaro:getSelfId()
local sliderString1
local sliderString2
local numSliders = 13
  
fibaro:debug('-----------------------------------------------------------')
fibaro:debug('--Set Sliders----------------------------------------------')
for i = 1, numSliders do
      fibaro:call(device, "setSlider", tostring(i), tostring(i))
       fibaro:debug('Slider ' .. tostring(i) .. ' = ' .. tostring(i))
end
fibaro:debug('--Read Sliders---------------------------------------------')
for i = 1, numSliders do
    sliderString1 = ('ui.Slider' .. tostring(i) .. '.value')
    sliderString2 = fibaro:getValue(device, sliderString1)
    fibaro:debug(device .. ', ' .. sliderString1 .. ' = ' .. sliderString2)
end

 

Give this:

 

[DEBUG] 16:43:02: --Set Sliders----------------------------------------------
[DEBUG] 16:43:02: Slider 1 = 1
[DEBUG] 16:43:02: Slider 2 = 2
[DEBUG] 16:43:02: Slider 3 = 3
[DEBUG] 16:43:02: Slider 4 = 4
[DEBUG] 16:43:02: Slider 5 = 5
[DEBUG] 16:43:02: Slider 6 = 6
[DEBUG] 16:43:02: Slider 7 = 7
[DEBUG] 16:43:02: Slider 8 = 8
[DEBUG] 16:43:02: Slider 9 = 9
[DEBUG] 16:43:03: Slider 10 = 10
[DEBUG] 16:43:03: Slider 11 = 11
[DEBUG] 16:43:04: Slider 12 = 12
[DEBUG] 16:43:04: Slider 13 = 13
[DEBUG] 16:43:04: --Read Sliders---------------------------------------------
[DEBUG] 16:43:04: 1044, ui.Slider1.value = 10
[DEBUG] 16:43:04: 1044, ui.Slider2.value = 11
[DEBUG] 16:43:04: 1044, ui.Slider3.value = 12
[DEBUG] 16:43:04: 1044, ui.Slider4.value = 13
[DEBUG] 16:43:04: 1044, ui.Slider5.value = 5
[DEBUG] 16:43:04: 1044, ui.Slider6.value = 6
[DEBUG] 16:43:04: 1044, ui.Slider7.value = 7
[DEBUG] 16:43:04: 1044, ui.Slider8.value = 8
[DEBUG] 16:43:04: 1044, ui.Slider9.value = 9
[DEBUG] 16:43:04: 1044, ui.Slider10.value = 10
[DEBUG] 16:43:04: 1044, ui.Slider11.value = 11
[DEBUG] 16:43:04: 1044, ui.Slider12.value = 12
[DEBUG] 16:43:04: 1044, ui.Slider13.value = 13

 

Which is clearly wrong. Is this a bug, or have I done something really dumb (if so please enlighten me). If it is a bug, does a workaround exist?

 

TIA.

 

 

 

Link to post
Share on other sites

1 answer to this question

Recommended Posts

  • 0

Hi,

I also observe a problem with the slider, even in the second one in the VD.

By the second method I cannot update the value to Slider by issueing the small code under the VD button.

 

Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Answer this question...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...