188 lines
4.4 KiB
YAML
188 lines
4.4 KiB
YAML
###########################################
|
|
## ##
|
|
## filename: base.yaml ##
|
|
## description: contains configuration ##
|
|
## that will be the same for all the ##
|
|
## possible configurations ##
|
|
## ##
|
|
###########################################
|
|
|
|
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: 400khz
|
|
|
|
spi:
|
|
clk_pin: GPIO6
|
|
mosi_pin: GPIO5
|
|
|
|
substitutions:
|
|
nr_of_pages: 1
|
|
page_names: '{"Page 1"}'
|
|
|
|
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: true
|
|
ambient_light:
|
|
name: "Ambient Light"
|
|
id: buttonplus_ambientlight
|
|
unit_of_measurement: "lx"
|
|
icon: "mdi:brightness-percent"
|
|
device_class: "illuminance"
|
|
state_class: "measurement"
|
|
accuracy_decimals: 0
|
|
- platform: template
|
|
name: "Active Page ID"
|
|
icon: "mdi:order-numeric-ascending"
|
|
id: active_page_id_ha
|
|
update_interval: never
|
|
|
|
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}
|
|
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;
|
|
}
|
|
|
|
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: update_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);'
|
|
- number.set:
|
|
id: menuselector
|
|
value: !lambda 'return id(actual_page);'
|
|
- script.execute: update_all
|
|
|