The piston is not updating the dimming level properly


#1

Hi,

I have a Sonoff button with 3 actions for pushed, double and held. It triggers my Ikea bulb. For every press, the dimming level should rise by 10% and for hold, it should goes to 100% and the color temperature should be max.
When I hold the button, the color temperature goes to max, but the dimming level goes to something else. This is my first piston and I am not sure if I do something wrong.

I thought that the held button also triggers a push action, but from the logs, I cannot see this. Also the dimming level jumps somehow from 20 to 37. I am not sure how it is possible since everything should be a multiple of 10

Note: The same dimming problem and jumping level happens with 99% max dimming level

Note2: I can save a scene for ‘held’ in Smartthings app, but I need to sync this piston and that action. I want to have everything in one place

Here is my piston:

Here are the logs:

21/02/2021, 10:17:07 +359ms
+1ms ╔Received event [sonoff button].button = pushed with a delay of 39ms
+49ms ║RunTime Analysis CS > 11ms > PS > 3ms > PE > 34ms > CE
+51ms ║Runtime (39963 bytes) successfully initialized in 3ms (v0.3.113.20210203) (50ms)
+52ms ║╔Execution stage started
+57ms ║║Evaluating switch with values [[i::8a123b9f925cd25a4c84fba0a2ac2092::button, v:[t:enum, v:pushed, d::8a123b9f925cd25a4c84fba0a2ac2092:, a:button, i:[], x:false, vt:string]]]
+60ms ║║Comparison (enum) pushed is (string) pushed = true (1ms)
+62ms ║║Cancelling statement #5’s schedules…
+71ms ║║Calculating (integer) 10 % (integer) 100 >> (integer) 10
+73ms ║║Calculating (integer) 10 + (integer) 10 >> (integer) 20
+83ms ║║Executed physical command [IKEA Light].setLevel([20]) (7ms)
+84ms ║║Executed [IKEA Light].setLevel (9ms)
+86ms ║╚Execution stage complete. (34ms)
+87ms ╚Event processed successfully (87ms)

21/02/2021, 10:17:14 +886ms
+0ms ╔Received event [sonoff button].button = held with a delay of 36ms
+46ms ║RunTime Analysis CS > 13ms > PS > 3ms > PE > 30ms > CE
+48ms ║Runtime (39961 bytes) successfully initialized in 3ms (v0.3.113.20210203) (47ms)
+49ms ║╔Execution stage started
+54ms ║║Evaluating switch with values [[i::8a123b9f925cd25a4c84fba0a2ac2092::button, v:[t:enum, v:held, d::8a123b9f925cd25a4c84fba0a2ac2092:, a:button, i:[], x:false, vt:string]]]
+57ms ║║Comparison (enum) held is (string) pushed = false (1ms)
+60ms ║║Comparison (enum) held is (string) double = false (1ms)
+62ms ║║Comparison (enum) held is (string) held = true (1ms)
+64ms ║║Cancelling statement #13’s schedules…
+76ms ║║Executed physical command [IKEA Light].setLevel([100]) (6ms)
+77ms ║║Executed [IKEA Light].setLevel (8ms)
+86ms ║║Executed physical command [IKEA Light].setColorTemperature([6200]) (2ms)
+87ms ║║Executed virtual command [IKEA Light].adjustColorTemperature (7ms)
+89ms ║╚Execution stage complete. (39ms)
+90ms ╚Event processed successfully (90ms)

21/02/2021, 10:17:20 +857ms
+1ms ╔Received event [sonoff button].button = pushed with a delay of 39ms
+46ms ║RunTime Analysis CS > 12ms > PS > 3ms > PE > 31ms > CE
+49ms ║Runtime (39961 bytes) successfully initialized in 3ms (v0.3.113.20210203) (47ms)
+50ms ║╔Execution stage started
+54ms ║║Evaluating switch with values [[i::8a123b9f925cd25a4c84fba0a2ac2092::button, v:[t:enum, v:pushed, d::8a123b9f925cd25a4c84fba0a2ac2092:, a:button, i:[], x:false, vt:string]]]
+57ms ║║Comparison (enum) pushed is (string) pushed = true (1ms)
+59ms ║║Cancelling statement #5’s schedules…
+68ms ║║Calculating (integer) 37 % (integer) 100 >> (integer) 37
+71ms ║║Calculating (integer) 37 + (integer) 10 >> (integer) 47
+81ms ║║Executed physical command [IKEA Light].setLevel([47]) (8ms)
+82ms ║║Executed [IKEA Light].setLevel (8ms)
+84ms ║╚Execution stage complete. (35ms)
+85ms ╚Event processed successfully (85ms)