Some fixes (integers for speed, Serial returns back to HA etc.)

This commit is contained in:
2026-04-22 16:14:10 +02:00
parent 558c5b18c2
commit 795eb0ecf3

View File

@@ -131,6 +131,20 @@ uart:
# Uncomment to log raw Arduino traffic: # Uncomment to log raw Arduino traffic:
# debug: # debug:
# direction: BOTH # direction: BOTH
on_data:
- lambda: |-
for (uint8_t b : x) {
if (b == '\n') {
std::string &buf = id(uart_rx_buf);
if (!buf.empty() && buf.back() == '\r') buf.pop_back();
if (!buf.empty() && buf != "OK" && buf != "PONG") {
id(arduino_last_message).publish_state(buf);
}
buf.clear();
} else if (id(uart_rx_buf).size() < 128) {
id(uart_rx_buf) += static_cast<char>(b);
}
}
# --------------------------------------------------------------------------- # ---------------------------------------------------------------------------
# Connectivity diagnostics # Connectivity diagnostics
@@ -259,6 +273,11 @@ text_sensor:
name: SSID name: SSID
entity_category: diagnostic entity_category: diagnostic
- platform: template
id: arduino_last_message
name: Arduino Last Message
entity_category: diagnostic
# --------------------------------------------------------------------------- # ---------------------------------------------------------------------------
# Gauge target numbers # Gauge target numbers
# --------------------------------------------------------------------------- # ---------------------------------------------------------------------------
@@ -702,11 +721,26 @@ button:
id: arduino_uart id: arduino_uart
data: "HOMEALL\n" data: "HOMEALL\n"
# ---------------------------------------------------------------------------
# Periodic auto-rezero
# ---------------------------------------------------------------------------
interval:
- interval: ${rezero_interval}
then:
- uart.write:
id: arduino_uart
data: "HOMEALL\n"
# --------------------------------------------------------------------------- # ---------------------------------------------------------------------------
# Gauge light state cache # Gauge light state cache
# --------------------------------------------------------------------------- # ---------------------------------------------------------------------------
globals: globals:
- id: uart_rx_buf
type: std::string
restore_value: no
initial_value: '""'
- id: vfd_text_value - id: vfd_text_value
type: std::string type: std::string
restore_value: no restore_value: no
@@ -736,35 +770,35 @@ globals:
restore_value: no restore_value: no
initial_value: ${gauge3_min} initial_value: ${gauge3_min}
- id: gauge0_speed_value - id: gauge0_speed_value
type: float type: int
restore_value: no restore_value: no
initial_value: ${gauge0_default_speed} initial_value: ${gauge0_default_speed}
- id: gauge0_accel_value - id: gauge0_accel_value
type: float type: int
restore_value: no restore_value: no
initial_value: ${gauge0_default_accel} initial_value: ${gauge0_default_accel}
- id: gauge1_speed_value - id: gauge1_speed_value
type: float type: int
restore_value: no restore_value: no
initial_value: ${gauge1_default_speed} initial_value: ${gauge1_default_speed}
- id: gauge1_accel_value - id: gauge1_accel_value
type: float type: int
restore_value: no restore_value: no
initial_value: ${gauge1_default_accel} initial_value: ${gauge1_default_accel}
- id: gauge2_speed_value - id: gauge2_speed_value
type: float type: int
restore_value: no restore_value: no
initial_value: ${gauge2_default_speed} initial_value: ${gauge2_default_speed}
- id: gauge2_accel_value - id: gauge2_accel_value
type: float type: int
restore_value: no restore_value: no
initial_value: ${gauge2_default_accel} initial_value: ${gauge2_default_accel}
- id: gauge3_speed_value - id: gauge3_speed_value
type: float type: int
restore_value: no restore_value: no
initial_value: ${gauge3_default_speed} initial_value: ${gauge3_default_speed}
- id: gauge3_accel_value - id: gauge3_accel_value
type: float type: int
restore_value: no restore_value: no
initial_value: ${gauge3_default_accel} initial_value: ${gauge3_default_accel}
- id: gauge0_bl_r - id: gauge0_bl_r