//Create a class for beacon sensor
package BeaconSensor
-import Timer.SimulatedTimer
+import SmartThing.SmartThing
-public class BeaconSensor {
- private String id
- private String label
- private String displayName
- private String presence
- private String currentPresence
- private String presenceLatestValue
+public class BeaconSensor extends SmartThing {
+ // id, label, and display name of the device
+ StringBuilder id = new StringBuilder()
+ StringBuilder label = new StringBuilder()
+ StringBuilder displayName = new StringBuilder()
+ // Features with string values
+ StringBuilder currentPresence = new StringBuilder()
+ // Maps from features to values
+ HashMap<String, StringBuilder> deviceValuesMap = new HashMap<String, StringBuilder>()
- BeaconSensor(String id, String label, String displayName, String presence, String presenceLatestValue) {
+ BeaconSensor(Closure sendEvent, StringBuilder id, StringBuilder label, StringBuilder displayName, StringBuilder currentPresence) {
+ deviceValuesMap = deviceValueSmartThing
+ idSmartThing = id
+ labelSmartThing = label
+ displayNameSmartThing = displayName
+ sendEventSmartThings = sendEvent
+
+ // Initialization
this.id = id
this.label = label
this.displayName = displayName
- this.presence = presence
- this.currentPresence = presence
- this.presenceLatestValue = presenceLatestValue
- }
-
- def setValue(String value) {
- println("the beacon sensor with id:$id is triggered to $value!")
- this.presenceLatestValue = value
- this.presence = value
- this.currentPresence = value
- }
-
-
- def currentValue(String deviceFeature) {
- if (deviceFeature == "beacon") {
- return presence
- }
+ this.currentPresence = currentPresence
+
+ deviceValuesMap.put("beacon", currentPresence)
}
- def latestValue(String deviceFeature) {
- if (deviceFeature == "beacon") {
- return presenceLatestValue
- }
+ // Methods to return values
+ def getCurrentPresence() {
+ return currentPresence.toString()
}
}