Skip to content

Commit

Permalink
add a test build for github
Browse files Browse the repository at this point in the history
  • Loading branch information
whitty committed Jul 25, 2024
1 parent 2d15786 commit c6b47f4
Show file tree
Hide file tree
Showing 2 changed files with 105 additions and 0 deletions.
42 changes: 42 additions & 0 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
name: Test build for emerald_ble
on:
push:
pull_request:

jobs:
build:
name: ${{matrix.python}} on ${{matrix.os}}
runs-on: ${{matrix.os}}
strategy:
fail-fast: true
matrix:
os: [ubuntu-latest]
python:
- 3.12

timeout-minutes: 10
steps:
- uses: actions/checkout@v4

- uses: actions/setup-python@v5
with:
python-version: ${{matrix.python}}
cache: 'pip' # caching pip dependencies
cache-dependency-path: '**/requirements-dev.txt'

- name: Install esphome
run: pip install -r test/requirements-dev.txt

- uses: actions/cache@v3
id: esphome-cache # use this to check for `cache-hit` ==> if: steps.esphome-cache.outputs.cache-hit != 'true'
with:
path: |
test/.esphome/**
$HOME/.platformio/**
key: ${{ matrix.os }}-${{matrix.python}}-esphome

- name: Check config
run: esphome config tests/*emerald*.yaml

- name: Build
run: esphome compile tests/*emerald*.yaml
63 changes: 63 additions & 0 deletions tests/test-emerald-ble.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
substitutions:
name: emerald-reader

esphome:
name: $name
friendly_name: emerald_reader
platformio_options:
build_flags:
- -Wall
- -Wextra

esp32:
board: esp32dev
framework:
type: arduino

# Enable logging
logger:
level: DEBUG

# Enable Home Assistant API
api:
{}

ota:
platform: esphome

wifi:
ap:
{}

captive_portal:

external_components:
- source: ../esphome/components
# requires ble_client and ble_tracker because I had to add some small features to authenticate properly
components: [ ble_client, esp32_ble_tracker, emerald_ble ]

# optional requirement used with daily energy sensor
time:
- platform: homeassistant
id: homeassistant_time

esp32_ble_tracker:

ble_client:
- mac_address: 01:02:03:04:05:06
id: emerald_advisor

sensor:
- platform: emerald_ble
ble_client_id: emerald_advisor
power:
name: "Emerald Power"
daily_energy:
name: "Emerald Daily Energy"
energy:
name: "Emerald Total Energy"
battery_level:
name: "Emerald Battery"
pairing_code: 012345
pulses_per_kwh: 3200
time_id: homeassistant_time # daily energy still works without a time_id, but recommended to include one to properly handle daylight savings, etc.

0 comments on commit c6b47f4

Please sign in to comment.