Some variables not show proper value [integer numbers missing trailing zero]

verified

#1

1) Give a description of the problem
Hello, I have a Fibaro roller shutter 2 with original device type.
Reading attribute Position that have vAlues from 0 to 100 webcore reports
1 if position is 100
2 if position is 20
3 if position is 30
3 if position is 3
Otherwise the right position value (96 if position is 96).
Seems it cannot understand when values are multiple of 10 or Webcore removes zeros…

Here Device type link https://github.com/richb1/FIBARO-Official-SmartThings-Device-Handlers/blob/master/FIBARO-%20Roller%20Shutter%202

2) What is the expected behavior?
Right vAlues, from 0 to 100

3) What is happening/not happening?
If I look in dev SmartThings page, in Device section, position is reported as expected (correctly)

**4) Post a Green Snapshot of the piston!
just logging Fibaro roller shutter 2 position attribute

**5) Attach any logs (From [ST IDE](
619c4952-8042-498c-b240-cee75e53b4bc 08:09:26:info ╔ Event processed successfully (95ms)

619c4952-8042-498c-b240-cee75e53b4bc 08:09:26:trace ║╔ Execution stage complete. (14ms)

619c4952-8042-498c-b240-cee75e53b4bc 08:09:26:trace ║║ Executed virtual command log (1ms)

619c4952-8042-498c-b240-cee75e53b4bc 08:09:26:info ║║ 1

619c4952-8042-498c-b240-cee75e53b4bc 08:09:26:debug ║║ Cancelling statement #1’s schedules…

619c4952-8042-498c-b240-cee75e53b4bc 08:09:26:trace ║╚ Execution stage started

619c4952-8042-498c-b240-cee75e53b4bc 08:09:26:trace ║ Runtime (38240 bytes) successfully initialized in 34ms (v0.3.107.20180806) (77ms)

619c4952-8042-498c-b240-cee75e53b4bc 08:09:26:debug ║ RunTime Analysis CS > 14ms > PS > 34ms > PE > 29ms > CE

619c4952-8042-498c-b240-cee75e53b4bc 08:09:25:info ╚ Received event [CicciHouse].test = 1534313365958 with a delay of 0ms


webCoRE Update v0.3.108.20180906 - restore pistons from backup file, bug fixes
#2

I don’t have a fibaro to test stuff on but post a copy of your piston that you used for logging.


#3

Here the picture… quite easy piston :slight_smile:


#4

Absolutely simple, and absolutely broken. I do not have a roller shade but I do have a different device with a custom attribute (indicated by the ⌂ symbol in webCoRE) that ends in zero. webCoRE drops the trailing zero on that as well.

Since I have an example to test with I will attempt to fix this for the next release.


#5

If this could be useful, position is an attribute exposed as an extra attribute. The one in webcore dashboard appear with a house symbol


#6

Unfortunately I do not have a temporary workaround for you; I cannot find any way to get the actual value.


#7

Thanks,
Happy you have identified the problem.
I hope there is a fix soon so I can automate my shades. :slight_smile:

Thanks a lot
Marco


#8

Ohhhh my. This is definitely wrong

return value.toString().replaceFirst(/\.?(0+)$/, '')

This code looks like it intends to remove the .00 from 5.00 to leave 5 and perhaps the 0 from 5.50 to leave 5.5, but instead it just removes any zeroes at the end of the number regardless of whether there is a decimal point or not.

I will fix this properly for the next release but if you want a quick patch you can EDIT this line (around 7289 in webCoRE Piston smart app) to match:

return value.toString().replaceFirst(/(?:\.|(\.\d*?))0+$/, '$1')

Edit the smart app in ide.smartthings.com > My SmartApps > webCoRE Piston then hit Save and Publish > For Me.

This code is specifically for decimal numbers being casted to a string. I don’t know why these integer values get converted to a decimal first but they do, then they get converted back to a string for logging. So this isn’t nearly as extreme or straightforward as “integers ending in zero are broken.”

EDIT: Updated with the official fix


#9

Thanks it worked :slight_smile:
Thanks for your help!
M


#10

Ian to the rescue once again!!

I am about to install 9 Fibaro roller shutter modules so its great to hear someone is using them successfully with webCoRE.

I was going to use a custom handler I wrote myself last year. I’ve never actually had one of these on my system before and wrote the handler blind to help another user on ST… chuffed to see an official Fibaro produced handler out there now, I had no idea that was released and it is obviously far better than my clunky version!!

Out of interest, what roller blinds are you using? Does the module calibrate to the stop positions ok?


#11

Yes the module calibrate everything well.
With respect to what you find on Fibaro website I have just added open and close button and a position that is quadratic. The one used by Fibaro is linear so it doesn’t represent the real status of the shutter.

Thanks
Marco


#12

@Marco_Raimondi

Would you mind sharing your improved handler on GitHub?


#13

@Marco_Raimondi

Here’s my new setup for 9nr roller shutter modules.

Won’t be installed till mid November though…

Any chance of sharing your DTH?


#14

I’m really sorry but until Tuesday I haven’t my Pc with me (holiday) and with iPhone is quite hard. I’ll be back with DT in a couple of days. Thanks
M


#15

Thanks… no hurry.


#16

#17

Thank you… I’d better fire up Google Translate lol…


#18

come on… just a few comments in italian :slight_smile:


#19

The fix for this was just released in v0.3.108.20180906