mirror of
https://github.com/ferdzo/iotDashboard.git
synced 2026-04-05 01:06:24 +00:00
Refactored and updated tasks.py
This commit is contained in:
@@ -1,12 +1,13 @@
|
|||||||
import json
|
import json
|
||||||
import redis
|
import datetime
|
||||||
import requests
|
import requests
|
||||||
import psycopg2
|
import psycopg2
|
||||||
import datetime
|
|
||||||
from django.conf import settings
|
from django.conf import settings
|
||||||
from huey import crontab
|
from huey import crontab
|
||||||
from huey.contrib.djhuey import periodic_task
|
from huey.contrib.djhuey import periodic_task
|
||||||
from .models import Device
|
from .models import Device
|
||||||
|
import redis
|
||||||
|
|
||||||
|
|
||||||
# Initialize Redis client
|
# Initialize Redis client
|
||||||
redis_client = redis.StrictRedis(host='10.10.0.1', port=6379, db=0)
|
redis_client = redis.StrictRedis(host='10.10.0.1', port=6379, db=0)
|
||||||
@@ -34,7 +35,7 @@ def fetch_data_http(device):
|
|||||||
"device": device.name,
|
"device": device.name,
|
||||||
}
|
}
|
||||||
try:
|
try:
|
||||||
temperature_response = requests.get(f"http://{device.ip}/sensor/temperature")
|
temperature_response = requests.get(f"http://{device.ip}/sensor/tempreature")
|
||||||
humidity_response = requests.get(f"http://{device.ip}/sensor/humidity")
|
humidity_response = requests.get(f"http://{device.ip}/sensor/humidity")
|
||||||
data["temperature"] = temperature_response.json().get('value')
|
data["temperature"] = temperature_response.json().get('value')
|
||||||
data["humidity"] = humidity_response.json().get('value')
|
data["humidity"] = humidity_response.json().get('value')
|
||||||
|
|||||||
Reference in New Issue
Block a user