date time fixed
This commit is contained in:
@@ -1,12 +1,12 @@
|
||||
import paho.mqtt.client as mqtt
|
||||
|
||||
import software.defines
|
||||
from software.defines import MQTT_BROKER_LOCAL
|
||||
import software.backend.defines
|
||||
from software.backend.defines import MQTT_BROKER_LOCAL
|
||||
from random import randrange, uniform
|
||||
import time
|
||||
import json
|
||||
from software.defines import Topics, PLANTDATA
|
||||
mqttBroker = software.defines.MQTT_BROKER_GLOBAL
|
||||
from software.backend.defines import Topics, PLANTDATA
|
||||
mqttBroker = software.backend.defines.MQTT_BROKER_GLOBAL
|
||||
|
||||
|
||||
def on_connect(client, userdata, flags, rc):
|
||||
@@ -22,10 +22,18 @@ client.on_connect = on_connect
|
||||
client.connect(mqttBroker)
|
||||
|
||||
plantdata = {
|
||||
"PlantName": "Kemal"
|
||||
"AirTemperature": 1.0,
|
||||
"AirHumidity": 1.0,
|
||||
"SoilMoisture": 1.0,
|
||||
"Brightness": 1,
|
||||
"PlantID": 2,
|
||||
"Timestamp": "",
|
||||
"MeasurementID": 0,
|
||||
"PlantName": "test"
|
||||
}
|
||||
|
||||
|
||||
print(type(PLANTDATA))
|
||||
client.publish("BACKEND/ACTION/GETBATTERY", json.dumps(plantdata))
|
||||
client.publish(Topics['BACKEND_ACTION_NEWPLANT'], json.dumps(plantdata))
|
||||
print(json.dumps(plantdata))
|
||||
time.sleep(2)
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
import paho.mqtt.client as mqtt
|
||||
import time
|
||||
from software.defines import Topics
|
||||
from software.backend.defines import Topics
|
||||
from software.backend.defines import MQTT_BROKER_GLOBAL
|
||||
|
||||
|
||||
def on_message(client, userdata, message):
|
||||
@@ -14,12 +15,12 @@ def on_connect(client, userdata, flags, rc):
|
||||
print("Connection failed")
|
||||
|
||||
|
||||
mqttBroker = "192.168.178.182"
|
||||
mqttBroker = ""
|
||||
|
||||
client = mqtt.Client()
|
||||
client.connect(mqttBroker, 1883)
|
||||
client.connect(MQTT_BROKER_GLOBAL, 1883)
|
||||
|
||||
client.on_message = on_message
|
||||
|
||||
client.subscribe("TEST")
|
||||
client.subscribe(Topics['BACKEND_ACTION_GETALLDATA'])
|
||||
client.loop_forever()
|
||||
|
||||
Reference in New Issue
Block a user