From 9b79b004e5673b7bc9e4557c823bf23ff939ea7d Mon Sep 17 00:00:00 2001 From: Finn Christiansen Date: Tue, 8 Oct 2024 22:15:04 +0200 Subject: [PATCH] =?UTF-8?q?=F0=9F=94=90=20add=20EnvironmentFile=20to=20sys?= =?UTF-8?q?temd=20service?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .env.example | 1 + powermeter.py | 2 +- powermeter.service | 1 + 3 files changed, 3 insertions(+), 1 deletion(-) diff --git a/.env.example b/.env.example index 277fcb0..b31ef00 100644 --- a/.env.example +++ b/.env.example @@ -5,3 +5,4 @@ INFLUXDB_BUCKET="electricity" INFLUXDB_ENABLED=True FLASK_APP_URL="http://localhost/impulses" FLASK_APP_ENABLED=True +SENSOR_PIN=27 diff --git a/powermeter.py b/powermeter.py index 9d425ef..4b8c68a 100755 --- a/powermeter.py +++ b/powermeter.py @@ -21,7 +21,7 @@ if os.getenv("INFLUXDB_ENABLED", False).lower() == "true": client = influxdb_client.InfluxDBClient(url=url, token=token, org=org) write_api = client.write_api(write_options=SYNCHRONOUS) -SENSOR_PIN = 27 +SENSOR_PIN = os.environ.get("SENSOR_PIN") GPIO.setmode(GPIO.BCM) GPIO.setup(SENSOR_PIN, GPIO.IN) diff --git a/powermeter.service b/powermeter.service index f5f154b..1a7e63b 100644 --- a/powermeter.service +++ b/powermeter.service @@ -4,6 +4,7 @@ Description=PowerMeter Service [Service] Type=simple User=root +EnvironmentFile=/etc/powermeter-environment ExecStart=/usr/local/bin/powermeter.py Restart=always RestartSec=30