Compare commits

...

30 Commits
v0.1 ... main

Author SHA1 Message Date
Nick Trimborn ed97c06180 updated dashboard
Docker Push / build (push) Successful in 42s Details
2023-07-21 11:21:06 +02:00
nick b7bc47e2d5 Update metrics.py
Docker Push / build (push) Successful in 40s Details
2023-07-20 13:32:20 +00:00
nick 9ac6a3f7da Update metrics.py
Docker Push / build (push) Successful in 40s Details
2023-07-20 13:29:51 +00:00
nick 70e44a432c Update metrics.py
Docker Push / build (push) Successful in 40s Details
2023-07-20 13:24:58 +00:00
nick cd2e65544e Update metrics.py
Docker Push / build (push) Successful in 40s Details
2023-07-20 13:16:24 +00:00
Nick Trimborn 4e45eb26f4 added error handling back in
Docker Push / build (push) Successful in 40s Details
2023-07-20 14:59:23 +02:00
Nick Trimborn 83dc893fbb updated port
Docker Push / build (push) Successful in 39s Details
2023-07-20 14:47:16 +02:00
Nick Trimborn 00f5029972 updated to match fork
Docker Push / build (push) Successful in 40s Details
2023-07-20 13:07:41 +02:00
Nick Trimborn 36c3489c55 updated workflow
Docker Push / build (push) Successful in 39s Details
2023-07-20 11:16:49 +02:00
Nick Trimborn 9213b3900f updated workflow
Docker Push / build (push) Failing after 32s Details
2023-07-20 11:13:55 +02:00
Nick Trimborn c227745639 update meta to match x.x version numbering
Docker Push / build (push) Failing after 29s Details
2023-07-20 11:09:34 +02:00
Nick Trimborn d0fd783e5f updated workflow
Docker Push / build (push) Failing after 28s Details
2023-07-20 10:59:04 +02:00
Nick Trimborn 4dc2220ed6 updated workflow
Docker Push / build (push) Successful in 1m7s Details
2023-07-20 10:53:37 +02:00
nick 385dd54468 Update .github/workflows/docker-deploy.yaml
Gitea Actions Demo / Explore-Gitea-Actions (push) Successful in 11s Details
Docker Push / build (push) Successful in 1m7s Details
2023-07-20 08:26:43 +00:00
nick 8f2f0db9da Update .github/workflows/docker-deploy.yaml
Gitea Actions Demo / Explore-Gitea-Actions (push) Successful in 11s Details
Docker Push / build (push) Successful in 1m7s Details
2023-07-20 08:23:38 +00:00
nick 97342b3bab Update .github/workflows/docker-deploy.yaml
Gitea Actions Demo / Explore-Gitea-Actions (push) Successful in 11s Details
Docker Push / build (push) Failing after 56s Details
2023-07-20 08:13:57 +00:00
Nicolas Trimborn be1bac4d9b updated repo
Gitea Actions Demo / Explore-Gitea-Actions (push) Successful in 11s Details
Docker Push / build (push) Successful in 1m7s Details
2023-07-19 20:02:00 +02:00
Nicolas Trimborn f7c499c964 fixed indent
Docker Push / build (push) Failing after 1m13s Details
Gitea Actions Demo / Explore-Gitea-Actions (push) Successful in 10s Details
2023-07-19 19:50:59 +02:00
Nicolas Trimborn 02d81ce818 fixed indent error
Gitea Actions Demo / Explore-Gitea-Actions (push) Successful in 11s Details
2023-07-19 19:48:21 +02:00
Nicolas Trimborn e6144a8b99 Merge branch 'main' of https://git.nicktrimborn.de/Nick/tasmota-power-exporter
Gitea Actions Demo / Explore-Gitea-Actions (push) Successful in 11s Details
2023-07-19 19:44:41 +02:00
Nicolas Trimborn d7ff1fa0bc updated workflow for personal gitea registry 2023-07-19 19:43:45 +02:00
nick 547c294f11 Add .github/workflows/demo.yaml
Gitea Actions Demo / Explore-Gitea-Actions (push) Successful in 12s Details
Docker / build (push) Failing after 39s Details
2023-07-19 11:27:27 +00:00
Nicolas Trimborn 2d16d728ab added devicename tagging 2023-07-18 18:25:12 +02:00
Nathan Higley 3877e91c1b
Merge pull request #1 from jlti-dev/main
add fix for updated tasmota web interface
2022-11-23 16:24:18 -05:00
Nathan Higley 5985b2f5e3
Update Dockerfile 2022-11-23 16:12:19 -05:00
Nathan Higley 099f7894ff
Update docker-publish.yml 2022-11-23 16:09:12 -05:00
Nathan Higley e56a3d6a5f
Update docker-publish.yml 2022-11-23 16:08:16 -05:00
LarsTi 2ab8a8402d
Merge pull request #2 from jlti-dev/dev
Dev
2022-11-16 09:11:34 +01:00
LarsTi 5d4c9662d9 deleted logging 2022-11-16 09:09:15 +01:00
LarsTi 5631de230d readded unit 2022-11-16 09:07:25 +01:00
8 changed files with 1604 additions and 1358 deletions

19
.github/workflows/demo.yaml.bak vendored Normal file
View File

@ -0,0 +1,19 @@
name: Gitea Actions Demo
run-name: ${{ gitea.actor }} is testing out Gitea Actions 🚀
on: [push]
jobs:
Explore-Gitea-Actions:
runs-on: ubuntu-latest
steps:
- run: echo "🎉 The job was automatically triggered by a ${{ gitea.event_name }} event."
- run: echo "🐧 This job is now running on a ${{ runner.os }} server hosted by Gitea!"
- run: echo "🔎 The name of your branch is ${{ gitea.ref }} and your repository is ${{ gitea.repository }}."
- name: Check out repository code
uses: actions/checkout@v3
- run: echo "💡 The ${{ gitea.repository }} repository has been cloned to the runner."
- run: echo "🖥️ The workflow is now ready to test your code on the runner."
- name: List files in the repository
run: |
ls ${{ gitea.workspace }}
- run: echo "🍏 This job's status is ${{ job.status }}."

66
.github/workflows/docker-deploy.yaml vendored Normal file
View File

@ -0,0 +1,66 @@
name: Docker Push
on:
push:
branches:
- 'main'
tags:
- 'v*'
pull_request:
branches:
- 'main'
jobs:
build:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v3
# Install the cosign tool except on PR
# https://github.com/sigstore/cosign-installer
# - name: Install cosign
# if: github.event_name != 'pull_request'
# uses: sigstore/cosign-installer@f3c664df7af409cb4873aa5068053ba9d61a57b6 #v2.6.0
# with:
# cosign-release: 'v1.13.1'
- name: Set up QEMU
uses: docker/setup-qemu-action@v1
# Workaround: https://github.com/docker/build-push-action/issues/461
- name: Setup Docker buildx
uses: docker/setup-buildx-action@79abd3f86f79a9d68a23c75a09a9a85889262adf
- name: Login to DockerHub
if: github.event_name != 'pull_request'
uses: docker/login-action@v2
with:
registry: git.nicktrimborn.de
username: ${{ secrets.ACTION_USER }}
password: ${{ secrets.PASSWORD }}
- name: Docker meta
id: meta
uses: docker/metadata-action@v4
with:
images: |
git.nicktrimborn.de/nick/tasmota-power-exporter
tags: |
type=ref,event=branch
type=ref,event=pr
type=semver,pattern={{version}}
type=semver,pattern={{major}}.{{minor}}
- name: Build and push
uses: docker/build-push-action@v4
with:
context: .
push: ${{ github.event_name != 'pull_request' }}
tags: |
git.nicktrimborn.de/nick/tasmota-power-exporter:latest
${{ steps.meta.outputs.tags }}
#tags: ${{ steps.meta.outputs.tags }}
#tags: git.nicktrimborn.de/nick/tasmota-power-exporter/tasmota-power-exporter:latest
labels: ${{ steps.meta.outputs.labels }}

View File

@ -1,58 +0,0 @@
name: Docker
# This workflow uses actions that are not certified by GitHub.
# They are provided by a third-party and are governed by
# separate terms of service, privacy policy, and support
# documentation.
on:
push:
branches: [ main ]
pull_request:
branches: [ main ]
env:
# Use docker.io for Docker Hub if empty
REGISTRY: ghcr.io
# github.repository as <account>/<repo>
IMAGE_NAME: ${{ github.repository }}
jobs:
build:
runs-on: ubuntu-latest
permissions:
contents: read
packages: write
steps:
- name: Checkout repository
uses: actions/checkout@v2
- name: Set up QEMU
uses: docker/setup-qemu-action@v1
- name: Setup Docker buildx
uses: docker/setup-buildx-action@v1
# Login against a Docker registry except on PR
# https://github.com/docker/login-action
- name: Log into registry ${{ env.REGISTRY }}
if: github.event_name != 'pull_request'
uses: docker/login-action@v1
with:
registry: ${{ env.REGISTRY }}
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
# Build and push Docker image with Buildx (don't push on PR)
# https://github.com/docker/build-push-action
- name: Build and push Docker image
id: build-and-push
uses: docker/build-push-action@v2
with:
context: .
push: ${{ github.event_name != 'pull_request' }}
tags: ghcr.io/astr0n8t/tasmota-power-exporter:latest
platforms: linux/arm/v7,linux/arm64/v8,linux/amd64

106
.github/workflows/docker-publish.yml.bak vendored Normal file
View File

@ -0,0 +1,106 @@
name: Docker
# This workflow uses actions that are not certified by GitHub.
# They are provided by a third-party and are governed by
# separate terms of service, privacy policy, and support
# documentation.
on:
schedule:
- cron: '41 11 * * 0'
push:
branches: [ "main" ]
# Publish semver tags as releases.
tags: [ 'v*.*.*' ]
pull_request:
branches: [ "main" ]
env:
# Use docker.io for Docker Hub if empty
REGISTRY: ghcr.io
# github.repository as <account>/<repo>
IMAGE_NAME: ${{ github.repository }}
jobs:
build:
runs-on: ubuntu-latest
permissions:
contents: read
packages: write
# This is used to complete the identity challenge
# with sigstore/fulcio when running outside of PRs.
id-token: write
steps:
- name: Checkout repository
uses: actions/checkout@v3
# Install the cosign tool except on PR
# https://github.com/sigstore/cosign-installer
- name: Install cosign
if: github.event_name != 'pull_request'
uses: sigstore/cosign-installer@f3c664df7af409cb4873aa5068053ba9d61a57b6 #v2.6.0
with:
cosign-release: 'v1.13.1'
- name: Set up QEMU
uses: docker/setup-qemu-action@v1
# Workaround: https://github.com/docker/build-push-action/issues/461
- name: Setup Docker buildx
uses: docker/setup-buildx-action@79abd3f86f79a9d68a23c75a09a9a85889262adf
# Login against a Docker registry except on PR
# https://github.com/docker/login-action
- name: Log into registry ${{ env.REGISTRY }}
if: github.event_name != 'pull_request'
uses: docker/login-action@28218f9b04b4f3f62068d7b6ce6ca5b26e35336c
with:
registry: ${{ env.REGISTRY }}
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
# Extract metadata (tags, labels) for Docker
# https://github.com/docker/metadata-action
- name: Extract Docker metadata
id: meta
uses: docker/metadata-action@98669ae865ea3cffbcbaa878cf57c20bbf1c6c38
with:
images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}
tags: |
type=ref,event=branch
type=ref,event=pr
type=semver,pattern={{version}}
type=semver,pattern={{major}}.{{minor}}
# Build and push Docker image with Buildx (don't push on PR)
# https://github.com/docker/build-push-action
- name: Build and push Docker image
id: build-and-push
uses: docker/build-push-action@ac9327eae2b366085ac7f6a2d02df8aa8ead720a
with:
context: .
push: ${{ github.event_name != 'pull_request' }}
tags: |
ghcr.io/astr0n8t/tasmota-power-exporter:latest
${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
cache-from: type=gha
cache-to: type=gha,mode=max
platforms: linux/arm/v7,linux/arm64/v8,linux/amd64
# Sign the resulting Docker image digest except on PRs.
# This will only write to the public Rekor transparency log when the Docker
# repository is public to avoid leaking data. If you would like to publish
# transparency data even for private images, pass --force to cosign below.
# https://github.com/sigstore/cosign
- name: Sign the published Docker image
if: ${{ github.event_name != 'pull_request' }}
env:
COSIGN_EXPERIMENTAL: "true"
# This step uses the identity token to provision an ephemeral certificate
# against the sigstore community Fulcio instance.
run: echo "${{ steps.meta.outputs.tags }}" | xargs -I {} cosign sign {}@${{ steps.build-and-push.outputs.digest }}

View File

@ -1,9 +1,10 @@
FROM python:alpine
RUN apk add --no-cache tini
ADD metrics.py /metrics.py
ADD requirements.txt /requirements.txt
RUN pip install -r /requirements.txt
ADD metrics.py /app/metrics.py
ADD requirements.txt /tmp/requirements.txt
RUN pip install -r /tmp/requirements.txt && \
rm -rf /tmp/requirements.txt
ENTRYPOINT ["/sbin/tini", "--"]
CMD ["python" , "/metrics.py"]
CMD ["python" , "/app/metrics.py"]

File diff suppressed because it is too large Load Diff

View File

@ -5,13 +5,15 @@ from os import getenv
from time import sleep
from prometheus_client.core import GaugeMetricFamily, REGISTRY, CounterMetricFamily
from prometheus_client import start_http_server
from loguru import logger
class TasmotaCollector(object):
def __init__(self):
self.ip = getenv('DEVICE_IP')
if not self.ip:
self.ip = "192.168.4.1"
logger.info("Env variable from DEVICE_NAME used is: " + self.ip)
self.device_name = getenv("DEVICE_NAME").lower()
logger.info("Env variable from DEVICE_NAME used is: " + self.device_name)
self.user = getenv('USER')
self.password = getenv('PASSWORD')
@ -36,7 +38,7 @@ class TasmotaCollector(object):
def fetch(self):
url = 'http://' + self.ip + '/?m=1'
logger.info("Getting Metrics from: " + url)
session = requests.Session()
if self.user and self.password:
@ -53,7 +55,8 @@ class TasmotaCollector(object):
label = string_values[i].split("{m}")[0]
value = string_values[i].split("{m}")[1].split("{e}")[0]
if "<td" in value:
value = value.replace("</td><td style='text-align:left'>", "").split("</td>")[0]
value = value.replace("</td><td style='text-align:left'>", "")
value = value.replace("</td><td>&nbsp;</td><td>", "")
values[label] = value
except IndexError:
@ -68,12 +71,9 @@ signal.signal(signal.SIGINT, signal_handler)
if __name__ == '__main__':
port = getenv('EXPORTER_PORT')
if not port:
port = 8000
logger.info("Starting HTTP server on port: " + port)
start_http_server(int(port))
REGISTRY.register(TasmotaCollector())
while(True):
sleep(1)

View File

@ -1,2 +1,3 @@
prometheus_client
requests
requests
loguru