auto-commit to deploy afsar
This commit is contained in:
@@ -7,5 +7,6 @@ RUN pip install --no-cache-dir -r requirements.txt
|
||||
#EXPOSE 9999
|
||||
|
||||
WORKDIR /app/src
|
||||
RUN mkdir -p tmp/archive
|
||||
|
||||
CMD ["python", "main.py"]
|
||||
@@ -1,3 +1,4 @@
|
||||
import os
|
||||
import time
|
||||
|
||||
from loguru import logger
|
||||
@@ -8,7 +9,9 @@ from services.llms import OllamaApi
|
||||
from services.ha import HomeassistantApi
|
||||
|
||||
haapi = HomeassistantApi()
|
||||
camera = CameraService()
|
||||
camera = CameraService(
|
||||
archive_base=os.path.dirname(os.path.realpath(__file__))
|
||||
)
|
||||
service_llm = OllamaApi()
|
||||
|
||||
while True:
|
||||
|
||||
@@ -7,6 +7,9 @@ import io
|
||||
|
||||
|
||||
class CameraService:
|
||||
def __init__(self, archive_base):
|
||||
self.archive_base_path = archive_base
|
||||
|
||||
def capture_image(self):
|
||||
# Access the webcam (usually webcam is at index 0 or -1)
|
||||
cap = cv2.VideoCapture(0)
|
||||
@@ -18,7 +21,7 @@ class CameraService:
|
||||
|
||||
# Save the image to a file in the tmp directory with a timestamp
|
||||
timestamp = datetime.datetime.now().strftime("%Y%m%d-%H%M")
|
||||
filename = os.path.join(os.path.dirname(os.path.realpath(__file__)), f"tmp/archive/image_{timestamp}.jpg")
|
||||
filename = os.path.join(self.archive_base_path, f"}tmp/archive/image_{timestamp}.jpg")
|
||||
with open(filename, 'wb') as f:
|
||||
f.write(byte_im)
|
||||
|
||||
|
||||
@@ -17,7 +17,6 @@ class HomeassistantApi:
|
||||
|
||||
db_url ="postgresql://postgres:postgres@192.168.1.211:33744/homeassistant"
|
||||
self.db = detective.HassDatabase(db_url)
|
||||
#db.entities
|
||||
|
||||
def _fetch_sensor_data(self, sensors, limit):
|
||||
# get limited temp data
|
||||
@@ -28,14 +27,3 @@ class HomeassistantApi:
|
||||
|
||||
def get_entity_state(self, entity):
|
||||
return self.ha.get_state(entity)
|
||||
|
||||
# # fix timezone diff
|
||||
# df['last_updated_ts'] = pd.to_datetime(df['last_updated_ts'], unit='s')
|
||||
# df["last_updated_ts"] = df["last_updated_ts"] + pd.DateOffset(hours=3)
|
||||
|
||||
# get latest data point
|
||||
#df.iloc[0].state
|
||||
|
||||
#df[df["state"] == "not_home"]
|
||||
#df["entity_id"].unique()
|
||||
|
||||
|
||||
0
tmp/archive/.gitkeep
Normal file
0
tmp/archive/.gitkeep
Normal file
Reference in New Issue
Block a user