@@ -529,29 +529,7 @@ def parseEvent(String event_text) {
529
529
530
530
// JSON format
531
531
case ~/ ^\{ .*\} $/ :
532
- details = parseJson(event_data)
533
-
534
- // These may or may not exist on any given event
535
- user_info = formatEventUser(details)
536
- message = details. event_name ?: details. message ?: ' '
537
- device_type = details. device_type ?: ' '
538
- event_type = details. event_type ?: ' '
539
- alert_value = [
540
- details. device_name,
541
- event_type
542
- ]. findAll { it. isEmpty() == false }. join(' ' )
543
-
544
- if (event_type == ' Automation' ) {
545
- alert_type = ' CUE Automation'
546
- // Automation puts the rule name in device_name, which is backwards for our purposes
547
- alert_value = details. device_name
548
- }
549
- else if (user_info. isEmpty() == false )
550
- alert_type = user_info
551
- else if (device_type. isEmpty() == false )
552
- alert_type = device_type
553
- else
554
- alert_type = ' '
532
+ json_data = parseJson(event_data)
555
533
break
556
534
557
535
default :
@@ -564,20 +542,43 @@ def parseEvent(String event_text) {
564
542
updateMode(message)
565
543
break
566
544
545
+ // Presence/Geofence updates
546
+ case ~/ fence.update.*/ :
547
+ if (saveGeofence)
548
+ sendEvent(name : ' gatewayTimeline' ,
549
+ value : " ${ json_data.name} @${ json_data.location} =${ json_data.state} " ,
550
+ descriptionText : json_data. message,
551
+ type : ' Geofence'
552
+ )
553
+ break
554
+
567
555
case ~/ ^gateway\. timeline.*/ :
568
- if (logDebug) log. debug " ${ event_class} -${ device_type} ${ message} "
556
+ event_type = json_data. event_type
557
+ message = json_data. event_name
558
+ user_info = formatEventUser(json_data)
559
+
560
+ if (logDebug) log. debug " ${ event_class} -${ json_data.device_type} ${ message} "
561
+
562
+ if (event_type == ' Automation' ) {
563
+ alert_type = ' CUE Automation'
564
+ // Automation puts the rule name in device_name, which is backwards for our purposes
565
+ alert_value = json_data. device_name
566
+ }
567
+ else {
568
+ alert_value = [json_data. device_name, event_type]. findAll { it. isEmpty() == false }. join(' =' )
569
+ if (user_info. isEmpty() == false )
570
+ alert_type = user_info
571
+ else if (json_data. device_type. isEmpty() == false )
572
+ alert_type = json_data. device_type
573
+ else
574
+ alert_type = ' '
575
+ }
569
576
570
577
// Devices we ignore events for
571
- if (! devicesToIgnore(). contains(details . device_name)) {
578
+ if (! devicesToIgnore(). contains(json_data . device_name)) {
572
579
if (syncArming) syncArmingEvents(event_type)
573
- sendEnabledEvents(alert_value, message, alert_type)
580
+ sendEnabledEvents(alert_value, message, alert_type)
574
581
}
575
- break
576
-
577
- // Presence/Geofence updates
578
- case ~/ fence.update.*/ :
579
- if (saveGeofence)
580
- sendEvent(name : ' gatewayTimeline' , value : details. location, descriptionText : details. message, type : ' Geofence' )
581
582
break
582
583
583
584
default :
0 commit comments