diff --git a/esp-home-rewrite.yaml b/esp-home-rewrite.yaml index 9ea7f14..2e1474a 100644 --- a/esp-home-rewrite.yaml +++ b/esp-home-rewrite.yaml @@ -37,6 +37,30 @@ substitutions: gauge1_default_speed: "5000" gauge1_default_accel: "6000" + # --- Gauge 3 --- + gauge2_entity_name: Selsyn 3 Power + gauge2_min: "0.0" + gauge2_max: "7300.0" + gauge2_max_steps: "4000" + gauge2_unit: W + gauge2_step: "1.0" + gauge2_speed_step: "100" + gauge2_accel_step: "100" + gauge2_default_speed: "5000" + gauge2_default_accel: "6000" + + # --- Gauge 4 --- + gauge3_entity_name: Selsyn 4 Power + gauge3_min: "0.0" + gauge3_max: "7300.0" + gauge3_max_steps: "4000" + gauge3_unit: W + gauge3_step: "1.0" + gauge3_speed_step: "100" + gauge3_accel_step: "100" + gauge3_default_speed: "5000" + gauge3_default_accel: "6000" + # --- Timing --- rezero_interval: 3600s @@ -138,6 +162,22 @@ sensor: accuracy_decimals: 1 update_interval: 5s + - platform: template + name: "${gauge2_entity_name} Target" + lambda: |- + return id(gauge2_target_value); + unit_of_measurement: "${gauge2_unit}" + accuracy_decimals: 1 + update_interval: 5s + + - platform: template + name: "${gauge3_entity_name} Target" + lambda: |- + return id(gauge3_target_value); + unit_of_measurement: "${gauge3_unit}" + accuracy_decimals: 1 + update_interval: 5s + - platform: template name: "${gauge0_entity_name} Speed" lambda: |- @@ -174,6 +214,42 @@ sensor: update_interval: 5s entity_category: config + - platform: template + name: "${gauge2_entity_name} Speed" + lambda: |- + return id(gauge2_speed_value); + unit_of_measurement: "steps/s" + accuracy_decimals: 0 + update_interval: 5s + entity_category: config + + - platform: template + name: "${gauge2_entity_name} Acceleration" + lambda: |- + return id(gauge2_accel_value); + unit_of_measurement: "steps/s^2" + accuracy_decimals: 0 + update_interval: 5s + entity_category: config + + - platform: template + name: "${gauge3_entity_name} Speed" + lambda: |- + return id(gauge3_speed_value); + unit_of_measurement: "steps/s" + accuracy_decimals: 0 + update_interval: 5s + entity_category: config + + - platform: template + name: "${gauge3_entity_name} Acceleration" + lambda: |- + return id(gauge3_accel_value); + unit_of_measurement: "steps/s^2" + accuracy_decimals: 0 + update_interval: 5s + entity_category: config + text_sensor: - platform: wifi_info ip_address: @@ -242,6 +318,60 @@ number: snprintf(cmd, sizeof(cmd), "SET 1 %d\n", steps); id(arduino_uart).write_str(cmd); + - platform: template + id: gauge2_target_number + name: "${gauge2_entity_name}" + unit_of_measurement: "${gauge2_unit}" + min_value: ${gauge2_min} + max_value: ${gauge2_max} + step: ${gauge2_step} + mode: box + optimistic: true + restore_value: false + initial_value: ${gauge2_min} + set_action: + - lambda: |- + const float min_value = ${gauge2_min}; + const float max_value = ${gauge2_max}; + const int max_steps = ${gauge2_max_steps}; + const float clamped = std::max(min_value, std::min(max_value, x)); + int steps = 0; + if (max_value > min_value) { + const float fraction = (clamped - min_value) / (max_value - min_value); + steps = static_cast(lroundf(fraction * max_steps)); + } + id(gauge2_target_value) = clamped; + char cmd[24]; + snprintf(cmd, sizeof(cmd), "SET 2 %d\n", steps); + id(arduino_uart).write_str(cmd); + + - platform: template + id: gauge3_target_number + name: "${gauge3_entity_name}" + unit_of_measurement: "${gauge3_unit}" + min_value: ${gauge3_min} + max_value: ${gauge3_max} + step: ${gauge3_step} + mode: box + optimistic: true + restore_value: false + initial_value: ${gauge3_min} + set_action: + - lambda: |- + const float min_value = ${gauge3_min}; + const float max_value = ${gauge3_max}; + const int max_steps = ${gauge3_max_steps}; + const float clamped = std::max(min_value, std::min(max_value, x)); + int steps = 0; + if (max_value > min_value) { + const float fraction = (clamped - min_value) / (max_value - min_value); + steps = static_cast(lroundf(fraction * max_steps)); + } + id(gauge3_target_value) = clamped; + char cmd[24]; + snprintf(cmd, sizeof(cmd), "SET 3 %d\n", steps); + id(arduino_uart).write_str(cmd); + - platform: template id: gauge0_speed_number name: "${gauge0_entity_name} Speed" @@ -322,6 +452,86 @@ number: snprintf(cmd, sizeof(cmd), "ACCEL 1 %d\n", clamped); id(arduino_uart).write_str(cmd); + - platform: template + id: gauge2_speed_number + name: "${gauge2_entity_name} Speed" + entity_category: config + unit_of_measurement: "steps/s" + min_value: 1 + max_value: 20000 + step: ${gauge2_speed_step} + mode: box + optimistic: true + restore_value: false + initial_value: ${gauge2_default_speed} + set_action: + - lambda: |- + const int clamped = std::max(1, static_cast(lroundf(x))); + id(gauge2_speed_value) = clamped; + char cmd[24]; + snprintf(cmd, sizeof(cmd), "SPEED 2 %d\n", clamped); + id(arduino_uart).write_str(cmd); + + - platform: template + id: gauge2_accel_number + name: "${gauge2_entity_name} Acceleration" + entity_category: config + unit_of_measurement: "steps/s^2" + min_value: 1 + max_value: 50000 + step: ${gauge2_accel_step} + mode: box + optimistic: true + restore_value: false + initial_value: ${gauge2_default_accel} + set_action: + - lambda: |- + const int clamped = std::max(1, static_cast(lroundf(x))); + id(gauge2_accel_value) = clamped; + char cmd[24]; + snprintf(cmd, sizeof(cmd), "ACCEL 2 %d\n", clamped); + id(arduino_uart).write_str(cmd); + + - platform: template + id: gauge3_speed_number + name: "${gauge3_entity_name} Speed" + entity_category: config + unit_of_measurement: "steps/s" + min_value: 1 + max_value: 20000 + step: ${gauge3_speed_step} + mode: box + optimistic: true + restore_value: false + initial_value: ${gauge3_default_speed} + set_action: + - lambda: |- + const int clamped = std::max(1, static_cast(lroundf(x))); + id(gauge3_speed_value) = clamped; + char cmd[24]; + snprintf(cmd, sizeof(cmd), "SPEED 3 %d\n", clamped); + id(arduino_uart).write_str(cmd); + + - platform: template + id: gauge3_accel_number + name: "${gauge3_entity_name} Acceleration" + entity_category: config + unit_of_measurement: "steps/s^2" + min_value: 1 + max_value: 50000 + step: ${gauge3_accel_step} + mode: box + optimistic: true + restore_value: false + initial_value: ${gauge3_default_accel} + set_action: + - lambda: |- + const int clamped = std::max(1, static_cast(lroundf(x))); + id(gauge3_accel_value) = clamped; + char cmd[24]; + snprintf(cmd, sizeof(cmd), "ACCEL 3 %d\n", clamped); + id(arduino_uart).write_str(cmd); + # --------------------------------------------------------------------------- # VFD controls # --------------------------------------------------------------------------- @@ -447,6 +657,51 @@ switch: cmd += "\n"; id(arduino_uart).write_str(cmd); +# --------------------------------------------------------------------------- +# Gauge homing buttons +# --------------------------------------------------------------------------- + +button: + - platform: template + name: "${gauge0_entity_name} Rezero" + entity_category: config + on_press: + - uart.write: + id: arduino_uart + data: "HOME 0\n" + + - platform: template + name: "${gauge1_entity_name} Rezero" + entity_category: config + on_press: + - uart.write: + id: arduino_uart + data: "HOME 1\n" + + - platform: template + name: "${gauge2_entity_name} Rezero" + entity_category: config + on_press: + - uart.write: + id: arduino_uart + data: "HOME 2\n" + + - platform: template + name: "${gauge3_entity_name} Rezero" + entity_category: config + on_press: + - uart.write: + id: arduino_uart + data: "HOME 3\n" + + - platform: template + name: Rezero All Gauges + entity_category: config + on_press: + - uart.write: + id: arduino_uart + data: "HOMEALL\n" + # --------------------------------------------------------------------------- # Gauge light state cache # --------------------------------------------------------------------------- @@ -472,6 +727,14 @@ globals: type: float restore_value: no initial_value: ${gauge1_min} + - id: gauge2_target_value + type: float + restore_value: no + initial_value: ${gauge2_min} + - id: gauge3_target_value + type: float + restore_value: no + initial_value: ${gauge3_min} - id: gauge0_speed_value type: float restore_value: no @@ -488,6 +751,22 @@ globals: type: float restore_value: no initial_value: ${gauge1_default_accel} + - id: gauge2_speed_value + type: float + restore_value: no + initial_value: ${gauge2_default_speed} + - id: gauge2_accel_value + type: float + restore_value: no + initial_value: ${gauge2_default_accel} + - id: gauge3_speed_value + type: float + restore_value: no + initial_value: ${gauge3_default_speed} + - id: gauge3_accel_value + type: float + restore_value: no + initial_value: ${gauge3_default_accel} - id: gauge0_bl_r type: int restore_value: no @@ -512,6 +791,30 @@ globals: type: int restore_value: no initial_value: "0" + - id: gauge2_bl_r + type: int + restore_value: no + initial_value: "0" + - id: gauge2_bl_g + type: int + restore_value: no + initial_value: "0" + - id: gauge2_bl_b + type: int + restore_value: no + initial_value: "0" + - id: gauge3_bl_r + type: int + restore_value: no + initial_value: "0" + - id: gauge3_bl_g + type: int + restore_value: no + initial_value: "0" + - id: gauge3_bl_b + type: int + restore_value: no + initial_value: "0" - id: gauge0_red_on type: bool restore_value: no @@ -544,6 +847,38 @@ globals: type: bool restore_value: no initial_value: "false" + - id: gauge2_red_on + type: bool + restore_value: no + initial_value: "false" + - id: gauge2_green_on + type: bool + restore_value: no + initial_value: "false" + - id: gauge2_status_red_on + type: bool + restore_value: no + initial_value: "false" + - id: gauge2_status_green_on + type: bool + restore_value: no + initial_value: "false" + - id: gauge3_red_on + type: bool + restore_value: no + initial_value: "false" + - id: gauge3_green_on + type: bool + restore_value: no + initial_value: "false" + - id: gauge3_status_red_on + type: bool + restore_value: no + initial_value: "false" + - id: gauge3_status_green_on + type: bool + restore_value: no + initial_value: "false" # --------------------------------------------------------------------------- # Light outputs @@ -616,6 +951,72 @@ output: id(gauge1_bl_r), id(gauge1_bl_g), id(gauge1_bl_b)); id(arduino_uart).write_str(cmd); + - platform: template + id: gauge2_backlight_red_output + type: float + write_action: + - lambda: |- + id(gauge2_bl_r) = static_cast(state * 255.0f + 0.5f); + char cmd[32]; + snprintf(cmd, sizeof(cmd), "LED 2 0-2 %d %d %d\n", + id(gauge2_bl_r), id(gauge2_bl_g), id(gauge2_bl_b)); + id(arduino_uart).write_str(cmd); + + - platform: template + id: gauge2_backlight_green_output + type: float + write_action: + - lambda: |- + id(gauge2_bl_g) = static_cast(state * 255.0f + 0.5f); + char cmd[32]; + snprintf(cmd, sizeof(cmd), "LED 2 0-2 %d %d %d\n", + id(gauge2_bl_r), id(gauge2_bl_g), id(gauge2_bl_b)); + id(arduino_uart).write_str(cmd); + + - platform: template + id: gauge2_backlight_blue_output + type: float + write_action: + - lambda: |- + id(gauge2_bl_b) = static_cast(state * 255.0f + 0.5f); + char cmd[32]; + snprintf(cmd, sizeof(cmd), "LED 2 0-2 %d %d %d\n", + id(gauge2_bl_r), id(gauge2_bl_g), id(gauge2_bl_b)); + id(arduino_uart).write_str(cmd); + + - platform: template + id: gauge3_backlight_red_output + type: float + write_action: + - lambda: |- + id(gauge3_bl_r) = static_cast(state * 255.0f + 0.5f); + char cmd[32]; + snprintf(cmd, sizeof(cmd), "LED 3 0-2 %d %d %d\n", + id(gauge3_bl_r), id(gauge3_bl_g), id(gauge3_bl_b)); + id(arduino_uart).write_str(cmd); + + - platform: template + id: gauge3_backlight_green_output + type: float + write_action: + - lambda: |- + id(gauge3_bl_g) = static_cast(state * 255.0f + 0.5f); + char cmd[32]; + snprintf(cmd, sizeof(cmd), "LED 3 0-2 %d %d %d\n", + id(gauge3_bl_r), id(gauge3_bl_g), id(gauge3_bl_b)); + id(arduino_uart).write_str(cmd); + + - platform: template + id: gauge3_backlight_blue_output + type: float + write_action: + - lambda: |- + id(gauge3_bl_b) = static_cast(state * 255.0f + 0.5f); + char cmd[32]; + snprintf(cmd, sizeof(cmd), "LED 3 0-2 %d %d %d\n", + id(gauge3_bl_r), id(gauge3_bl_g), id(gauge3_bl_b)); + id(arduino_uart).write_str(cmd); + - platform: template id: gauge0_red_indicator_output type: binary @@ -680,6 +1081,70 @@ output: 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"); + - platform: template + id: gauge2_red_indicator_output + type: binary + write_action: + - lambda: |- + id(gauge2_red_on) = state; + id(arduino_uart).write_str(state ? "LED 2 3 255 0 0\n" : "LED 2 3 0 0 0\n"); + + - platform: template + id: gauge2_green_indicator_output + type: binary + write_action: + - lambda: |- + id(gauge2_green_on) = state; + id(arduino_uart).write_str(state ? "LED 2 4 0 255 0\n" : "LED 2 4 0 0 0\n"); + + - platform: template + id: gauge2_status_red_output + type: binary + write_action: + - lambda: |- + id(gauge2_status_red_on) = state; + id(arduino_uart).write_str(state ? "LED 2 5 255 0 0\n" : "LED 2 5 0 0 0\n"); + + - platform: template + id: gauge2_status_green_output + type: binary + write_action: + - lambda: |- + id(gauge2_status_green_on) = state; + id(arduino_uart).write_str(state ? "LED 2 6 0 255 0\n" : "LED 2 6 0 0 0\n"); + + - platform: template + id: gauge3_red_indicator_output + type: binary + write_action: + - lambda: |- + id(gauge3_red_on) = state; + id(arduino_uart).write_str(state ? "LED 3 3 255 0 0\n" : "LED 3 3 0 0 0\n"); + + - platform: template + id: gauge3_green_indicator_output + type: binary + write_action: + - lambda: |- + id(gauge3_green_on) = state; + id(arduino_uart).write_str(state ? "LED 3 4 0 255 0\n" : "LED 3 4 0 0 0\n"); + + - platform: template + id: gauge3_status_red_output + type: binary + write_action: + - lambda: |- + id(gauge3_status_red_on) = state; + id(arduino_uart).write_str(state ? "LED 3 5 255 0 0\n" : "LED 3 5 0 0 0\n"); + + - platform: template + id: gauge3_status_green_output + type: binary + write_action: + - lambda: |- + id(gauge3_status_green_on) = state; + id(arduino_uart).write_str(state ? "LED 3 6 0 255 0\n" : "LED 3 6 0 0 0\n"); + # --------------------------------------------------------------------------- # Native HA lights # --------------------------------------------------------------------------- @@ -1326,3 +1791,645 @@ light: } else { id(arduino_uart).write_str("LED 1 6 0 255 0\n"); } + + - platform: rgb + id: gauge2_backlight + name: "${gauge2_entity_name} Backlight" + red: gauge2_backlight_red_output + green: gauge2_backlight_green_output + blue: gauge2_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 2 0-2 800 800 %d %d %d\n", + id(gauge2_bl_r), id(gauge2_bl_g), id(gauge2_bl_b)); + id(arduino_uart).write_str(cmd); + - lambda: + name: Blink Fast + update_interval: 750ms + lambda: |- + char cmd[36]; + snprintf(cmd, sizeof(cmd), "BLINK 2 0-2 150 150 %d %d %d\n", + id(gauge2_bl_r), id(gauge2_bl_g), id(gauge2_bl_b)); + id(arduino_uart).write_str(cmd); + - lambda: + name: Blink Alert + update_interval: 750ms + lambda: |- + char cmd[36]; + snprintf(cmd, sizeof(cmd), "BLINK 2 0-2 100 400 %d %d %d\n", + id(gauge2_bl_r), id(gauge2_bl_g), id(gauge2_bl_b)); + id(arduino_uart).write_str(cmd); + - lambda: + name: Breathe Slow + update_interval: 750ms + lambda: |- + char cmd[34]; + snprintf(cmd, sizeof(cmd), "BREATHE 2 0-2 3000 %d %d %d\n", + id(gauge2_bl_r), id(gauge2_bl_g), id(gauge2_bl_b)); + id(arduino_uart).write_str(cmd); + - lambda: + name: Breathe Fast + update_interval: 750ms + lambda: |- + char cmd[34]; + snprintf(cmd, sizeof(cmd), "BREATHE 2 0-2 1200 %d %d %d\n", + id(gauge2_bl_r), id(gauge2_bl_g), id(gauge2_bl_b)); + id(arduino_uart).write_str(cmd); + - lambda: + name: Double Flash + update_interval: 750ms + lambda: |- + char cmd[32]; + snprintf(cmd, sizeof(cmd), "DFLASH 2 0-2 %d %d %d\n", + id(gauge2_bl_r), id(gauge2_bl_g), id(gauge2_bl_b)); + id(arduino_uart).write_str(cmd); + on_state: + - lambda: |- + auto effect = id(gauge2_backlight).get_effect_name(); + char cmd[36]; + if (effect == "Blink Slow") { + snprintf(cmd, sizeof(cmd), "BLINK 2 0-2 800 800 %d %d %d\n", + id(gauge2_bl_r), id(gauge2_bl_g), id(gauge2_bl_b)); + } else if (effect == "Blink Fast") { + snprintf(cmd, sizeof(cmd), "BLINK 2 0-2 150 150 %d %d %d\n", + id(gauge2_bl_r), id(gauge2_bl_g), id(gauge2_bl_b)); + } else if (effect == "Blink Alert") { + snprintf(cmd, sizeof(cmd), "BLINK 2 0-2 100 400 %d %d %d\n", + id(gauge2_bl_r), id(gauge2_bl_g), id(gauge2_bl_b)); + } else if (effect == "Breathe Slow") { + snprintf(cmd, sizeof(cmd), "BREATHE 2 0-2 3000 %d %d %d\n", + id(gauge2_bl_r), id(gauge2_bl_g), id(gauge2_bl_b)); + } else if (effect == "Breathe Fast") { + snprintf(cmd, sizeof(cmd), "BREATHE 2 0-2 1200 %d %d %d\n", + id(gauge2_bl_r), id(gauge2_bl_g), id(gauge2_bl_b)); + } else if (effect == "Double Flash") { + snprintf(cmd, sizeof(cmd), "DFLASH 2 0-2 %d %d %d\n", + id(gauge2_bl_r), id(gauge2_bl_g), id(gauge2_bl_b)); + } else { + snprintf(cmd, sizeof(cmd), "LED 2 0-2 %d %d %d\n", + id(gauge2_bl_r), id(gauge2_bl_g), id(gauge2_bl_b)); + } + id(arduino_uart).write_str(cmd); + + - platform: binary + id: gauge2_red_indicator + name: "${gauge2_entity_name} Red Indicator" + output: gauge2_red_indicator_output + restore_mode: ALWAYS_OFF + effects: + - lambda: + name: Blink Slow + update_interval: 750ms + lambda: |- + id(arduino_uart).write_str("BLINK 2 3 800 800 255 0 0\n"); + - lambda: + name: Blink Fast + update_interval: 750ms + lambda: |- + id(arduino_uart).write_str("BLINK 2 3 150 150 255 0 0\n"); + - lambda: + name: Blink Alert + update_interval: 750ms + lambda: |- + id(arduino_uart).write_str("BLINK 2 3 100 400 255 0 0\n"); + - lambda: + name: Breathe Slow + update_interval: 750ms + lambda: |- + id(arduino_uart).write_str("BREATHE 2 3 3000 255 0 0\n"); + - lambda: + name: Breathe Fast + update_interval: 750ms + lambda: |- + id(arduino_uart).write_str("BREATHE 2 3 1200 255 0 0\n"); + - lambda: + name: Double Flash + update_interval: 750ms + lambda: |- + id(arduino_uart).write_str("DFLASH 2 3 255 0 0\n"); + on_state: + - lambda: |- + if (!id(gauge2_red_on)) { + id(arduino_uart).write_str("LED 2 3 0 0 0\n"); + return; + } + auto effect = id(gauge2_red_indicator).get_effect_name(); + if (effect == "Blink Slow") { + id(arduino_uart).write_str("BLINK 2 3 800 800 255 0 0\n"); + } else if (effect == "Blink Fast") { + id(arduino_uart).write_str("BLINK 2 3 150 150 255 0 0\n"); + } else if (effect == "Blink Alert") { + id(arduino_uart).write_str("BLINK 2 3 100 400 255 0 0\n"); + } else if (effect == "Breathe Slow") { + id(arduino_uart).write_str("BREATHE 2 3 3000 255 0 0\n"); + } else if (effect == "Breathe Fast") { + id(arduino_uart).write_str("BREATHE 2 3 1200 255 0 0\n"); + } else if (effect == "Double Flash") { + id(arduino_uart).write_str("DFLASH 2 3 255 0 0\n"); + } else { + id(arduino_uart).write_str("LED 2 3 255 0 0\n"); + } + + - platform: binary + id: gauge2_green_indicator + name: "${gauge2_entity_name} Green Indicator" + output: gauge2_green_indicator_output + restore_mode: ALWAYS_OFF + effects: + - lambda: + name: Blink Slow + update_interval: 750ms + lambda: |- + id(arduino_uart).write_str("BLINK 2 4 800 800 0 255 0\n"); + - lambda: + name: Blink Fast + update_interval: 750ms + lambda: |- + id(arduino_uart).write_str("BLINK 2 4 150 150 0 255 0\n"); + - lambda: + name: Blink Alert + update_interval: 750ms + lambda: |- + id(arduino_uart).write_str("BLINK 2 4 100 400 0 255 0\n"); + - lambda: + name: Breathe Slow + update_interval: 750ms + lambda: |- + id(arduino_uart).write_str("BREATHE 2 4 3000 0 255 0\n"); + - lambda: + name: Breathe Fast + update_interval: 750ms + lambda: |- + id(arduino_uart).write_str("BREATHE 2 4 1200 0 255 0\n"); + - lambda: + name: Double Flash + update_interval: 750ms + lambda: |- + id(arduino_uart).write_str("DFLASH 2 4 0 255 0\n"); + on_state: + - lambda: |- + if (!id(gauge2_green_on)) { + id(arduino_uart).write_str("LED 2 4 0 0 0\n"); + return; + } + auto effect = id(gauge2_green_indicator).get_effect_name(); + if (effect == "Blink Slow") { + id(arduino_uart).write_str("BLINK 2 4 800 800 0 255 0\n"); + } else if (effect == "Blink Fast") { + id(arduino_uart).write_str("BLINK 2 4 150 150 0 255 0\n"); + } else if (effect == "Blink Alert") { + id(arduino_uart).write_str("BLINK 2 4 100 400 0 255 0\n"); + } else if (effect == "Breathe Slow") { + id(arduino_uart).write_str("BREATHE 2 4 3000 0 255 0\n"); + } else if (effect == "Breathe Fast") { + id(arduino_uart).write_str("BREATHE 2 4 1200 0 255 0\n"); + } else if (effect == "Double Flash") { + id(arduino_uart).write_str("DFLASH 2 4 0 255 0\n"); + } else { + id(arduino_uart).write_str("LED 2 4 0 255 0\n"); + } + + - platform: binary + id: gauge2_status_red + name: "${gauge2_entity_name} Status Red" + output: gauge2_status_red_output + restore_mode: ALWAYS_OFF + effects: + - lambda: + name: Blink Slow + update_interval: 750ms + lambda: |- + id(arduino_uart).write_str("BLINK 2 5 800 800 255 0 0\n"); + - lambda: + name: Blink Fast + update_interval: 750ms + lambda: |- + id(arduino_uart).write_str("BLINK 2 5 150 150 255 0 0\n"); + - lambda: + name: Blink Alert + update_interval: 750ms + lambda: |- + id(arduino_uart).write_str("BLINK 2 5 100 400 255 0 0\n"); + - lambda: + name: Breathe Slow + update_interval: 750ms + lambda: |- + id(arduino_uart).write_str("BREATHE 2 5 3000 255 0 0\n"); + - lambda: + name: Breathe Fast + update_interval: 750ms + lambda: |- + id(arduino_uart).write_str("BREATHE 2 5 1200 255 0 0\n"); + - lambda: + name: Double Flash + update_interval: 750ms + lambda: |- + id(arduino_uart).write_str("DFLASH 2 5 255 0 0\n"); + on_state: + - lambda: |- + if (!id(gauge2_status_red_on)) { + id(arduino_uart).write_str("LED 2 5 0 0 0\n"); + return; + } + auto effect = id(gauge2_status_red).get_effect_name(); + if (effect == "Blink Slow") { + id(arduino_uart).write_str("BLINK 2 5 800 800 255 0 0\n"); + } else if (effect == "Blink Fast") { + id(arduino_uart).write_str("BLINK 2 5 150 150 255 0 0\n"); + } else if (effect == "Blink Alert") { + id(arduino_uart).write_str("BLINK 2 5 100 400 255 0 0\n"); + } else if (effect == "Breathe Slow") { + id(arduino_uart).write_str("BREATHE 2 5 3000 255 0 0\n"); + } else if (effect == "Breathe Fast") { + id(arduino_uart).write_str("BREATHE 2 5 1200 255 0 0\n"); + } else if (effect == "Double Flash") { + id(arduino_uart).write_str("DFLASH 2 5 255 0 0\n"); + } else { + id(arduino_uart).write_str("LED 2 5 255 0 0\n"); + } + + - platform: binary + id: gauge2_status_green + name: "${gauge2_entity_name} Status Green" + output: gauge2_status_green_output + restore_mode: ALWAYS_OFF + effects: + - lambda: + name: Blink Slow + update_interval: 750ms + lambda: |- + id(arduino_uart).write_str("BLINK 2 6 800 800 0 255 0\n"); + - lambda: + name: Blink Fast + update_interval: 750ms + lambda: |- + id(arduino_uart).write_str("BLINK 2 6 150 150 0 255 0\n"); + - lambda: + name: Blink Alert + update_interval: 750ms + lambda: |- + id(arduino_uart).write_str("BLINK 2 6 100 400 0 255 0\n"); + - lambda: + name: Breathe Slow + update_interval: 750ms + lambda: |- + id(arduino_uart).write_str("BREATHE 2 6 3000 0 255 0\n"); + - lambda: + name: Breathe Fast + update_interval: 750ms + lambda: |- + id(arduino_uart).write_str("BREATHE 2 6 1200 0 255 0\n"); + - lambda: + name: Double Flash + update_interval: 750ms + lambda: |- + id(arduino_uart).write_str("DFLASH 2 6 0 255 0\n"); + on_state: + - lambda: |- + if (!id(gauge2_status_green_on)) { + id(arduino_uart).write_str("LED 2 6 0 0 0\n"); + return; + } + auto effect = id(gauge2_status_green).get_effect_name(); + if (effect == "Blink Slow") { + id(arduino_uart).write_str("BLINK 2 6 800 800 0 255 0\n"); + } else if (effect == "Blink Fast") { + id(arduino_uart).write_str("BLINK 2 6 150 150 0 255 0\n"); + } else if (effect == "Blink Alert") { + id(arduino_uart).write_str("BLINK 2 6 100 400 0 255 0\n"); + } else if (effect == "Breathe Slow") { + id(arduino_uart).write_str("BREATHE 2 6 3000 0 255 0\n"); + } else if (effect == "Breathe Fast") { + id(arduino_uart).write_str("BREATHE 2 6 1200 0 255 0\n"); + } else if (effect == "Double Flash") { + id(arduino_uart).write_str("DFLASH 2 6 0 255 0\n"); + } else { + id(arduino_uart).write_str("LED 2 6 0 255 0\n"); + } + + - platform: rgb + id: gauge3_backlight + name: "${gauge3_entity_name} Backlight" + red: gauge3_backlight_red_output + green: gauge3_backlight_green_output + blue: gauge3_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 3 0-2 800 800 %d %d %d\n", + id(gauge3_bl_r), id(gauge3_bl_g), id(gauge3_bl_b)); + id(arduino_uart).write_str(cmd); + - lambda: + name: Blink Fast + update_interval: 750ms + lambda: |- + char cmd[36]; + snprintf(cmd, sizeof(cmd), "BLINK 3 0-2 150 150 %d %d %d\n", + id(gauge3_bl_r), id(gauge3_bl_g), id(gauge3_bl_b)); + id(arduino_uart).write_str(cmd); + - lambda: + name: Blink Alert + update_interval: 750ms + lambda: |- + char cmd[36]; + snprintf(cmd, sizeof(cmd), "BLINK 3 0-2 100 400 %d %d %d\n", + id(gauge3_bl_r), id(gauge3_bl_g), id(gauge3_bl_b)); + id(arduino_uart).write_str(cmd); + - lambda: + name: Breathe Slow + update_interval: 750ms + lambda: |- + char cmd[34]; + snprintf(cmd, sizeof(cmd), "BREATHE 3 0-2 3000 %d %d %d\n", + id(gauge3_bl_r), id(gauge3_bl_g), id(gauge3_bl_b)); + id(arduino_uart).write_str(cmd); + - lambda: + name: Breathe Fast + update_interval: 750ms + lambda: |- + char cmd[34]; + snprintf(cmd, sizeof(cmd), "BREATHE 3 0-2 1200 %d %d %d\n", + id(gauge3_bl_r), id(gauge3_bl_g), id(gauge3_bl_b)); + id(arduino_uart).write_str(cmd); + - lambda: + name: Double Flash + update_interval: 750ms + lambda: |- + char cmd[32]; + snprintf(cmd, sizeof(cmd), "DFLASH 3 0-2 %d %d %d\n", + id(gauge3_bl_r), id(gauge3_bl_g), id(gauge3_bl_b)); + id(arduino_uart).write_str(cmd); + on_state: + - lambda: |- + auto effect = id(gauge3_backlight).get_effect_name(); + char cmd[36]; + if (effect == "Blink Slow") { + snprintf(cmd, sizeof(cmd), "BLINK 3 0-2 800 800 %d %d %d\n", + id(gauge3_bl_r), id(gauge3_bl_g), id(gauge3_bl_b)); + } else if (effect == "Blink Fast") { + snprintf(cmd, sizeof(cmd), "BLINK 3 0-2 150 150 %d %d %d\n", + id(gauge3_bl_r), id(gauge3_bl_g), id(gauge3_bl_b)); + } else if (effect == "Blink Alert") { + snprintf(cmd, sizeof(cmd), "BLINK 3 0-2 100 400 %d %d %d\n", + id(gauge3_bl_r), id(gauge3_bl_g), id(gauge3_bl_b)); + } else if (effect == "Breathe Slow") { + snprintf(cmd, sizeof(cmd), "BREATHE 3 0-2 3000 %d %d %d\n", + id(gauge3_bl_r), id(gauge3_bl_g), id(gauge3_bl_b)); + } else if (effect == "Breathe Fast") { + snprintf(cmd, sizeof(cmd), "BREATHE 3 0-2 1200 %d %d %d\n", + id(gauge3_bl_r), id(gauge3_bl_g), id(gauge3_bl_b)); + } else if (effect == "Double Flash") { + snprintf(cmd, sizeof(cmd), "DFLASH 3 0-2 %d %d %d\n", + id(gauge3_bl_r), id(gauge3_bl_g), id(gauge3_bl_b)); + } else { + snprintf(cmd, sizeof(cmd), "LED 3 0-2 %d %d %d\n", + id(gauge3_bl_r), id(gauge3_bl_g), id(gauge3_bl_b)); + } + id(arduino_uart).write_str(cmd); + + - platform: binary + id: gauge3_red_indicator + name: "${gauge3_entity_name} Red Indicator" + output: gauge3_red_indicator_output + restore_mode: ALWAYS_OFF + effects: + - lambda: + name: Blink Slow + update_interval: 750ms + lambda: |- + id(arduino_uart).write_str("BLINK 3 3 800 800 255 0 0\n"); + - lambda: + name: Blink Fast + update_interval: 750ms + lambda: |- + id(arduino_uart).write_str("BLINK 3 3 150 150 255 0 0\n"); + - lambda: + name: Blink Alert + update_interval: 750ms + lambda: |- + id(arduino_uart).write_str("BLINK 3 3 100 400 255 0 0\n"); + - lambda: + name: Breathe Slow + update_interval: 750ms + lambda: |- + id(arduino_uart).write_str("BREATHE 3 3 3000 255 0 0\n"); + - lambda: + name: Breathe Fast + update_interval: 750ms + lambda: |- + id(arduino_uart).write_str("BREATHE 3 3 1200 255 0 0\n"); + - lambda: + name: Double Flash + update_interval: 750ms + lambda: |- + id(arduino_uart).write_str("DFLASH 3 3 255 0 0\n"); + on_state: + - lambda: |- + if (!id(gauge3_red_on)) { + id(arduino_uart).write_str("LED 3 3 0 0 0\n"); + return; + } + auto effect = id(gauge3_red_indicator).get_effect_name(); + if (effect == "Blink Slow") { + id(arduino_uart).write_str("BLINK 3 3 800 800 255 0 0\n"); + } else if (effect == "Blink Fast") { + id(arduino_uart).write_str("BLINK 3 3 150 150 255 0 0\n"); + } else if (effect == "Blink Alert") { + id(arduino_uart).write_str("BLINK 3 3 100 400 255 0 0\n"); + } else if (effect == "Breathe Slow") { + id(arduino_uart).write_str("BREATHE 3 3 3000 255 0 0\n"); + } else if (effect == "Breathe Fast") { + id(arduino_uart).write_str("BREATHE 3 3 1200 255 0 0\n"); + } else if (effect == "Double Flash") { + id(arduino_uart).write_str("DFLASH 3 3 255 0 0\n"); + } else { + id(arduino_uart).write_str("LED 3 3 255 0 0\n"); + } + + - platform: binary + id: gauge3_green_indicator + name: "${gauge3_entity_name} Green Indicator" + output: gauge3_green_indicator_output + restore_mode: ALWAYS_OFF + effects: + - lambda: + name: Blink Slow + update_interval: 750ms + lambda: |- + id(arduino_uart).write_str("BLINK 3 4 800 800 0 255 0\n"); + - lambda: + name: Blink Fast + update_interval: 750ms + lambda: |- + id(arduino_uart).write_str("BLINK 3 4 150 150 0 255 0\n"); + - lambda: + name: Blink Alert + update_interval: 750ms + lambda: |- + id(arduino_uart).write_str("BLINK 3 4 100 400 0 255 0\n"); + - lambda: + name: Breathe Slow + update_interval: 750ms + lambda: |- + id(arduino_uart).write_str("BREATHE 3 4 3000 0 255 0\n"); + - lambda: + name: Breathe Fast + update_interval: 750ms + lambda: |- + id(arduino_uart).write_str("BREATHE 3 4 1200 0 255 0\n"); + - lambda: + name: Double Flash + update_interval: 750ms + lambda: |- + id(arduino_uart).write_str("DFLASH 3 4 0 255 0\n"); + on_state: + - lambda: |- + if (!id(gauge3_green_on)) { + id(arduino_uart).write_str("LED 3 4 0 0 0\n"); + return; + } + auto effect = id(gauge3_green_indicator).get_effect_name(); + if (effect == "Blink Slow") { + id(arduino_uart).write_str("BLINK 3 4 800 800 0 255 0\n"); + } else if (effect == "Blink Fast") { + id(arduino_uart).write_str("BLINK 3 4 150 150 0 255 0\n"); + } else if (effect == "Blink Alert") { + id(arduino_uart).write_str("BLINK 3 4 100 400 0 255 0\n"); + } else if (effect == "Breathe Slow") { + id(arduino_uart).write_str("BREATHE 3 4 3000 0 255 0\n"); + } else if (effect == "Breathe Fast") { + id(arduino_uart).write_str("BREATHE 3 4 1200 0 255 0\n"); + } else if (effect == "Double Flash") { + id(arduino_uart).write_str("DFLASH 3 4 0 255 0\n"); + } else { + id(arduino_uart).write_str("LED 3 4 0 255 0\n"); + } + + - platform: binary + id: gauge3_status_red + name: "${gauge3_entity_name} Status Red" + output: gauge3_status_red_output + restore_mode: ALWAYS_OFF + effects: + - lambda: + name: Blink Slow + update_interval: 750ms + lambda: |- + id(arduino_uart).write_str("BLINK 3 5 800 800 255 0 0\n"); + - lambda: + name: Blink Fast + update_interval: 750ms + lambda: |- + id(arduino_uart).write_str("BLINK 3 5 150 150 255 0 0\n"); + - lambda: + name: Blink Alert + update_interval: 750ms + lambda: |- + id(arduino_uart).write_str("BLINK 3 5 100 400 255 0 0\n"); + - lambda: + name: Breathe Slow + update_interval: 750ms + lambda: |- + id(arduino_uart).write_str("BREATHE 3 5 3000 255 0 0\n"); + - lambda: + name: Breathe Fast + update_interval: 750ms + lambda: |- + id(arduino_uart).write_str("BREATHE 3 5 1200 255 0 0\n"); + - lambda: + name: Double Flash + update_interval: 750ms + lambda: |- + id(arduino_uart).write_str("DFLASH 3 5 255 0 0\n"); + on_state: + - lambda: |- + if (!id(gauge3_status_red_on)) { + id(arduino_uart).write_str("LED 3 5 0 0 0\n"); + return; + } + auto effect = id(gauge3_status_red).get_effect_name(); + if (effect == "Blink Slow") { + id(arduino_uart).write_str("BLINK 3 5 800 800 255 0 0\n"); + } else if (effect == "Blink Fast") { + id(arduino_uart).write_str("BLINK 3 5 150 150 255 0 0\n"); + } else if (effect == "Blink Alert") { + id(arduino_uart).write_str("BLINK 3 5 100 400 255 0 0\n"); + } else if (effect == "Breathe Slow") { + id(arduino_uart).write_str("BREATHE 3 5 3000 255 0 0\n"); + } else if (effect == "Breathe Fast") { + id(arduino_uart).write_str("BREATHE 3 5 1200 255 0 0\n"); + } else if (effect == "Double Flash") { + id(arduino_uart).write_str("DFLASH 3 5 255 0 0\n"); + } else { + id(arduino_uart).write_str("LED 3 5 255 0 0\n"); + } + + - platform: binary + id: gauge3_status_green + name: "${gauge3_entity_name} Status Green" + output: gauge3_status_green_output + restore_mode: ALWAYS_OFF + effects: + - lambda: + name: Blink Slow + update_interval: 750ms + lambda: |- + id(arduino_uart).write_str("BLINK 3 6 800 800 0 255 0\n"); + - lambda: + name: Blink Fast + update_interval: 750ms + lambda: |- + id(arduino_uart).write_str("BLINK 3 6 150 150 0 255 0\n"); + - lambda: + name: Blink Alert + update_interval: 750ms + lambda: |- + id(arduino_uart).write_str("BLINK 3 6 100 400 0 255 0\n"); + - lambda: + name: Breathe Slow + update_interval: 750ms + lambda: |- + id(arduino_uart).write_str("BREATHE 3 6 3000 0 255 0\n"); + - lambda: + name: Breathe Fast + update_interval: 750ms + lambda: |- + id(arduino_uart).write_str("BREATHE 3 6 1200 0 255 0\n"); + - lambda: + name: Double Flash + update_interval: 750ms + lambda: |- + id(arduino_uart).write_str("DFLASH 3 6 0 255 0\n"); + on_state: + - lambda: |- + if (!id(gauge3_status_green_on)) { + id(arduino_uart).write_str("LED 3 6 0 0 0\n"); + return; + } + auto effect = id(gauge3_status_green).get_effect_name(); + if (effect == "Blink Slow") { + id(arduino_uart).write_str("BLINK 3 6 800 800 0 255 0\n"); + } else if (effect == "Blink Fast") { + id(arduino_uart).write_str("BLINK 3 6 150 150 0 255 0\n"); + } else if (effect == "Blink Alert") { + id(arduino_uart).write_str("BLINK 3 6 100 400 0 255 0\n"); + } else if (effect == "Breathe Slow") { + id(arduino_uart).write_str("BREATHE 3 6 3000 0 255 0\n"); + } else if (effect == "Breathe Fast") { + id(arduino_uart).write_str("BREATHE 3 6 1200 0 255 0\n"); + } else if (effect == "Double Flash") { + id(arduino_uart).write_str("DFLASH 3 6 0 255 0\n"); + } else { + id(arduino_uart).write_str("LED 3 6 0 255 0\n"); + }