forked from kevin.shehu/GGD
21 lines
1.1 KiB
Plaintext
21 lines
1.1 KiB
Plaintext
|
import java.util.HashMap;
|
||
|
import java.util.Map;
|
||
|
import eu.hsrw.ias.ggd.SensorData
|
||
|
import javax.swing.JOptionPane
|
||
|
import HttpCall.HttpPost
|
||
|
import eu.hsrw.ias.ggd.Notification
|
||
|
import eu.hsrw.ias.ggd.Severity;
|
||
|
import eu.hsrw.ias.ggd.Device;
|
||
|
|
||
|
rule "CriticalSoilMoisture"
|
||
|
when
|
||
|
device: Device(sensorDatas: sensorData)
|
||
|
sensorData: SensorData(tag == "soilMoisture", value < 28.0) from sensorDatas
|
||
|
then
|
||
|
String greenhouse1="8bdbe6ae-eafb-4e99-bb01-db8784dd9633";
|
||
|
HttpPost httpPost = new HttpPost();
|
||
|
final String criticalSoilMoistureOutput = String.format("{\"id\":\"%s\",\"data\":{\"measured\":[{ \"status\": \"Critical Soil Moisture %s in the following device %s \", \"soilMoisture\": %s}]}}",greenhouse1, sensorData.getValue(),sensorData.getTag(),sensorData.getValue());
|
||
|
httpPost.HttpCallPost("http://connector.dev.whysor.com/default/insert?access_token=3hosOhAeh4k0XmcuAMQGfYldvTuQDvtAj2PJJ4irKPBefD5Ijij6gnUkLtVLd4fW",criticalSoilMoistureOutput);
|
||
|
insert(new Notification("soilMoisture", sensorData, Severity.Critical));
|
||
|
end
|