Skip to content

Commit

Permalink
add default waveform icon to sensors
Browse files Browse the repository at this point in the history
  • Loading branch information
stas-sl committed Sep 29, 2024
1 parent 776e621 commit 068c0c3
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 24 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/ci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ jobs:
name: ${{ matrix.name }}
runs-on: ubuntu-latest
env:
ESPHOME_VERSION: 2023.11.6
ESPHOME_VERSION: 2024.9.0
PLATFORMIO_LIBDEPS_DIR: ~/.platformio/libdeps
strategy:
fail-fast: false
Expand Down Expand Up @@ -58,7 +58,7 @@ jobs:
- name: Run clang-format
run: |
clang-format-13 --dry-run --Werror $(git ls-files '*.cpp' '*.h')
clang-format --dry-run --Werror $(git ls-files '*.cpp' '*.h')
- name: Compile configs
run: |
Expand Down
6 changes: 3 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -264,9 +264,9 @@ I'm not so familiar with assembler and it is hard to understand and maintain, so
### Supported platforms
Tested with ESPHome version 2023.2.0, platforms:
- [x] ESP32 (Arduino v2.0.5, ESP-IDF v4.4.2)
- [x] ESP32-IDF (ESP-IDF v4.4.2)
Tested with ESPHome version 2024.9.0, platforms:
- [x] ESP32 (Arduino v2.0.6, ESP-IDF v4.4.5)
- [x] ESP32-IDF (ESP-IDF v4.4.7)
### Sending data to sensor.community
Expand Down
13 changes: 9 additions & 4 deletions components/sound_level_meter/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -55,22 +55,25 @@
CONF_OFFSET = "offset"
CONF_IS_ON = "is_on"

ICON_WAVEFORM = "mdi:waveform"

CONFIG_SENSOR_SCHEMA = cv.typed_schema(
{
CONF_EQ: sensor.sensor_schema(
SoundLevelMeterSensorEq,
unit_of_measurement=UNIT_DECIBEL,
accuracy_decimals=2,
state_class=STATE_CLASS_MEASUREMENT
state_class=STATE_CLASS_MEASUREMENT,
icon=ICON_WAVEFORM
).extend({
cv.Optional(CONF_UPDATE_INTERVAL): cv.positive_time_period_milliseconds
}),
CONF_MAX: sensor.sensor_schema(
SoundLevelMeterSensorMax,
unit_of_measurement=UNIT_DECIBEL,
accuracy_decimals=2,
state_class=STATE_CLASS_MEASUREMENT
state_class=STATE_CLASS_MEASUREMENT,
icon=ICON_WAVEFORM
).extend({
cv.Optional(CONF_UPDATE_INTERVAL): cv.positive_time_period_milliseconds,
cv.Required(CONF_WINDOW_SIZE): cv.positive_time_period_milliseconds
Expand All @@ -79,7 +82,8 @@
SoundLevelMeterSensorMin,
unit_of_measurement=UNIT_DECIBEL,
accuracy_decimals=2,
state_class=STATE_CLASS_MEASUREMENT
state_class=STATE_CLASS_MEASUREMENT,
icon=ICON_WAVEFORM
).extend({
cv.Optional(CONF_UPDATE_INTERVAL): cv.positive_time_period_milliseconds,
cv.Required(CONF_WINDOW_SIZE): cv.positive_time_period_milliseconds
Expand All @@ -88,7 +92,8 @@
SoundLevelMeterSensorPeak,
unit_of_measurement=UNIT_DECIBEL,
accuracy_decimals=2,
state_class=STATE_CLASS_MEASUREMENT
state_class=STATE_CLASS_MEASUREMENT,
icon=ICON_WAVEFORM
).extend({
cv.Optional(CONF_UPDATE_INTERVAL): cv.positive_time_period_milliseconds
})
Expand Down
18 changes: 3 additions & 15 deletions configs/sensor-community-example-config.yaml
Original file line number Diff line number Diff line change
@@ -1,17 +1,6 @@
---
esphome:
name: sound-level-meter
includes:
# should contain single line: #include <esp_task_wdt.h>
- wdt_include.h

on_boot:
then:
- lambda: !lambda |-
// increase watchdog timeout to 30 seconds
// so that ESP32 don't crash on long http requests
// which might happen with sensor.community quite often
esp_task_wdt_init(30, false);

external_components:
- source: github://stas-sl/esphome-sound-level-meter
Expand All @@ -29,17 +18,17 @@ api:
reboot_timeout: 0s

ota:
platform: esphome
password: !secret ota_password

http_request:
# default is 5 seconds, but you might consider increasing it,
# if data will be missing in sensor.community
verify_ssl: false
timeout: 5s
watchdog_timeout: 10s

wifi:
ssid: !secret wifi_ssid
password: !secret wifi_password
reboot_timeout: 0s
fast_connect: true

web_server:
Expand Down Expand Up @@ -97,7 +86,6 @@ interval:
lambda: 'return id(LAeq_1min).has_state();'
then:
- http_request.post:
verify_ssl: false
url: http://api.sensor.community/v1/push-sensor-data/
headers:
X-Pin: 15
Expand Down

0 comments on commit 068c0c3

Please sign in to comment.