How to Clear Out a Boolean Variable


#1

1) Give a description of the problem
I’m trying to clear a boolean Variable (set to " ", not just set to false). Can can that be done? This is for a virtual thermostat I’m working on. I want to be able to adjust my Simulated Thermostat so that if I set it to 50 or 70, the program takes over, if it is set to anythign else, the Thermostat controls it. This is to control an appliance switch.

2) What is the expected behavior?
Set Variable {Programmatic} = [blank], should return “boolean Programmatic; /* */”

3) What is happening/not happening?
It keeps the last setting /* false */

4) Post a Green Snapshot of the pistonimage
(UPLOAD YOUR IMAGE H

ERE)

5) Attach any logs (From ST IDE and by turning logging level to Full)
1/10/2018, 11:15:28 AM +760ms +1ms ╔Received event [Home].time = 1515600929361 with a delay of -601ms +234ms ║RunTime Analysis CS > 43ms > PS > 96ms > PE > 95ms > CE +238ms ║Runtime (61520 bytes) successfully initialized in 96ms (v0.2.101.20171227) (236ms) +239ms ║╔Execution stage started +248ms ║║Cancelling statement #142's schedules... +1900ms ║║Executed physical command [Master Bedroom TStat - Virtual].setTemperature([60]) (1639ms) +1901ms ║║Executed [Master Bedroom TStat - Virtual].setTemperature (1641ms) +1911ms ║║Comparison (enum) heat is_not (string) off = true (2ms) +1913ms ║║Condition #121 evaluated true (9ms) +1924ms ║║Comparison (decimal) 69.0 is_equal_to (decimal) 70.0 = false (1ms) +1925ms ║║Condition #150 evaluated false (11ms) +1935ms ║║Comparison (decimal) 69.0 is_equal_to (integer) 50 = false (1ms) +1936ms ║║Condition #151 evaluated false (11ms) +1937ms ║║Condition group #149 evaluated false (state did not change) (24ms) +1938ms ║║Condition group #117 evaluated false (state did not change) (34ms) +1940ms ║║Cancelling statement #118's schedules... +1946ms ║║Executed virtual command setVariable (3ms) +1952ms ║║Comparison (boolean) false is_not (boolean) true = true (2ms) +1953ms ║║Condition #157 evaluated true (5ms) +1969ms ║║Comparison (decimal) 60.0 is_less_than_or_equal_to (decimal) 69.0 = true (1ms) +1970ms ║║Condition #158 evaluated true (16ms) +1971ms ║║Condition group #152 evaluated true (state did not change) (23ms) +1973ms ║║Cancelling statement #155's schedules... +1978ms ║║Executed virtual command setVariable (3ms) +1984ms ║║Comparison (string) :7cbc16b5a791742beb269d87212ee95c: is_any_of (string) :7cbc16b5a791742beb269d87212ee95c:,:6370f13e157a8bd6303a747a552bd516:,:6392e11996141424120e5e0142441c3d: = true (1ms) +1986ms ║║Condition #23 evaluated true (5ms) +1991ms ║║Comparison (integer) 1 is_greater_than_or_equal_to (integer) 2 = false (1ms) +1992ms ║║Condition #69 evaluated false (5ms) +1995ms ║║Comparison (string) :7cbc16b5a791742beb269d87212ee95c: changes = false (0ms) +1995ms ║║Condition #70 evaluated false (2ms) +1996ms ║║Condition group #68 evaluated false (state did not change) (9ms) +1997ms ║║Condition group #2 evaluated false (state did not change) (16ms) +2003ms ║║Comparison (string) :7cbc16b5a791742beb269d87212ee95c: is_any_of (string) :7cbc16b5a791742beb269d87212ee95c:,:6370f13e157a8bd6303a747a552bd516:,:6392e11996141424120e5e0142441c3d: = true (2ms) +2004ms ║║Condition #45 evaluated true (5ms) +2009ms ║║Comparison (integer) 1 is_greater_than_or_equal_to (integer) 2 = false (1ms) +2011ms ║║Condition #72 evaluated false (5ms) +2013ms ║║Comparison (string) :7cbc16b5a791742beb269d87212ee95c: changes = false (0ms) +2014ms ║║Condition #73 evaluated false (2ms) +2014ms ║║Condition group #71 evaluated false (state did not change) (9ms) +2015ms ║║Condition group #24 evaluated false (state did not change) (16ms) +2022ms ║║Comparison (integer) 1 is_less_than (integer) 2 = true (2ms) +2023ms ║║Condition #82 evaluated true (6ms) +2027ms ║║Comparison (dynamic) Home Day is (string) Home Day = true (1ms) +2028ms ║║Condition #86 evaluated true (4ms) +2029ms ║║Condition group #77 evaluated true (state did not change) (12ms) +2031ms ║║Cancelling statement #80's schedules... +2035ms ║║Calculating (integer) 1 + (integer) 1 >> (integer) 2 +2041ms ║║Executed virtual command setVariable (4ms) +2045ms ║║Comparison (string) :7cbc16b5a791742beb269d87212ee95c: changes = false (1ms) +2046ms ║║Condition #106 evaluated false (3ms) +2047ms ║║Condition group #103 evaluated false (state did not change) (4ms) +2052ms ║║Comparison (boolean) true is (boolean) true = true (1ms) +2054ms ║║Condition #148 evaluated true (4ms) +2054ms ║║Condition group #136 evaluated true (state did not change) (5ms) +2056ms ║║Cancelling statement #161's schedules... +2065ms ║║Skipped execution of physical command [Master Bedroom Switch].on([]) because it would make no change to the device. (3ms) +2065ms ║║Executed [Master Bedroom Switch].on (5ms) +2068ms ║║Cancelling statement #163's schedules... +2075ms ║║Error retrieving JSON data part null +2079ms ║║Executed virtual command setVariable (3ms) +2082ms ║╚Execution stage complete. (1844ms) +2083ms ║Setting up scheduled job for Wed, Jan 10 2018 @ 11:16:29 AM EST (in 58.518s) +2092ms ╚Event processed successfully (2092ms) 1/10/2018, 11:15:05 AM +59ms +4ms ╔Received event [Home].test = 1515600905053 with a delay of 2ms +256ms ║RunTime Analysis CS > 25ms > PS > 135ms > PE > 99ms > CE +267ms ║Runtime (61519 bytes) successfully initialized in 135ms (v0.2.101.20171227) (261ms) +271ms ║╔Execution stage started +339ms ║╚Execution stage complete. (69ms) +352ms ║Setting up scheduled job for Wed, Jan 10 2018 @ 11:15:29 AM EST (in 23.953s) +364ms ╚Event processed successfully (365ms)


#2

By the way, this piston is derived from the very awesome TempThing
https://community.webcore.co/t/tempthing-an-intelligent-thermostat-controller/2311/5


#3

Assuming you have good reason to require three states rather than two, there is no way to set a boolean back to unset because the value will always be coerced to true or false. You may instead consider using numbers like -1 0 and 1, or a string variable with values that webCoRE understands as boolean, like "true" and "false" or "on" and "off". These strings are treated as boolean true and false:

(expression) bool('off') »»» (boolean) false
(expression) bool('on') »»» (boolean) true
(expression) 'off' && 'on' »»» (boolean) false
(expression) 'off' || 'on' »»» (boolean) true

#4

I ran into the same thing a while back… not being a coder/programmer kind of got stuck and ended up using strings ‘y’ and ‘n’, I didn’t know about the on, off, true, and false. Thanks for that. :smiley:


#5

For reference, here is the current full list of strings that behave as true and false values:

true

  • "1"
  • "true"
  • "on"
  • "open"
  • "locked"
  • "active"
  • "wet"
  • "detected"
  • "present"
  • "occupied"
  • "muted"
  • "sleeping"

false

  • "0"
  • "false"
  • "off"
  • "closed"
  • "unlocked"
  • "inactive"
  • "dry"
  • "clear"
  • "not detected"
  • "not present"
  • "not occupied"
  • "unmuted"
  • "not sleeping"
  • "null"