Need to encode data to be used later in piston


#1

1) Give a description of the problem
I am 99% done with a piston that tells me when family members come and go home and other places. Unfortunately, when they leave, the previousEventValue setting is shared by all the devices. I need a code to save the location that particular driver so it can be used in the second part of the piston when they leave.

2) What is the expected behaviour?

{“PreviousLocation”[{ParticularPerson}]] = [$currentEventDevice[{$currentEventValue}]]

Later, when the person leaves, I’ll get “{driver} has left " {“PreviousLocation”[{ParticularPerson}]]”

I’m thinking of encoding the information like a string array, but using each user’s label instead of integers, since this piston could potentially be tracking four people simultaneously. I’ve been trying to crack this, but I’m just too tired to think straight anymore. Any pointers would be appreciated.

3) What is happening/not happening?

simon says Eric has left Edwards Theater
Yesterday at 07:13 PM on Living Room Echo
(I, my wife and son all leave together. Edwards Theater is now the $previousEventValue)

_simon says Tisha has left 1566 north Dahlia Ct _
Yesterday at 07:14 PM on Living Room Echo
(This should be Edwards, but instead it’s giving the $previousEventValue for the current location we just left, either from my or my son’s Life360 apps.

simon says Derek has left 6229 I- 10
Yesterday at 07:16 PM on Living Room Echo
(Again, this should be Edwards, but instead it’s giving the $previousEventValue for the current location we just left.)

simon says Julie has left Home
Yesterday at 10:04 PM on Living Room Echo
(This was supposed to be Edwards Theater…it’s actually the $previousEventValue for when I/wife/son got home)

_simon says Julie has arrived at Edwards Theater _
Yesterday at 10:05 PM on Living Room Echo
(She momentarily re-enters the zone while in the process of leaving)

simon says Julie has left Edwards Theater
Yesterday at 10:08 PM on Living Room Echo
(She basically reset the $previousEventValue to where she is, so now it’s correct)

**4) Post a Green Snapshot of the piston


#2

Instead of previousEventValue, use previousValue([$currentEventDevice:currentPlace])


#3

That makes sense…I’m still trying to figure out when to use {} and []. I’ll let you know how it goes.


#4

{} force evaluation of an expression or variable in a value field e.g. if variable contained ‘hello’, then variable in a value field will return ‘vatiable’ but {variable} will return ‘hello’
[] are used for devices: either [deviceName] or [deviceName:attribute]


#5

@guxdude

Hmmm…not working…the $previous line had nothing around it like the second pic, so I tried adding {} and [], but there was no change. In fact, when i put {} around the whole statement, it wouldn’t accept those. The currentEvent for arrival still works. :frowning:

11/29/2019, 5:18:54 PM +668ms
+2ms ╔Received event [Life360 Julie].address1 = 1202 W Sixth St with a delay of 184ms
+128ms ║RunTime Analysis CS > 23ms > PS > 60ms > PE > 44ms > CE
+130ms ║Runtime (44730 bytes) successfully initialized in 60ms (v0.3.110.20191009) (127ms)
+131ms ║╔Execution stage started
+161ms ║║Comparison (string) 1202 W Sixth St changes_to_any_of (string) Kathleen’s House,The Hollisbraus,Tisha’s School,Western Christian,Kathy’s House,Edwards Theater,Test,Granada,Jack in the Box,Ralphs = false (6ms)
+166ms ║║Condition #2 evaluated false (31ms)
+167ms ║║Condition group #1 evaluated false (state did not change) (32ms)
+459ms ║║Comparison (string) 1202 W Sixth St changes_away_from_any_of (string) Kathleen’s House,The Hollisbraus,Tisha’s School,Western Christian,Kathy’s House,Edwards Theater,Test,Granada,Jack in the Box,Ralphs = true (4ms)
+463ms ║║Cancelling condition #266’s schedules…
+464ms ║║Condition #266 evaluated true (295ms)
+465ms ║║Cancelling condition #264’s schedules…
+466ms ║║Condition group #264 evaluated true (state changed) (297ms)
+468ms ║║Cancelling statement #267’s schedules…
+474ms ║║Executed virtual command setVariable (2ms)
+479ms ║║Executed virtual command setVariable (2ms)
+487ms ║║Executed virtual command setVariable (2ms)
+492ms ║║Calculating (string) Julie + (string) has left >> (string) Julie has left
+495ms ║║Calculating (string) Julie has left + (string) ($previousValue([$currentEventDevice:currentPlace])) >> (string) Julie has left ($previousValue([$currentEventDevice:currentPlace]))
+497ms ║║Executed virtual command setVariable (1ms)
+501ms ║║Executed virtual command setVariable (1ms)
+507ms ║║Calculating (string) Julie + (string) has left >> (string) Julie has left
+509ms ║║Calculating (string) Julie has left + (string) ($previousValue([$currentEventDevice:currentPlace])) >> (string) Julie has left ($previousValue([$currentEventDevice:currentPlace]))
+526ms ║║Executed virtual command sendPushNotification (13ms)
+528ms ║╚Execution stage complete. (397ms)
+529ms ╚Event processed successfully (529ms)


#6

sorry, it appears you are using a different presence sensor device type than I am using. I believe you should just replace ‘currentPlace’ with ‘address1’ for your DTH. I won’t be near a computer for another week but you can look at this piston as example how it should look. If it doesn’t work using value, change to expression and remove the {}.


#7

Hmmm…no go. The Piston can correctly tell that my presence sensors have moved aware from my list of address, so it’s clearly aware of what the previous address was, but I can’t seem to find the setting of the previous address. I either get nothing, or Empty device list.

[EDIT] I found a preAddress attribute setting, so that must be what it’s comparing the change to…but I haven’t been able to pull that information out. I’ve tried all these combinations…

Variable - dynamic
Expression {[$currentEventValue:prevAddress1]}

Variable - dynamic
Expression [$currentEventValue:prevAddress1]

Variable string
Value {[$currentEventValue:prevAddress1]}

variable dynamic
{[$currentEventDevice:prevAddress1]}

variable dynamic
[$currentEventValue:prevAddress1]

variable string
[$currentEventValue:prevAddress1]


#8

Sorry I couldn’t help. You will need someone who uses life360 to help you. I am using the webCoRE presence sensor on my phone.


#9

I know…I’m hoping it’s just a formatting error…but man, I feel like I’m almost there.


#10

Well, what do you know…it magically started working. So bizarre.