Files
TX-Ultimate-Easy/ESPHome/TX-Ultimate-Easy-ESPHome_core.yaml
2024-05-27 14:08:30 +02:00

384 lines
8.9 KiB
YAML

substitutions:
name: tx-ultimate-easy
friendly_name: TX Ultimate Easy
latitude: '0'
longitude: '0'
zone_home: 'zone.home'
version: '0.0.1'
api:
id: api_server
services:
- service: set_float
variables:
component: string
val: float
then:
- lambda: |-
if (!isnan(val)) {
if (component == "latitude") sun_entity->set_latitude(val);
else if (component == "longitude") sun_entity->set_longitude(val);
}
binary_sensor:
- id: bs_vibrating
name: Vibrating
icon: mdi:vibrate
internal: false
platform: template
lambda: return sw_vibration_motor->state;
# bluetooth_proxy:
button:
- id: bt_restart
name: Restart
internal: false
platform: restart
- id: bt_vibrate
name: Vibrate
icon: mdi:vibrate
internal: false
platform: template
on_press:
then:
- switch.turn_on: sw_vibration_motor
- delay: !lambda return nr_vibrating_duration->state;
- switch.turn_off: sw_vibration_motor
captive_portal:
esp32:
board: esp32dev
framework:
# type: esp-idf
type: arduino
# sdkconfig_options:
# CONFIG_BT_ALLOCATION_FROM_SPIRAM_FIRST: "y"
# CONFIG_BT_BLE_DYNAMIC_ENV_MEMORY: "y"
# CONFIG_ESP32_REV_MIN_3: "y"
# CONFIG_MBEDTLS_DYNAMIC_BUFFER: "y"
# CONFIG_MBEDTLS_DYNAMIC_FREE_CA_CERT: "y"
# CONFIG_MBEDTLS_DYNAMIC_FREE_CONFIG_DATA: "y"
# CONFIG_MBEDTLS_EXTERNAL_MEM_ALLOC: "y"
# CONFIG_SPIRAM_ALLOW_BSS_SEG_EXTERNAL_MEMORY: "y"
# CONFIG_SPIRAM_RODATA: "y"
# CONFIG_SPIRAM_TRY_ALLOCATE_WIFI_LWIP: "y"
esphome:
name: ${name}
friendly_name: ${friendly_name}
platformio_options:
build_flags:
- -DCONFIG_BT_ALLOCATION_FROM_SPIRAM_FIRST=true
# - -DCONFIG_BT_BLE_DYNAMIC_ENV_MEMORY=true
- -DCONFIG_ESP32_REV_MIN_3=true
- -DCONFIG_MBEDTLS_DYNAMIC_BUFFER=true
- -DCONFIG_MBEDTLS_DYNAMIC_FREE_CA_CERT=true
- -DCONFIG_MBEDTLS_DYNAMIC_FREE_CONFIG_DATA=true
- -DCONFIG_MBEDTLS_EXTERNAL_MEM_ALLOC=true
- -DCONFIG_SPIRAM_ALLOW_BSS_SEG_EXTERNAL_MEMORY=true
- -DCONFIG_SPIRAM_RODATA=true
- -DCONFIG_SPIRAM_TRY_ALLOCATE_WIFI_LWIP=true
on_boot:
- priority: 700
then:
- wait_until:
condition:
- lambda: return sl_tx_model_gang->active_index().has_value();
- lambda: |-
auto index = sl_tx_model_gang->active_index();
if (index.has_value()) {
sw_relay_1->set_internal(false);
sw_relay_2->set_internal(index.value() < 1);
sw_relay_3->set_internal(index.value() < 2);
sw_relay_4->set_internal(index.value() < 3);
}
- priority: 600 # This is where most sensors are set up.
then:
- lambda: |-
tx_fw_version->publish_state("${version}");
tx_device_name->publish_state("${name}");
external_components:
- source:
type: git
url: https://github.com/edwardtfn/TX-Ultimate-Easy/
ref: dev
components:
- tx_ultimate_easy
i2s_audio:
id: if_i2s_audio
i2s_bclk_pin: GPIO2
i2s_lrclk_pin: GPIO4
light:
- id: light_led
name: Light - LED
platform: neopixelbus
type: GRB
variant: WS2811
# platform: esp32_rmt_led_strip
# rgb_order: GRB
# rmt_channel: 0
# chipset: ws2812
num_leds: 28
pin: GPIO13
effects:
- addressable_rainbow:
- addressable_rainbow:
name: "Rainbow - Fast"
speed: 50
- pulse:
- pulse:
name: "Pulse - Fast"
transition_length: 0.5s
update_interval: 0.5s
- pulse:
name: "Pulse - Slow"
update_interval: 2s
- addressable_scan:
- addressable_scan:
name: Scan Effect With Custom Values
move_interval: 100ms
scan_width: 3
- addressable_twinkle:
- addressable_twinkle:
name: Twinkle Effect With Custom Values
twinkle_probability: 5%
progress_interval: 4ms
- addressable_random_twinkle:
- addressable_random_twinkle:
name: Random Twinkle Effect With Custom Values
twinkle_probability: 20%
progress_interval: 32ms
- addressable_fireworks:
- addressable_fireworks:
name: Fireworks Effect With Custom Values
update_interval: 32ms
spark_probability: 10%
use_random_color: false
fade_out_rate: 120
- addressable_flicker:
- addressable_flicker:
name: Flicker Effect With Custom Values
update_interval: 16ms
intensity: 5%
- random:
# - id: light_status
# name: Light - Status
# platform: esp32_rmt_led_strip
# rgb_order: GRB
# pin: GPIO13
# num_leds: 1
# rmt_channel: 0
# chipset: ws2812
logger:
media_player:
- id: mp_speaker
name: Speaker
platform: i2s_audio
i2s_dout_pin: GPIO15
i2s_audio_id: if_i2s_audio
i2s_comm_fmt: lsb
dac_type: external
mode: mono
mute_pin:
number: GPIO26
inverted: true
allow_other_uses: true
internal: false
number:
- id: nr_vibrating_duration
name: Vibrate duration
icon: mdi:vibrate
unit_of_measurement: ms
# mode: box
internal: false
platform: template
min_value: 1
max_value: 500
step: 1
initial_value: 15
optimistic: true
restore_value: true
ota:
psram:
select:
- id: sl_tx_model_gang
name: Model
platform: template
options:
- "1 Gang"
- "2 Gang"
- "3 Gang"
- "4 Gang"
initial_option: "1 Gang"
optimistic: true
restore_value: true
internal: false
entity_category: config
disabled_by_default: false
icon: mdi:dip-switch
sensor:
- id: sun_elevation
name: Sun Elevation
platform: sun
type: elevation
internal: true
- id: zone_home_latitude
platform: homeassistant
entity_id: ${zone_home}
attribute: latitude
internal: false
on_value:
- lambda: if (!isnan(x)) sun_entity->set_latitude(x);
- id: zone_home_longitude
platform: homeassistant
entity_id: ${zone_home}
attribute: longitude
internal: false
on_value:
- lambda: if (!isnan(x)) sun_entity->set_longitude(x);
sun:
id: sun_entity
latitude: ${latitude}
longitude: ${longitude}
switch:
- id: sw_speaker_aplifier
name: Speaker - Aplifier
platform: gpio
pin:
number: GPIO26
inverted: true
allow_other_uses: true
restore_mode: RESTORE_DEFAULT_ON
internal: true
- id: sw_relay_1
name: Relay 1
platform: gpio
pin: GPIO18
restore_mode: RESTORE_DEFAULT_OFF
internal: false
- id: sw_relay_2
name: Relay 2
platform: gpio
pin: GPIO17
restore_mode: RESTORE_DEFAULT_OFF
internal: true
- id: sw_relay_3
name: Relay 3
platform: gpio
pin: GPIO27
restore_mode: RESTORE_DEFAULT_OFF
internal: true
- id: sw_relay_4
name: Relay 4
platform: gpio
pin: GPIO23
restore_mode: RESTORE_DEFAULT_OFF
internal: true
- id: sw_touch_panel_power
name: Touch panel - Power
platform: gpio
pin:
number: GPIO5
inverted: true
restore_mode: ALWAYS_ON
internal: true
- id: sw_vibration_motor
name: Vibration motor
platform: gpio
pin: GPIO21
restore_mode: ALWAYS_OFF
internal: true
on_turn_on:
then:
- lambda: bs_vibrating->publish_state(true);
on_turn_off:
then:
- lambda: bs_vibrating->publish_state(false);
text_sensor:
- id: tx_fw_version
name: Firmware version
platform: template
entity_category: diagnostic
icon: mdi:tag-text-outline
internal: false
update_interval: never
lambda: |-
return {"${version}"};
- id: tx_device_name
name: Device Name
platform: template
icon: mdi:identifier
entity_category: diagnostic
internal: false
disabled_by_default: false
lambda: |-
return {"${name}"};
filters:
- lambda: |-
const std::string raw_name = x;
std::string result;
bool last_was_underscore = false;
for (const char& c : raw_name) {
if (isalnum(c)) {
result += tolower(c); // Add alphanumeric characters as lowercase
last_was_underscore = false;
} else if (!last_was_underscore) { // Replace non-alphanumeric with '_' but avoid consecutive '_'
result += '_';
last_was_underscore = true;
}
}
return result;
time:
- id: time_source
platform: homeassistant
tx_ultimate_easy:
uart:
id: if_uart_touch
tx_pin: GPIO19
rx_pin: GPIO22
baud_rate: 115200
debug:
direction: BOTH #RX
dummy_receiver: false
after:
timeout: 2s
bytes: 2048
sequence:
# - lambda: UARTDebug::log_string(direction, bytes);
- lambda: UARTDebug::log_hex(direction, bytes, ' ');
web_server:
wifi:
ap: