Sign inSign up

gf78/smartmetervienna

By gf78

•Updated almost 3 years ago

Save your smart meter measurements automatically to your influx database. (Wiener Netze)

Image
0

50K+

gf78/smartmetervienna repository overview

⁠SmartMeter Vienna

⁠Table of Contents

⁠Features

  • Support smart meters used in Vienna by Wiener Netze
  • Retrieve power consumption and avg. load for a single day or for a date range (max. 3yrs)
  • Store values into influx database (V2)
  • Import measurements for a single day or a date range manually via the web UI
  • Run daily cron job to store data of prev. day(s)
  • Retrieve measurement data via Rest API
  • Optional API-KEY authorization
  • Swagger: API definition and interactive web UI
  • Check service configuration and log on web UI
  • Receive email notifications about cron job result
  • Trigger webhook requests on cron job run
  • Grafana dashboard JSON model included
  • Extensive logging service
  • Dockerized based on Alpine Linux image

⁠Screenshots

⁠Grafana Dashboard

Grafana Dashboard

⁠Swagger UI for Rest API

Swagger UI

Swagger UI

⁠Web UI

Login

Home

Import

Log

Config

Info

⁠Prerequisites

⁠Installation

Edit the docker-compose.ymlfile and create a new docker container:

version: "3.3"
services:
  smartmetervienna:
    container_name: smartmetervienna
    image: "gf78/smartmetervienna:latest"
    restart: unless-stopped
    ports:
      - "80:1978"
    environment:
      PORT: 1978
      API_KEY: "xxx"
      LOG_LEVEL: "error"
      CRON_SCHEDULE: "0 12 * * *"
      CRON_DAYS_IN_PAST: "7"
      LOGWIEN_USERNAME: "xxx"
      LOGWIEN_PASSWORD: "xxx"
      INLUXDB_URL: "http://xxx:8086"
      INLUXDB_ORGANISATION: "xxx"
      INLUXDB_BUCKET: "smartmetervienna"
      INLUXDB_MEASUREMENT: "Consumption_15min_Wh"
      INLUXDB_TOKEN: "xxx"
      SMTP_HOST: "xxx"
      SMTP_PORT: 587
      SMTP_SECURE: false
      SMTP_CIPHERS: "SSLv3"
      SMTP_USERNAME: "xxx"
      SMTP_PASSWORD: "xxx"
      SMTP_FROM: "xxx"
      SMTP_TO: "xxx"
      MAIL_ENABLED: false
      MAIL_SUBJECT: "SmartMeter Vienna"
      MAIL_ON_SUCCESS: true
      MAIL_ON_FAILURE: true
      MAIL_ON_RESTART: true
      WEBHOOK_ENABLED: false
      WEBHOOK_METHOD: POST
      WEBHOOK_URL_RESTART: "http(s)://xxx"
      WEBHOOK_URL_SUCCESS: "http(s)://xxx"
      WEBHOOK_URL_FAILURE: "http(s)://xxx"
    volumes:
      - "smartmetervienna-logs:/logs"
volumes:
  smartmetervienna-logs:
    external: true
    name: smartmetervienna-logs

⁠Configuration

Use the following environment variables to configure the service

VariableDescriptionMandatory
PORTWeb UI port 1978no
API_KEYSecure Web UI and Rest APIno
LOG_LEVELLevel of logging service error, info, verboseno
CRON_SCHEDULESchedule for cron job 0 10,16 * * *no
CRON_DAYS_IN_PASTNumber of days in the past should be importedno
LOGWIEN_USERNAMEUsername for smart meter portal of Wiener Netzeyes
LOGWIEN_PASSWORDPassword for smart meter portal of Wiener Netzeyes
METER_IDMeter id (Zählerpunkt) of Wiener Netzeno
INLUXDB_URLURL of influx db http://xxx:8086no
INLUXDB_TOKENToken of influx dbno
INLUXDB_ORGANISATIONOrganisation of influx dbno
INLUXDB_BUCKETBucket of influx db (default: smartmetervienna)no
INLUXDB_MEASUREMENTMeasurement name for influx db (default: Consumption_15min_Wh)no
SMTP_HOSTSMTP server hostno
SMTP_PORTSMTP server port 587no
SMTP_SECURESMTP server sercurity true, falseno
SMTP_CIPHERSSMTP server ciphers SSLv3no
SMTP_USERNAMESMTP server usernameno
SMTP_PASSWORDSMTP server passwordno
SMTP_FROMSender email addressno
MAIL_ENABLEDEmail notifications enabled: true, falseno
MAIL_TOReceipients email addressno
MAIL_SUBJECTEmail subjectno
MAIL_ON_SUCCESSSend otifications on success: true, falseno
MAIL_ON_FAILURESend otifications on failure: true, falseno
MAIL_ON_RESTARTSend otifications on restart: true, falseno
WEBHOOK_ENABLEDWebhook notifications enabled: true, falseno
WEBHOOK_METHODWebhook protocol: POST, GETno
WEBHOOK_URL_RESTARTWebhook URL on restartno
WEBHOOK_URL_SUCCESSWebhook URL on success, supported placeholders %%FROM%%, %%TO%%, %%DAYS%%, %%COUNT%%, %%RATE%% and %%SUCCESS%%no
WEBHOOK_URL_FAILUREWebhook URL on failure, supported placeholders %%FROM%%, %%TO%%, %%DAYS%%, %%COUNT%%, %%RATE%% and %%SUCCESS%%no

⁠Cron Job

Set CRON_SCHEDULE ENV variable for example to "0 10,16 * * * to request daily at 10am and 4pm the measurements of the last day(s) and store them into the database. If enabled you will receive email and/or webhook notifications on success/failure. It is recommended to set CRON_DAYS_IN_PAST to a value greater than 1 to import measurements that where not provided in time by Wiener Netzte on one of the following days.

Schedule format: https://crontab.guru/⁠

⁠Rest API

See swagger file for more details.

⁠Security

Set a value for the ENV variable API_KEY to activate the authorization for the Rest API and the Web UI. The ApiKey can be provided as header, query param or cookie.

⁠Meter
  • Original response of SmartMeter-Portal: /api/v1/meter/raw?from=YYYY-MM-DD&to=YYYY-MM-DD
  • Basic measurements for DB storage: /api/v1/meter/measurements?from=YYYY-MM-DD&to=YYYY-MM-DD
  • Enhanced consumption measurements /api/v1/meter/consumption?from=YYYY-MM-DD&to=YYYY-MM-DD
  • Enhanced load measurements /api/v1/meter/load?from=YYYY-MM-DD&to=YYYY-MM-DD
[
  {
    "measurement": "Consumption",
    "unit": "Wh",
    "value": 97,
    "timestamp": "2023-03-31T22:00:00.000Z",
    "start": "2023-03-31T22:00:00.000Z",
    "end": "2023-03-31T22:14:59.999Z",
    "text": "97Wh"
  },
  {}
]
⁠Log
  • Get log of the current day: /api/v1/log
[
  {
    "level": "info",
    "message": "[WEB] Listening on port 1978",
    "timestamp": "2023-04-27T06:45:46.806Z"
  },
  {}
]

⁠Web UI

Access the status page: //your-server:your-port/

  • Home: Check current version and if update is available
  • Import: Manually trigger import of measurements to database
  • Log: Check log entries
  • Config: Check current configuration
  • Info: Further information and links

⁠Notifications

⁠Email

Configure the SMTP/Email service to receive emails in case of restart, cron job success and cron jobfailure.

⁠Webhook

Configure the webhook service to receive GET or POST webhook requests in case of restart, cron job success and cron job failure. The payload of a POST request will include the retrieved measurement data.

Use the following placeholder in the URL if needed: %%FROM%%, %%TO%%, %%DAYS%%, %%COUNT%%, %%RATE%% and %%SUCCESS%%

⁠Grafana

Feel free to use the included Grafana Dashboard Model⁠.

Tag summary

Content type

Image

Digest

sha256:fe877bdc6…

Size

76.1 MB

Last updated

almost 3 years ago

docker pull gf78/smartmetervienna