Compare commits

...

12 commits

Author SHA1 Message Date
336eefb963 acc cost filter
Some checks are pending
Docker Build and Push / build-and-push (push) Waiting to run
2024-12-19 01:48:58 +01:00
b13d3e6857 change retries 2024-12-11 18:31:24 +01:00
9d3afcd801 change timing 2024-08-18 01:18:19 +02:00
9fa7581574 aaaaaaarghhhhhhhh 2024-08-18 00:21:28 +02:00
877cda9640 aaaaaaarghhhhhhhh 2024-08-18 00:16:16 +02:00
d5fce90b8d aaaaaaarghhhhhhhh 2024-08-18 00:13:59 +02:00
83a23b3c1b aaaaaaarghhhhhhhh 2024-08-18 00:10:44 +02:00
043170481a NMBFYGTGG 2024-08-18 00:08:00 +02:00
610cdd6a65 Merge remote-tracking branch 'origin/main'
# Conflicts:
#	Dockerfile
2024-08-18 00:06:51 +02:00
fdad6c3d72 x vcbxfdfsfgrfWFEFF 2024-08-18 00:06:38 +02:00
cd4819252d Merge remote-tracking branch 'origin/main'
# Conflicts:
#	Dockerfile
#	pulse.py
2024-08-17 23:45:18 +02:00
4a716859b0 combine scripts 2024-08-17 23:44:58 +02:00
6 changed files with 18 additions and 29 deletions

2
DataPoints.py Normal file → Executable file
View file

@ -14,7 +14,7 @@ class Pulse:
"power": float(power),
"lastMeterConsumption": float(lastMeterConsumption)
}
if cost is not None:
if cost is not None and float(cost) > 0:
fields.update({'accumulatedCost':cost})
self.datapoint = {"fields": fields,
"tags": tags,

View file

@ -2,8 +2,6 @@ FROM python:3.12-slim-bookworm
WORKDIR /app
LABEL MAINTAINER="Jan-Ole Hübner <huebner@jan-ole.de>"
RUN apt-get update && apt-get install -y cron
ADD requirements.txt /app
RUN pip3 install -r /app/requirements.txt
@ -11,15 +9,6 @@ ENV PYTHONIOENCODING=utf-8
ADD . /app
RUN echo "SHELL=/bin/bash\nBASH_ENV=/app/env\n* * * * * root /app/delay_price.sh >> /var/log/cron.log 2>&1" > /etc/cron.d/get_price
RUN chmod 0644 /etc/cron.d/get_price
RUN crontab /etc/cron.d/get_price
RUN touch /var/log/cron.log
RUN chmod 755 /app/pulse.py /app/get_price.py /app/start.sh /app/delay_price.sh
RUN chmod 755 /app/pulse.py /app/get_price.py /app/start.sh
CMD ["/app/start.sh"]

View file

@ -1,6 +0,0 @@
#!/bin/bash
source /app/env
printenv
sleep 2
python3 /app/get_price.py >> /var/log/cron.log 2>&1

2
get_price.py Normal file → Executable file
View file

@ -21,7 +21,7 @@ ch.setFormatter(formatter)
logger.addHandler(ch)
logger.setLevel(logging.INFO)
__version__ = "v0.3.0"
__version__ = "v0.4.2"
logger.info(__version__)
client = InfluxDBClient(url=URL, token=TOKEN, org=ORG)

7
pulse.py Normal file → Executable file
View file

@ -1,7 +1,8 @@
import asyncio
import os
import signal
import sys
import time
import tibber
from influxdb_client import InfluxDBClient
@ -24,7 +25,7 @@ ch.setFormatter(formatter)
logger.addHandler(ch)
logger.setLevel(logging.INFO)
__version__ = "v0.3.5_debug"
__version__ = "v0.4.3"
logger.info(__version__)
@ -60,7 +61,7 @@ def stop(home):
try:
signal.signal(signal.SIGALRM, timeout_handler)
signal.alarm(15)
home.start_live_feed(user_agent="pulse.py/0.3.5",exit_condition=stop(home),retries=2,retry_interval=3.0)
home.start_live_feed(user_agent="pulse.py/0.4.3",exit_condition=stop(home),retries=4,retry_interval=5.0)
except TypeError:
logger.exception("Timeout occurred while executing start_live_feed()")
client.close()

View file

@ -1,11 +1,16 @@
#!/bin/bash
printenv > /app/env
# Start the cron service
service cron start
# Run your main application script (pulse.py) in the background
python3 /app/pulse.py &
# Keep the container running and output both cron logs and pulse.py output
tail -f /var/log/cron.log &
# Run the other script at 0, 15, 30, 45, and 60 minutes
(
while true; do
current_minute=$(date +'%M')
if [[ "$current_minute" == "00" || "$current_minute" == "15" || "$current_minute" == "30" || "$current_minute" == "45" || "$current_minute" == "00" ]]; then
python3 /app/get_price.py
fi
sleep 60 # Check every minute
done
) &
wait -n