-
Notifications
You must be signed in to change notification settings - Fork 0
/
vehicle.rules
62 lines (55 loc) · 1.46 KB
/
vehicle.rules
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
//
// Vehicle Presence Rules
//
rule "Vehicle STATUS (LWT) changed"
when
Item swVehicleFordStatus received update
then
// Get LWT status - if receiving updates, then it must be home
if (swVehicleFordStatus.state == 1)
{
logInfo("vehicle", "Ford Ranger is HOME (LWT)")
s_VehicleFordRanger.postUpdate("Home")
}
else if (swVehicleFordStatus.state == 0) // LWT = off
{
// If LWT = OFF and Last HomeorAway Message = OFF - it's likely AWAY
if (swVehicleFordHomeOrAway.state == OFF)
{
logInfo("vehicle", "Ford Ranger is AWAY")
s_VehicleFordRanger.postUpdate("Away")
}
else
{
// Likely still home - but don't update that it is
logInfo("vehicle", "LWT - AWAY received, but last STATE says we're HOME")
}
}
// If LWT is off (no wifi) does not nessarily mean car is away
// Could be that ignition is switched off
end
rule "Vehicle HOME or AWAY state changed"
when
Item swVehicleFordHomeOrAway changed
then
// Get state from vehicle
if (swVehicleFordHomeOrAway.state == ON)
{
logInfo("vehicle", "Ford Ranger is HOME")
s_VehicleFordRanger.postUpdate("Home")
}
else if (swVehicleFordHomeOrAway.state == OFF)
{
// Check LWT status as well - if it's off then it's likely away
if (swVehicleFordStatus.state == 0)
{
logInfo("vehicle", "Ford Ranger is AWAY")
s_VehicleFordRanger.postUpdate("Away")
}
else
{
// Likely home, as LWT overrides state
logInfo("vehicle", "STATE - AWAY received, but LWT says we're home")
}
}
end