2020-09-12 19:08:02 +00:00
|
|
|
|
#-------------------------------------------
|
|
|
|
|
# @CCOSTAN
|
|
|
|
|
# Original Repo : https://github.com/CCOSTAN/Home-AssistantConfig
|
|
|
|
|
# ESPHome YAML by Jeremy Shephard
|
|
|
|
|
#-------------------------------------------
|
|
|
|
|
######################################################################
|
|
|
|
|
## https://www.vcloudinfo.com/2020/09/home-assistant-smart-diy-basketball-backboard-project.html
|
|
|
|
|
######################################################################
|
|
|
|
|
|
|
|
|
|
|
2020-09-12 02:22:45 +00:00
|
|
|
|
esphome:
|
|
|
|
|
name: bb_node
|
|
|
|
|
platform: ESP8266
|
|
|
|
|
board: d1_mini
|
|
|
|
|
|
|
|
|
|
wifi:
|
|
|
|
|
ssid: "********"
|
|
|
|
|
password: "********"
|
|
|
|
|
|
2020-09-12 19:08:02 +00:00
|
|
|
|
|
2020-09-12 02:22:45 +00:00
|
|
|
|
# Enable fallback hotspot (captive portal) in case wifi connection fails
|
|
|
|
|
ap:
|
|
|
|
|
ssid: "Bb Node Fallback Hotspot"
|
|
|
|
|
password: "*******"
|
|
|
|
|
|
|
|
|
|
captive_portal:
|
|
|
|
|
|
|
|
|
|
# Enable logging
|
|
|
|
|
logger:
|
|
|
|
|
|
|
|
|
|
# Enable Home Assistant API
|
|
|
|
|
api:
|
|
|
|
|
|
|
|
|
|
ota:
|
|
|
|
|
|
|
|
|
|
sensor:
|
|
|
|
|
- platform: template
|
|
|
|
|
name: Baskets
|
|
|
|
|
id: basket
|
|
|
|
|
icon: mdi:basketball-hoop-outline
|
2020-09-12 19:08:02 +00:00
|
|
|
|
|
2020-09-12 02:22:45 +00:00
|
|
|
|
- platform: template
|
|
|
|
|
name: Swish
|
|
|
|
|
id: swish
|
|
|
|
|
icon: mdi:basketball
|
2020-09-12 19:08:02 +00:00
|
|
|
|
|
2020-09-12 02:22:45 +00:00
|
|
|
|
- platform: template
|
|
|
|
|
name: Backboards
|
|
|
|
|
id: backboard
|
|
|
|
|
icon: mdi:basketball-hoop
|
2020-09-12 19:08:02 +00:00
|
|
|
|
|
2020-09-12 02:22:45 +00:00
|
|
|
|
- platform: template
|
|
|
|
|
name: Previous Baskets
|
|
|
|
|
id: last_basket
|
|
|
|
|
icon: mdi:basketball-hoop-outline
|
2020-09-12 19:08:02 +00:00
|
|
|
|
|
2020-09-12 02:22:45 +00:00
|
|
|
|
- platform: template
|
|
|
|
|
name: Previous Swishes
|
|
|
|
|
id: last_swish
|
|
|
|
|
icon: mdi:basketball
|
2020-09-12 19:08:02 +00:00
|
|
|
|
|
2020-09-12 02:22:45 +00:00
|
|
|
|
- platform: template
|
|
|
|
|
name: Previous Backboards
|
|
|
|
|
id: last_backboard
|
|
|
|
|
icon: mdi:basketball-hoop
|
2020-09-12 19:08:02 +00:00
|
|
|
|
|
2020-09-12 02:22:45 +00:00
|
|
|
|
binary_sensor:
|
|
|
|
|
- platform: gpio
|
|
|
|
|
pin: D0
|
|
|
|
|
name: "Vibration Sensor"
|
|
|
|
|
id: bs
|
|
|
|
|
filters:
|
2020-09-12 19:08:02 +00:00
|
|
|
|
- delayed_on: 50ms
|
2020-09-12 02:22:45 +00:00
|
|
|
|
- delayed_off: 2s
|
|
|
|
|
on_press:
|
|
|
|
|
- lambda: |-
|
|
|
|
|
id(backboard_gbl) += 1;
|
|
|
|
|
id(backboard).publish_state(id(backboard_gbl));
|
2020-09-12 19:08:02 +00:00
|
|
|
|
|
2020-09-12 02:22:45 +00:00
|
|
|
|
- if:
|
|
|
|
|
condition:
|
|
|
|
|
switch.is_on: bb_on_lights_off
|
|
|
|
|
then:
|
|
|
|
|
- light.turn_on:
|
|
|
|
|
id: bb_light
|
|
|
|
|
brightness: 100%
|
|
|
|
|
red: 100%
|
|
|
|
|
green: 0%
|
|
|
|
|
blue: 0%
|
|
|
|
|
- delay: 3s
|
|
|
|
|
- light.turn_off: bb_light
|
|
|
|
|
- platform: gpio
|
2020-09-12 19:08:02 +00:00
|
|
|
|
pin:
|
2020-09-12 02:22:45 +00:00
|
|
|
|
number: D5
|
|
|
|
|
inverted: True
|
|
|
|
|
name: "Distance Sensor"
|
|
|
|
|
id: ds
|
|
|
|
|
filters:
|
|
|
|
|
- delayed_off: 500ms
|
|
|
|
|
on_press:
|
|
|
|
|
- if:
|
|
|
|
|
condition:
|
|
|
|
|
switch.is_on: bb_on
|
|
|
|
|
then:
|
|
|
|
|
- if:
|
|
|
|
|
condition:
|
|
|
|
|
binary_sensor.is_off: bs
|
|
|
|
|
then:
|
|
|
|
|
- lambda: |-
|
|
|
|
|
id(swish_gbl) += 1;
|
|
|
|
|
id(swish).publish_state(id(swish_gbl));
|
|
|
|
|
auto call = id(bb_light).turn_on();
|
|
|
|
|
call.set_brightness(1.0);
|
|
|
|
|
call.set_effect("Strobe Effect With Custom Values");
|
|
|
|
|
call.perform();
|
|
|
|
|
- delay: 5s
|
|
|
|
|
- light.turn_off: bb_light
|
|
|
|
|
- light.turn_on:
|
|
|
|
|
id: bb_light
|
|
|
|
|
brightness: 60%
|
|
|
|
|
red: 100%
|
|
|
|
|
green: 0%
|
|
|
|
|
blue: 0%
|
2020-09-12 19:08:02 +00:00
|
|
|
|
|
2020-09-12 02:22:45 +00:00
|
|
|
|
- if:
|
|
|
|
|
condition:
|
|
|
|
|
binary_sensor.is_on: bs
|
|
|
|
|
then:
|
|
|
|
|
- lambda: |-
|
|
|
|
|
id(basket_gbl) += 1;
|
|
|
|
|
id(backboard_gbl) -= 1;
|
|
|
|
|
id(basket).publish_state(id(basket_gbl));
|
|
|
|
|
- light.turn_on:
|
|
|
|
|
id: bb_light
|
|
|
|
|
brightness: 100%
|
|
|
|
|
red: 25%
|
|
|
|
|
green: 100%
|
|
|
|
|
blue: 0%
|
|
|
|
|
- delay: 3s
|
|
|
|
|
- light.turn_off: bb_light
|
|
|
|
|
- light.turn_on:
|
|
|
|
|
id: bb_light
|
|
|
|
|
brightness: 60%
|
|
|
|
|
red: 100%
|
|
|
|
|
green: 0%
|
|
|
|
|
blue: 0%
|
2020-09-12 19:08:02 +00:00
|
|
|
|
|
2020-09-12 02:22:45 +00:00
|
|
|
|
- if:
|
|
|
|
|
condition:
|
|
|
|
|
switch.is_on: bb_on_lights_off
|
|
|
|
|
then:
|
|
|
|
|
- if:
|
|
|
|
|
condition:
|
|
|
|
|
binary_sensor.is_off: bs
|
|
|
|
|
then:
|
|
|
|
|
- lambda: |-
|
|
|
|
|
id(swish_gbl) += 1;
|
|
|
|
|
id(swish).publish_state(id(swish_gbl));
|
|
|
|
|
auto call = id(bb_light).turn_on();
|
|
|
|
|
call.set_brightness(1.0);
|
|
|
|
|
call.set_effect("Strobe Effect With Custom Values");
|
|
|
|
|
call.perform();
|
|
|
|
|
- delay: 5s
|
|
|
|
|
- light.turn_off: bb_light
|
2020-09-12 19:08:02 +00:00
|
|
|
|
|
2020-09-12 02:22:45 +00:00
|
|
|
|
- if:
|
|
|
|
|
condition:
|
|
|
|
|
binary_sensor.is_on: bs
|
|
|
|
|
then:
|
|
|
|
|
- lambda: |-
|
|
|
|
|
id(basket_gbl) += 1;
|
|
|
|
|
id(backboard_gbl) -= 1;
|
|
|
|
|
id(basket).publish_state(id(basket_gbl));
|
|
|
|
|
- light.turn_on:
|
|
|
|
|
id: bb_light
|
|
|
|
|
brightness: 100%
|
|
|
|
|
red: 0%
|
|
|
|
|
green: 100%
|
|
|
|
|
blue: 10%
|
|
|
|
|
- delay: 3s
|
|
|
|
|
- light.turn_off: bb_light
|
2020-09-12 19:08:02 +00:00
|
|
|
|
|
|
|
|
|
|
2020-09-12 02:22:45 +00:00
|
|
|
|
light:
|
2020-09-12 19:08:02 +00:00
|
|
|
|
|
2020-09-12 02:22:45 +00:00
|
|
|
|
- platform: fastled_clockless
|
|
|
|
|
chipset: WS2812
|
|
|
|
|
name: "FastLED WS2811 Light"
|
|
|
|
|
pin: D2
|
|
|
|
|
num_leds: 150
|
|
|
|
|
rgb_order: GRB
|
|
|
|
|
id: bb_light
|
|
|
|
|
effects:
|
|
|
|
|
- addressable_scan:
|
|
|
|
|
- addressable_scan:
|
|
|
|
|
name: Scan Effect With Custom Values
|
|
|
|
|
move_interval: 30ms
|
|
|
|
|
scan_width: 20
|
|
|
|
|
- strobe:
|
|
|
|
|
- strobe:
|
|
|
|
|
name: Strobe Effect With Custom Values
|
|
|
|
|
colors:
|
|
|
|
|
- state: True
|
|
|
|
|
brightness: 100%
|
|
|
|
|
red: 0%
|
|
|
|
|
green: 0%
|
|
|
|
|
blue: 100%
|
|
|
|
|
duration: 500ms
|
|
|
|
|
- state: False
|
|
|
|
|
duration: 250ms
|
|
|
|
|
- state: True
|
|
|
|
|
brightness: 100%
|
|
|
|
|
red: 50%
|
|
|
|
|
green: 0%
|
|
|
|
|
blue: 100%
|
|
|
|
|
duration: 500ms
|
|
|
|
|
- addressable_color_wipe:
|
|
|
|
|
- addressable_color_wipe:
|
|
|
|
|
name: Color Wipe Effect With Custom Values
|
|
|
|
|
colors:
|
|
|
|
|
- red: 0%
|
|
|
|
|
green: 0%
|
|
|
|
|
blue: 100%
|
|
|
|
|
num_leds: 10
|
|
|
|
|
- red: 0%
|
|
|
|
|
green: 0%
|
|
|
|
|
blue: 0%
|
|
|
|
|
num_leds: 10
|
|
|
|
|
- red: 0%
|
|
|
|
|
green: 0%
|
|
|
|
|
blue: 100%
|
2020-09-12 19:08:02 +00:00
|
|
|
|
num_leds: 20
|
2020-09-12 02:22:45 +00:00
|
|
|
|
- red: 0%
|
|
|
|
|
green: 0%
|
|
|
|
|
blue: 0%
|
2020-09-12 19:08:02 +00:00
|
|
|
|
num_leds: 10
|
2020-09-12 02:22:45 +00:00
|
|
|
|
- red: 0%
|
|
|
|
|
green: 0%
|
|
|
|
|
blue: 100%
|
2020-09-12 19:08:02 +00:00
|
|
|
|
num_leds: 40
|
2020-09-12 02:22:45 +00:00
|
|
|
|
- red: 0%
|
|
|
|
|
green: 0%
|
|
|
|
|
blue: 0%
|
2020-09-12 19:08:02 +00:00
|
|
|
|
num_leds: 10
|
2020-09-12 02:22:45 +00:00
|
|
|
|
add_led_interval: 32ms
|
|
|
|
|
reverse: False
|
|
|
|
|
- addressable_fireworks:
|
|
|
|
|
name: Fireworks Effect With Custom Values
|
|
|
|
|
update_interval: 10ms
|
|
|
|
|
spark_probability: 80%
|
|
|
|
|
use_random_color: true
|
|
|
|
|
fade_out_rate: 50
|
2020-09-12 19:08:02 +00:00
|
|
|
|
|
2020-09-12 02:22:45 +00:00
|
|
|
|
switch:
|
|
|
|
|
- platform: template
|
|
|
|
|
name: Basketball Status Lights
|
|
|
|
|
id: bb_on_lights_off
|
|
|
|
|
icon: mdi:handball
|
|
|
|
|
turn_on_action:
|
|
|
|
|
- switch.template.publish:
|
|
|
|
|
id: bb_on_lights_off
|
|
|
|
|
state: ON
|
|
|
|
|
turn_off_action:
|
|
|
|
|
- switch.template.publish:
|
|
|
|
|
id: bb_on_lights_off
|
|
|
|
|
state: OFF
|
|
|
|
|
- lambda: |-
|
|
|
|
|
id(last_backboard).publish_state(id(backboard_gbl));
|
|
|
|
|
id(last_basket).publish_state(id(basket_gbl));
|
|
|
|
|
id(last_swish).publish_state(id(swish_gbl));
|
|
|
|
|
id(backboard_gbl) = 0;
|
|
|
|
|
id(basket_gbl) = 0;
|
|
|
|
|
id(swish_gbl) = 0;
|
|
|
|
|
id(backboard).publish_state(id(backboard_gbl));
|
|
|
|
|
id(basket).publish_state(id(basket_gbl));
|
|
|
|
|
id(swish).publish_state(id(swish_gbl));
|
2020-09-12 19:08:02 +00:00
|
|
|
|
|
2020-09-12 02:22:45 +00:00
|
|
|
|
- platform: template
|
|
|
|
|
name: Basketball Always Lights
|
|
|
|
|
id: bb_on
|
|
|
|
|
icon: mdi:handball
|
|
|
|
|
turn_on_action:
|
|
|
|
|
- switch.template.publish:
|
|
|
|
|
id: bb_on
|
|
|
|
|
state: ON
|
|
|
|
|
- light.turn_on:
|
|
|
|
|
id: bb_light
|
|
|
|
|
brightness: 60%
|
|
|
|
|
red: 100%
|
|
|
|
|
green: 0%
|
|
|
|
|
blue: 0%
|
2020-09-12 19:08:02 +00:00
|
|
|
|
|
2020-09-12 02:22:45 +00:00
|
|
|
|
turn_off_action:
|
|
|
|
|
- switch.template.publish:
|
|
|
|
|
id: bb_on
|
|
|
|
|
state: OFF
|
|
|
|
|
- light.turn_off: bb_light
|
|
|
|
|
- lambda: |-
|
|
|
|
|
id(last_backboard).publish_state(id(backboard_gbl));
|
|
|
|
|
id(last_basket).publish_state(id(basket_gbl));
|
|
|
|
|
id(last_swish).publish_state(id(swish_gbl));
|
|
|
|
|
id(backboard_gbl) = 0;
|
|
|
|
|
id(basket_gbl) = 0;
|
|
|
|
|
id(swish_gbl) = 0;
|
|
|
|
|
id(backboard).publish_state(id(backboard_gbl));
|
|
|
|
|
id(basket).publish_state(id(basket_gbl));
|
|
|
|
|
id(swish).publish_state(id(swish_gbl));
|
|
|
|
|
|
|
|
|
|
globals:
|
|
|
|
|
- id: backboard_gbl
|
|
|
|
|
type: int
|
|
|
|
|
restore_value: no
|
|
|
|
|
initial_value: '0'
|
2020-09-12 19:08:02 +00:00
|
|
|
|
|
2020-09-12 02:22:45 +00:00
|
|
|
|
- id: basket_gbl
|
|
|
|
|
type: int
|
|
|
|
|
restore_value: no
|
|
|
|
|
initial_value: '0'
|
2020-09-12 19:08:02 +00:00
|
|
|
|
|
2020-09-12 02:22:45 +00:00
|
|
|
|
- id: swish_gbl
|
|
|
|
|
type: int
|
|
|
|
|
restore_value: no
|
|
|
|
|
initial_value: '0’
|