Continued rewrite - Lights and light effects implemented

This commit is contained in:
2026-04-22 14:39:01 +02:00
parent ad50fd2ee5
commit 427dde8c72

970
esp-home-rewrite.yaml Normal file
View File

@@ -0,0 +1,970 @@
substitutions:
# --- Device identity ---
device_name: gauge_controller
device_friendly_name: Selsyn Multi
device_area: Control Panels
# --- WiFi ---
wifi_ssid: MyNetwork
wifi_password: MyPassword
# --- Arduino UART bridge ---
arduino_tx_pin: GPIO17
arduino_rx_pin: GPIO16
arduino_baud: "38400"
# --- Gauge 1 ---
gauge0_entity_name: Selsyn 1 Power
gauge0_min: "0.0"
gauge0_max: "7300.0"
gauge0_max_steps: "4000"
gauge0_unit: W
gauge0_default_speed: "5000"
gauge0_default_accel: "6000"
# --- Gauge 2 ---
gauge1_entity_name: Selsyn 2 Power
gauge1_min: "0.0"
gauge1_max: "7300.0"
gauge1_max_steps: "4000"
gauge1_unit: W
gauge1_default_speed: "5000"
gauge1_default_accel: "6000"
# --- Timing ---
rezero_interval: 3600s
# ---------------------------------------------------------------------------
# Core ESPHome identity
# ---------------------------------------------------------------------------
esphome:
name: ${device_name}
friendly_name: ${device_friendly_name}
on_boot:
priority: -100
then:
- delay: 2s
- uart.write:
id: arduino_uart
data: "HOMEALL\n"
- logger.log: "Boot: HOMEALL sent to Arduino"
esp32:
board: esp32dev
framework:
type: arduino
# ---------------------------------------------------------------------------
# Logging (set level: NONE in production)
# ---------------------------------------------------------------------------
logger:
level: INFO
# ---------------------------------------------------------------------------
# Native HA API — handles all entity registration, state sync, and commands.
# No manual discovery payloads needed.
# ---------------------------------------------------------------------------
api:
# ---------------------------------------------------------------------------
# OTA — replaces ota.py / Gitea updater; managed from HA or esphome CLI
# ---------------------------------------------------------------------------
ota:
- platform: esphome
# ---------------------------------------------------------------------------
# WiFi — replaces connect_wifi() + check_wifi() + all reconnect logic
# ---------------------------------------------------------------------------
wifi:
ssid: ${wifi_ssid}
password: ${wifi_password}
ap:
ssid: "${device_name} Fallback"
password: "esphomefb"
captive_portal:
# ---------------------------------------------------------------------------
# Arduino UART bridge
# ---------------------------------------------------------------------------
uart:
id: arduino_uart
tx_pin: ${arduino_tx_pin}
rx_pin: ${arduino_rx_pin}
baud_rate: ${arduino_baud}
# Uncomment to log raw Arduino traffic:
# debug:
# direction: BOTH
# ---------------------------------------------------------------------------
# Connectivity diagnostics
# ---------------------------------------------------------------------------
sensor:
- platform: wifi_signal
name: WiFi Signal
update_interval: 60s
entity_category: diagnostic
- platform: uptime
name: Uptime
entity_category: diagnostic
text_sensor:
- platform: wifi_info
ip_address:
name: IP Address
entity_category: diagnostic
ssid:
name: SSID
entity_category: diagnostic
# ---------------------------------------------------------------------------
# Gauge light state cache
# ---------------------------------------------------------------------------
globals:
- id: gauge0_bl_r
type: int
restore_value: no
initial_value: "0"
- id: gauge0_bl_g
type: int
restore_value: no
initial_value: "0"
- id: gauge0_bl_b
type: int
restore_value: no
initial_value: "0"
- id: gauge1_bl_r
type: int
restore_value: no
initial_value: "0"
- id: gauge1_bl_g
type: int
restore_value: no
initial_value: "0"
- id: gauge1_bl_b
type: int
restore_value: no
initial_value: "0"
- id: gauge0_red_on
type: bool
restore_value: no
initial_value: "false"
- id: gauge0_green_on
type: bool
restore_value: no
initial_value: "false"
- id: gauge0_status_red_on
type: bool
restore_value: no
initial_value: "false"
- id: gauge0_status_green_on
type: bool
restore_value: no
initial_value: "false"
- id: gauge1_red_on
type: bool
restore_value: no
initial_value: "false"
- id: gauge1_green_on
type: bool
restore_value: no
initial_value: "false"
- id: gauge1_status_red_on
type: bool
restore_value: no
initial_value: "false"
- id: gauge1_status_green_on
type: bool
restore_value: no
initial_value: "false"
# ---------------------------------------------------------------------------
# Light outputs
# ---------------------------------------------------------------------------
output:
- platform: template
id: gauge0_backlight_red_output
type: float
write_action:
- lambda: |-
id(gauge0_bl_r) = static_cast<int>(state * 255.0f + 0.5f);
char cmd[32];
snprintf(cmd, sizeof(cmd), "LED 0 0-2 %d %d %d\n",
id(gauge0_bl_r), id(gauge0_bl_g), id(gauge0_bl_b));
id(arduino_uart).write_str(cmd);
- platform: template
id: gauge0_backlight_green_output
type: float
write_action:
- lambda: |-
id(gauge0_bl_g) = static_cast<int>(state * 255.0f + 0.5f);
char cmd[32];
snprintf(cmd, sizeof(cmd), "LED 0 0-2 %d %d %d\n",
id(gauge0_bl_r), id(gauge0_bl_g), id(gauge0_bl_b));
id(arduino_uart).write_str(cmd);
- platform: template
id: gauge0_backlight_blue_output
type: float
write_action:
- lambda: |-
id(gauge0_bl_b) = static_cast<int>(state * 255.0f + 0.5f);
char cmd[32];
snprintf(cmd, sizeof(cmd), "LED 0 0-2 %d %d %d\n",
id(gauge0_bl_r), id(gauge0_bl_g), id(gauge0_bl_b));
id(arduino_uart).write_str(cmd);
- platform: template
id: gauge1_backlight_red_output
type: float
write_action:
- lambda: |-
id(gauge1_bl_r) = static_cast<int>(state * 255.0f + 0.5f);
char cmd[32];
snprintf(cmd, sizeof(cmd), "LED 1 0-2 %d %d %d\n",
id(gauge1_bl_r), id(gauge1_bl_g), id(gauge1_bl_b));
id(arduino_uart).write_str(cmd);
- platform: template
id: gauge1_backlight_green_output
type: float
write_action:
- lambda: |-
id(gauge1_bl_g) = static_cast<int>(state * 255.0f + 0.5f);
char cmd[32];
snprintf(cmd, sizeof(cmd), "LED 1 0-2 %d %d %d\n",
id(gauge1_bl_r), id(gauge1_bl_g), id(gauge1_bl_b));
id(arduino_uart).write_str(cmd);
- platform: template
id: gauge1_backlight_blue_output
type: float
write_action:
- lambda: |-
id(gauge1_bl_b) = static_cast<int>(state * 255.0f + 0.5f);
char cmd[32];
snprintf(cmd, sizeof(cmd), "LED 1 0-2 %d %d %d\n",
id(gauge1_bl_r), id(gauge1_bl_g), id(gauge1_bl_b));
id(arduino_uart).write_str(cmd);
- platform: template
id: gauge0_red_indicator_output
type: binary
write_action:
- lambda: |-
id(gauge0_red_on) = state;
id(arduino_uart).write_str(state ? "LED 0 3 255 0 0\n" : "LED 0 3 0 0 0\n");
- platform: template
id: gauge0_green_indicator_output
type: binary
write_action:
- lambda: |-
id(gauge0_green_on) = state;
id(arduino_uart).write_str(state ? "LED 0 4 0 255 0\n" : "LED 0 4 0 0 0\n");
- platform: template
id: gauge0_status_red_output
type: binary
write_action:
- lambda: |-
id(gauge0_status_red_on) = state;
id(arduino_uart).write_str(state ? "LED 0 5 255 0 0\n" : "LED 0 5 0 0 0\n");
- platform: template
id: gauge0_status_green_output
type: binary
write_action:
- lambda: |-
id(gauge0_status_green_on) = state;
id(arduino_uart).write_str(state ? "LED 0 6 0 255 0\n" : "LED 0 6 0 0 0\n");
- platform: template
id: gauge1_red_indicator_output
type: binary
write_action:
- lambda: |-
id(gauge1_red_on) = state;
id(arduino_uart).write_str(state ? "LED 1 3 255 0 0\n" : "LED 1 3 0 0 0\n");
- platform: template
id: gauge1_green_indicator_output
type: binary
write_action:
- lambda: |-
id(gauge1_green_on) = state;
id(arduino_uart).write_str(state ? "LED 1 4 0 255 0\n" : "LED 1 4 0 0 0\n");
- platform: template
id: gauge1_status_red_output
type: binary
write_action:
- lambda: |-
id(gauge1_status_red_on) = state;
id(arduino_uart).write_str(state ? "LED 1 5 255 0 0\n" : "LED 1 5 0 0 0\n");
- platform: template
id: gauge1_status_green_output
type: binary
write_action:
- lambda: |-
id(gauge1_status_green_on) = state;
id(arduino_uart).write_str(state ? "LED 1 6 0 255 0\n" : "LED 1 6 0 0 0\n");
# ---------------------------------------------------------------------------
# Native HA lights
# ---------------------------------------------------------------------------
light:
- platform: rgb
id: gauge0_backlight
name: "${gauge0_entity_name} Backlight"
red: gauge0_backlight_red_output
green: gauge0_backlight_green_output
blue: gauge0_backlight_blue_output
default_transition_length: 0s
restore_mode: ALWAYS_OFF
effects:
- lambda:
name: Blink Slow
update_interval: 750ms
lambda: |-
char cmd[36];
snprintf(cmd, sizeof(cmd), "BLINK 0 0-2 800 800 %d %d %d\n",
id(gauge0_bl_r), id(gauge0_bl_g), id(gauge0_bl_b));
id(arduino_uart).write_str(cmd);
- lambda:
name: Blink Fast
update_interval: 750ms
lambda: |-
char cmd[36];
snprintf(cmd, sizeof(cmd), "BLINK 0 0-2 150 150 %d %d %d\n",
id(gauge0_bl_r), id(gauge0_bl_g), id(gauge0_bl_b));
id(arduino_uart).write_str(cmd);
- lambda:
name: Blink Alert
update_interval: 750ms
lambda: |-
char cmd[36];
snprintf(cmd, sizeof(cmd), "BLINK 0 0-2 100 400 %d %d %d\n",
id(gauge0_bl_r), id(gauge0_bl_g), id(gauge0_bl_b));
id(arduino_uart).write_str(cmd);
- lambda:
name: Breathe Slow
update_interval: 750ms
lambda: |-
char cmd[34];
snprintf(cmd, sizeof(cmd), "BREATHE 0 0-2 3000 %d %d %d\n",
id(gauge0_bl_r), id(gauge0_bl_g), id(gauge0_bl_b));
id(arduino_uart).write_str(cmd);
- lambda:
name: Breathe Fast
update_interval: 750ms
lambda: |-
char cmd[34];
snprintf(cmd, sizeof(cmd), "BREATHE 0 0-2 1200 %d %d %d\n",
id(gauge0_bl_r), id(gauge0_bl_g), id(gauge0_bl_b));
id(arduino_uart).write_str(cmd);
- lambda:
name: Double Flash
update_interval: 750ms
lambda: |-
char cmd[32];
snprintf(cmd, sizeof(cmd), "DFLASH 0 0-2 %d %d %d\n",
id(gauge0_bl_r), id(gauge0_bl_g), id(gauge0_bl_b));
id(arduino_uart).write_str(cmd);
on_state:
- lambda: |-
auto effect = id(gauge0_backlight).get_effect_name();
char cmd[36];
if (effect == "Blink Slow") {
snprintf(cmd, sizeof(cmd), "BLINK 0 0-2 800 800 %d %d %d\n",
id(gauge0_bl_r), id(gauge0_bl_g), id(gauge0_bl_b));
} else if (effect == "Blink Fast") {
snprintf(cmd, sizeof(cmd), "BLINK 0 0-2 150 150 %d %d %d\n",
id(gauge0_bl_r), id(gauge0_bl_g), id(gauge0_bl_b));
} else if (effect == "Blink Alert") {
snprintf(cmd, sizeof(cmd), "BLINK 0 0-2 100 400 %d %d %d\n",
id(gauge0_bl_r), id(gauge0_bl_g), id(gauge0_bl_b));
} else if (effect == "Breathe Slow") {
snprintf(cmd, sizeof(cmd), "BREATHE 0 0-2 3000 %d %d %d\n",
id(gauge0_bl_r), id(gauge0_bl_g), id(gauge0_bl_b));
} else if (effect == "Breathe Fast") {
snprintf(cmd, sizeof(cmd), "BREATHE 0 0-2 1200 %d %d %d\n",
id(gauge0_bl_r), id(gauge0_bl_g), id(gauge0_bl_b));
} else if (effect == "Double Flash") {
snprintf(cmd, sizeof(cmd), "DFLASH 0 0-2 %d %d %d\n",
id(gauge0_bl_r), id(gauge0_bl_g), id(gauge0_bl_b));
} else {
snprintf(cmd, sizeof(cmd), "LED 0 0-2 %d %d %d\n",
id(gauge0_bl_r), id(gauge0_bl_g), id(gauge0_bl_b));
}
id(arduino_uart).write_str(cmd);
- platform: binary
id: gauge0_red_indicator
name: "${gauge0_entity_name} Red Indicator"
output: gauge0_red_indicator_output
restore_mode: ALWAYS_OFF
effects:
- lambda:
name: Blink Slow
update_interval: 750ms
lambda: |-
id(arduino_uart).write_str("BLINK 0 3 800 800 255 0 0\n");
- lambda:
name: Blink Fast
update_interval: 750ms
lambda: |-
id(arduino_uart).write_str("BLINK 0 3 150 150 255 0 0\n");
- lambda:
name: Blink Alert
update_interval: 750ms
lambda: |-
id(arduino_uart).write_str("BLINK 0 3 100 400 255 0 0\n");
- lambda:
name: Breathe Slow
update_interval: 750ms
lambda: |-
id(arduino_uart).write_str("BREATHE 0 3 3000 255 0 0\n");
- lambda:
name: Breathe Fast
update_interval: 750ms
lambda: |-
id(arduino_uart).write_str("BREATHE 0 3 1200 255 0 0\n");
- lambda:
name: Double Flash
update_interval: 750ms
lambda: |-
id(arduino_uart).write_str("DFLASH 0 3 255 0 0\n");
on_state:
- lambda: |-
if (!id(gauge0_red_on)) {
id(arduino_uart).write_str("LED 0 3 0 0 0\n");
return;
}
auto effect = id(gauge0_red_indicator).get_effect_name();
if (effect == "Blink Slow") {
id(arduino_uart).write_str("BLINK 0 3 800 800 255 0 0\n");
} else if (effect == "Blink Fast") {
id(arduino_uart).write_str("BLINK 0 3 150 150 255 0 0\n");
} else if (effect == "Blink Alert") {
id(arduino_uart).write_str("BLINK 0 3 100 400 255 0 0\n");
} else if (effect == "Breathe Slow") {
id(arduino_uart).write_str("BREATHE 0 3 3000 255 0 0\n");
} else if (effect == "Breathe Fast") {
id(arduino_uart).write_str("BREATHE 0 3 1200 255 0 0\n");
} else if (effect == "Double Flash") {
id(arduino_uart).write_str("DFLASH 0 3 255 0 0\n");
} else {
id(arduino_uart).write_str("LED 0 3 255 0 0\n");
}
- platform: binary
id: gauge0_green_indicator
name: "${gauge0_entity_name} Green Indicator"
output: gauge0_green_indicator_output
restore_mode: ALWAYS_OFF
effects:
- lambda:
name: Blink Slow
update_interval: 750ms
lambda: |-
id(arduino_uart).write_str("BLINK 0 4 800 800 0 255 0\n");
- lambda:
name: Blink Fast
update_interval: 750ms
lambda: |-
id(arduino_uart).write_str("BLINK 0 4 150 150 0 255 0\n");
- lambda:
name: Blink Alert
update_interval: 750ms
lambda: |-
id(arduino_uart).write_str("BLINK 0 4 100 400 0 255 0\n");
- lambda:
name: Breathe Slow
update_interval: 750ms
lambda: |-
id(arduino_uart).write_str("BREATHE 0 4 3000 0 255 0\n");
- lambda:
name: Breathe Fast
update_interval: 750ms
lambda: |-
id(arduino_uart).write_str("BREATHE 0 4 1200 0 255 0\n");
- lambda:
name: Double Flash
update_interval: 750ms
lambda: |-
id(arduino_uart).write_str("DFLASH 0 4 0 255 0\n");
on_state:
- lambda: |-
if (!id(gauge0_green_on)) {
id(arduino_uart).write_str("LED 0 4 0 0 0\n");
return;
}
auto effect = id(gauge0_green_indicator).get_effect_name();
if (effect == "Blink Slow") {
id(arduino_uart).write_str("BLINK 0 4 800 800 0 255 0\n");
} else if (effect == "Blink Fast") {
id(arduino_uart).write_str("BLINK 0 4 150 150 0 255 0\n");
} else if (effect == "Blink Alert") {
id(arduino_uart).write_str("BLINK 0 4 100 400 0 255 0\n");
} else if (effect == "Breathe Slow") {
id(arduino_uart).write_str("BREATHE 0 4 3000 0 255 0\n");
} else if (effect == "Breathe Fast") {
id(arduino_uart).write_str("BREATHE 0 4 1200 0 255 0\n");
} else if (effect == "Double Flash") {
id(arduino_uart).write_str("DFLASH 0 4 0 255 0\n");
} else {
id(arduino_uart).write_str("LED 0 4 0 255 0\n");
}
- platform: binary
id: gauge0_status_red
name: "${gauge0_entity_name} Status Red"
output: gauge0_status_red_output
restore_mode: ALWAYS_OFF
effects:
- lambda:
name: Blink Slow
update_interval: 750ms
lambda: |-
id(arduino_uart).write_str("BLINK 0 5 800 800 255 0 0\n");
- lambda:
name: Blink Fast
update_interval: 750ms
lambda: |-
id(arduino_uart).write_str("BLINK 0 5 150 150 255 0 0\n");
- lambda:
name: Blink Alert
update_interval: 750ms
lambda: |-
id(arduino_uart).write_str("BLINK 0 5 100 400 255 0 0\n");
- lambda:
name: Breathe Slow
update_interval: 750ms
lambda: |-
id(arduino_uart).write_str("BREATHE 0 5 3000 255 0 0\n");
- lambda:
name: Breathe Fast
update_interval: 750ms
lambda: |-
id(arduino_uart).write_str("BREATHE 0 5 1200 255 0 0\n");
- lambda:
name: Double Flash
update_interval: 750ms
lambda: |-
id(arduino_uart).write_str("DFLASH 0 5 255 0 0\n");
on_state:
- lambda: |-
if (!id(gauge0_status_red_on)) {
id(arduino_uart).write_str("LED 0 5 0 0 0\n");
return;
}
auto effect = id(gauge0_status_red).get_effect_name();
if (effect == "Blink Slow") {
id(arduino_uart).write_str("BLINK 0 5 800 800 255 0 0\n");
} else if (effect == "Blink Fast") {
id(arduino_uart).write_str("BLINK 0 5 150 150 255 0 0\n");
} else if (effect == "Blink Alert") {
id(arduino_uart).write_str("BLINK 0 5 100 400 255 0 0\n");
} else if (effect == "Breathe Slow") {
id(arduino_uart).write_str("BREATHE 0 5 3000 255 0 0\n");
} else if (effect == "Breathe Fast") {
id(arduino_uart).write_str("BREATHE 0 5 1200 255 0 0\n");
} else if (effect == "Double Flash") {
id(arduino_uart).write_str("DFLASH 0 5 255 0 0\n");
} else {
id(arduino_uart).write_str("LED 0 5 255 0 0\n");
}
- platform: binary
id: gauge0_status_green
name: "${gauge0_entity_name} Status Green"
output: gauge0_status_green_output
restore_mode: ALWAYS_OFF
effects:
- lambda:
name: Blink Slow
update_interval: 750ms
lambda: |-
id(arduino_uart).write_str("BLINK 0 6 800 800 0 255 0\n");
- lambda:
name: Blink Fast
update_interval: 750ms
lambda: |-
id(arduino_uart).write_str("BLINK 0 6 150 150 0 255 0\n");
- lambda:
name: Blink Alert
update_interval: 750ms
lambda: |-
id(arduino_uart).write_str("BLINK 0 6 100 400 0 255 0\n");
- lambda:
name: Breathe Slow
update_interval: 750ms
lambda: |-
id(arduino_uart).write_str("BREATHE 0 6 3000 0 255 0\n");
- lambda:
name: Breathe Fast
update_interval: 750ms
lambda: |-
id(arduino_uart).write_str("BREATHE 0 6 1200 0 255 0\n");
- lambda:
name: Double Flash
update_interval: 750ms
lambda: |-
id(arduino_uart).write_str("DFLASH 0 6 0 255 0\n");
on_state:
- lambda: |-
if (!id(gauge0_status_green_on)) {
id(arduino_uart).write_str("LED 0 6 0 0 0\n");
return;
}
auto effect = id(gauge0_status_green).get_effect_name();
if (effect == "Blink Slow") {
id(arduino_uart).write_str("BLINK 0 6 800 800 0 255 0\n");
} else if (effect == "Blink Fast") {
id(arduino_uart).write_str("BLINK 0 6 150 150 0 255 0\n");
} else if (effect == "Blink Alert") {
id(arduino_uart).write_str("BLINK 0 6 100 400 0 255 0\n");
} else if (effect == "Breathe Slow") {
id(arduino_uart).write_str("BREATHE 0 6 3000 0 255 0\n");
} else if (effect == "Breathe Fast") {
id(arduino_uart).write_str("BREATHE 0 6 1200 0 255 0\n");
} else if (effect == "Double Flash") {
id(arduino_uart).write_str("DFLASH 0 6 0 255 0\n");
} else {
id(arduino_uart).write_str("LED 0 6 0 255 0\n");
}
- platform: rgb
id: gauge1_backlight
name: "${gauge1_entity_name} Backlight"
red: gauge1_backlight_red_output
green: gauge1_backlight_green_output
blue: gauge1_backlight_blue_output
default_transition_length: 0s
restore_mode: ALWAYS_OFF
effects:
- lambda:
name: Blink Slow
update_interval: 750ms
lambda: |-
char cmd[36];
snprintf(cmd, sizeof(cmd), "BLINK 1 0-2 800 800 %d %d %d\n",
id(gauge1_bl_r), id(gauge1_bl_g), id(gauge1_bl_b));
id(arduino_uart).write_str(cmd);
- lambda:
name: Blink Fast
update_interval: 750ms
lambda: |-
char cmd[36];
snprintf(cmd, sizeof(cmd), "BLINK 1 0-2 150 150 %d %d %d\n",
id(gauge1_bl_r), id(gauge1_bl_g), id(gauge1_bl_b));
id(arduino_uart).write_str(cmd);
- lambda:
name: Blink Alert
update_interval: 750ms
lambda: |-
char cmd[36];
snprintf(cmd, sizeof(cmd), "BLINK 1 0-2 100 400 %d %d %d\n",
id(gauge1_bl_r), id(gauge1_bl_g), id(gauge1_bl_b));
id(arduino_uart).write_str(cmd);
- lambda:
name: Breathe Slow
update_interval: 750ms
lambda: |-
char cmd[34];
snprintf(cmd, sizeof(cmd), "BREATHE 1 0-2 3000 %d %d %d\n",
id(gauge1_bl_r), id(gauge1_bl_g), id(gauge1_bl_b));
id(arduino_uart).write_str(cmd);
- lambda:
name: Breathe Fast
update_interval: 750ms
lambda: |-
char cmd[34];
snprintf(cmd, sizeof(cmd), "BREATHE 1 0-2 1200 %d %d %d\n",
id(gauge1_bl_r), id(gauge1_bl_g), id(gauge1_bl_b));
id(arduino_uart).write_str(cmd);
- lambda:
name: Double Flash
update_interval: 750ms
lambda: |-
char cmd[32];
snprintf(cmd, sizeof(cmd), "DFLASH 1 0-2 %d %d %d\n",
id(gauge1_bl_r), id(gauge1_bl_g), id(gauge1_bl_b));
id(arduino_uart).write_str(cmd);
on_state:
- lambda: |-
auto effect = id(gauge1_backlight).get_effect_name();
char cmd[36];
if (effect == "Blink Slow") {
snprintf(cmd, sizeof(cmd), "BLINK 1 0-2 800 800 %d %d %d\n",
id(gauge1_bl_r), id(gauge1_bl_g), id(gauge1_bl_b));
} else if (effect == "Blink Fast") {
snprintf(cmd, sizeof(cmd), "BLINK 1 0-2 150 150 %d %d %d\n",
id(gauge1_bl_r), id(gauge1_bl_g), id(gauge1_bl_b));
} else if (effect == "Blink Alert") {
snprintf(cmd, sizeof(cmd), "BLINK 1 0-2 100 400 %d %d %d\n",
id(gauge1_bl_r), id(gauge1_bl_g), id(gauge1_bl_b));
} else if (effect == "Breathe Slow") {
snprintf(cmd, sizeof(cmd), "BREATHE 1 0-2 3000 %d %d %d\n",
id(gauge1_bl_r), id(gauge1_bl_g), id(gauge1_bl_b));
} else if (effect == "Breathe Fast") {
snprintf(cmd, sizeof(cmd), "BREATHE 1 0-2 1200 %d %d %d\n",
id(gauge1_bl_r), id(gauge1_bl_g), id(gauge1_bl_b));
} else if (effect == "Double Flash") {
snprintf(cmd, sizeof(cmd), "DFLASH 1 0-2 %d %d %d\n",
id(gauge1_bl_r), id(gauge1_bl_g), id(gauge1_bl_b));
} else {
snprintf(cmd, sizeof(cmd), "LED 1 0-2 %d %d %d\n",
id(gauge1_bl_r), id(gauge1_bl_g), id(gauge1_bl_b));
}
id(arduino_uart).write_str(cmd);
- platform: binary
id: gauge1_red_indicator
name: "${gauge1_entity_name} Red Indicator"
output: gauge1_red_indicator_output
restore_mode: ALWAYS_OFF
effects:
- lambda:
name: Blink Slow
update_interval: 750ms
lambda: |-
id(arduino_uart).write_str("BLINK 1 3 800 800 255 0 0\n");
- lambda:
name: Blink Fast
update_interval: 750ms
lambda: |-
id(arduino_uart).write_str("BLINK 1 3 150 150 255 0 0\n");
- lambda:
name: Blink Alert
update_interval: 750ms
lambda: |-
id(arduino_uart).write_str("BLINK 1 3 100 400 255 0 0\n");
- lambda:
name: Breathe Slow
update_interval: 750ms
lambda: |-
id(arduino_uart).write_str("BREATHE 1 3 3000 255 0 0\n");
- lambda:
name: Breathe Fast
update_interval: 750ms
lambda: |-
id(arduino_uart).write_str("BREATHE 1 3 1200 255 0 0\n");
- lambda:
name: Double Flash
update_interval: 750ms
lambda: |-
id(arduino_uart).write_str("DFLASH 1 3 255 0 0\n");
on_state:
- lambda: |-
if (!id(gauge1_red_on)) {
id(arduino_uart).write_str("LED 1 3 0 0 0\n");
return;
}
auto effect = id(gauge1_red_indicator).get_effect_name();
if (effect == "Blink Slow") {
id(arduino_uart).write_str("BLINK 1 3 800 800 255 0 0\n");
} else if (effect == "Blink Fast") {
id(arduino_uart).write_str("BLINK 1 3 150 150 255 0 0\n");
} else if (effect == "Blink Alert") {
id(arduino_uart).write_str("BLINK 1 3 100 400 255 0 0\n");
} else if (effect == "Breathe Slow") {
id(arduino_uart).write_str("BREATHE 1 3 3000 255 0 0\n");
} else if (effect == "Breathe Fast") {
id(arduino_uart).write_str("BREATHE 1 3 1200 255 0 0\n");
} else if (effect == "Double Flash") {
id(arduino_uart).write_str("DFLASH 1 3 255 0 0\n");
} else {
id(arduino_uart).write_str("LED 1 3 255 0 0\n");
}
- platform: binary
id: gauge1_green_indicator
name: "${gauge1_entity_name} Green Indicator"
output: gauge1_green_indicator_output
restore_mode: ALWAYS_OFF
effects:
- lambda:
name: Blink Slow
update_interval: 750ms
lambda: |-
id(arduino_uart).write_str("BLINK 1 4 800 800 0 255 0\n");
- lambda:
name: Blink Fast
update_interval: 750ms
lambda: |-
id(arduino_uart).write_str("BLINK 1 4 150 150 0 255 0\n");
- lambda:
name: Blink Alert
update_interval: 750ms
lambda: |-
id(arduino_uart).write_str("BLINK 1 4 100 400 0 255 0\n");
- lambda:
name: Breathe Slow
update_interval: 750ms
lambda: |-
id(arduino_uart).write_str("BREATHE 1 4 3000 0 255 0\n");
- lambda:
name: Breathe Fast
update_interval: 750ms
lambda: |-
id(arduino_uart).write_str("BREATHE 1 4 1200 0 255 0\n");
- lambda:
name: Double Flash
update_interval: 750ms
lambda: |-
id(arduino_uart).write_str("DFLASH 1 4 0 255 0\n");
on_state:
- lambda: |-
if (!id(gauge1_green_on)) {
id(arduino_uart).write_str("LED 1 4 0 0 0\n");
return;
}
auto effect = id(gauge1_green_indicator).get_effect_name();
if (effect == "Blink Slow") {
id(arduino_uart).write_str("BLINK 1 4 800 800 0 255 0\n");
} else if (effect == "Blink Fast") {
id(arduino_uart).write_str("BLINK 1 4 150 150 0 255 0\n");
} else if (effect == "Blink Alert") {
id(arduino_uart).write_str("BLINK 1 4 100 400 0 255 0\n");
} else if (effect == "Breathe Slow") {
id(arduino_uart).write_str("BREATHE 1 4 3000 0 255 0\n");
} else if (effect == "Breathe Fast") {
id(arduino_uart).write_str("BREATHE 1 4 1200 0 255 0\n");
} else if (effect == "Double Flash") {
id(arduino_uart).write_str("DFLASH 1 4 0 255 0\n");
} else {
id(arduino_uart).write_str("LED 1 4 0 255 0\n");
}
- platform: binary
id: gauge1_status_red
name: "${gauge1_entity_name} Status Red"
output: gauge1_status_red_output
restore_mode: ALWAYS_OFF
effects:
- lambda:
name: Blink Slow
update_interval: 750ms
lambda: |-
id(arduino_uart).write_str("BLINK 1 5 800 800 255 0 0\n");
- lambda:
name: Blink Fast
update_interval: 750ms
lambda: |-
id(arduino_uart).write_str("BLINK 1 5 150 150 255 0 0\n");
- lambda:
name: Blink Alert
update_interval: 750ms
lambda: |-
id(arduino_uart).write_str("BLINK 1 5 100 400 255 0 0\n");
- lambda:
name: Breathe Slow
update_interval: 750ms
lambda: |-
id(arduino_uart).write_str("BREATHE 1 5 3000 255 0 0\n");
- lambda:
name: Breathe Fast
update_interval: 750ms
lambda: |-
id(arduino_uart).write_str("BREATHE 1 5 1200 255 0 0\n");
- lambda:
name: Double Flash
update_interval: 750ms
lambda: |-
id(arduino_uart).write_str("DFLASH 1 5 255 0 0\n");
on_state:
- lambda: |-
if (!id(gauge1_status_red_on)) {
id(arduino_uart).write_str("LED 1 5 0 0 0\n");
return;
}
auto effect = id(gauge1_status_red).get_effect_name();
if (effect == "Blink Slow") {
id(arduino_uart).write_str("BLINK 1 5 800 800 255 0 0\n");
} else if (effect == "Blink Fast") {
id(arduino_uart).write_str("BLINK 1 5 150 150 255 0 0\n");
} else if (effect == "Blink Alert") {
id(arduino_uart).write_str("BLINK 1 5 100 400 255 0 0\n");
} else if (effect == "Breathe Slow") {
id(arduino_uart).write_str("BREATHE 1 5 3000 255 0 0\n");
} else if (effect == "Breathe Fast") {
id(arduino_uart).write_str("BREATHE 1 5 1200 255 0 0\n");
} else if (effect == "Double Flash") {
id(arduino_uart).write_str("DFLASH 1 5 255 0 0\n");
} else {
id(arduino_uart).write_str("LED 1 5 255 0 0\n");
}
- platform: binary
id: gauge1_status_green
name: "${gauge1_entity_name} Status Green"
output: gauge1_status_green_output
restore_mode: ALWAYS_OFF
effects:
- lambda:
name: Blink Slow
update_interval: 750ms
lambda: |-
id(arduino_uart).write_str("BLINK 1 6 800 800 0 255 0\n");
- lambda:
name: Blink Fast
update_interval: 750ms
lambda: |-
id(arduino_uart).write_str("BLINK 1 6 150 150 0 255 0\n");
- lambda:
name: Blink Alert
update_interval: 750ms
lambda: |-
id(arduino_uart).write_str("BLINK 1 6 100 400 0 255 0\n");
- lambda:
name: Breathe Slow
update_interval: 750ms
lambda: |-
id(arduino_uart).write_str("BREATHE 1 6 3000 0 255 0\n");
- lambda:
name: Breathe Fast
update_interval: 750ms
lambda: |-
id(arduino_uart).write_str("BREATHE 1 6 1200 0 255 0\n");
- lambda:
name: Double Flash
update_interval: 750ms
lambda: |-
id(arduino_uart).write_str("DFLASH 1 6 0 255 0\n");
on_state:
- lambda: |-
if (!id(gauge1_status_green_on)) {
id(arduino_uart).write_str("LED 1 6 0 0 0\n");
return;
}
auto effect = id(gauge1_status_green).get_effect_name();
if (effect == "Blink Slow") {
id(arduino_uart).write_str("BLINK 1 6 800 800 0 255 0\n");
} else if (effect == "Blink Fast") {
id(arduino_uart).write_str("BLINK 1 6 150 150 0 255 0\n");
} else if (effect == "Blink Alert") {
id(arduino_uart).write_str("BLINK 1 6 100 400 0 255 0\n");
} else if (effect == "Breathe Slow") {
id(arduino_uart).write_str("BREATHE 1 6 3000 0 255 0\n");
} else if (effect == "Breathe Fast") {
id(arduino_uart).write_str("BREATHE 1 6 1200 0 255 0\n");
} else if (effect == "Double Flash") {
id(arduino_uart).write_str("DFLASH 1 6 0 255 0\n");
} else {
id(arduino_uart).write_str("LED 1 6 0 255 0\n");
}