diff --git a/src/main/java/Data/securityToken.txt b/src/main/java/Data/securityToken.txt index 18b3348..3c46a82 100644 --- a/src/main/java/Data/securityToken.txt +++ b/src/main/java/Data/securityToken.txt @@ -1 +1 @@ -936JzYXxJIzzITnuVOGYMDHRCYtKuaF4EOSY3p8jUPeZNV9HeqPBYXQ0WybUy11V \ No newline at end of file +ZW6n3ZlQ5NFeWjfjhX3aQmdUJJxkCGy6tsZbMeZqHLiyAcHOAiR0f7QCQj655VBV \ No newline at end of file diff --git a/src/main/resources/rules/CriticalPrecipitation.drl b/src/main/resources/rules/CriticalPrecipitation.drl index 6cc9f40..9663cae 100644 --- a/src/main/resources/rules/CriticalPrecipitation.drl +++ b/src/main/resources/rules/CriticalPrecipitation.drl @@ -12,12 +12,12 @@ rule "CriticalPrecipitation" device: Device(sensorDatas: sensorData) sensorData: SensorData(tag == "precipitation", value > 15.5) from sensorDatas then - String greenhouse1="8bdbe6ae-eafb-4e99-bb01-db8784dd9633"; - String greenhouse2="e5ec9f15-f214-455d-9f02-3c134c770dc1";//Nica - HttpPost httpPost = new HttpPost(); - final String criticalPrecipitationOutput = String.format("{\"id\":\"%s\",\"data\":{\"measured\":[{ \"status\": \"Critical Precipitation %s in the following sensor %s \", \"precipitation\": %s}]}}",greenhouse2, sensorData.getValue(),sensorData.getTag(),sensorData.getValue()); - httpPost.HttpCallPost("http://connector.dev.whysor.com/default/insert?access_token=3hosOhAeh4k0XmcuAMQGfYldvTuQDvtAj2PJJ4irKPBefD5Ijij6gnUkLtVLd4fW",criticalPrecipitationOutput); - insert(new Notification("precipitation", sensorData, Severity.Warning)); +// String greenhouse1="8bdbe6ae-eafb-4e99-bb01-db8784dd9633"; +// String greenhouse2="e5ec9f15-f214-455d-9f02-3c134c770dc1";//Nica +// HttpPost httpPost = new HttpPost(); +// final String criticalPrecipitationOutput = String.format("{\"id\":\"%s\",\"data\":{\"measured\":[{ \"status\": \"Critical Precipitation %s in the following sensor %s \", \"precipitation\": %s}]}}",greenhouse2, sensorData.getValue(),sensorData.getTag(),sensorData.getValue()); +// httpPost.HttpCallPost("http://connector.dev.whysor.com/default/insert?access_token=3hosOhAeh4k0XmcuAMQGfYldvTuQDvtAj2PJJ4irKPBefD5Ijij6gnUkLtVLd4fW",criticalPrecipitationOutput); +// insert(new Notification("precipitation", sensorData, Severity.Warning)); // modify(sensorData){ // setState(Severity.Critical) diff --git a/src/main/resources/rules/CriticalSoilMoisture.drl b/src/main/resources/rules/CriticalSoilMoisture.drl index 505d8c6..d12de8c 100644 --- a/src/main/resources/rules/CriticalSoilMoisture.drl +++ b/src/main/resources/rules/CriticalSoilMoisture.drl @@ -15,7 +15,7 @@ rule "CriticalSoilMoisture" // String greenhouse1="8bdbe6ae-eafb-4e99-bb01-db8784dd9633";//Germes String greenhouse2="e5ec9f15-f214-455d-9f02-3c134c770dc1";//Nica HttpPost httpPost = new HttpPost(); - final String criticalSoilMoistureOutput = String.format("{\"id\":\"%s\",\"data\":{\"measured\":[{ \"status\": \"Critical Soil Moisture %s in the following device %s. It’s too dry and the field needs fertilizer \", \"soilMoisture\": %s}]}}",greenhouse2, sensorData.getValue(),sensorData.getTag(),sensorData.getValue()); + final String criticalSoilMoistureOutput = String.format("{\"id\":\"%s\",\"data\":{\"measured\":[{ \"status\": \"Critical Soil Moisture %s in the following device: %s. It’s too dry and the field needs fertilizer \", \"soilMoisture\": %s}]}}",greenhouse2, sensorData.getValue(),sensorData.getTag(),sensorData.getValue()); httpPost.HttpCallPost("http://connector.dev.whysor.com/default/insert?access_token=3hosOhAeh4k0XmcuAMQGfYldvTuQDvtAj2PJJ4irKPBefD5Ijij6gnUkLtVLd4fW",criticalSoilMoistureOutput); final String deviceCritical = String.format("{\"id\":\"%s-status\",\"data\":{\"measured\":[{ \"criticalStatus\": \"The status of %s device is critical\"}]}}",device.IdMapper(device.getId()),device.getId()); httpPost.HttpCallPost("http://connector.dev.whysor.com/default/insert?access_token=3hosOhAeh4k0XmcuAMQGfYldvTuQDvtAj2PJJ4irKPBefD5Ijij6gnUkLtVLd4fW",deviceCritical); @@ -27,9 +27,9 @@ rule "OptimalSoilMoisture" device: Device(sensorDatas: sensorData) sensorData: SensorData(tag == "soilMoisture", value > 28.0) from sensorDatas then - String greenhouse1="8bdbe6ae-eafb-4e99-bb01-db8784dd9633"; + String greenhouse1="e5ec9f15-f214-455d-9f02-3c134c770dc1"; HttpPost httpPost = new HttpPost(); - final String optimalSoilMoistureOutput = String.format("{\"id\":\"%s\",\"data\":{\"measured\":[{ \"status\": \"Optimal Soil Moisture %s in the following device %s \", \"soilMoisture\": %s}]}}",greenhouse1, sensorData.getValue(),sensorData.getTag(),sensorData.getValue()); + final String optimalSoilMoistureOutput = String.format("{\"id\":\"%s\",\"data\":{\"measured\":[{ \"status\": \"Optimal Soil Moisture %s in the following device %s. Everything is in order. \", \"soilMoisture\": %s}]}}",greenhouse1, sensorData.getValue(),sensorData.getTag(),sensorData.getValue()); httpPost.HttpCallPost("http://connector.dev.whysor.com/default/insert?access_token=3hosOhAeh4k0XmcuAMQGfYldvTuQDvtAj2PJJ4irKPBefD5Ijij6gnUkLtVLd4fW",optimalSoilMoistureOutput); insert(new Notification("soilMoisture", sensorData, Severity.Optimal)); //device.setState(Severity.Optimal); diff --git a/target/classes/rules/CriticalPrecipitation.drl b/target/classes/rules/CriticalPrecipitation.drl index 6cc9f40..9663cae 100644 --- a/target/classes/rules/CriticalPrecipitation.drl +++ b/target/classes/rules/CriticalPrecipitation.drl @@ -12,12 +12,12 @@ rule "CriticalPrecipitation" device: Device(sensorDatas: sensorData) sensorData: SensorData(tag == "precipitation", value > 15.5) from sensorDatas then - String greenhouse1="8bdbe6ae-eafb-4e99-bb01-db8784dd9633"; - String greenhouse2="e5ec9f15-f214-455d-9f02-3c134c770dc1";//Nica - HttpPost httpPost = new HttpPost(); - final String criticalPrecipitationOutput = String.format("{\"id\":\"%s\",\"data\":{\"measured\":[{ \"status\": \"Critical Precipitation %s in the following sensor %s \", \"precipitation\": %s}]}}",greenhouse2, sensorData.getValue(),sensorData.getTag(),sensorData.getValue()); - httpPost.HttpCallPost("http://connector.dev.whysor.com/default/insert?access_token=3hosOhAeh4k0XmcuAMQGfYldvTuQDvtAj2PJJ4irKPBefD5Ijij6gnUkLtVLd4fW",criticalPrecipitationOutput); - insert(new Notification("precipitation", sensorData, Severity.Warning)); +// String greenhouse1="8bdbe6ae-eafb-4e99-bb01-db8784dd9633"; +// String greenhouse2="e5ec9f15-f214-455d-9f02-3c134c770dc1";//Nica +// HttpPost httpPost = new HttpPost(); +// final String criticalPrecipitationOutput = String.format("{\"id\":\"%s\",\"data\":{\"measured\":[{ \"status\": \"Critical Precipitation %s in the following sensor %s \", \"precipitation\": %s}]}}",greenhouse2, sensorData.getValue(),sensorData.getTag(),sensorData.getValue()); +// httpPost.HttpCallPost("http://connector.dev.whysor.com/default/insert?access_token=3hosOhAeh4k0XmcuAMQGfYldvTuQDvtAj2PJJ4irKPBefD5Ijij6gnUkLtVLd4fW",criticalPrecipitationOutput); +// insert(new Notification("precipitation", sensorData, Severity.Warning)); // modify(sensorData){ // setState(Severity.Critical) diff --git a/target/classes/rules/CriticalSoilMoisture.drl b/target/classes/rules/CriticalSoilMoisture.drl index bd71d93..b84a48d 100644 --- a/target/classes/rules/CriticalSoilMoisture.drl +++ b/target/classes/rules/CriticalSoilMoisture.drl @@ -15,7 +15,7 @@ rule "CriticalSoilMoisture" // String greenhouse1="8bdbe6ae-eafb-4e99-bb01-db8784dd9633";//Germes String greenhouse2="e5ec9f15-f214-455d-9f02-3c134c770dc1";//Nica HttpPost httpPost = new HttpPost(); - final String criticalSoilMoistureOutput = String.format("{\"id\":\"%s\",\"data\":{\"measured\":[{ \"status\": \"Critical Soil Moisture %s in the following device %s. It’s too dry and the field needs fertilizer \", \"soilMoisture\": %s}]}}",greenhouse2, sensorData.getValue(),sensorData.getTag(),sensorData.getValue()); + final String criticalSoilMoistureOutput = String.format("{\"id\":\"%s\",\"data\":{\"measured\":[{ \"status\": \"Critical Soil Moisture %s in the following device: %s. It’s too dry and the field needs fertilizer \", \"soilMoisture\": %s}]}}",greenhouse2, sensorData.getValue(),sensorData.getTag(),sensorData.getValue()); httpPost.HttpCallPost("http://connector.dev.whysor.com/default/insert?access_token=3hosOhAeh4k0XmcuAMQGfYldvTuQDvtAj2PJJ4irKPBefD5Ijij6gnUkLtVLd4fW",criticalSoilMoistureOutput); final String deviceCritical = String.format("{\"id\":\"%s-status\",\"data\":{\"measured\":[{ \"criticalStatus\": \"The status of %s device is critical\"}]}}",device.IdMapper(device.getId()),device.getId()); httpPost.HttpCallPost("http://connector.dev.whysor.com/default/insert?access_token=3hosOhAeh4k0XmcuAMQGfYldvTuQDvtAj2PJJ4irKPBefD5Ijij6gnUkLtVLd4fW",deviceCritical); @@ -32,9 +32,9 @@ rule "OptimalSoilMoisture" device: Device(sensorDatas: sensorData) sensorData: SensorData(tag == "soilMoisture", value > 28.0) from sensorDatas then - String greenhouse1="8bdbe6ae-eafb-4e99-bb01-db8784dd9633"; + String greenhouse1="e5ec9f15-f214-455d-9f02-3c134c770dc1"; HttpPost httpPost = new HttpPost(); - final String optimalSoilMoistureOutput = String.format("{\"id\":\"%s\",\"data\":{\"measured\":[{ \"status\": \"Optimal Soil Moisture %s in the following device %s \", \"soilMoisture\": %s}]}}",greenhouse1, sensorData.getValue(),sensorData.getTag(),sensorData.getValue()); + final String optimalSoilMoistureOutput = String.format("{\"id\":\"%s\",\"data\":{\"measured\":[{ \"status\": \"Optimal Soil Moisture %s in the following device %s. Everything is in order. \", \"soilMoisture\": %s}]}}",greenhouse1, sensorData.getValue(),sensorData.getTag(),sensorData.getValue()); httpPost.HttpCallPost("http://connector.dev.whysor.com/default/insert?access_token=3hosOhAeh4k0XmcuAMQGfYldvTuQDvtAj2PJJ4irKPBefD5Ijij6gnUkLtVLd4fW",optimalSoilMoistureOutput); insert(new Notification("soilMoisture", sensorData, Severity.Optimal)); //device.setState(Severity.Optimal); diff --git a/target/classes/rules/optimal.drl b/target/classes/rules/optimal.drl index 9d0657f..b3e714f 100644 --- a/target/classes/rules/optimal.drl +++ b/target/classes/rules/optimal.drl @@ -9,7 +9,7 @@ when then HttpPost httpPost = new HttpPost(); - final String optimalGreenhouse = String.format("{\"id\":\"germes-greenhouse-status\",\"data\":{\"measured\":[{ \"status\": \"The status of the greenhouse is optimal\"}]}}"); + final String optimalGreenhouse = String.format("{\"id\":\"nica-greenhouse-status\",\"data\":{\"measured\":[{ \"status\": \"The status of the greenhouse is optimal\"}]}}"); httpPost.HttpCallPost("http://connector.dev.whysor.com/default/insert?access_token=3hosOhAeh4k0XmcuAMQGfYldvTuQDvtAj2PJJ4irKPBefD5Ijij6gnUkLtVLd4fW",optimalGreenhouse); System.out.println("Green House optimal, because of: '"+warning.getType()+"'"); end