backup 20240718
This commit is contained in:
@@ -1,45 +1,37 @@
|
||||
# ESPHome code for the LilyGO TTGO Display
|
||||
# Copyright 2023 by Smart Home Junkie
|
||||
#
|
||||
# Visit my website at https://www.smarthomejunkie.net
|
||||
# Watch the tutorial for this display and code at https://youtu.be/LJCeelAzlS0
|
||||
|
||||
substitutions:
|
||||
esp_name: "ttgo-display"
|
||||
device_name: "ttgo-display"
|
||||
friendly_name: "ttgo-display"
|
||||
comment: "esp32, display, distance"
|
||||
api_password: !secret ttgo-t-display_api
|
||||
ota_password: !secret ota_password
|
||||
wifi_ssid: !secret wifi_ssid
|
||||
wifi_password: !secret wifi_password
|
||||
gateway: !secret ip_gateway
|
||||
subnet: !secret ip_subnet
|
||||
ip: !secret ttgo-t-display_ip
|
||||
pin_sda: GPIO21
|
||||
pin_scl: GPIO22
|
||||
pin_but0: GPIO0
|
||||
pin_but1: GPIO35
|
||||
pin_spi_clk: GPIO18
|
||||
pin_spi_mosi: GPIO19
|
||||
pin_lcd_bl: GPIO4
|
||||
pin_lcd_cs: GPIO5
|
||||
pin_lcd_dc: GPIO16
|
||||
pin_lcd_rst: GPIO23
|
||||
|
||||
esphome:
|
||||
name: ${esp_name}
|
||||
comment: ${esp_name}
|
||||
|
||||
# Enable Home Assistant API
|
||||
api:
|
||||
encryption:
|
||||
key: !secret ttgo
|
||||
|
||||
# Define board type
|
||||
esp32:
|
||||
board: esp32dev
|
||||
|
||||
# Enable logging
|
||||
logger:
|
||||
|
||||
ota:
|
||||
password: !secret aqs1_ota_passwoord
|
||||
|
||||
wifi:
|
||||
ssid: !secret wifi_ssid
|
||||
password: !secret wifi_password
|
||||
|
||||
# Enable fallback hotspot (captive portal) in case wifi connection fails
|
||||
ap:
|
||||
ssid: ${esp_name} fallback
|
||||
password: !secret fallback_password
|
||||
|
||||
captive_portal:
|
||||
packages:
|
||||
board: !include boards/esp32_wroom_arduino.yaml
|
||||
device_base: !include common/common.yaml
|
||||
connection: !include common/wifi.yaml
|
||||
logger: !include templates/logger.yaml
|
||||
time: !include templates/time.yaml
|
||||
|
||||
spi:
|
||||
clk_pin: GPIO18
|
||||
mosi_pin: GPIO19
|
||||
clk_pin: ${pin_spi_clk}
|
||||
mosi_pin: ${pin_spi_mosi}
|
||||
|
||||
# Define the rotate variable. This indicates if the pages should be rotated or not
|
||||
globals:
|
||||
@@ -47,16 +39,12 @@ globals:
|
||||
type: boolean
|
||||
initial_value: "true"
|
||||
|
||||
# Define time sensor
|
||||
time:
|
||||
- platform: homeassistant
|
||||
id: esptime
|
||||
|
||||
# Define binary sensors
|
||||
binary_sensor:
|
||||
- platform: gpio # Short Press button 0
|
||||
pin:
|
||||
number: GPIO0
|
||||
number: ${pin_but0}
|
||||
inverted: true
|
||||
mode:
|
||||
input: true
|
||||
@@ -69,31 +57,9 @@ binary_sensor:
|
||||
then:
|
||||
- display.page.show_previous: my_display
|
||||
- component.update: my_display
|
||||
- platform: gpio # Long Press button 0
|
||||
pin:
|
||||
number: GPIO0
|
||||
inverted: true
|
||||
id: button_2
|
||||
on_click:
|
||||
min_length: 1001ms
|
||||
max_length: 5000ms
|
||||
then:
|
||||
- switch.toggle: backlight
|
||||
- platform: gpio # Short Press button 1
|
||||
pin:
|
||||
number: GPIO35
|
||||
inverted: true
|
||||
name: "Short Press Button 1"
|
||||
id: short_press_button_1
|
||||
on_click:
|
||||
min_length: 1ms
|
||||
max_length: 1000ms
|
||||
then:
|
||||
- display.page.show_next: my_display
|
||||
- component.update: my_display
|
||||
- platform: gpio # Long Press button 1
|
||||
pin:
|
||||
number: GPIO35
|
||||
number: ${pin_but1}
|
||||
inverted: true
|
||||
name: "Long Press Button 1"
|
||||
id: long_press_button_1
|
||||
@@ -114,28 +80,9 @@ binary_sensor:
|
||||
id: rotate
|
||||
value: "true"
|
||||
|
||||
# Allow dimmable control of the backlight (pin GPIO4) - Currently not working
|
||||
output:
|
||||
- platform: ledc
|
||||
pin: GPIO4
|
||||
id: gpio4
|
||||
|
||||
light:
|
||||
- platform: monochromatic
|
||||
output: gpio4
|
||||
name: "Backlight"
|
||||
|
||||
switch:
|
||||
- platform: gpio
|
||||
pin: GPIO4
|
||||
id: backlight
|
||||
internal: true
|
||||
|
||||
# Define all the numeric sensors used
|
||||
sensor:
|
||||
- platform: homeassistant
|
||||
entity_id: sensor.subscriptions_short
|
||||
id: subscriptions
|
||||
- platform: homeassistant
|
||||
entity_id: sensor.views
|
||||
id: views
|
||||
@@ -144,17 +91,11 @@ sensor:
|
||||
attribute: netto_power
|
||||
id: nettopower
|
||||
- platform: homeassistant
|
||||
entity_id: sensor.Temperatuur_Zolder_Werkkamer
|
||||
entity_id: sensor.esp32_s2_aqs_ikea_temperature
|
||||
id: office_temperature
|
||||
- platform: homeassistant
|
||||
entity_id: sensor.humidity_zolder_werkkamer
|
||||
entity_id: sensor.esp32_s2_aqs_ikea_humidity
|
||||
id: office_humidity
|
||||
- platform: homeassistant
|
||||
entity_id: sensor.office_multi_sensor_pressure
|
||||
id: office_pressure
|
||||
- platform: homeassistant
|
||||
entity_id: sensor.office_light_sensor
|
||||
id: office_light_sensor
|
||||
- platform: homeassistant
|
||||
entity_id: sensor.ttgo_display_data
|
||||
attribute: temperature
|
||||
@@ -164,7 +105,7 @@ sensor:
|
||||
attribute: wind_speed
|
||||
id: wind_speed
|
||||
- platform: homeassistant
|
||||
entity_id: sensor.bitcoin
|
||||
entity_id: sensor.exchange_rate_1_btc
|
||||
id: bitcoin
|
||||
|
||||
# Define all the string sensors used
|
||||
@@ -274,7 +215,7 @@ graph:
|
||||
duration: 4h
|
||||
width: 220
|
||||
height: 90
|
||||
x_grid: 1h
|
||||
x_grid: 1min
|
||||
y_grid: 5
|
||||
min_range: 5
|
||||
max_range: 35
|
||||
@@ -286,31 +227,31 @@ graph:
|
||||
duration: 4h
|
||||
width: 220
|
||||
height: 90
|
||||
x_grid: 1h
|
||||
x_grid: 1min
|
||||
y_grid: 25
|
||||
min_range: 1
|
||||
max_range: 100
|
||||
min_value: 1
|
||||
max_value: 100
|
||||
color: BLUE
|
||||
- id: office_pressure_graph
|
||||
sensor: office_pressure
|
||||
- id: power_graph
|
||||
sensor: nettopower
|
||||
duration: 4h
|
||||
width: 220
|
||||
height: 90
|
||||
x_grid: 1h
|
||||
x_grid: 15min
|
||||
y_grid: 100.0
|
||||
color: YELLOW
|
||||
- id: office_light_sensor_graph
|
||||
duration: 4h
|
||||
width: 220
|
||||
height: 90
|
||||
x_grid: 1h
|
||||
traces:
|
||||
- sensor: office_light_sensor
|
||||
color: ORANGE
|
||||
line_type: SOLID
|
||||
line_thickness: 5
|
||||
# - id: office_light_sensor_graph
|
||||
# duration: 4h
|
||||
# width: 220
|
||||
# height: 90
|
||||
# x_grid: 1h
|
||||
# traces:
|
||||
# - sensor: office_light_sensor
|
||||
# color: ORANGE
|
||||
# line_type: SOLID
|
||||
# line_thickness: 5
|
||||
|
||||
# Define qr code locations
|
||||
qr_code:
|
||||
@@ -321,51 +262,28 @@ qr_code:
|
||||
display:
|
||||
- platform: st7789v
|
||||
model: TTGO_TDISPLAY_135x240
|
||||
backlight_pin: GPIO4
|
||||
cs_pin: GPIO5
|
||||
dc_pin: GPIO16
|
||||
reset_pin: GPIO23
|
||||
backlight_pin: ${pin_lcd_bl}
|
||||
cs_pin: ${pin_lcd_cs}
|
||||
dc_pin: ${pin_lcd_dc}
|
||||
reset_pin: ${pin_lcd_rst}
|
||||
rotation: 90°
|
||||
update_interval: 1s
|
||||
id: my_display
|
||||
pages: # Define the pages
|
||||
# - id: showintro
|
||||
# lambda: |-
|
||||
# it.image(0, 10, id(logo));
|
||||
# it.printf(135, 10, id(latoblack), WHITE, "SMART");
|
||||
# it.printf(140, 50, id(latoblack), WHITE, "HOME");
|
||||
# it.printf(130, 90, id(latoblack), WHITE, "JUNKIE");
|
||||
- id: showtime
|
||||
lambda: |-
|
||||
it.strftime(45, 20, id(latoblack), "%d-%m-%Y", id(esptime).now());
|
||||
it.strftime(25, 55, id(latoblackheading1), "%H:%M:%S", id(esptime).now());
|
||||
# - id: showsubscribers
|
||||
# lambda: |-
|
||||
# it.printf(0,0,id(latoblack), WHITE, "SUBSCRIBERS");
|
||||
# it.image(0, 40, id(youtube_image));
|
||||
# if (id(subscriptions).has_state()) {
|
||||
# it.printf(95, 60, id(latoblack), WHITE, "%.1fK", id(subscriptions).state);
|
||||
# } else {
|
||||
# it.printf(95, 65, id(lato), WHITE, "LOADING...");
|
||||
# }
|
||||
# - id: showviews
|
||||
# lambda: |-
|
||||
# it.printf(0,0,id(latoblack), WHITE, "VIEWS");
|
||||
# it.image(0, 40, id(youtube_image));
|
||||
# if (id(views).has_state()) {
|
||||
# it.printf(95, 60, id(latoblack), WHITE, "%.0f", id(views).state);
|
||||
# } else {
|
||||
# it.printf(95, 65, id(lato), WHITE, "LOADING...");
|
||||
# }
|
||||
it.strftime(45, 20, id(latoblack), "%d-%m-%Y", id(homeassistant_time).now());
|
||||
it.strftime(25, 55, id(latoblackheading1), "%H:%M:%S", id(homeassistant_time).now());
|
||||
|
||||
- id: shownettopower
|
||||
lambda: |-
|
||||
it.printf(0,0,id(latoblack), WHITE, "NETTO POWER");
|
||||
it.image(0, 40, id(electricity_image));
|
||||
if (id(nettopower).has_state()) {
|
||||
if (id(nettopower).state > -1000) {
|
||||
it.printf(95, 60, id(latoblack), WHITE, "%.0f Watt", id(nettopower).state);
|
||||
it.printf(95, 60, id(latoblack), WHITE, "%.2f kWh", id(nettopower).state);
|
||||
} else {
|
||||
it.printf(95, 60, id(latobold), WHITE, "%.0f Watt", id(nettopower).state);
|
||||
it.printf(95, 60, id(latobold), WHITE, "%.2f kWh", id(nettopower).state);
|
||||
}
|
||||
} else {
|
||||
it.printf(95, 65, id(lato), WHITE, "LOADING...");
|
||||
@@ -397,15 +315,15 @@ display:
|
||||
it.printf(0,0,id(latoblack), WHITE, "HUMIDITY");
|
||||
it.printf(80, 65, id(lato), WHITE, "LOADING...");
|
||||
}
|
||||
# - id: show_office_pressure_graph
|
||||
# lambda: |-
|
||||
# if (id(office_pressure).has_state()) {
|
||||
# it.printf(0,0,id(latoblack), WHITE, "PRS: %.0f hPA", id(office_pressure).state);
|
||||
# it.graph(10, 40, id(office_pressure_graph));
|
||||
# } else {
|
||||
# it.printf(0,0,id(latoblack), WHITE, "PRESSURE");
|
||||
# it.printf(80, 65, id(lato), WHITE, "LOADING...");
|
||||
# }
|
||||
- id: show_nettopower_graph
|
||||
lambda: |-
|
||||
if (id(nettopower).has_state()) {
|
||||
it.printf(0,0,id(latoblack), WHITE, "power: %.2f Kwh", id(nettopower).state);
|
||||
it.graph(10, 40, id(power_graph));
|
||||
} else {
|
||||
it.printf(0,0,id(latoblack), WHITE, "PRESSURE");
|
||||
it.printf(80, 65, id(lato), WHITE, "LOADING...");
|
||||
}
|
||||
# - id: show_office_light_sensor_graph
|
||||
# lambda: |-
|
||||
# if (id(office_light_sensor).has_state()) {
|
||||
|
||||
39
esphome/cfg_experimental/ep1-woonkamer.yaml
Executable file
39
esphome/cfg_experimental/ep1-woonkamer.yaml
Executable file
@@ -0,0 +1,39 @@
|
||||
substitutions:
|
||||
name: ${device_name}
|
||||
device_name: "ep1_woonkamer"
|
||||
location: "woonkamer"
|
||||
comment: "esp32, mmwave, pir"
|
||||
friendly_name: "ep1_woonkamer"
|
||||
project_name: "Everything Smart Technology.Everything Presence One"
|
||||
project_version: "1.1.3"
|
||||
temperature_offset: "-3"
|
||||
humidity_offset: "5"
|
||||
temperature_update_interval: "60s"
|
||||
illuminance_update_interval: "30s"
|
||||
pir_delay_off: "10s"
|
||||
occupancy_delay_off: "15s"
|
||||
hidden_ssid: "false"
|
||||
factory_reset_disabled: "true"
|
||||
uart_target_output_disabled: "true"
|
||||
uart_presence_output_disabled: "true"
|
||||
api_password: !secret ep1_woonkamer_api
|
||||
ota_password: !secret ota_password
|
||||
wifi_ssid: !secret wifi_ssid
|
||||
wifi_password: !secret wifi_password
|
||||
gateway: !secret ip_gateway
|
||||
subnet: !secret ip_subnet
|
||||
ip: !secret ep1_woonkamer_ip
|
||||
pin_sda: GPIO26
|
||||
pin_scl: GPIO25
|
||||
pin_status: GPIO32
|
||||
|
||||
packages:
|
||||
board: !include boards/esp32_wroom_arduino.yaml
|
||||
device_base: !include common/common.yaml
|
||||
connection: !include common/wifi.yaml
|
||||
logger: !include templates/logger.yaml
|
||||
i2c: !include interfaces/i2c_a.yaml
|
||||
sensor_base: !include sensors/sen0395_base.yaml
|
||||
sensor: !include sensors/sen0395.yaml
|
||||
|
||||
#improv_serial:
|
||||
187
esphome/cfg_experimental/t-embed.yaml
Normal file
187
esphome/cfg_experimental/t-embed.yaml
Normal file
@@ -0,0 +1,187 @@
|
||||
substitutions:
|
||||
device_name: "t-embed"
|
||||
friendly_name: "t-embed"
|
||||
comment: "esp32-s3, lcd, rotary, leds, mic, spk"
|
||||
location: "zolder"
|
||||
api_password: !secret t-embed_api
|
||||
ota_password: !secret ota_password
|
||||
wifi_ssid: !secret wifi_ssid
|
||||
wifi_password: !secret wifi_password
|
||||
gateway: !secret ip_gateway
|
||||
subnet: !secret ip_subnet
|
||||
ip: !secret t-embed_ip
|
||||
update_interval: 30s
|
||||
num_leds: "7"
|
||||
led_chipset: APA102
|
||||
|
||||
#t-embed pins
|
||||
|
||||
pin_i2slrclk: GPIO05
|
||||
pin_i2sbclk: GPIO07
|
||||
pin_i2sdout: GPIO06
|
||||
pin_es7210_blck: GPIO47
|
||||
pin_es7210_lrck: GPIO21
|
||||
pin_es7210_din: GPIO14
|
||||
pin_es7210_mclk: GPIO48
|
||||
pin_sd_cs: GPIO39
|
||||
pin_sd_sck: GPIO40
|
||||
pin_sd_mosi: GPIO41
|
||||
pin_sd_miso: GPIO38
|
||||
pin_power: GPIO46
|
||||
pin_led_data: GPIO42
|
||||
pin_led_clk: GPIO45
|
||||
pin_encode_a: GPIO02
|
||||
pin_encode_b: GPIO01
|
||||
pin_encode_btn: GPIO00
|
||||
pin_sda: GPIO18
|
||||
pin_scl: GPIO8
|
||||
pin_lcd_bl: GPIO15
|
||||
pin_lcd_dc: GPIO13
|
||||
pin_lcd_cs: GPIO10
|
||||
pin_lcd_clk: GPIO12
|
||||
pin_lcd_mosi: GPIO11
|
||||
pin_lcd_res: GPIO09
|
||||
pin_vbat: GPIO4
|
||||
|
||||
|
||||
packages:
|
||||
board: !include boards/esp32-s3-voice.yaml
|
||||
spkmic: !include interfaces/SpkMicVoiceTembed.yaml
|
||||
#leds: !include templates/light_fastled_spi.yaml
|
||||
connection: !include common/wifi.yaml
|
||||
logger: !include templates/logger.yaml
|
||||
backlight: !include templates/backlight.yaml
|
||||
i2c: !include interfaces/i2c_a.yaml
|
||||
encoder: !include sensors/encoder.yaml
|
||||
|
||||
esphome:
|
||||
name: ${device_name}
|
||||
platformio_options:
|
||||
board_build.mcu: esp32s3
|
||||
board_build.name: "LilyGO T-Embed ESP32-S3"
|
||||
board_build.upload.flash_size: "16MB"
|
||||
board_build.upload.maximum_size: 16777216
|
||||
board_build.vendor: "LilyGO"
|
||||
on_boot:
|
||||
priority: 800
|
||||
then:
|
||||
- lambda: |-
|
||||
id(disp).enable();
|
||||
id(disp).transfer_byte(0x11);
|
||||
id(disp).disable();
|
||||
- switch.turn_on: power_on
|
||||
|
||||
button:
|
||||
- platform: restart
|
||||
name: 'Restart'
|
||||
|
||||
api:
|
||||
on_client_connected:
|
||||
then:
|
||||
- delay: 50ms
|
||||
- micro_wake_word.start:
|
||||
on_client_disconnected:
|
||||
then:
|
||||
- voice_assistant.stop:
|
||||
|
||||
switch:
|
||||
- platform: template
|
||||
id: mute
|
||||
name: mute
|
||||
optimistic: true
|
||||
on_turn_on:
|
||||
- micro_wake_word.stop:
|
||||
- voice_assistant.stop:
|
||||
on_turn_off:
|
||||
- micro_wake_word.start:
|
||||
- platform: gpio
|
||||
pin:
|
||||
number: ${pin_power}
|
||||
mode:
|
||||
output: True
|
||||
restore_mode: RESTORE_DEFAULT_ON
|
||||
name: "Power On"
|
||||
id: power_on
|
||||
|
||||
|
||||
time:
|
||||
- platform: homeassistant
|
||||
id: home_time
|
||||
|
||||
voice_assistant:
|
||||
id: va
|
||||
microphone: mic
|
||||
noise_suppression_level: 2.0
|
||||
volume_multiplier: 4.0
|
||||
on_error:
|
||||
- micro_wake_word.start:
|
||||
on_end:
|
||||
then:
|
||||
- wait_until:
|
||||
not:
|
||||
voice_assistant.is_running:
|
||||
- micro_wake_word.start:
|
||||
|
||||
|
||||
micro_wake_word:
|
||||
on_wake_word_detected:
|
||||
- voice_assistant.start:
|
||||
model: okay_nabu
|
||||
|
||||
|
||||
# spi:
|
||||
# id: ledbus
|
||||
# mosi_pin: ${pin_led_data}
|
||||
# clk_pin: ${pin_led_clk}
|
||||
|
||||
external_components:
|
||||
# - source:
|
||||
# type: local
|
||||
# path: components
|
||||
- source: github://rpatel3001/esphome@es7210
|
||||
components: [ es7210 ]
|
||||
|
||||
|
||||
# light:
|
||||
# - platform: spi_led_strip
|
||||
# num_leds: 30
|
||||
# spi_id: "ledbus"
|
||||
# color_correct: [80%, 60%, 100%]
|
||||
# id: rgb_led
|
||||
# name: "RGB LED Strip"
|
||||
# data_rate: 1MHz
|
||||
|
||||
font:
|
||||
- file: "gfonts://Roboto"
|
||||
id: roboto
|
||||
size: 96
|
||||
|
||||
spi:
|
||||
- id: spi_display
|
||||
clk_pin: ${pin_lcd_clk}
|
||||
mosi_pin: ${pin_lcd_mosi}
|
||||
|
||||
display:
|
||||
- platform: ili9xxx
|
||||
model: st7789V
|
||||
dimensions:
|
||||
height: 170
|
||||
width: 320
|
||||
offset_height: 35
|
||||
offset_width: 0
|
||||
transform:
|
||||
swap_xy: true
|
||||
mirror_x: false
|
||||
mirror_y: true
|
||||
color_order: bgr
|
||||
data_rate: 80MHz
|
||||
cs_pin: ${pin_lcd_cs}
|
||||
dc_pin: ${pin_lcd_dc}
|
||||
reset_pin: ${pin_lcd_res}
|
||||
update_interval: 5s
|
||||
id: disp
|
||||
lambda: |-
|
||||
it.strftime(10, 20, id(roboto), "%H:%M", id(home_time).now());
|
||||
//it.line(0, 0, 50, 50);
|
||||
|
||||
|
||||
76
esphome/cfg_experimental/tuya-plug-001.yaml
Normal file
76
esphome/cfg_experimental/tuya-plug-001.yaml
Normal file
@@ -0,0 +1,76 @@
|
||||
|
||||
substitutions:
|
||||
device_name: "tuyaplug001"
|
||||
friendly_name: "tuya plug 001"
|
||||
comment: "eps-02S, tuya-hack"
|
||||
location: "zolder"
|
||||
api_password: !secret tuya_plug_api
|
||||
ota_password: !secret ota_password
|
||||
wifi_ssid: !secret wifi_ssid
|
||||
wifi_password: !secret wifi_password
|
||||
gateway: !secret ip_gateway
|
||||
subnet: !secret ip_subnet
|
||||
ip: !secret tuya_plug_001_ip
|
||||
pin_relay: GPIO14
|
||||
pin_button: GPIO1
|
||||
pin_status: GPIO13
|
||||
pin_cf: GPIO05
|
||||
pin_cf1: GPIO04
|
||||
pin_sel: GPIO12
|
||||
|
||||
|
||||
|
||||
packages:
|
||||
board: !include boards/esp01.yaml
|
||||
connection: !include common/wifi.yaml
|
||||
device_base: !include common/common.yaml
|
||||
status: !include templates/status.yaml
|
||||
logger: !include templates/nologger.yaml
|
||||
|
||||
|
||||
binary_sensor:
|
||||
- platform: gpio
|
||||
pin:
|
||||
number: ${pin_button}
|
||||
mode:
|
||||
input: true
|
||||
pullup: true
|
||||
inverted: true
|
||||
name: "Button"
|
||||
on_press:
|
||||
- switch.toggle: relay
|
||||
|
||||
switch:
|
||||
# the power relay
|
||||
- platform: gpio
|
||||
id: relay
|
||||
pin: ${pin_relay}
|
||||
name: '${device_name}'
|
||||
restore_mode: RESTORE_DEFAULT_ON # attempt to restore state on start and defaults to OFF if failed
|
||||
icon: mdi:power-socket-de
|
||||
|
||||
sensor:
|
||||
- platform: hlw8012
|
||||
model: BL0937 # note that the model must be specified to use special calculation parameters
|
||||
current_resistor: 0.001 # adjust it according to the actual resistor value on board
|
||||
voltage_divider: 2012 # (2008.1K)/998 = 2004, adjust it according to the actual resistor values on board
|
||||
sel_pin:
|
||||
number: ${pin_sel}
|
||||
inverted: true # the logic of BL0937 is opposite from HLW8012
|
||||
cf_pin: ${pin_cf}
|
||||
cf1_pin: ${pin_cf1}
|
||||
current:
|
||||
name: '${device_name} Current'
|
||||
voltage:
|
||||
name: '${device_name} Voltage'
|
||||
power:
|
||||
name: '${device_name} Power'
|
||||
energy:
|
||||
name: '${device_name} Energy'
|
||||
# convert to kWh
|
||||
filters:
|
||||
- multiply: 0.001
|
||||
unit_of_measurement: 'kWh'
|
||||
accuracy_decimals: 4
|
||||
update_interval: 10s
|
||||
change_mode_every: 3
|
||||
320
esphome/cfg_experimental/voiceassistS3.yaml
Normal file
320
esphome/cfg_experimental/voiceassistS3.yaml
Normal file
@@ -0,0 +1,320 @@
|
||||
substitutions:
|
||||
device_name: "voiceassist1"
|
||||
friendly_name: "ESP32 voice Assist 2"
|
||||
comment: "esp32-s3, mic, dac, RGB"
|
||||
api_password: !secret voiceassist1_api
|
||||
ota_password: !secret ota_password
|
||||
wifi_ssid: !secret wifi_ssid
|
||||
wifi_password: !secret wifi_password
|
||||
gateway: !secret ip_gateway
|
||||
subnet: !secret ip_subnet
|
||||
ip: !secret voiceassist1_ip
|
||||
pin_lrclk: GPIO18
|
||||
pin_bclk: GPIO6
|
||||
pin_i2sdin: GPIO16
|
||||
pin_i2sdout: GPIO17
|
||||
#pin_button: GPIO14
|
||||
pin_led1: GPIO48
|
||||
num_leds: "1"
|
||||
chipset: ws2812
|
||||
|
||||
micro_wake_word_model: okay_nabu
|
||||
|
||||
voice_assist_idle_phase_id: "1"
|
||||
voice_assist_listening_phase_id: "2"
|
||||
voice_assist_thinking_phase_id: "3"
|
||||
voice_assist_replying_phase_id: "4"
|
||||
voice_assist_not_ready_phase_id: "10"
|
||||
voice_assist_error_phase_id: "11"
|
||||
voice_assist_muted_phase_id: "12"
|
||||
|
||||
packages:
|
||||
board: !include boards/esp32-s3-voice.yaml
|
||||
spkmic: !include interfaces/SpkMicVoice.yaml
|
||||
leds: !include templates/light_rgbw_rmt.yaml
|
||||
connection: !include common/wifi.yaml
|
||||
logger: !include templates/logger.yaml
|
||||
|
||||
|
||||
esphome:
|
||||
name: ${device_name}
|
||||
friendly_name: ${friendly_name}
|
||||
name_add_mac_suffix: true
|
||||
platformio_options:
|
||||
board_build.flash_mode: dio
|
||||
min_version: 2023.11.5
|
||||
project:
|
||||
name: esphome.voice-assistant
|
||||
version: "2.0"
|
||||
on_boot:
|
||||
priority: 600
|
||||
then:
|
||||
- delay: 30s
|
||||
- if:
|
||||
condition:
|
||||
lambda: return id(init_in_progress);
|
||||
then:
|
||||
- lambda: id(init_in_progress) = false;
|
||||
- light.turn_on:
|
||||
id: led_lights
|
||||
brightness: 30%
|
||||
red: 0%
|
||||
green: 50%
|
||||
blue: 50%
|
||||
effect: pulse
|
||||
|
||||
dashboard_import:
|
||||
package_import_url: github://esphome/firmware/wake-word-voice-assistant/esp32-s3-box.yaml@main
|
||||
|
||||
button:
|
||||
- platform: factory_reset
|
||||
id: factory_reset_btn
|
||||
name: Factory reset
|
||||
|
||||
esp32_improv:
|
||||
authorizer: none
|
||||
|
||||
binary_sensor:
|
||||
- platform: gpio
|
||||
pin:
|
||||
number: GPIO1
|
||||
inverted: true
|
||||
name: "Mute"
|
||||
disabled_by_default: true
|
||||
entity_category: diagnostic
|
||||
|
||||
micro_wake_word:
|
||||
model: ${micro_wake_word_model}
|
||||
on_wake_word_detected:
|
||||
- voice_assistant.start
|
||||
|
||||
voice_assistant:
|
||||
id: va
|
||||
microphone: mic
|
||||
use_wake_word: true
|
||||
noise_suppression_level: 2
|
||||
auto_gain: 31dBFS
|
||||
volume_multiplier: 2.0
|
||||
speaker: big_speaker
|
||||
on_client_connected:
|
||||
- if:
|
||||
condition:
|
||||
switch.is_off: mute
|
||||
then:
|
||||
- wait_until:
|
||||
not: ble.enabled
|
||||
- if:
|
||||
condition:
|
||||
lambda: return id(wake_word_engine_location).state == "In Home Assistant";
|
||||
then:
|
||||
- lambda: id(va).set_use_wake_word(true);
|
||||
- voice_assistant.start_continuous:
|
||||
- if:
|
||||
condition:
|
||||
lambda: return id(wake_word_engine_location).state == "On device";
|
||||
then:
|
||||
- micro_wake_word.start
|
||||
- lambda: id(voice_assistant_phase) = ${voice_assist_idle_phase_id};
|
||||
else:
|
||||
- lambda: id(voice_assistant_phase) = ${voice_assist_muted_phase_id};
|
||||
- lambda: id(init_in_progress) = false;
|
||||
- light.turn_on:
|
||||
id: led_lights
|
||||
brightness: 30%
|
||||
red: 0%
|
||||
green: 100%
|
||||
blue: 0%
|
||||
effect: none
|
||||
on_listening:
|
||||
- lambda: id(voice_assistant_phase) = ${voice_assist_listening_phase_id};
|
||||
- light.turn_on:
|
||||
id: led_lights
|
||||
brightness: 30%
|
||||
red: 0%
|
||||
green: 100%
|
||||
blue: 0%
|
||||
effect: pulse
|
||||
on_stt_vad_end:
|
||||
- lambda: id(voice_assistant_phase) = ${voice_assist_thinking_phase_id};
|
||||
- light.turn_on:
|
||||
id: led_lights
|
||||
brightness: 30%
|
||||
red: 0%
|
||||
green: 100%
|
||||
blue: 100%
|
||||
effect: Pulse
|
||||
on_tts_stream_start:
|
||||
- lambda: id(voice_assistant_phase) = ${voice_assist_replying_phase_id};
|
||||
- light.turn_on:
|
||||
id: led_lights
|
||||
brightness: 30%
|
||||
red: 0%
|
||||
green: 100%
|
||||
blue: 100%
|
||||
effect: none
|
||||
on_tts_stream_end:
|
||||
- lambda: id(voice_assistant_phase) = ${voice_assist_idle_phase_id};
|
||||
- light.turn_on:
|
||||
id: led_lights
|
||||
brightness: 30%
|
||||
red: 0%
|
||||
green: 0%
|
||||
blue: 100%
|
||||
effect: Pulse
|
||||
on_error:
|
||||
- if:
|
||||
condition:
|
||||
lambda: return !id(init_in_progress);
|
||||
then:
|
||||
- lambda: id(voice_assistant_phase) = ${voice_assist_error_phase_id};
|
||||
- delay: 1s
|
||||
- if:
|
||||
condition:
|
||||
switch.is_off: mute
|
||||
then:
|
||||
- lambda: id(voice_assistant_phase) = ${voice_assist_idle_phase_id};
|
||||
else:
|
||||
- lambda: id(voice_assistant_phase) = ${voice_assist_muted_phase_id};
|
||||
- light.turn_on:
|
||||
id: led_lights
|
||||
brightness: 30%
|
||||
red: 100%
|
||||
green: 0%
|
||||
blue: 0%
|
||||
effect: Pulse
|
||||
- delay: 4s
|
||||
- light.turn_off:
|
||||
id: led_lights
|
||||
on_client_disconnected:
|
||||
- if:
|
||||
condition:
|
||||
lambda: return id(wake_word_engine_location).state == "In Home Assistant";
|
||||
then:
|
||||
- lambda: id(va).set_use_wake_word(false);
|
||||
- voice_assistant.stop:
|
||||
- if:
|
||||
condition:
|
||||
lambda: return id(wake_word_engine_location).state == "On device";
|
||||
then:
|
||||
- micro_wake_word.stop
|
||||
- lambda: id(voice_assistant_phase) = ${voice_assist_not_ready_phase_id};
|
||||
- light.turn_on:
|
||||
id: led_lights
|
||||
brightness: 30%
|
||||
red: 100%
|
||||
green: 0%
|
||||
blue: 0%
|
||||
effect: none
|
||||
on_end:
|
||||
- if:
|
||||
condition:
|
||||
and:
|
||||
- switch.is_off: mute
|
||||
- lambda: return id(wake_word_engine_location).state == "On device";
|
||||
then:
|
||||
- wait_until:
|
||||
not:
|
||||
voice_assistant.is_running:
|
||||
- micro_wake_word.start:
|
||||
|
||||
switch:
|
||||
# - platform: template
|
||||
# name: Use wake word
|
||||
# id: use_wake_word
|
||||
# optimistic: true
|
||||
# restore_mode: RESTORE_DEFAULT_ON
|
||||
# entity_category: config
|
||||
# on_turn_on:
|
||||
# - lambda: id(assist).set_use_wake_word(true);
|
||||
# - if:
|
||||
# condition:
|
||||
# not:
|
||||
# - voice_assistant.is_running
|
||||
# then:
|
||||
# - voice_assistant.start_continuous
|
||||
# on_turn_off:
|
||||
# - voice_assistant.stop
|
||||
# - lambda: id(assist).set_use_wake_word(false);
|
||||
|
||||
- platform: template
|
||||
name: Mute
|
||||
id: mute
|
||||
optimistic: true
|
||||
restore_mode: RESTORE_DEFAULT_OFF
|
||||
entity_category: config
|
||||
on_turn_off:
|
||||
- if:
|
||||
condition:
|
||||
lambda: return !id(init_in_progress);
|
||||
then:
|
||||
- lambda: id(voice_assistant_phase) = ${voice_assist_idle_phase_id};
|
||||
- if:
|
||||
condition:
|
||||
not:
|
||||
- voice_assistant.is_running
|
||||
then:
|
||||
- if:
|
||||
condition:
|
||||
lambda: return id(wake_word_engine_location).state == "In Home Assistant";
|
||||
then:
|
||||
- lambda: id(va).set_use_wake_word(true);
|
||||
- voice_assistant.start_continuous
|
||||
- if:
|
||||
condition:
|
||||
lambda: return id(wake_word_engine_location).state == "On device";
|
||||
then:
|
||||
- micro_wake_word.start
|
||||
on_turn_on:
|
||||
- if:
|
||||
condition:
|
||||
lambda: return !id(init_in_progress);
|
||||
then:
|
||||
- lambda: id(va).set_use_wake_word(false);
|
||||
- voice_assistant.stop
|
||||
- micro_wake_word.stop
|
||||
- lambda: id(voice_assistant_phase) = ${voice_assist_muted_phase_id};
|
||||
|
||||
select:
|
||||
- platform: template
|
||||
entity_category: config
|
||||
name: Wake word engine location
|
||||
id: wake_word_engine_location
|
||||
optimistic: true
|
||||
restore_value: true
|
||||
options:
|
||||
- In Home Assistant
|
||||
- On device
|
||||
initial_option: On device
|
||||
on_value:
|
||||
- wait_until:
|
||||
lambda: return id(voice_assistant_phase) == ${voice_assist_muted_phase_id} || id(voice_assistant_phase) == ${voice_assist_idle_phase_id};
|
||||
- if:
|
||||
condition:
|
||||
lambda: return x == "In Home Assistant";
|
||||
then:
|
||||
- micro_wake_word.stop
|
||||
- delay: 500ms
|
||||
- if:
|
||||
condition:
|
||||
switch.is_off: mute
|
||||
then:
|
||||
- lambda: id(va).set_use_wake_word(true);
|
||||
- voice_assistant.start_continuous:
|
||||
- if:
|
||||
condition:
|
||||
lambda: return x == "On device";
|
||||
then:
|
||||
- lambda: id(va).set_use_wake_word(false);
|
||||
- voice_assistant.stop
|
||||
- delay: 500ms
|
||||
- micro_wake_word.start
|
||||
|
||||
globals:
|
||||
- id: init_in_progress
|
||||
type: bool
|
||||
restore_value: false
|
||||
initial_value: "true"
|
||||
- id: voice_assistant_phase
|
||||
type: int
|
||||
restore_value: false
|
||||
initial_value: ${voice_assist_not_ready_phase_id}
|
||||
Reference in New Issue
Block a user