Skip to content

Commit

Permalink
Merge branch 'release/0.2.7'
Browse files Browse the repository at this point in the history
  • Loading branch information
ledermann committed Aug 30, 2024
2 parents 1e86042 + a7ef294 commit 6decee6
Show file tree
Hide file tree
Showing 10 changed files with 163 additions and 121 deletions.
18 changes: 10 additions & 8 deletions .env.example
Original file line number Diff line number Diff line change
@@ -1,19 +1,21 @@
# Demo
# Tibber demo token, replace with your own
TIBBER_TOKEN=5K4MVS-OjfWhK_4yrjOlFe1F6kJXPVf7eQYggo8ebAE

# Update interval in seconds
TIBBER_INTERVAL=3600

# Credentials of your InfluxDB installation
INFLUX_HOST=influxdb.example.com
INFLUX_SCHEMA=https
INFLUX_PORT=443
INFLUX_TOKEN=my-super-secret-write-token
INFLUX_ORG=solectrus
INFLUX_HOST=localhost
INFLUX_SCHEMA=http
INFLUX_PORT=8086
INFLUX_TOKEN=my-token
INFLUX_ORG=my-org
INFLUX_PASSWORD=my-password
INFLUX_USERNAME=my-user

# Customize InfluxDB storage
INFLUX_BUCKET=my-solectrus-bucket
INFLUX_MEASUREMENT=Tibber
INFLUX_BUCKET=my-bucket
INFLUX_MEASUREMENT=my-prices

# Timezone
TZ=Europe/Berlin
2 changes: 1 addition & 1 deletion .github/workflows/push.yml
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ jobs:
run: bundle exec rake test

- name: Send test coverage to CodeClimate
uses: paambaati/codeclimate-action@v8.0.0
uses: paambaati/codeclimate-action@v9.0.0
if: ${{ env.CC_TEST_REPORTER_ID }}
with:
coverageCommand: true
Expand Down
14 changes: 7 additions & 7 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
FROM ruby:3.3.4-alpine AS Builder
FROM ruby:3.3.4-alpine AS builder
RUN apk add --no-cache build-base

WORKDIR /tibber-collector
Expand All @@ -15,21 +15,21 @@ LABEL maintainer="[email protected]"
RUN apk add --no-cache tzdata

# Decrease memory usage
ENV MALLOC_ARENA_MAX 2
ENV MALLOC_ARENA_MAX=2

# Move build arguments to environment variables
ARG BUILDTIME
ENV BUILDTIME ${BUILDTIME}
ENV BUILDTIME=${BUILDTIME}

ARG VERSION
ENV VERSION ${VERSION}
ENV VERSION=${VERSION}

ARG REVISION
ENV REVISION ${REVISION}
ENV REVISION=${REVISION}

WORKDIR /tibber-collector

COPY --from=Builder /usr/local/bundle/ /usr/local/bundle/
COPY --from=builder /usr/local/bundle/ /usr/local/bundle/
COPY . /tibber-collector/

ENTRYPOINT bundle exec app/main.rb
ENTRYPOINT ["bundle", "exec", "app/main.rb"]
45 changes: 25 additions & 20 deletions Gemfile.lock
Original file line number Diff line number Diff line change
@@ -1,58 +1,61 @@
GEM
remote: https://rubygems.org/
specs:
activesupport (7.1.3.4)
activesupport (7.2.1)
base64
bigdecimal
concurrent-ruby (~> 1.0, >= 1.0.2)
concurrent-ruby (~> 1.0, >= 1.3.1)
connection_pool (>= 2.2.5)
drb
i18n (>= 1.6, < 2)
logger (>= 1.4.2)
minitest (>= 5.1)
mutex_m
tzinfo (~> 2.0)
securerandom (>= 0.3)
tzinfo (~> 2.0, >= 2.0.5)
addressable (2.8.7)
public_suffix (>= 2.0.2, < 7.0)
ast (2.4.2)
base64 (0.2.0)
bigdecimal (3.1.8)
climate_control (1.2.0)
concurrent-ruby (1.3.3)
concurrent-ruby (1.3.4)
connection_pool (2.4.1)
crack (1.0.0)
bigdecimal
rexml
csv (3.3.0)
docile (1.4.0)
docile (1.4.1)
dotenv (3.1.2)
drb (2.2.1)
graphql (2.3.8)
fiber-storage (1.0.0)
graphql (2.3.14)
base64
fiber-storage
graphql-client (0.23.0)
activesupport (>= 3.0)
graphql (>= 1.13.0)
hashdiff (1.1.0)
hashdiff (1.1.1)
i18n (1.14.5)
concurrent-ruby (~> 1.0)
influxdb-client (3.1.0)
json (2.7.2)
language_server-protocol (3.17.0.3)
minitest (5.24.1)
logger (1.6.0)
minitest (5.25.1)
minitest-silence (0.2.4)
minitest (~> 5.12)
mutex_m (0.2.0)
parallel (1.25.1)
parser (3.3.4.0)
parallel (1.26.3)
parser (3.3.4.2)
ast (~> 2.4.1)
racc
public_suffix (6.0.0)
racc (1.8.0)
public_suffix (6.0.1)
racc (1.8.1)
rainbow (3.1.1)
rake (13.2.1)
regexp_parser (2.9.2)
rexml (3.3.1)
rexml (3.3.6)
strscan
rubocop (1.65.0)
rubocop (1.65.1)
json (~> 2.3)
language_server-protocol (>= 3.17.0)
parallel (~> 1.10)
Expand All @@ -63,9 +66,9 @@ GEM
rubocop-ast (>= 1.31.1, < 2.0)
ruby-progressbar (~> 1.7)
unicode-display_width (>= 2.4.0, < 3.0)
rubocop-ast (1.31.3)
rubocop-ast (1.32.1)
parser (>= 3.3.1.0)
rubocop-graphql (1.5.3)
rubocop-graphql (1.5.4)
rubocop (>= 1.50, < 2)
rubocop-minitest (0.35.1)
rubocop (>= 1.61, < 2.0)
Expand All @@ -76,6 +79,7 @@ GEM
rubocop-rake (0.6.0)
rubocop (~> 1.0)
ruby-progressbar (1.13.0)
securerandom (0.3.1)
simplecov (0.22.0)
docile (~> 1.1)
simplecov-html (~> 0.11)
Expand All @@ -86,7 +90,8 @@ GEM
tzinfo (2.0.6)
concurrent-ruby (~> 1.0)
unicode-display_width (2.5.0)
vcr (6.2.0)
vcr (6.3.1)
base64
webmock (3.23.1)
addressable (>= 2.8.0)
crack (>= 0.3.2)
Expand Down Expand Up @@ -115,4 +120,4 @@ DEPENDENCIES
webmock

BUNDLED WITH
2.5.15
2.5.18
17 changes: 8 additions & 9 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,23 +7,22 @@

Collect upcoming Tibber energy prices and push them to InfluxDB.

## Usage
This is a companion service to the [SENEC Charger](https://github.com/solectrus/senec-charger), which allows you to charge your SENEC.Home battery when energy is cheap.

1. Make sure your InfluxDB database is ready (not subject of this README)
## Usage

2. Prepare an `.env` file (see `.env.example`) with your InfluxDB credentials and the Tibber API token.
1. Prepare an `.env` file (see `.env.example`)

3. Run the Docker container on your Linux box:
2. Run the Docker containers on your Linux box:

```bash
docker run -it --rm \
--env-file .env \
ghcr.io/solectrus/tibber-collector
docker compose up
```

It's recommended to integrate the `tibber-collector` into your [SOLECTRUS hosting](https://github.com/solectrus/hosting).
In the `senec-charger` repository you can find an [example](https://github.com/solectrus/senec-charger/blob/develop/compose.yml) of how to use `tibber-collector` with the SENEC charger.

It's recommended to add `tibber-collector` and `senec-charger` to your [SOLECTRUS hosting](https://github.com/solectrus/hosting).

To charge your SENEC.Home battery when energy is cheap, you can use the [SENEC Charger](https://github.com/solectrus/senec-charger).

## License

Expand Down
36 changes: 36 additions & 0 deletions compose.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
services:
tibber-collector:
image: ghcr.io/solectrus/tibber-collector:latest
depends_on:
influxdb:
condition: service_healthy
links:
- influxdb
environment:
- TZ
- INFLUX_HOST=influxdb
- INFLUX_TOKEN
- INFLUX_ORG
- INFLUX_BUCKET
- INFLUX_MEASUREMENT
- TIBBER_TOKEN
- TIBBER_INTERVAL
restart: unless-stopped

influxdb:
image: influxdb:2.7-alpine
environment:
- DOCKER_INFLUXDB_INIT_MODE=setup
- DOCKER_INFLUXDB_INIT_USERNAME=${INFLUX_USERNAME}
- DOCKER_INFLUXDB_INIT_PASSWORD=${INFLUX_PASSWORD}
- DOCKER_INFLUXDB_INIT_ORG=${INFLUX_ORG}
- DOCKER_INFLUXDB_INIT_BUCKET=${INFLUX_BUCKET}
- DOCKER_INFLUXDB_INIT_ADMIN_TOKEN=${INFLUX_TOKEN}
command: influxd run --bolt-path /var/lib/influxdb2/influxd.bolt --engine-path /var/lib/influxdb2/engine --store disk
restart: unless-stopped
healthcheck:
test: ['CMD', 'influx', 'ping']
interval: 10s
timeout: 10s
retries: 5
start_period: 10s
Loading

0 comments on commit 6decee6

Please sign in to comment.