Project setup
This commit is contained in:
@@ -0,0 +1,304 @@
|
||||
packages:
|
||||
base: !include ../common.yaml
|
||||
scripts: !include scripts.yaml
|
||||
events: !include events.yaml
|
||||
|
||||
esphome:
|
||||
on_boot:
|
||||
priority: -100
|
||||
then:
|
||||
- script.execute: setup_bar_displays
|
||||
- script.execute: update_bar1_left
|
||||
- script.execute: update_bar1_right
|
||||
- script.execute: update_bar2_left
|
||||
- script.execute: update_bar2_right
|
||||
- script.execute: update_bar3_left
|
||||
- script.execute: update_bar3_right
|
||||
|
||||
mcp23008:
|
||||
- id: 'base_J0'
|
||||
i2c_id: buttons
|
||||
address: 0x20
|
||||
- id: 'base_J1'
|
||||
i2c_id: buttons
|
||||
address: 0x21
|
||||
- id: 'base_J2'
|
||||
i2c_id: buttons
|
||||
address: 0x22
|
||||
- id: 'base_J3'
|
||||
i2c_id: buttons
|
||||
address: 0x23
|
||||
|
||||
binary_sensor:
|
||||
############################
|
||||
### Buttons Main Display ###
|
||||
############################
|
||||
- platform: gpio
|
||||
id: 'main_display_btn_left'
|
||||
name: "Main Display button Left"
|
||||
pin:
|
||||
mcp23xxx: base_J0
|
||||
number: 6
|
||||
mode: INPUT_PULLUP
|
||||
inverted: true
|
||||
- platform: gpio
|
||||
id: 'main_display_btn_right'
|
||||
name: "Main Display button Right"
|
||||
pin:
|
||||
mcp23xxx: base_J0
|
||||
number: 2
|
||||
mode: INPUT_PULLUP
|
||||
inverted: true
|
||||
|
||||
############################
|
||||
### Buttons BAR module 1 ###
|
||||
############################
|
||||
- platform: gpio
|
||||
id: 'bar1_btn_left'
|
||||
name: "BAR 1 button Left"
|
||||
pin:
|
||||
mcp23xxx: base_J1
|
||||
number: 6
|
||||
mode: INPUT_PULLUP
|
||||
inverted: true
|
||||
- platform: gpio
|
||||
id: 'bar1_btn_right'
|
||||
name: "BAR 1 button Right"
|
||||
pin:
|
||||
mcp23xxx: base_J1
|
||||
number: 2
|
||||
mode: INPUT_PULLUP
|
||||
inverted: true
|
||||
|
||||
############################
|
||||
### Buttons BAR module 2 ###
|
||||
############################
|
||||
- platform: gpio
|
||||
id: 'bar2_btn_left'
|
||||
name: "BAR 2 button Left"
|
||||
pin:
|
||||
mcp23xxx: base_J2
|
||||
number: 6
|
||||
mode: INPUT_PULLUP
|
||||
inverted: true
|
||||
- platform: gpio
|
||||
id: 'bar2_btn_right'
|
||||
name: "BAR 2 button Right"
|
||||
pin:
|
||||
mcp23xxx: base_J2
|
||||
number: 2
|
||||
mode: INPUT_PULLUP
|
||||
inverted: true
|
||||
|
||||
############################
|
||||
### Buttons BAR module 3 ###
|
||||
############################
|
||||
- platform: gpio
|
||||
id: 'bar3_btn_left'
|
||||
name: "BAR 3 button Left"
|
||||
pin:
|
||||
mcp23xxx: base_J3
|
||||
number: 6
|
||||
mode: INPUT_PULLUP
|
||||
inverted: true
|
||||
- platform: gpio
|
||||
id: 'bar3_btn_right'
|
||||
name: "BAR 3 button Right"
|
||||
pin:
|
||||
mcp23xxx: base_J3
|
||||
number: 2
|
||||
mode: INPUT_PULLUP
|
||||
inverted: true
|
||||
|
||||
light:
|
||||
- id: !extend neopixels
|
||||
num_leds: 13
|
||||
##############################
|
||||
### RGB LED's BAR module 1 ###
|
||||
##############################
|
||||
- platform: partition
|
||||
name: "BAR 1 Left RGB Front"
|
||||
id: bar1_left_rgb_front
|
||||
segments:
|
||||
- id: neopixels
|
||||
from: 0
|
||||
to: 0
|
||||
- platform: partition
|
||||
name: "BAR 1 Left RGB Back"
|
||||
id: bar1_left_rgb_back
|
||||
segments:
|
||||
- id: neopixels
|
||||
from: 1
|
||||
to: 1
|
||||
- platform: partition
|
||||
name: "BAR 1 Right RGB Front"
|
||||
id: bar1_right_rgb_front
|
||||
segments:
|
||||
- id: neopixels
|
||||
from: 2
|
||||
to: 2
|
||||
- platform: partition
|
||||
name: "BAR 1 Right RGB Back"
|
||||
id: bar1_right_rgb_back
|
||||
segments:
|
||||
- id: neopixels
|
||||
from: 3
|
||||
to: 3
|
||||
##############################
|
||||
### RGB LED's BAR module 2 ###
|
||||
##############################
|
||||
- platform: partition
|
||||
name: "BAR 2 Left RGB Front"
|
||||
id: bar2_left_rgb_front
|
||||
segments:
|
||||
- id: neopixels
|
||||
from: 4
|
||||
to: 4
|
||||
- platform: partition
|
||||
name: "BAR 2 Left RGB Back"
|
||||
id: bar2_left_rgb_back
|
||||
segments:
|
||||
- id: neopixels
|
||||
from: 5
|
||||
to: 5
|
||||
- platform: partition
|
||||
name: "BAR 2 Right RGB Front"
|
||||
id: bar2_right_rgb_front
|
||||
segments:
|
||||
- id: neopixels
|
||||
from: 6
|
||||
to: 6
|
||||
- platform: partition
|
||||
name: "BAR 2 Right RGB Back"
|
||||
id: bar2_right_rgb_back
|
||||
segments:
|
||||
- id: neopixels
|
||||
from: 7
|
||||
to: 7
|
||||
##############################
|
||||
### RGB LED's BAR module 3 ###
|
||||
##############################
|
||||
- platform: partition
|
||||
name: "BAR 3 Left RGB Front"
|
||||
id: bar3_left_rgb_front
|
||||
segments:
|
||||
- id: neopixels
|
||||
from: 8
|
||||
to: 8
|
||||
- platform: partition
|
||||
name: "BAR 3 Left RGB Back"
|
||||
id: bar3_left_rgb_back
|
||||
segments:
|
||||
- id: neopixels
|
||||
from: 9
|
||||
to: 9
|
||||
- platform: partition
|
||||
name: "BAR 3 Right RGB Front"
|
||||
id: bar3_right_rgb_front
|
||||
segments:
|
||||
- id: neopixels
|
||||
from: 10
|
||||
to: 10
|
||||
- platform: partition
|
||||
name: "BAR 3 Right RGB Back"
|
||||
id: bar3_right_rgb_back
|
||||
segments:
|
||||
- id: neopixels
|
||||
from: 11
|
||||
to: 11
|
||||
|
||||
output:
|
||||
#######################################
|
||||
### CS pins to control BAR Displays ###
|
||||
#######################################
|
||||
- id: cs_pin_bar1_left
|
||||
platform: gpio
|
||||
pin:
|
||||
mcp23xxx: base_J1
|
||||
number: 5
|
||||
mode:
|
||||
output: true
|
||||
inverted: true
|
||||
- id: cs_pin_bar1_right
|
||||
platform: gpio
|
||||
pin:
|
||||
mcp23xxx: base_J1
|
||||
number: 1
|
||||
mode:
|
||||
output: true
|
||||
inverted: true
|
||||
- id: cs_pin_bar2_left
|
||||
platform: gpio
|
||||
pin:
|
||||
mcp23xxx: base_J2
|
||||
number: 5
|
||||
mode:
|
||||
output: true
|
||||
inverted: true
|
||||
- id: cs_pin_bar2_right
|
||||
platform: gpio
|
||||
pin:
|
||||
mcp23xxx: base_J2
|
||||
number: 1
|
||||
mode:
|
||||
output: true
|
||||
inverted: true
|
||||
- id: cs_pin_bar3_left
|
||||
platform: gpio
|
||||
pin:
|
||||
mcp23xxx: base_J3
|
||||
number: 5
|
||||
mode:
|
||||
output: true
|
||||
inverted: true
|
||||
- id: cs_pin_bar3_right
|
||||
platform: gpio
|
||||
pin:
|
||||
mcp23xxx: base_J3
|
||||
number: 1
|
||||
mode:
|
||||
output: true
|
||||
inverted: true
|
||||
|
||||
display:
|
||||
####################
|
||||
### Main Display ###
|
||||
####################
|
||||
- id: main_display
|
||||
platform: ili9xxx
|
||||
model: ili9341
|
||||
invert_colors: false
|
||||
color_order: rgb
|
||||
update_interval: 30s
|
||||
dc_pin:
|
||||
number: GPIO7
|
||||
allow_other_uses: true
|
||||
cs_pin:
|
||||
mcp23xxx: base_J0
|
||||
number: 5
|
||||
mode:
|
||||
output: true
|
||||
inverted: false
|
||||
show_test_card: false
|
||||
dimensions:
|
||||
height: 240
|
||||
width: 320
|
||||
rotation: 180
|
||||
###################
|
||||
### BAR modules ###
|
||||
###################
|
||||
- id: bar_display
|
||||
platform: ili9xxx
|
||||
model: ST7735
|
||||
color_order: bgr
|
||||
update_interval: never
|
||||
dc_pin:
|
||||
number: GPIO7
|
||||
allow_other_uses: true
|
||||
invert_colors: false
|
||||
show_test_card: false
|
||||
auto_clear_enabled: false
|
||||
dimensions:
|
||||
height: 160
|
||||
width: 80
|
||||
offset_width: 24
|
||||
@@ -0,0 +1,275 @@
|
||||
esphome:
|
||||
name: buttonplus
|
||||
friendly_name: ButtonPlus
|
||||
|
||||
esp32:
|
||||
variant: ESP32S3
|
||||
board: esp32-s3-devkitc1-n16r8
|
||||
flash_size: 16MB
|
||||
framework:
|
||||
type: esp-idf
|
||||
|
||||
# Enable logging
|
||||
logger:
|
||||
level: DEBUG
|
||||
|
||||
# Enable Home Assistant API
|
||||
api:
|
||||
encryption:
|
||||
key: ""
|
||||
|
||||
ota:
|
||||
- platform: esphome
|
||||
password: ""
|
||||
|
||||
wifi:
|
||||
ssid: !secret wifi_ssid
|
||||
password: !secret wifi_password
|
||||
|
||||
# Enable fallback hotspot (captive portal) in case wifi connection fails
|
||||
ap:
|
||||
ssid: "Buttonplus"
|
||||
password: ""
|
||||
|
||||
packages:
|
||||
remote_package_files:
|
||||
files:
|
||||
- path: 'base.yaml'
|
||||
vars:
|
||||
nr_of_pages: '3'
|
||||
page_names: '{"Start", "Music", "Page 3"}'
|
||||
- path: '../cards/music.yaml'
|
||||
vars:
|
||||
music_card_entity_id: 'media_player.spotifyplus_kennyboy44'
|
||||
music_card_text_color: FFFFFF
|
||||
music_card_icon_main_color: FF7F00
|
||||
music_card_icon_bar_color: FF7F00
|
||||
|
||||
font:
|
||||
- file: "https://github.com/web-fonts/ttf/raw/refs/heads/master/bpg-ingiri-arial-webfont.ttf"
|
||||
id: font_arial20
|
||||
size: 20
|
||||
bpp: 4
|
||||
- file: "https://torinak.com/font/7segment.ttf"
|
||||
id: font_clock
|
||||
size: 64
|
||||
bpp: 4
|
||||
- file: "https://torinak.com/font/7segment.ttf"
|
||||
id: font_date
|
||||
size: 24
|
||||
bpp: 4
|
||||
|
||||
image:
|
||||
- file: mdi:lightbulb
|
||||
id: lightbulb
|
||||
resize: 80x80
|
||||
type: GRAYSCALE
|
||||
- file: mdi:alert
|
||||
id: alert
|
||||
resize: 80x80
|
||||
type: GRAYSCALE
|
||||
- file: mdi:chevron-right
|
||||
id: icon_next_page
|
||||
resize: 30x30
|
||||
type: GRAYSCALE
|
||||
- file: mdi:chevron-left
|
||||
id: icon_prev_page
|
||||
resize: 30x30
|
||||
type: GRAYSCALE
|
||||
- file: mdi:home-thermometer-outline
|
||||
id: icon_temp_inside
|
||||
resize: 40x40
|
||||
type: GRAYSCALE
|
||||
- file: mdi:brightness-percent
|
||||
id: icon_ambient_inside
|
||||
resize: 40x40
|
||||
type: GRAYSCALE
|
||||
|
||||
color:
|
||||
- id: red
|
||||
hex: FF0000
|
||||
- id: blue
|
||||
hex: 0000FF
|
||||
- id: yellow
|
||||
hex: FFFF00
|
||||
- id: green
|
||||
hex: 00FF00
|
||||
- id: orange
|
||||
hex: FF7F00
|
||||
- id: white
|
||||
hex: FFFFFF
|
||||
- id: grey
|
||||
hex: A6A6A6
|
||||
|
||||
display:
|
||||
#########
|
||||
# MAIN ##
|
||||
#########
|
||||
- id: !extend main_display
|
||||
# data_rate: 40MHz
|
||||
lambda: |-
|
||||
id(all_pages_main).execute();
|
||||
|
||||
switch (id(actual_page)){
|
||||
case 0:
|
||||
it.print(100, 150, id(font_arial20), "Hooray, it works!");
|
||||
break;
|
||||
case 1:
|
||||
id(music_card).execute(20, 125);
|
||||
break;
|
||||
case 2:
|
||||
it.print(100, 150, id(font_arial20), "Last Page");
|
||||
break;
|
||||
}
|
||||
|
||||
script:
|
||||
- id: all_pages_main
|
||||
then:
|
||||
- lambda: |-
|
||||
//>>> prev/next icons next to butotns
|
||||
id(main_display).image(0, 208, id(icon_prev_page), ImageAlign::TOP_LEFT, id(red));
|
||||
id(main_display).image(320, 208, id(icon_next_page), ImageAlign::TOP_RIGHT, id(red));
|
||||
//
|
||||
//>>> Page name
|
||||
id(main_display).print(100, 208, id(font_arial20), id(active_page_name).c_str());
|
||||
//
|
||||
//>>> temperature inside:
|
||||
id(main_display).image(36, 15, id(icon_temp_inside), ImageAlign::TOP_CENTER, id(red));
|
||||
id(main_display).printf(36, 80, id(font_arial20), id(white), TextAlign::TOP_CENTER , "%.1f°", id(buttonplus_temperature).state);
|
||||
//
|
||||
//>>> ambient light:
|
||||
id(main_display).image(285, 15, id(icon_ambient_inside), ImageAlign::TOP_CENTER, id(red));
|
||||
id(main_display).printf(285, 80, id(font_arial20), id(white), TextAlign::TOP_CENTER , "%.1flux", id(buttonplus_ambientlight).state);
|
||||
//
|
||||
//>>> print time and date
|
||||
id(main_display).strftime(160, 5, id(font_clock), TextAlign::TOP_CENTER, "%H:%M", id(datetime).now());
|
||||
id(main_display).strftime(160, 80, id(font_date), TextAlign::TOP_CENTER, "%d-%m-%Y", id(datetime).now());
|
||||
- id: !extend bar1_left_draw
|
||||
then:
|
||||
- lambda: |-
|
||||
switch (id(actual_page)){
|
||||
case 0:
|
||||
id(bar_display).image(80, 0, id(lightbulb), ImageAlign::TOP_CENTER, id(red));
|
||||
break;
|
||||
case 1:
|
||||
id(music_card_bar).execute("volume_down");
|
||||
break;
|
||||
}
|
||||
- id: !extend bar1_right_draw
|
||||
then:
|
||||
- lambda: |-
|
||||
switch (id(actual_page)){
|
||||
case 0:
|
||||
id(bar_display).image(80, 0, id(lightbulb), ImageAlign::TOP_CENTER, id(red));
|
||||
break;
|
||||
case 1:
|
||||
id(music_card_bar).execute("volume_up");
|
||||
break;
|
||||
}
|
||||
- id: !extend bar2_left_draw
|
||||
then:
|
||||
- lambda: |-
|
||||
switch (id(actual_page)){
|
||||
case 0:
|
||||
id(bar_display).image(80, 0, id(lightbulb), ImageAlign::TOP_CENTER, id(red));
|
||||
break;
|
||||
case 1:
|
||||
id(music_card_bar).execute("prev");
|
||||
break;
|
||||
}
|
||||
- id: !extend bar2_right_draw
|
||||
then:
|
||||
- lambda: |-
|
||||
switch (id(actual_page)){
|
||||
case 0:
|
||||
id(bar_display).image(80, 0, id(lightbulb), ImageAlign::TOP_CENTER, id(red));
|
||||
break;
|
||||
case 1:
|
||||
id(music_card_bar).execute("next");
|
||||
break;
|
||||
}
|
||||
- id: !extend bar3_left_draw
|
||||
then:
|
||||
- lambda: |-
|
||||
switch (id(actual_page)){
|
||||
case 0:
|
||||
id(bar_display).image(80, 0, id(lightbulb), ImageAlign::TOP_CENTER, id(red));
|
||||
break;
|
||||
case 1:
|
||||
id(music_card_bar).execute("power");
|
||||
break;
|
||||
}
|
||||
- id: !extend bar3_right_draw
|
||||
then:
|
||||
- lambda: |-
|
||||
switch (id(actual_page)){
|
||||
case 0:
|
||||
id(bar_display).image(80, 0, id(lightbulb), ImageAlign::TOP_CENTER, id(red));
|
||||
break;
|
||||
case 1:
|
||||
id(music_card_bar).execute("playpause");
|
||||
break;
|
||||
}
|
||||
|
||||
event:
|
||||
- id: !extend bar1_btn_left_event
|
||||
on_event:
|
||||
then:
|
||||
- lambda: |-
|
||||
ESP_LOGD("main", "BAR1LEFT event %s triggered.", event_type.c_str());
|
||||
- lambda: |-
|
||||
if (event_type == "click page 1"){
|
||||
id(music_card_vol_down).execute();
|
||||
ESP_LOGD("main", "VOL DOWN");
|
||||
}
|
||||
- id: !extend bar1_btn_right_event
|
||||
on_event:
|
||||
then:
|
||||
- lambda: |-
|
||||
ESP_LOGD("main", "BAR1RIGHT event %s triggered.", event_type.c_str());
|
||||
- lambda: |-
|
||||
if (event_type == "click page 1"){
|
||||
id(music_card_vol_up).execute();
|
||||
ESP_LOGD("main", "VOL UP");
|
||||
}
|
||||
- id: !extend bar2_btn_left_event
|
||||
on_event:
|
||||
then:
|
||||
- lambda: |-
|
||||
ESP_LOGD("main", "BAR2LEFT event %s triggered.", event_type.c_str());
|
||||
- lambda: |-
|
||||
if (event_type == "click page 1"){
|
||||
id(music_card_prev).execute();
|
||||
ESP_LOGD("main", "PREV");
|
||||
}
|
||||
- id: !extend bar2_btn_right_event
|
||||
on_event:
|
||||
then:
|
||||
- lambda: |-
|
||||
ESP_LOGD("main", "BAR2RIGHT event %s triggered.", event_type.c_str());
|
||||
- lambda: |-
|
||||
if (event_type == "click page 1"){
|
||||
id(music_card_next).execute();
|
||||
ESP_LOGD("main", "NEXT");
|
||||
}
|
||||
- id: !extend bar3_btn_left_event
|
||||
on_event:
|
||||
then:
|
||||
- lambda: |-
|
||||
ESP_LOGD("main", "BAR3LEFT event %s triggered.", event_type.c_str());
|
||||
- lambda: |-
|
||||
if (event_type == "click page 1"){
|
||||
id(music_card_power).execute();
|
||||
ESP_LOGD("main", "POWER");
|
||||
}
|
||||
- id: !extend bar3_btn_right_event
|
||||
on_event:
|
||||
then:
|
||||
- lambda: |-
|
||||
ESP_LOGD("main", "BAR3RIGHT event %s triggered.", event_type.c_str());
|
||||
- lambda: |-
|
||||
if (event_type == "click page 1"){
|
||||
id(music_card_playpause).execute();
|
||||
ESP_LOGD("main", "PLAY PAUSE");
|
||||
}
|
||||
|
||||
@@ -0,0 +1,549 @@
|
||||
## Events for 3 pages
|
||||
|
||||
substitutions:
|
||||
nr_of_pages: '3'
|
||||
display_events:
|
||||
- double_click page 0
|
||||
- triple_click page 0
|
||||
- hold page 0
|
||||
- double_click page 1
|
||||
- triple_click page 1
|
||||
- hold page 1
|
||||
- double_click page 2
|
||||
- triple_click page 2
|
||||
- hold page 2
|
||||
button_events:
|
||||
- click page 0
|
||||
- double_click page 0
|
||||
- triple_click page 0
|
||||
- hold page 0
|
||||
- click page 1
|
||||
- double_click page 1
|
||||
- triple_click page 1
|
||||
- hold page 1
|
||||
- click page 2
|
||||
- double_click page 2
|
||||
- triple_click page 2
|
||||
- hold page 2
|
||||
script:
|
||||
- id: trigger_with_feedback
|
||||
parameters:
|
||||
event_id: esphome::template_::TemplateEvent*
|
||||
event_msg: std::string
|
||||
led_id: light::LightState*
|
||||
r: float
|
||||
g: float
|
||||
b: float
|
||||
then:
|
||||
- lambda: event_id->trigger(event_msg);
|
||||
- if:
|
||||
condition:
|
||||
lambda: return led_id != nullptr;
|
||||
then:
|
||||
- lambda: |-
|
||||
auto call = led_id->make_call();
|
||||
call.set_state(true);
|
||||
call.set_rgb(r, g, b);
|
||||
call.set_brightness(1.0);
|
||||
call.set_flash_length(200); // Returns to previous state automatically
|
||||
call.perform();
|
||||
event:
|
||||
- platform: template
|
||||
name: DISPLAY Button Left
|
||||
id: display_btn_left_event
|
||||
device_class: button
|
||||
event_types: ${display_events}
|
||||
- platform: template
|
||||
name: DISPLAY Button Right
|
||||
id: display_btn_right_event
|
||||
device_class: button
|
||||
event_types: ${display_events}
|
||||
- platform: template
|
||||
name: BAR1 Button Left
|
||||
id: bar1_btn_left_event
|
||||
device_class: button
|
||||
event_types: ${button_events}
|
||||
- platform: template
|
||||
name: BAR1 Button Right
|
||||
id: bar1_btn_right_event
|
||||
device_class: button
|
||||
event_types: ${button_events}
|
||||
- platform: template
|
||||
name: BAR2 Button Left
|
||||
id: bar2_btn_left_event
|
||||
device_class: button
|
||||
event_types: ${button_events}
|
||||
- platform: template
|
||||
name: BAR2 Button Right
|
||||
id: bar2_btn_right_event
|
||||
device_class: button
|
||||
event_types: ${button_events}
|
||||
- platform: template
|
||||
name: BAR3 Button Left
|
||||
id: bar3_btn_left_event
|
||||
device_class: button
|
||||
event_types: ${button_events}
|
||||
- platform: template
|
||||
name: BAR3 Button Right
|
||||
id: bar3_btn_right_event
|
||||
device_class: button
|
||||
event_types: ${button_events}
|
||||
binary_sensor:
|
||||
- id: !extend 'main_display_btn_left'
|
||||
filters:
|
||||
- delayed_off: 10ms
|
||||
internal: true
|
||||
on_multi_click:
|
||||
- timing:
|
||||
- ON for at most 300ms
|
||||
- OFF for at least 0.2s
|
||||
then:
|
||||
- script.execute: prev_page
|
||||
- timing:
|
||||
- ON for at most 300ms
|
||||
- OFF for at most 0.2s
|
||||
- ON for at most 300ms
|
||||
- OFF for at least 0.2s
|
||||
then:
|
||||
- script.execute:
|
||||
id: trigger_with_feedback
|
||||
event_id: display_btn_left_event
|
||||
event_msg: !lambda "return \"double_click page \" + std::to_string(id(actual_page));"
|
||||
led_id: !lambda "return nullptr;"
|
||||
r: 0.0
|
||||
g: 0.0
|
||||
b: 1.0
|
||||
- timing:
|
||||
- ON for at most 300ms
|
||||
- OFF for at most 0.2s
|
||||
- ON for at most 300ms
|
||||
- OFF for at most 0.2s
|
||||
- ON for at most 300ms
|
||||
- OFF for at least 0.2s
|
||||
then:
|
||||
- script.execute:
|
||||
id: trigger_with_feedback
|
||||
event_id: display_btn_left_event
|
||||
event_msg: !lambda "return \"triple_click page \" + std::to_string(id(actual_page));"
|
||||
led_id: !lambda "return nullptr;"
|
||||
r: 1.0
|
||||
g: 0.0
|
||||
b: 1.0
|
||||
- timing:
|
||||
- ON for at least 1s
|
||||
- OFF for at least 0.2s
|
||||
then:
|
||||
- script.execute:
|
||||
id: trigger_with_feedback
|
||||
event_id: display_btn_left_event
|
||||
event_msg: !lambda "return \"hold page \" + std::to_string(id(actual_page));"
|
||||
led_id: !lambda "return nullptr;"
|
||||
r: 1.0
|
||||
g: 0.5
|
||||
b: 0.0
|
||||
- id: !extend 'main_display_btn_right'
|
||||
filters:
|
||||
- delayed_off: 10ms
|
||||
internal: true
|
||||
on_multi_click:
|
||||
- timing:
|
||||
- ON for at most 300ms
|
||||
- OFF for at least 0.2s
|
||||
then:
|
||||
- script.execute: next_page
|
||||
- timing:
|
||||
- ON for at most 300ms
|
||||
- OFF for at most 0.2s
|
||||
- ON for at most 300ms
|
||||
- OFF for at least 0.2s
|
||||
then:
|
||||
- script.execute:
|
||||
id: trigger_with_feedback
|
||||
event_id: display_btn_right_event
|
||||
event_msg: !lambda "return \"double_click page \" + std::to_string(id(actual_page));"
|
||||
led_id: !lambda "return nullptr;"
|
||||
r: 0.0
|
||||
g: 0.0
|
||||
b: 1.0
|
||||
- timing:
|
||||
- ON for at most 300ms
|
||||
- OFF for at most 0.2s
|
||||
- ON for at most 300ms
|
||||
- OFF for at most 0.2s
|
||||
- ON for at most 300ms
|
||||
- OFF for at least 0.2s
|
||||
then:
|
||||
- script.execute:
|
||||
id: trigger_with_feedback
|
||||
event_id: display_btn_right_event
|
||||
event_msg: !lambda "return \"triple_click page \" + std::to_string(id(actual_page));"
|
||||
led_id: !lambda "return nullptr;"
|
||||
r: 1.0
|
||||
g: 0.0
|
||||
b: 1.0
|
||||
- timing:
|
||||
- ON for at least 1s
|
||||
- OFF for at least 0.2s
|
||||
then:
|
||||
- script.execute:
|
||||
id: trigger_with_feedback
|
||||
event_id: display_btn_right_event
|
||||
event_msg: !lambda "return \"hold page \" + std::to_string(id(actual_page));"
|
||||
led_id: !lambda "return nullptr;"
|
||||
r: 1.0
|
||||
g: 0.5
|
||||
b: 0.0
|
||||
- id: !extend 'bar1_btn_left'
|
||||
filters:
|
||||
- delayed_off: 10ms
|
||||
internal: true
|
||||
on_multi_click:
|
||||
- timing:
|
||||
- ON for at most 300ms
|
||||
- OFF for at least 0.2s
|
||||
then:
|
||||
- script.execute:
|
||||
id: trigger_with_feedback
|
||||
event_id: bar1_btn_left_event
|
||||
event_msg: !lambda "return \"click page \" + std::to_string(id(actual_page));"
|
||||
led_id: bar1_left_rgb_front
|
||||
r: 0.0
|
||||
g: 1.0
|
||||
b: 0.0
|
||||
- timing:
|
||||
- ON for at most 300ms
|
||||
- OFF for at most 0.2s
|
||||
- ON for at most 300ms
|
||||
- OFF for at least 0.2s
|
||||
then:
|
||||
- script.execute:
|
||||
id: trigger_with_feedback
|
||||
event_id: bar1_btn_left_event
|
||||
event_msg: !lambda "return \"double_click page \" + std::to_string(id(actual_page));"
|
||||
led_id: bar1_left_rgb_front
|
||||
r: 0.0
|
||||
g: 0.0
|
||||
b: 1.0
|
||||
- timing:
|
||||
- ON for at most 300ms
|
||||
- OFF for at most 0.2s
|
||||
- ON for at most 300ms
|
||||
- OFF for at most 0.2s
|
||||
- ON for at most 300ms
|
||||
- OFF for at least 0.2s
|
||||
then:
|
||||
- script.execute:
|
||||
id: trigger_with_feedback
|
||||
event_id: bar1_btn_left_event
|
||||
event_msg: !lambda "return \"triple_click page \" + std::to_string(id(actual_page));"
|
||||
led_id: bar1_left_rgb_front
|
||||
r: 1.0
|
||||
g: 0.0
|
||||
b: 1.0
|
||||
- timing:
|
||||
- ON for at least 1s
|
||||
- OFF for at least 0.2s
|
||||
then:
|
||||
- script.execute:
|
||||
id: trigger_with_feedback
|
||||
event_id: bar1_btn_left_event
|
||||
event_msg: !lambda "return \"hold page \" + std::to_string(id(actual_page));"
|
||||
led_id: bar1_left_rgb_front
|
||||
r: 1.0
|
||||
g: 0.5
|
||||
b: 0.0
|
||||
- id: !extend 'bar1_btn_right'
|
||||
filters:
|
||||
- delayed_off: 10ms
|
||||
internal: true
|
||||
on_multi_click:
|
||||
- timing:
|
||||
- ON for at most 300ms
|
||||
- OFF for at least 0.2s
|
||||
then:
|
||||
- script.execute:
|
||||
id: trigger_with_feedback
|
||||
event_id: bar1_btn_right_event
|
||||
event_msg: !lambda "return \"click page \" + std::to_string(id(actual_page));"
|
||||
led_id: bar1_right_rgb_front
|
||||
r: 0.0
|
||||
g: 1.0
|
||||
b: 0.0
|
||||
- timing:
|
||||
- ON for at most 300ms
|
||||
- OFF for at most 0.2s
|
||||
- ON for at most 300ms
|
||||
- OFF for at least 0.2s
|
||||
then:
|
||||
- script.execute:
|
||||
id: trigger_with_feedback
|
||||
event_id: bar1_btn_right_event
|
||||
event_msg: !lambda "return \"double_click page \" + std::to_string(id(actual_page));"
|
||||
led_id: bar1_right_rgb_front
|
||||
r: 0.0
|
||||
g: 0.0
|
||||
b: 1.0
|
||||
- timing:
|
||||
- ON for at most 300ms
|
||||
- OFF for at most 0.2s
|
||||
- ON for at most 300ms
|
||||
- OFF for at most 0.2s
|
||||
- ON for at most 300ms
|
||||
- OFF for at least 0.2s
|
||||
then:
|
||||
- script.execute:
|
||||
id: trigger_with_feedback
|
||||
event_id: bar1_btn_right_event
|
||||
event_msg: !lambda "return \"triple_click page \" + std::to_string(id(actual_page));"
|
||||
led_id: bar1_right_rgb_front
|
||||
r: 1.0
|
||||
g: 0.0
|
||||
b: 1.0
|
||||
- timing:
|
||||
- ON for at least 1s
|
||||
- OFF for at least 0.2s
|
||||
then:
|
||||
- script.execute:
|
||||
id: trigger_with_feedback
|
||||
event_id: bar1_btn_right_event
|
||||
event_msg: !lambda "return \"hold page \" + std::to_string(id(actual_page));"
|
||||
led_id: bar1_right_rgb_front
|
||||
r: 1.0
|
||||
g: 0.5
|
||||
b: 0.0
|
||||
- id: !extend 'bar2_btn_left'
|
||||
filters:
|
||||
- delayed_off: 10ms
|
||||
internal: true
|
||||
on_multi_click:
|
||||
- timing:
|
||||
- ON for at most 300ms
|
||||
- OFF for at least 0.2s
|
||||
then:
|
||||
- script.execute:
|
||||
id: trigger_with_feedback
|
||||
event_id: bar2_btn_left_event
|
||||
event_msg: !lambda "return \"click page \" + std::to_string(id(actual_page));"
|
||||
led_id: bar2_left_rgb_front
|
||||
r: 0.0
|
||||
g: 1.0
|
||||
b: 0.0
|
||||
- timing:
|
||||
- ON for at most 300ms
|
||||
- OFF for at most 0.2s
|
||||
- ON for at most 300ms
|
||||
- OFF for at least 0.2s
|
||||
then:
|
||||
- script.execute:
|
||||
id: trigger_with_feedback
|
||||
event_id: bar2_btn_left_event
|
||||
event_msg: !lambda "return \"double_click page \" + std::to_string(id(actual_page));"
|
||||
led_id: bar2_left_rgb_front
|
||||
r: 0.0
|
||||
g: 0.0
|
||||
b: 1.0
|
||||
- timing:
|
||||
- ON for at most 300ms
|
||||
- OFF for at most 0.2s
|
||||
- ON for at most 300ms
|
||||
- OFF for at most 0.2s
|
||||
- ON for at most 300ms
|
||||
- OFF for at least 0.2s
|
||||
then:
|
||||
- script.execute:
|
||||
id: trigger_with_feedback
|
||||
event_id: bar2_btn_left_event
|
||||
event_msg: !lambda "return \"triple_click page \" + std::to_string(id(actual_page));"
|
||||
led_id: bar2_left_rgb_front
|
||||
r: 1.0
|
||||
g: 0.0
|
||||
b: 1.0
|
||||
- timing:
|
||||
- ON for at least 1s
|
||||
- OFF for at least 0.2s
|
||||
then:
|
||||
- script.execute:
|
||||
id: trigger_with_feedback
|
||||
event_id: bar2_btn_left_event
|
||||
event_msg: !lambda "return \"hold page \" + std::to_string(id(actual_page));"
|
||||
led_id: bar2_left_rgb_front
|
||||
r: 1.0
|
||||
g: 0.5
|
||||
b: 0.0
|
||||
- id: !extend 'bar2_btn_right'
|
||||
filters:
|
||||
- delayed_off: 10ms
|
||||
internal: true
|
||||
on_multi_click:
|
||||
- timing:
|
||||
- ON for at most 300ms
|
||||
- OFF for at least 0.2s
|
||||
then:
|
||||
- script.execute:
|
||||
id: trigger_with_feedback
|
||||
event_id: bar2_btn_right_event
|
||||
event_msg: !lambda "return \"click page \" + std::to_string(id(actual_page));"
|
||||
led_id: bar2_right_rgb_front
|
||||
r: 0.0
|
||||
g: 1.0
|
||||
b: 0.0
|
||||
- timing:
|
||||
- ON for at most 300ms
|
||||
- OFF for at most 0.2s
|
||||
- ON for at most 300ms
|
||||
- OFF for at least 0.2s
|
||||
then:
|
||||
- script.execute:
|
||||
id: trigger_with_feedback
|
||||
event_id: bar2_btn_right_event
|
||||
event_msg: !lambda "return \"double_click page \" + std::to_string(id(actual_page));"
|
||||
led_id: bar2_right_rgb_front
|
||||
r: 0.0
|
||||
g: 0.0
|
||||
b: 1.0
|
||||
- timing:
|
||||
- ON for at most 300ms
|
||||
- OFF for at most 0.2s
|
||||
- ON for at most 300ms
|
||||
- OFF for at most 0.2s
|
||||
- ON for at most 300ms
|
||||
- OFF for at least 0.2s
|
||||
then:
|
||||
- script.execute:
|
||||
id: trigger_with_feedback
|
||||
event_id: bar2_btn_right_event
|
||||
event_msg: !lambda "return \"triple_click page \" + std::to_string(id(actual_page));"
|
||||
led_id: bar2_right_rgb_front
|
||||
r: 1.0
|
||||
g: 0.0
|
||||
b: 1.0
|
||||
- timing:
|
||||
- ON for at least 1s
|
||||
- OFF for at least 0.2s
|
||||
then:
|
||||
- script.execute:
|
||||
id: trigger_with_feedback
|
||||
event_id: bar2_btn_right_event
|
||||
event_msg: !lambda "return \"hold page \" + std::to_string(id(actual_page));"
|
||||
led_id: bar2_right_rgb_front
|
||||
r: 1.0
|
||||
g: 0.5
|
||||
b: 0.0
|
||||
- id: !extend 'bar3_btn_left'
|
||||
filters:
|
||||
- delayed_off: 10ms
|
||||
internal: true
|
||||
on_multi_click:
|
||||
- timing:
|
||||
- ON for at most 300ms
|
||||
- OFF for at least 0.2s
|
||||
then:
|
||||
- script.execute:
|
||||
id: trigger_with_feedback
|
||||
event_id: bar3_btn_left_event
|
||||
event_msg: !lambda "return \"click page \" + std::to_string(id(actual_page));"
|
||||
led_id: bar3_left_rgb_front
|
||||
r: 0.0
|
||||
g: 1.0
|
||||
b: 0.0
|
||||
- timing:
|
||||
- ON for at most 300ms
|
||||
- OFF for at most 0.2s
|
||||
- ON for at most 300ms
|
||||
- OFF for at least 0.2s
|
||||
then:
|
||||
- script.execute:
|
||||
id: trigger_with_feedback
|
||||
event_id: bar3_btn_left_event
|
||||
event_msg: !lambda "return \"double_click page \" + std::to_string(id(actual_page));"
|
||||
led_id: bar3_left_rgb_front
|
||||
r: 0.0
|
||||
g: 0.0
|
||||
b: 1.0
|
||||
- timing:
|
||||
- ON for at most 300ms
|
||||
- OFF for at most 0.2s
|
||||
- ON for at most 300ms
|
||||
- OFF for at most 0.2s
|
||||
- ON for at most 300ms
|
||||
- OFF for at least 0.2s
|
||||
then:
|
||||
- script.execute:
|
||||
id: trigger_with_feedback
|
||||
event_id: bar3_btn_left_event
|
||||
event_msg: !lambda "return \"triple_click page \" + std::to_string(id(actual_page));"
|
||||
led_id: bar3_left_rgb_front
|
||||
r: 1.0
|
||||
g: 0.0
|
||||
b: 1.0
|
||||
- timing:
|
||||
- ON for at least 1s
|
||||
- OFF for at least 0.2s
|
||||
then:
|
||||
- script.execute:
|
||||
id: trigger_with_feedback
|
||||
event_id: bar3_btn_left_event
|
||||
event_msg: !lambda "return \"hold page \" + std::to_string(id(actual_page));"
|
||||
led_id: bar3_left_rgb_front
|
||||
r: 1.0
|
||||
g: 0.5
|
||||
b: 0.0
|
||||
- id: !extend 'bar3_btn_right'
|
||||
filters:
|
||||
- delayed_off: 10ms
|
||||
internal: true
|
||||
on_multi_click:
|
||||
- timing:
|
||||
- ON for at most 300ms
|
||||
- OFF for at least 0.2s
|
||||
then:
|
||||
- script.execute:
|
||||
id: trigger_with_feedback
|
||||
event_id: bar3_btn_right_event
|
||||
event_msg: !lambda "return \"click page \" + std::to_string(id(actual_page));"
|
||||
led_id: bar3_right_rgb_front
|
||||
r: 0.0
|
||||
g: 1.0
|
||||
b: 0.0
|
||||
- timing:
|
||||
- ON for at most 300ms
|
||||
- OFF for at most 0.2s
|
||||
- ON for at most 300ms
|
||||
- OFF for at least 0.2s
|
||||
then:
|
||||
- script.execute:
|
||||
id: trigger_with_feedback
|
||||
event_id: bar3_btn_right_event
|
||||
event_msg: !lambda "return \"double_click page \" + std::to_string(id(actual_page));"
|
||||
led_id: bar3_right_rgb_front
|
||||
r: 0.0
|
||||
g: 0.0
|
||||
b: 1.0
|
||||
- timing:
|
||||
- ON for at most 300ms
|
||||
- OFF for at most 0.2s
|
||||
- ON for at most 300ms
|
||||
- OFF for at most 0.2s
|
||||
- ON for at most 300ms
|
||||
- OFF for at least 0.2s
|
||||
then:
|
||||
- script.execute:
|
||||
id: trigger_with_feedback
|
||||
event_id: bar3_btn_right_event
|
||||
event_msg: !lambda "return \"triple_click page \" + std::to_string(id(actual_page));"
|
||||
led_id: bar3_right_rgb_front
|
||||
r: 1.0
|
||||
g: 0.0
|
||||
b: 1.0
|
||||
- timing:
|
||||
- ON for at least 1s
|
||||
- OFF for at least 0.2s
|
||||
then:
|
||||
- script.execute:
|
||||
id: trigger_with_feedback
|
||||
event_id: bar3_btn_right_event
|
||||
event_msg: !lambda "return \"hold page \" + std::to_string(id(actual_page));"
|
||||
led_id: bar3_right_rgb_front
|
||||
r: 1.0
|
||||
g: 0.5
|
||||
b: 0.0
|
||||
@@ -0,0 +1,161 @@
|
||||
|
||||
script:
|
||||
######################
|
||||
### update scripts ###
|
||||
######################
|
||||
- id: update_bar1_left
|
||||
then:
|
||||
- lambda: |-
|
||||
id(cs_pin_bar1_left).turn_on(); // <<
|
||||
id(cs_pin_bar1_right).turn_off();
|
||||
id(cs_pin_bar2_left).turn_off();
|
||||
id(cs_pin_bar2_right).turn_off();
|
||||
id(cs_pin_bar3_left).turn_off();
|
||||
id(cs_pin_bar3_right).turn_off();
|
||||
id(bar_display).clear();
|
||||
id(bar_display).set_rotation(display::DisplayRotation::DISPLAY_ROTATION_270_DEGREES);
|
||||
id(bar1_left_draw).execute();
|
||||
id(bar_display).update();
|
||||
delay(1);
|
||||
id(cs_pin_bar1_left).turn_off();
|
||||
- id: update_bar1_right
|
||||
then:
|
||||
- lambda: |-
|
||||
id(cs_pin_bar1_left).turn_off();
|
||||
id(cs_pin_bar1_right).turn_on(); // <<
|
||||
id(cs_pin_bar2_left).turn_off();
|
||||
id(cs_pin_bar2_right).turn_off();
|
||||
id(cs_pin_bar3_left).turn_off();
|
||||
id(cs_pin_bar3_right).turn_off();
|
||||
id(bar_display).clear();
|
||||
id(bar_display).set_rotation(display::DisplayRotation::DISPLAY_ROTATION_90_DEGREES);
|
||||
id(bar1_right_draw).execute();
|
||||
id(bar_display).update();
|
||||
delay(1);
|
||||
id(cs_pin_bar1_right).turn_off();
|
||||
- id: update_bar2_left
|
||||
then:
|
||||
- lambda: |-
|
||||
id(cs_pin_bar1_left).turn_off();
|
||||
id(cs_pin_bar1_right).turn_off();
|
||||
id(cs_pin_bar2_left).turn_on(); // <<
|
||||
id(cs_pin_bar2_right).turn_off();
|
||||
id(cs_pin_bar3_left).turn_off();
|
||||
id(cs_pin_bar3_right).turn_off();
|
||||
id(bar_display).clear();
|
||||
id(bar_display).set_rotation(display::DisplayRotation::DISPLAY_ROTATION_270_DEGREES);
|
||||
id(bar2_left_draw).execute();
|
||||
id(bar_display).update();
|
||||
delay(1);
|
||||
id(cs_pin_bar2_left).turn_off();
|
||||
- id: update_bar2_right
|
||||
then:
|
||||
- lambda: |-
|
||||
id(cs_pin_bar1_left).turn_off();
|
||||
id(cs_pin_bar1_right).turn_off();
|
||||
id(cs_pin_bar2_left).turn_off();
|
||||
id(cs_pin_bar2_right).turn_on(); // <<
|
||||
id(cs_pin_bar3_left).turn_off();
|
||||
id(cs_pin_bar3_right).turn_off();
|
||||
id(bar_display).clear();
|
||||
id(bar_display).set_rotation(display::DisplayRotation::DISPLAY_ROTATION_90_DEGREES);
|
||||
id(bar2_right_draw).execute();
|
||||
id(bar_display).update();
|
||||
delay(1);
|
||||
id(cs_pin_bar2_right).turn_off();
|
||||
- id: update_bar3_left
|
||||
then:
|
||||
- lambda: |-
|
||||
id(cs_pin_bar1_left).turn_off();
|
||||
id(cs_pin_bar1_right).turn_off();
|
||||
id(cs_pin_bar2_left).turn_off();
|
||||
id(cs_pin_bar2_right).turn_off();
|
||||
id(cs_pin_bar3_left).turn_on(); // <<
|
||||
id(cs_pin_bar3_right).turn_off();
|
||||
id(bar_display).clear();
|
||||
id(bar_display).set_rotation(display::DisplayRotation::DISPLAY_ROTATION_270_DEGREES);
|
||||
id(bar3_left_draw).execute();
|
||||
id(bar_display).update();
|
||||
delay(1);
|
||||
id(cs_pin_bar3_left).turn_off();
|
||||
- id: update_bar3_right
|
||||
then:
|
||||
- lambda: |-
|
||||
id(cs_pin_bar1_left).turn_off();
|
||||
id(cs_pin_bar1_right).turn_off();
|
||||
id(cs_pin_bar2_left).turn_off();
|
||||
id(cs_pin_bar2_right).turn_off();
|
||||
id(cs_pin_bar3_left).turn_off();
|
||||
id(cs_pin_bar3_right).turn_on(); // <<
|
||||
id(bar_display).clear();
|
||||
id(bar_display).set_rotation(display::DisplayRotation::DISPLAY_ROTATION_90_DEGREES);
|
||||
id(bar3_right_draw).execute();
|
||||
id(bar_display).update();
|
||||
delay(1);
|
||||
id(cs_pin_bar3_right).turn_off();
|
||||
####################################
|
||||
### setup mini display's scripts ###
|
||||
####################################
|
||||
- id: setup_bar_displays
|
||||
then:
|
||||
- lambda: |-
|
||||
id(cs_pin_bar1_left).turn_on();
|
||||
id(bar_display).setup();
|
||||
delay(5);
|
||||
id(cs_pin_bar1_left).turn_off();
|
||||
id(cs_pin_bar1_right).turn_on();
|
||||
id(bar_display).setup();
|
||||
delay(5);
|
||||
id(cs_pin_bar1_right).turn_off();
|
||||
id(cs_pin_bar2_left).turn_on();
|
||||
id(bar_display).setup();
|
||||
delay(5);
|
||||
id(cs_pin_bar2_left).turn_off();
|
||||
id(cs_pin_bar2_right).turn_on();
|
||||
id(bar_display).setup();
|
||||
delay(5);
|
||||
id(cs_pin_bar2_right).turn_off();
|
||||
id(cs_pin_bar3_left).turn_on();
|
||||
id(bar_display).setup();
|
||||
delay(5);
|
||||
id(cs_pin_bar3_left).turn_off();
|
||||
id(cs_pin_bar3_right).turn_on();
|
||||
id(bar_display).setup();
|
||||
delay(5);
|
||||
id(cs_pin_bar3_right).turn_off();
|
||||
###############################
|
||||
### pre-define draw scripts ###
|
||||
###############################
|
||||
- id: bar1_left_draw
|
||||
then:
|
||||
- id: bar1_right_draw
|
||||
then:
|
||||
- id: bar2_left_draw
|
||||
then:
|
||||
- id: bar2_right_draw
|
||||
then:
|
||||
- id: bar3_left_draw
|
||||
then:
|
||||
- id: bar3_right_draw
|
||||
then:
|
||||
######################
|
||||
### update scripts ###
|
||||
######################
|
||||
- id: update_main
|
||||
then:
|
||||
- component.update: main_display
|
||||
- id: update_all
|
||||
then:
|
||||
- component.update: main_display
|
||||
- delay: 0.1s
|
||||
- script.execute: update_bar1_left
|
||||
- delay: 0.1s
|
||||
- script.execute: update_bar1_right
|
||||
- delay: 0.1s
|
||||
- script.execute: update_bar2_left
|
||||
- delay: 0.1s
|
||||
- script.execute: update_bar2_right
|
||||
- delay: 0.1s
|
||||
- script.execute: update_bar3_left
|
||||
- delay: 0.1s
|
||||
- script.execute: update_bar3_right
|
||||
@@ -0,0 +1,7 @@
|
||||
This folder contains the example working configuration on which this generator is based.
|
||||
|
||||
`common.yaml`: for all button+ configurations (max 3 bars, 1 display)
|
||||
`config.yaml`: the base for ESPHome with board configuration
|
||||
`base.yaml`: the base for the specific configuration with the GPIO definitions
|
||||
`events.yaml`: all events for all buttons based on a provided number of pages
|
||||
`scripts.yaml`: scripts to update the displays for the specific configuration
|
||||
@@ -0,0 +1,35 @@
|
||||
# ESPHome Button+ - Music card
|
||||
|
||||
## Usage
|
||||
|
||||
* Add the music card to the main display `lambda` and give it the position you want
|
||||
```
|
||||
id(music_card).execute(20, 125);
|
||||
```
|
||||
|
||||
* Add the icons buttons to the BAR's
|
||||
|
||||
Select one of the folowing types:
|
||||
* `volume_up`
|
||||
* `volume_down`
|
||||
* `next`
|
||||
* `prev`
|
||||
* `playpause`
|
||||
* `power`
|
||||
|
||||
```
|
||||
id(music_card_bar).execute("volume_up");
|
||||
```
|
||||
|
||||
* add actions to the buttons
|
||||
Select the a matching action for the button:
|
||||
* `music_card_vol_up`
|
||||
* `music_card_vol_down`
|
||||
* `music_card_next`
|
||||
* `music_card_prev`
|
||||
* `music_card_playpause`
|
||||
* `music_card_power`
|
||||
|
||||
```
|
||||
id(music_card_vol_up).execute();
|
||||
```
|
||||
@@ -0,0 +1,200 @@
|
||||
image:
|
||||
- file: mdi:music-box-outline
|
||||
type: GRAYSCALE
|
||||
id: icon_music_album
|
||||
resize: 20x20
|
||||
- file: mdi:account-music
|
||||
type: GRAYSCALE
|
||||
id: icon_music_artist
|
||||
resize: 20x20
|
||||
- file: mdi:music-note
|
||||
type: GRAYSCALE
|
||||
id: icon_music_songtitle
|
||||
resize: 20x20
|
||||
- file: mdi:power-off
|
||||
type: GRAYSCALE
|
||||
id: icon_music_off
|
||||
resize: 75x75
|
||||
- file: mdi:power-on
|
||||
type: GRAYSCALE
|
||||
id: icon_music_on
|
||||
resize: 75x75
|
||||
- file: mdi:power
|
||||
type: GRAYSCALE
|
||||
id: icon_music_power
|
||||
resize: 75x75
|
||||
- file: mdi:timer-sand-empty
|
||||
type: GRAYSCALE
|
||||
id: icon_music_idle
|
||||
resize: 75x75
|
||||
- file: mdi:play-pause
|
||||
type: GRAYSCALE
|
||||
id: icon_music_playpause
|
||||
resize: 75x75
|
||||
- file: mdi:play-box-outline
|
||||
type: GRAYSCALE
|
||||
id: icon_music_play_box
|
||||
resize: 75x75
|
||||
- file: mdi:pause-box-outline
|
||||
type: GRAYSCALE
|
||||
id: icon_music_pause_box
|
||||
resize: 75x75
|
||||
- file: mdi:power
|
||||
type: GRAYSCALE
|
||||
id: icon_music_standby
|
||||
resize: 75x75
|
||||
- file: mdi:download-box-outline
|
||||
type: GRAYSCALE
|
||||
id: icon_music_buffering
|
||||
resize: 75x75
|
||||
- file: mdi:volume-plus
|
||||
type: GRAYSCALE
|
||||
id: icon_music_vol_up
|
||||
resize: 75x75
|
||||
- file: mdi:volume-minus
|
||||
type: GRAYSCALE
|
||||
id: icon_music_vol_down
|
||||
resize: 75x75
|
||||
- file: mdi:skip-forward
|
||||
type: GRAYSCALE
|
||||
id: icon_music_next
|
||||
resize: 75x75
|
||||
- file: mdi:skip-backward
|
||||
type: GRAYSCALE
|
||||
id: icon_music_prev
|
||||
resize: 75x75
|
||||
- file: mdi:play
|
||||
type: GRAYSCALE
|
||||
id: icon_music_play
|
||||
resize: 75x75
|
||||
- file: mdi:pause
|
||||
type: GRAYSCALE
|
||||
id: icon_music_pause
|
||||
resize: 75x75
|
||||
|
||||
color:
|
||||
- id: music_card_text_color
|
||||
hex: ${music_card_text_color}
|
||||
- id: music_card_icon_main_color
|
||||
hex: ${music_card_icon_main_color}
|
||||
- id: music_card_icon_bar_color
|
||||
hex: ${music_card_icon_bar_color}
|
||||
|
||||
text_sensor:
|
||||
- platform: homeassistant
|
||||
id: music_album
|
||||
entity_id: ${music_card_entity_id}
|
||||
attribute: media_album_name
|
||||
on_value:
|
||||
- delay: 500ms
|
||||
- script.execute: update_main
|
||||
- platform: homeassistant
|
||||
id: music_artist
|
||||
entity_id: ${music_card_entity_id}
|
||||
attribute: media_artist
|
||||
- platform: homeassistant
|
||||
id: music_title
|
||||
entity_id: ${music_card_entity_id}
|
||||
attribute: media_title
|
||||
on_value:
|
||||
- delay: 500ms
|
||||
- script.execute: update_main
|
||||
- platform: homeassistant
|
||||
id: music_playerstate
|
||||
entity_id: ${music_card_entity_id}
|
||||
on_value:
|
||||
- script.execute: update_all
|
||||
|
||||
script:
|
||||
- id: music_card
|
||||
parameters:
|
||||
x: int
|
||||
y: int
|
||||
then:
|
||||
- lambda: |-
|
||||
// player state
|
||||
if (strcmp(id(music_playerstate).state.c_str(), "off") == 0) {
|
||||
id(main_display).image(x, 1+y, id(icon_music_off), ImageAlign::TOP_LEFT, id(music_card_icon_main_color));
|
||||
} else if (strcmp(id(music_playerstate).state.c_str(), "on") == 0) {
|
||||
id(main_display).image(x, 1+y, id(icon_music_on), ImageAlign::TOP_LEFT, id(music_card_icon_main_color));
|
||||
} else if (strcmp(id(music_playerstate).state.c_str(), "idle") == 0) {
|
||||
id(main_display).image(x, 1+y, id(icon_music_idle), ImageAlign::TOP_LEFT, id(music_card_icon_main_color));
|
||||
} else if (strcmp(id(music_playerstate).state.c_str(), "playing") == 0) {
|
||||
id(main_display).image(x, 1+y, id(icon_music_play_box), ImageAlign::TOP_LEFT, id(music_card_icon_main_color));
|
||||
} else if (strcmp(id(music_playerstate).state.c_str(), "paused") == 0) {
|
||||
id(main_display).image(x, 1+y, id(icon_music_pause_box), ImageAlign::TOP_LEFT, id(music_card_icon_main_color));
|
||||
} else if (strcmp(id(music_playerstate).state.c_str(), "standby") == 0) {
|
||||
id(main_display).image(x, 1+y, id(icon_music_standby), ImageAlign::TOP_LEFT, id(music_card_icon_main_color));
|
||||
} else if (strcmp(id(music_playerstate).state.c_str(), "buffering") == 0) {
|
||||
id(main_display).image(x, 1+y, id(icon_music_buffering), ImageAlign::TOP_LEFT, id(music_card_icon_main_color));
|
||||
}
|
||||
//
|
||||
// album
|
||||
id(main_display).image(75+3+x, 4+y, id(icon_music_album), ImageAlign::TOP_LEFT, id(music_card_icon_main_color));
|
||||
id(main_display).print(75+25+x, 0+y, id(font_arial20), id(music_card_text_color), TextAlign::TOP_LEFT , id(music_album).state.c_str());
|
||||
//
|
||||
// artist
|
||||
id(main_display).image(75+3+x, 30+y, id(icon_music_artist), ImageAlign::TOP_LEFT, id(music_card_icon_main_color));
|
||||
id(main_display).print(75+25+x, 26+y, id(font_arial20), id(music_card_text_color), TextAlign::TOP_LEFT , id(music_artist).state.c_str());
|
||||
//
|
||||
// song title
|
||||
id(main_display).image(75+3+x, 56+y, id(icon_music_songtitle), ImageAlign::TOP_LEFT, id(music_card_icon_main_color));
|
||||
id(main_display).print(75+25+x, 52+y, id(font_arial20), id(music_card_text_color), TextAlign::TOP_LEFT , id(music_title).state.c_str());
|
||||
- id: music_card_bar
|
||||
parameters:
|
||||
type: string
|
||||
then:
|
||||
- lambda: |-
|
||||
if (strcmp(type.c_str(), "volume_up") == 0) { // button "volume_up"
|
||||
id(bar_display).image(80, 2, id(icon_music_vol_up), ImageAlign::TOP_CENTER, id(music_card_icon_bar_color));
|
||||
} else if (strcmp(type.c_str(), "volume_down") == 0) { // button "volume_down"
|
||||
id(bar_display).image(80, 2, id(icon_music_vol_down), ImageAlign::TOP_CENTER, id(music_card_icon_bar_color));
|
||||
} else if (strcmp(type.c_str(), "next") == 0) { // button "next"
|
||||
id(bar_display).image(80, 2, id(icon_music_next), ImageAlign::TOP_CENTER, id(music_card_icon_bar_color));
|
||||
} else if (strcmp(type.c_str(), "prev") == 0) { // button "prev"
|
||||
id(bar_display).image(80, 2, id(icon_music_prev), ImageAlign::TOP_CENTER, id(music_card_icon_bar_color));
|
||||
} else if (strcmp(type.c_str(), "playpause") == 0) { // button "playpause"
|
||||
if (strcmp(id(music_playerstate).state.c_str(), "playing") == 0) {
|
||||
id(bar_display).image(80, 2, id(icon_music_pause), ImageAlign::TOP_CENTER, id(music_card_icon_bar_color));
|
||||
} else {
|
||||
id(bar_display).image(80, 2, id(icon_music_play), ImageAlign::TOP_CENTER, id(music_card_icon_bar_color));
|
||||
}
|
||||
} else if (strcmp(type.c_str(), "power") == 0) { // button "power"
|
||||
id(bar_display).image(80, 2, id(icon_music_power), ImageAlign::TOP_CENTER, id(music_card_icon_bar_color));
|
||||
}
|
||||
- id: music_card_vol_up
|
||||
then:
|
||||
- homeassistant.action:
|
||||
action: media_player.volume_up
|
||||
data:
|
||||
entity_id: ${music_card_entity_id}
|
||||
- id: music_card_vol_down
|
||||
then:
|
||||
- homeassistant.action:
|
||||
action: media_player.volume_down
|
||||
data:
|
||||
entity_id: ${music_card_entity_id}
|
||||
- id: music_card_next
|
||||
then:
|
||||
- homeassistant.action:
|
||||
action: media_player.media_next_track
|
||||
data:
|
||||
entity_id: ${music_card_entity_id}
|
||||
- id: music_card_prev
|
||||
then:
|
||||
- homeassistant.action:
|
||||
action: media_player.media_previous_track
|
||||
data:
|
||||
entity_id: ${music_card_entity_id}
|
||||
- id: music_card_playpause
|
||||
then:
|
||||
- homeassistant.action:
|
||||
action: media_player.media_play_pause
|
||||
data:
|
||||
entity_id: ${music_card_entity_id}
|
||||
- id: music_card_power
|
||||
then:
|
||||
- homeassistant.action:
|
||||
action: media_player.toggle
|
||||
data:
|
||||
entity_id: ${music_card_entity_id}
|
||||
@@ -0,0 +1,202 @@
|
||||
esp32:
|
||||
flash_size: 16MB
|
||||
|
||||
psram:
|
||||
mode: octal
|
||||
speed: 80MHz
|
||||
|
||||
interval:
|
||||
- interval: 1min
|
||||
then:
|
||||
- logger.log: "ESPHome for Button+ V2 v0.1.0"
|
||||
|
||||
i2c:
|
||||
# Devices at 0x20, 0x21, 0x22, 0x23
|
||||
- id: buttons
|
||||
sda: GPIO1
|
||||
scl: GPIO2
|
||||
frequency: 50khz
|
||||
|
||||
# Devices at 0x29 (ambient), 0x4A (temp)
|
||||
- id: sensors
|
||||
sda: GPIO47
|
||||
scl: GPIO48
|
||||
frequency: 50khz
|
||||
|
||||
spi:
|
||||
clk_pin: GPIO6
|
||||
mosi_pin: GPIO5
|
||||
|
||||
substitutions:
|
||||
nr_of_pages: '"2"'
|
||||
page_names: '{"Page 1", "Page 2"}'
|
||||
|
||||
globals:
|
||||
- id: nr_of_pages
|
||||
type: int
|
||||
initial_value: ${nr_of_pages}
|
||||
- id: actual_page
|
||||
type: int
|
||||
initial_value: '0'
|
||||
- id: page_names
|
||||
type: std::vector<std::string>
|
||||
initial_value: ${page_names}
|
||||
- id: active_page_name
|
||||
type: std::string
|
||||
initial_value: ""
|
||||
|
||||
output:
|
||||
- platform: ledc
|
||||
pin: GPIO3
|
||||
id: display_main_backlight_pwm
|
||||
inverted: True
|
||||
max_power: 1.0
|
||||
frequency: 500Hz
|
||||
- platform: ledc
|
||||
pin: GPIO46
|
||||
id: displays_mini_backlight_pwm
|
||||
inverted: True
|
||||
max_power: 0.6
|
||||
frequency: 500Hz
|
||||
|
||||
sensor:
|
||||
- platform: sts3x
|
||||
address: 0x4A
|
||||
id: buttonplus_temperature
|
||||
i2c_id: sensors
|
||||
name: "Temperature"
|
||||
update_interval: 10s
|
||||
unit_of_measurement: "°C"
|
||||
icon: "mdi:thermometer"
|
||||
device_class: "temperature"
|
||||
state_class: "measurement"
|
||||
accuracy_decimals: 1
|
||||
- platform: ltr_als_ps
|
||||
address: 0x29
|
||||
i2c_id: sensors
|
||||
update_interval: 10s
|
||||
type: ALS
|
||||
auto_mode: false
|
||||
gain: 48x
|
||||
ambient_light:
|
||||
name: "Ambient Light"
|
||||
id: buttonplus_ambientlight
|
||||
unit_of_measurement: "lx"
|
||||
icon: "mdi:brightness-6"
|
||||
device_class: "illuminance"
|
||||
state_class: "measurement"
|
||||
accuracy_decimals: 1
|
||||
infrared_counts:
|
||||
name: "Infrared Counts"
|
||||
id: buttonplus_infraredcounts
|
||||
unit_of_measurement: "#"
|
||||
icon: "mdi:brightness-5"
|
||||
accuracy_decimals: 0
|
||||
full_spectrum_counts :
|
||||
name: "Full Spectrum Counts"
|
||||
id: buttonplus_fullspectrumcounts
|
||||
unit_of_measurement: "#"
|
||||
icon: "mdi:brightness-7"
|
||||
accuracy_decimals: 0
|
||||
actual_gain:
|
||||
name: "Actual Gain"
|
||||
id: buttonplus_actualgain
|
||||
icon: "mdi:multiplication"
|
||||
accuracy_decimals: 0
|
||||
- platform: template
|
||||
name: "Active Page ID"
|
||||
icon: "mdi:order-numeric-ascending"
|
||||
id: active_page_id_ha
|
||||
update_interval: never
|
||||
accuracy_decimals: 0
|
||||
|
||||
text_sensor:
|
||||
- platform: template
|
||||
name: "Active Page Name"
|
||||
icon: "mdi:order-alphabetical-ascending"
|
||||
id: active_page_name_ha
|
||||
update_interval: never
|
||||
|
||||
light:
|
||||
- platform: esp32_rmt_led_strip
|
||||
id: neopixels
|
||||
rgb_order: RGB
|
||||
chipset: ws2812
|
||||
pin: GPIO4
|
||||
num_leds: 17
|
||||
- platform: monochromatic
|
||||
output: display_main_backlight_pwm
|
||||
gamma_correct : 2.2
|
||||
name: "Main Display Backlight"
|
||||
id: display_main_backlight
|
||||
restore_mode: ALWAYS_ON
|
||||
- platform: monochromatic
|
||||
output: displays_mini_backlight_pwm
|
||||
gamma_correct : 2.2
|
||||
name: "Bars Display Backlight"
|
||||
id: displays_mini_backlight
|
||||
restore_mode: ALWAYS_ON
|
||||
|
||||
time:
|
||||
- platform: homeassistant
|
||||
id: datetime
|
||||
|
||||
number:
|
||||
## Creates a number entity in Home Assistant
|
||||
# It sets the menu of the Button Plus
|
||||
- platform: template
|
||||
name: "Menu Selector"
|
||||
id: menuselector
|
||||
optimistic: true
|
||||
min_value: 0
|
||||
max_value: ${nr_of_pages | int - 1}
|
||||
step: 1
|
||||
on_value:
|
||||
then:
|
||||
- lambda: |-
|
||||
if(id(menuselector).state >= id(nr_of_pages)) {
|
||||
id(actual_page) = id(nr_of_pages)-1;
|
||||
} else {
|
||||
id(actual_page) = id(menuselector).state;
|
||||
}
|
||||
- logger.log: "Changing page"
|
||||
- script.execute: set_page
|
||||
|
||||
script:
|
||||
######################
|
||||
### paging scripts ###
|
||||
######################
|
||||
- id: next_page
|
||||
then:
|
||||
- lambda: |-
|
||||
id(actual_page) = id(actual_page) + 1;
|
||||
if(id(actual_page) >= id(nr_of_pages)) {
|
||||
id(actual_page) = 0;
|
||||
}
|
||||
- script.execute: update_page
|
||||
- id: prev_page
|
||||
then:
|
||||
- lambda: |-
|
||||
id(actual_page) = id(actual_page) - 1;
|
||||
if(id(actual_page) < 0) {
|
||||
id(actual_page) = id(nr_of_pages) - 1;
|
||||
}
|
||||
- script.execute: update_page
|
||||
- id: set_page
|
||||
then:
|
||||
- lambda: |-
|
||||
id(active_page_name) = id(page_names)[id(actual_page)];
|
||||
- sensor.template.publish:
|
||||
id: active_page_id_ha
|
||||
state: !lambda 'return id(actual_page);'
|
||||
- text_sensor.template.publish:
|
||||
id: active_page_name_ha
|
||||
state: !lambda 'return id(active_page_name);'
|
||||
- script.execute: update_all
|
||||
- id: update_page
|
||||
then:
|
||||
- number.set:
|
||||
id: menuselector
|
||||
value: !lambda 'return id(actual_page);'
|
||||
- script.execute: set_page
|
||||
|
||||
Reference in New Issue
Block a user