# drrcastro/leafcanwifi architecture

> Architecture diagram of the GitHub repository drrcastro/leafcanwifi, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-10-11). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/drrcastro/leafcanwifi
- Repository: https://github.com/drrcastro/leafcanwifi

## Overview

This repository provides an ESPHome-based Nissan Leaf ZE1 CAN monitor. The main workflow is to listen to the vehicle’s EV-CAN bus, decode telemetry on an ESP32, and expose it to Home Assistant; a fallback web UI offers access when Home Assistant is unavailable. The README also describes BMS GID filtering and safety-aware 12V polling. Source excerpts are unavailable, so relationships below reflect documented behavior rather than inspected implementation. The dashboard layout is a separate Home Assistant presentation artifact.

Main entry points: [`leafwifize1.yaml`](https://github.com/drrcastro/leafcanwifi/blob/main/leafwifize1.yaml) (Telemetry decoding), [`dashboard_layout.yaml`](https://github.com/drrcastro/leafcanwifi/blob/main/dashboard_layout.yaml) (Lovelace dashboard)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_vehicle["Vehicle telemetry"]
  node_can_bus["EV-CAN bus"]
end

subgraph group_firmware["ESPHome firmware"]
  node_firmware_config["ESPHome configuration<br/>[leafwifize1.yaml]"]
  node_can_capture["CAN capture<br/>[leafwifize1.yaml]"]
  node_telemetry_decode["Telemetry decoding<br/>[leafwifize1.yaml]"]
  node_gid_filter["GID filtering<br/>[leafwifize1.yaml]"]
  node_smart_polling["Smart polling<br/>[leafwifize1.yaml]"]
end

subgraph group_interfaces["User interfaces"]
  node_web_ui["Fallback web UI<br/>[leafwifize1.yaml]"]
  node_dashboard["Lovelace dashboard"]
end

node_leaf(("Nissan Leaf ZE1"))
node_ha(("Home Assistant"))

node_leaf -->|"emits frames"| node_can_bus
node_can_bus -->|"provides frames"| node_can_capture
node_can_capture -->|"feeds decoding"| node_telemetry_decode
node_telemetry_decode -->|"filters GIDs"| node_gid_filter
node_telemetry_decode -->|"exposes telemetry"| node_ha
node_telemetry_decode -->|"provides data"| node_web_ui
node_smart_polling -->|"polls conditionally"| node_can_bus
node_ha -->|"displays telemetry"| node_dashboard

click node_firmware_config "https://github.com/drrcastro/leafcanwifi/blob/main/leafwifize1.yaml"
click node_can_capture "https://github.com/drrcastro/leafcanwifi/blob/main/leafwifize1.yaml"
click node_telemetry_decode "https://github.com/drrcastro/leafcanwifi/blob/main/leafwifize1.yaml"
click node_gid_filter "https://github.com/drrcastro/leafcanwifi/blob/main/leafwifize1.yaml"
click node_smart_polling "https://github.com/drrcastro/leafcanwifi/blob/main/leafwifize1.yaml"
click node_web_ui "https://github.com/drrcastro/leafcanwifi/blob/main/leafwifize1.yaml"
click node_dashboard "https://github.com/drrcastro/leafcanwifi/blob/main/dashboard_layout.yaml"

classDef toneNeutral fill:#f8fafc,stroke:#334155,stroke-width:1.5px,color:#0f172a
classDef toneBlue fill:#dbeafe,stroke:#2563eb,stroke-width:1.5px,color:#172554
classDef toneAmber fill:#fef3c7,stroke:#d97706,stroke-width:1.5px,color:#78350f
classDef toneMint fill:#dcfce7,stroke:#16a34a,stroke-width:1.5px,color:#14532d
classDef toneRose fill:#ffe4e6,stroke:#e11d48,stroke-width:1.5px,color:#881337
classDef toneIndigo fill:#e0e7ff,stroke:#4f46e5,stroke-width:1.5px,color:#312e81
classDef toneTeal fill:#ccfbf1,stroke:#0f766e,stroke-width:1.5px,color:#134e4a
class node_can_bus toneBlue
class node_firmware_config,node_can_capture,node_telemetry_decode,node_gid_filter,node_smart_polling toneAmber
class node_web_ui,node_dashboard toneMint
class node_leaf,node_ha toneIndigo
```

## Components

### Vehicle telemetry

- **EV-CAN bus**

### ESPHome firmware

- [ESPHome configuration](https://github.com/drrcastro/leafcanwifi/blob/main/leafwifize1.yaml): `leafwifize1.yaml`
- [CAN capture](https://github.com/drrcastro/leafcanwifi/blob/main/leafwifize1.yaml): `leafwifize1.yaml`
- [Telemetry decoding](https://github.com/drrcastro/leafcanwifi/blob/main/leafwifize1.yaml): `leafwifize1.yaml`
- [GID filtering](https://github.com/drrcastro/leafcanwifi/blob/main/leafwifize1.yaml): `leafwifize1.yaml`
- [Smart polling](https://github.com/drrcastro/leafcanwifi/blob/main/leafwifize1.yaml): `leafwifize1.yaml`

### User interfaces

- [Fallback web UI](https://github.com/drrcastro/leafcanwifi/blob/main/leafwifize1.yaml): `leafwifize1.yaml`
- [Lovelace dashboard](https://github.com/drrcastro/leafcanwifi/blob/main/dashboard_layout.yaml): `dashboard_layout.yaml`

### Other components

- **Nissan Leaf ZE1**
- **Home Assistant**

## Connections

- Nissan Leaf ZE1 → EV-CAN bus: emits frames (evidence: `README.md`)
- EV-CAN bus → CAN capture: provides frames (evidence: `README.md`)
- CAN capture → Telemetry decoding: feeds decoding (evidence: `README.md`)
- Telemetry decoding → GID filtering: filters GIDs (evidence: `README.md`)
- Telemetry decoding → Home Assistant: exposes telemetry (evidence: `README.md`)
- Telemetry decoding → Fallback web UI: provides data (evidence: `README.md`)
- Smart polling → EV-CAN bus: polls conditionally (evidence: `README.md`)
- Home Assistant → Lovelace dashboard: displays telemetry (evidence: `README.md`)
