121 lines
3.6 KiB
YAML
121 lines
3.6 KiB
YAML
####################################################################################################
|
|
##### TX Ultimate Easy for ESPHome #####
|
|
##### Repository: https://github.com/edwardtfn/TX-Ultimate-Easy #####
|
|
####################################################################################################
|
|
##### Purpose: ESPHome Core - Hardware - Vibration system #####
|
|
####################################################################################################
|
|
##### Author: edwardtfn - https://github.com/edwardtfn - https://buymeacoffee.com/edwardfirmo #####
|
|
####################################################################################################
|
|
##### NOTE: #####
|
|
##### - Make changes ONLY if absolutely necessary and you have the required knowledge. #####
|
|
##### - For normal system use, modifications to this file are NOT required. #####
|
|
####################################################################################################
|
|
---
|
|
binary_sensor:
|
|
- id: bs_vibrating
|
|
name: Vibrating
|
|
icon: mdi:vibrate
|
|
internal: false
|
|
platform: template
|
|
lambda: return sw_vibration_motor->state;
|
|
|
|
button:
|
|
- id: bt_vibrate
|
|
name: Vibrate
|
|
icon: mdi:vibrate
|
|
internal: false
|
|
platform: template
|
|
on_press:
|
|
then:
|
|
- script.execute: vibrate
|
|
|
|
number:
|
|
- id: nr_vibrating_duration
|
|
name: Vibrate duration
|
|
icon: mdi:vibrate
|
|
unit_of_measurement: ms
|
|
# mode: box
|
|
internal: false
|
|
entity_category: config
|
|
platform: template
|
|
min_value: 1
|
|
max_value: 500
|
|
step: 1
|
|
initial_value: 15
|
|
optimistic: true
|
|
restore_value: true
|
|
|
|
script:
|
|
- id: !extend touch_on_multi_touch_release
|
|
then:
|
|
- script.execute: touch_on_multi_touch_release_vibration
|
|
|
|
- id: touch_on_multi_touch_release_vibration
|
|
mode: restart
|
|
then:
|
|
- lambda: |-
|
|
if (sl_touch_vibration_feedback->state != "Disabled")
|
|
vibrate->execute();
|
|
|
|
- id: !extend touch_on_press
|
|
then:
|
|
- script.execute: touch_on_press_vibration
|
|
|
|
- id: touch_on_press_vibration
|
|
mode: restart
|
|
then:
|
|
- lambda: |-
|
|
if (sl_touch_vibration_feedback->state == "On press" or sl_touch_vibration_feedback->state == "Always")
|
|
vibrate->execute();
|
|
|
|
- id: !extend touch_on_release
|
|
then:
|
|
- script.execute: touch_on_release_vibration
|
|
|
|
- id: touch_on_release_vibration
|
|
mode: restart
|
|
then:
|
|
- lambda: |-
|
|
if (sl_touch_vibration_feedback->state == "On release" or sl_touch_vibration_feedback->state == "Always")
|
|
vibrate->execute();
|
|
|
|
- id: vibrate
|
|
mode: restart
|
|
then:
|
|
- switch.turn_on: sw_vibration_motor
|
|
- delay: !lambda return nr_vibrating_duration->state;
|
|
- switch.turn_off: sw_vibration_motor
|
|
|
|
select:
|
|
- id: sl_touch_vibration_feedback
|
|
name: Touch - Vibration feedback
|
|
platform: template
|
|
options:
|
|
- "Disabled"
|
|
- "On press"
|
|
- "On release"
|
|
- "Always"
|
|
initial_option: "Disabled"
|
|
optimistic: true
|
|
restore_value: true
|
|
internal: false
|
|
entity_category: config
|
|
disabled_by_default: false
|
|
icon: mdi:vibrate
|
|
|
|
switch:
|
|
- 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);
|
|
|
|
...
|