Custom Attributes Missing from WebCore

bug

#1

Not all attributes for a given DTH are shown in WebCore.

I have a Keen smart vent with a DTH that has a pressure attribute:

The pressure attribute is visible in the API:

And in the SmartThings app:

However, it’s not available in WebCore. I’ve tried using it in a conditional:

In an expression:

And in the evaluation console:
cons

However, if I have several vents with the same DTH in a single variable and perform a function on them like sum or average, the values are there:


Any idea why the device variable Vents can see the pressure, but pressure isn’t available for a single device?


#2

Have you tried with only a single device stored in the variable?

define
    device vent = Todd's Office Vent
end define

execute
    Log to console = [vent : pressure]
end execute

Note, if you want to play with the Expression box, the piston will likely have to be saved first.


#3

Yes! Actually, as I was typing my last sentence it gave me the idea for a work-around, and it worked. I can get to the individual pressures by using an expression in the conditional with the counter variable.

Here’s what I have:

Thanks,
Todd


#4

Good that you found a workaround, but the fact that the pressure attribute is not coming up in the attribute dropdown list is still unusual.

Bit of a long shot but it may be a case sensitive issue in the webCoRE programming, just had a flick through a bunch of custom handlers where I know the attributes show in WC, and they all state:

attribute “name”, “Type”

rather than

attribute “name”, “type”

Also, if you change attributes in a handler you need to remove and re-add the device from webCoRE to see the change straight away. I believe you can also wait a period of time but I’m always too impatient for that. Removing a device from webCoRE and re-adding it will not break any pistons, as the device ID links everything back together automatically.


#5

I have never seen an empty device variable used as a counter…

Can you post a Full log showing us what is happening behind the scenes?


#6

Yes, here’s the full log of the latest run.

8/21/2020, 4:27:37 PM +71ms
+0ms   ╔Received event [Home].time = 1598052457766 with a delay of -696ms
+130ms ║RunTime Analysis CS > 24ms > PS > 45ms > PE > 61ms > CE
+133ms ║Runtime (46780 bytes) successfully initialized in 45ms (v0.3.110.20191009) (132ms)
+134ms ║╔Execution stage started
+157ms ║║Comparison (enum) idle is (string) idle = true (1ms)
+165ms ║║Condition #10 evaluated true (23ms)
+166ms ║║Condition group #9 evaluated true (state did not change) (24ms)
+190ms ║║Comparison (dynamic) 70837.7 is_greater_than (integer) 90000 = false (1ms)
+192ms ║║Cancelling condition #6's schedules...
+193ms ║║Condition #6 evaluated false (14ms)
+195ms ║║Cancelling condition #12's schedules...
+196ms ║║Condition group #12 evaluated false (state changed) (16ms)
+220ms ║║Comparison (dynamic) 76207.4 is_greater_than (integer) 90000 = false (2ms)
+222ms ║║Condition #6 evaluated false (12ms)
+223ms ║║Condition group #12 evaluated false (state did not change) (13ms)
+247ms ║║Comparison (dynamic) 99370.1 is_greater_than (integer) 90000 = true (1ms)
+249ms ║║Cancelling condition #6's schedules...
+250ms ║║Condition #6 evaluated true (13ms)
+252ms ║║Cancelling condition #12's schedules...
+253ms ║║Condition group #12 evaluated true (state changed) (15ms)
+255ms ║║Cancelling statement #15's schedules...
+357ms ║║Calculating (decimal) 0.0 + (decimal) 99370.1 >> (decimal) 99370.1
+360ms ║║Executed virtual command setVariable (1ms)
+367ms ║║Calculating (integer) 0 + (integer) 1 >> (integer) 1
+370ms ║║Executed virtual command setVariable (1ms)
+395ms ║║Comparison (dynamic) 99407.6 is_greater_than (integer) 90000 = true (1ms)
+397ms ║║Condition #6 evaluated true (12ms)
+398ms ║║Condition group #12 evaluated true (state did not change) (13ms)
+401ms ║║Cancelling statement #15's schedules...
+413ms ║║Calculating (decimal) 99370.1 + (decimal) 99407.6 >> (decimal) 198777.7
+416ms ║║Executed virtual command setVariable (1ms)
+421ms ║║Calculating (integer) 1 + (integer) 1 >> (integer) 2
+425ms ║║Executed virtual command setVariable (1ms)
+450ms ║║Comparison (dynamic) 99304 is_greater_than (integer) 90000 = true (2ms)
+452ms ║║Condition #6 evaluated true (11ms)
+453ms ║║Condition group #12 evaluated true (state did not change) (12ms)
+455ms ║║Cancelling statement #15's schedules...
+467ms ║║Calculating (decimal) 198777.7 + (decimal) 99304.0 >> (decimal) 298081.7
+471ms ║║Executed virtual command setVariable (1ms)
+476ms ║║Calculating (integer) 2 + (integer) 1 >> (integer) 3
+479ms ║║Executed virtual command setVariable (1ms)
+504ms ║║Comparison (dynamic) 99370.2 is_greater_than (integer) 90000 = true (1ms)
+506ms ║║Condition #6 evaluated true (11ms)
+507ms ║║Condition group #12 evaluated true (state did not change) (13ms)
+510ms ║║Cancelling statement #15's schedules...
+521ms ║║Calculating (decimal) 298081.7 + (decimal) 99370.2 >> (decimal) 397451.9
+524ms ║║Executed virtual command setVariable (1ms)
+530ms ║║Calculating (integer) 3 + (integer) 1 >> (integer) 4
+533ms ║║Executed virtual command setVariable (1ms)
+557ms ║║Comparison (dynamic) 99547.7 is_greater_than (integer) 90000 = true (1ms)
+558ms ║║Condition #6 evaluated true (10ms)
+559ms ║║Condition group #12 evaluated true (state did not change) (12ms)
+562ms ║║Cancelling statement #15's schedules...
+573ms ║║Calculating (decimal) 397451.9 + (decimal) 99547.7 >> (decimal) 496999.60000000003
+576ms ║║Executed virtual command setVariable (1ms)
+582ms ║║Calculating (integer) 4 + (integer) 1 >> (integer) 5
+585ms ║║Executed virtual command setVariable (1ms)
+609ms ║║Comparison (dynamic) 99356.6 is_greater_than (integer) 90000 = true (2ms)
+611ms ║║Condition #6 evaluated true (10ms)
+612ms ║║Condition group #12 evaluated true (state did not change) (13ms)
+614ms ║║Cancelling statement #15's schedules...
+626ms ║║Calculating (decimal) 496999.60000000003 + (decimal) 99356.6 >> (decimal) 596356.2000000001
+629ms ║║Executed virtual command setVariable (1ms)
+635ms ║║Calculating (integer) 5 + (integer) 1 >> (integer) 6
+638ms ║║Executed virtual command setVariable (1ms)
+648ms ║║Comparison (integer) 6 is_greater_than (integer) 0 = true (2ms)
+649ms ║║Condition #19 evaluated true (5ms)
+651ms ║║Condition group #18 evaluated true (state did not change) (6ms)
+653ms ║║Cancelling statement #2's schedules...
+659ms ║║Calculating (decimal) 596356.2000000001 / (decimal) 6.0 >> (decimal) 99392.70000000001
+663ms ║║Executed virtual command setVariable (1ms)
+685ms ║║Executed virtual command setState (1ms)
+696ms ║║Executed virtual command writeToFuelStream (6ms)
+700ms ║╚Execution stage complete. (565ms)
+701ms ║Setting up scheduled job for Fri, Aug 21 2020 @ 4:28:37 PM PDT (in 59.994s)
+709ms ╚Event processed successfully (708ms)

I wasn’t having any luck using $device as the counter variable, so I created the device vent variable.

I found I could also iterate and get the values with arrayItem(index,[Vents:pressure]), for example.

BTW, there was a bug in the code above (which I edited). The attribute was coming into WebCore as a string, and the sum = sum + vent:pressure wasn’t working right. I had to change it to sum=sum+decimal(vent:pressure), and now it works.

I had tried changing it from “number” to “NUMBER” and to “string” but nothing worked. I wasn’t removing and re-adding the device, though, so perhaps my changes weren’t propagating through in time. I didn’t know I needed to. Thanks for that!


#7

Very interesting workaround…

Although now that you know that [device : pressure] comes in as a string, you should be able to use that knowledge in your first post here.

pic

IE: Change decimal {vent} to string {vent}… or
Convert the string to a decimal before trying to write it to the variable

(since strings cannot be stored inside of a decimal variable)


#8

Maybe, but I’m not sure that was the problem. It was saying “Invalid attribute pressure” rather than giving me any type errors.

The weird thing is that with my bug before, not converting it to a decimal, I think it was dynamically casting sum to a string, then concatenating the strings, then setting it to the sum as zero. So sum always equaled zero after the iteration. I would expect that the same would happen above (a dynamic cast) instead of the invalid attribute error.


#9

I tend to work in steps. Save data into a variable. Then calculate using that variable.

It may add 5% to the code, but I get to see each step along the way.
(and it makes for much easier troubleshooting)

If you try to do 5 things in one line, then it is tough to try to figure out which element gave you trouble.


#10

I am pretty sure it is…

If I try to store a string into a string variable, it works:

pic


Alternatively, if I try to store the same string into a decimal, I get 0.

pic


The logic is:
a string cannot be stored inside of a decimal variable


#11

Oh, I agree with that! That was the problem with my routine once I was able to pull out the pressure, I was getting zero instead of the value. But in my first post in this thread I wasn’t able to even try it because I was getting an “invalid attribute pressure” error. The problem wasn’t that I was getting zero. I hadn’t even tried to run it. The problem was the attribute error.


#12

How true. It depends on what level you catch it at… the error looks very different.
(I was trying to remove all extra elements by pushing one data into one variable)


#13

I wonder if this is because of the apostrophe…
(or the single quote, as webCoRE’s expression sees it)

I would normally recommend avoiding using any symbols or punctuation when naming devices…


#14

I thought the same, but I tried it with other vents such as “Kitchen” with the same result.