Skip to content

Commit

Permalink
update build actions, esphome, logger
Browse files Browse the repository at this point in the history
- Merge Github actions into one file
- Add current Home Assistant version check
- Add custom component downloads for YAML based integrations
- Add ESPHome config
- Clean up logger
- Fix linting
  • Loading branch information
zanix committed Oct 27, 2023
1 parent db37622 commit 7fd9526
Show file tree
Hide file tree
Showing 11 changed files with 712 additions and 62 deletions.
26 changes: 0 additions & 26 deletions .github/workflows/build.yaml

This file was deleted.

113 changes: 113 additions & 0 deletions .github/workflows/home-assistant.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,113 @@
---
# Source: https://github.com/frenck/action-home-assistant
# Example: https://github.com/frenck/home-assistant-config/blob/master/.github/workflows/home-assistant.yml
#
name: Home Assistant CI
# yamllint disable-line rule:truthy
on:
push:
pull_request:
schedule:
- cron: 0 12 * * 4
jobs:
yamllint:
name: 🧹 YAML Lint
runs-on: ubuntu-latest
steps:
- name: 📥 Check out repository
uses: actions/[email protected]
- name: 🚀 Run YAMLlint
uses: frenck/[email protected]

remarklint:
name: 🧹 Remark Lint
runs-on: ubuntu-latest
steps:
- name: 📥 Check out repository
uses: actions/[email protected]
- name: 🚀 Run Remark lint
uses: "docker://pipelinecomponents/remark-lint:latest"
continue-on-error: true
with:
args: "remark --no-stdout --color --frail --use preset-lint-recommended ."

ha_version:
name: "🏠 Get Home Assistant Version"
runs-on: ubuntu-latest
outputs:
current_version: ${{ steps.currentver.outputs.current_version }}
steps:
- name: 📥 Check out repository
uses: actions/[email protected]
- name: 🚀 Get Installed Version from .HA_VERSION
id: currentver
run: |
HA_VERSION=$(<.HA_VERSION)
echo $HA_VERSION
echo "current_version=$HA_VERSION" >> $GITHUB_OUTPUT
home-assistant:
name: "🏠 Home Assistant Core ${{ matrix.version }} Configuration Check"
needs: [yamllint, ha_version]
runs-on: ubuntu-latest
strategy:
matrix:
version: ["${{ needs.ha_version.outputs.current_version }}", "stable", "beta", "dev"]
steps:
- name: 📥 Check out repository
uses: actions/[email protected]

- name: 📄 Create empty files
run: |
touch ./home-assistant_v2.db
touch ./home-assistant.log
- name: 📁 Create custom_components folder
run: |
mkdir -p ./custom_components
# Check out custom components that require YAML configuration.
# yamllint disable rule:line-length

- name: 📥 Clone custom component (Dreamscreen)
run: |
git clone https://github.com/J3n50m4t/Home-Assistant-DreamScreen-Service.git
mv -v Home-Assistant-DreamScreen-Service/custom_components/* ./custom_components
- name: 📥 Clone custom component (UniFi Status)
run: |
git clone https://github.com/zvldz/unifi_status.git
mv -v unifi_status/custom_components/* ./custom_components
# yamllint enable rule:line-length

- name: 🚀 Run Home Assistant Configuration Check
uses: frenck/[email protected]
with:
path: "."
secrets: ./.stubs/secrets.yaml
version: "${{ matrix.version }}"

esphome:
name: "🛠️ ESPHome Configuration Check"
runs-on: ubuntu-latest
needs: [yamllint]
steps:
- name: 📥 Check out repository
uses: actions/[email protected]
- name: Set up Python 3.8
uses: actions/setup-python@v4
with:
python-version: 3.8
- name: Install dependencies
run: |
python -m pip install --upgrade pip setuptools wheel
pip install esphome
pip list
esphome version
- name: Copy secrets stub into configuration folder
run: cp ./.stubs/espsecrets.yaml ./esphome/secrets.yaml
- name: 🚀 Run ESPHome on all files
# yamllint disable rule:line-length
run: |
for file in $(find ./esphome -type f -name "*.yaml" -maxdepth 1 -not -name "secrets.yaml"); do esphome "${file}" config; done
25 changes: 0 additions & 25 deletions .github/workflows/linters.yaml

This file was deleted.

8 changes: 8 additions & 0 deletions .stubs/espsecrets.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
---
# Example Secrets
#
wifi_ssid: "wifi_ssid"
wifi_password: "wifi_password"
ota_password: "ota_password"
ap_password: "ap_password"
encryption_key: "encryption_key"
4 changes: 2 additions & 2 deletions .yamllint
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,9 @@ ignore: |
.history/
blueprints/
custom_components/
integrations/keymaster/
lovelace/minimalist.yaml
packages/keymaster/
themes/
zigbee2mqtt/
automations.yaml
customize.yaml
govee_learning.yaml
Expand Down
6 changes: 6 additions & 0 deletions esphome/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
# Gitignore settings for ESPHome
# This is an example and may include too much for your use-case.
# You can modify this file to suit your needs.
/.esphome/
/secrets.yaml
/trash/
97 changes: 97 additions & 0 deletions esphome/car-presence.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,97 @@
---
# Car presence & position detection in Home Assistant with ESPHome
# source: https://adonno.com/car-presence-position-detection/

esphome:
name: car-presence
friendly_name: Car Presence

esp8266:
board: d1_mini

# Enable logging
logger:

# Enable Home Assistant API
api:
encryption:
key: !secret encryption_key

ota:
password: !secret ota_password

wifi:
ssid: !secret wifi_ssid
password: !secret wifi_password
fast_connect: true

# Enable fallback hotspot (captive portal) in case wifi connection fails
ap:
ssid: "AP"
password: !secret ap_password
ap_timeout: 3min

captive_portal:

time:
- platform: homeassistant
id: homeassistant_time
timezone: America/Boise

text_sensor:
- platform: version
name: "ESPHome Version"

- platform: wifi_info
ip_address:
name: "IP"
ssid:
name: "SSID"
bssid:
name: "BSSID"

button:
- platform: restart
name: "Restart"

binary_sensor:
- platform: template
name: "Left"
device_class: presence
lambda: |-
return id(car_presence_left_distance).state < 1.5;
- platform: template
name: "Right"
device_class: presence
lambda: |-
return id(car_presence_right_distance).state < 1.5;
sensor:
- platform: uptime
name: "Uptime"
unit_of_measurement: h
filters:
- lambda: return int((x + 1800.0) / 3600.0);

- platform: wifi_signal
name: "Wifi Signal"
update_interval: 5min

- platform: ultrasonic
name: "Left Distance"
id: "car_presence_left_distance"
trigger_pin: D1
echo_pin: D2
update_interval: 10s
filters:
- filter_out: nan

- platform: ultrasonic
name: "Right Distance"
id: "car_presence_right_distance"
trigger_pin: D3
echo_pin: D0
update_interval: 10s
filters:
- filter_out: nan
Loading

0 comments on commit 7fd9526

Please sign in to comment.