Getting Held on a button to dim a light


#1

1) Give a description of the problem
Hi,

I’m trying to get my Xiamio smart button to act as both a flip switch (pressing once to toggle the light) but also to dim the light when being held.
2) What is the expected behavior?
So what I want is when I hold the button it will start to increase brightness and stop at 100. If I press and hold again it should start to decrease brightness down to 0

3) What is happening/not happening?
The toggle works but not the dimming part.

4) Post a Green Snapshot of the pistonimage

5) Attach any logs (From ST IDE and by turning logging level to Full)
2017-12-28 19:14:14 +575ms +1ms ╔Received event [Xiaomi Button].button = pushed with a delay of 70ms +110ms ║RunTime Analysis CS > 12ms > PS > 64ms > PE > 33ms > CE +112ms ║Runtime (41314 bytes) successfully initialized in 64ms (v0.2.101.20171227) (110ms) +113ms ║╔Execution stage started +120ms ║║Comparison (enum) pushed gets (string) held = false (0ms) +122ms ║║Cancelling condition #25's schedules... +122ms ║║Condition #25 evaluated false (4ms) +123ms ║║Condition group #1 evaluated false (state did not change) (6ms) +128ms ║║Comparison (enum) pushed gets (string) held = false (1ms) +129ms ║║Cancelling condition #20's schedules... +130ms ║║Condition #20 evaluated false (5ms) +130ms ║║Condition group #2 evaluated false (state did not change) (5ms) +139ms ║║Comparison (integer) 20 is_greater_than_or_equal_to (integer) 99 = false (1ms) +140ms ║║Condition #17 evaluated false (8ms) +141ms ║║Condition group #3 evaluated false (state did not change) (9ms) +146ms ║║Comparison (enum) pushed gets (string) pushed = true (0ms) +148ms ║║Cancelling condition #8's schedules... +148ms ║║Condition #8 evaluated true (5ms) +149ms ║║Cancelling condition #4's schedules... +150ms ║║Condition group #4 evaluated true (state changed) (7ms) +152ms ║║Condition group #5 evaluated true (state did not change) (0ms) +154ms ║║Cancelling statement #6's schedules... +209ms ║║Executed physical command [Master Bedroom].off() (51ms) +210ms ║║Executed virtual command [Master Bedroom].toggle (54ms) +214ms ║╚Execution stage complete. (101ms) +215ms ╚Event processed successfully (215ms) 2017-12-28 19:14:10 +526ms +1ms ╔Received event [Xiaomi Button].button = held with a delay of 80ms +100ms ║RunTime Analysis CS > 13ms > PS > 55ms > PE > 33ms > CE +103ms ║Runtime (41312 bytes) successfully initialized in 55ms (v0.2.101.20171227) (101ms) +103ms ║╔Execution stage started +112ms ║║Comparison (enum) held gets (string) held = true (0ms) +113ms ║║Condition #25 evaluated true (4ms) +118ms ║║Comparison (string) down is (string) up = false (2ms) +119ms ║║Condition #27 evaluated false (5ms) +120ms ║║Condition group #26 evaluated false (state did not change) (6ms) +121ms ║║Condition group #1 evaluated false (state did not change) (13ms) +126ms ║║Comparison (enum) held gets (string) held = true (0ms) +128ms ║║Condition #20 evaluated true (4ms) +132ms ║║Comparison (string) down is (string) down = true (2ms) +133ms ║║Condition #21 evaluated true (5ms) +140ms ║║Comparison (integer) 20 is_greater_than_or_equal_to (integer) 21 = false (1ms) +142ms ║║Condition #22 evaluated false (8ms) +143ms ║║Condition group #2 evaluated false (state did not change) (19ms) +150ms ║║Comparison (integer) 20 is_greater_than_or_equal_to (integer) 99 = false (1ms) +152ms ║║Condition #17 evaluated false (7ms) +153ms ║║Condition group #3 evaluated false (state did not change) (7ms) +158ms ║║Comparison (enum) held gets (string) pushed = false (1ms) +159ms ║║Condition #8 evaluated false (4ms) +160ms ║║Condition group #4 evaluated false (state did not change) (5ms) +164ms ║╚Execution stage complete. (61ms) +165ms ╚Event processed successfully (166ms) 2017-12-28 19:13:56 +790ms +1ms ╔Received event [Xiaomi Button].button = held with a delay of 364ms +96ms ║RunTime Analysis CS > 12ms > PS > 55ms > PE > 29ms > CE +99ms ║Runtime (41316 bytes) successfully initialized in 55ms (v0.2.101.20171227) (97ms) +100ms ║╔Execution stage started +108ms ║║Comparison (enum) held gets (string) held = true (1ms) +109ms ║║Cancelling condition #25's schedules... +110ms ║║Condition #25 evaluated true (5ms) +115ms ║║Comparison (string) down is (string) up = false (2ms) +116ms ║║Condition #27 evaluated false (5ms) +117ms ║║Condition group #26 evaluated false (state did not change) (6ms) +118ms ║║Condition group #1 evaluated false (state did not change) (13ms) +123ms ║║Comparison (enum) held gets (string) held = true (1ms) +124ms ║║Cancelling condition #20's schedules... +125ms ║║Condition #20 evaluated true (5ms) +129ms ║║Comparison (string) down is (string) down = true (2ms) +130ms ║║Condition #21 evaluated true (4ms) +139ms ║║Comparison (integer) 20 is_greater_than_or_equal_to (integer) 21 = false (3ms) +140ms ║║Condition #22 evaluated false (9ms) +141ms ║║Condition group #2 evaluated false (state did not change) (21ms) +148ms ║║Comparison (integer) 20 is_greater_than_or_equal_to (integer) 99 = false (1ms) +150ms ║║Condition #17 evaluated false (6ms) +150ms ║║Condition group #3 evaluated false (state did not change) (7ms) +156ms ║║Comparison (enum) held gets (string) pushed = false (0ms) +157ms ║║Condition #8 evaluated false (5ms) +158ms ║║Condition group #4 evaluated false (state did not change) (6ms) +161ms ║╚Execution stage complete. (61ms) +162ms ╚Event processed successfully (162ms)


#2

Came across this post as I was thinking about the same thing. Did you have any luck?


#3

Based on the piston of @jcrocker (Remote Button Held) I created the following for the Xiaomi button.

You can set the time interval between the dimming steps and changes the direction of dimming on release of the button.


#4

Long time reader first time poster. Just used your piston and it works great. Any chance you would make one/ help me change it to two button. One for increased brightness and one for decrease?