← - Lambda Reference | Indice | Avanti: FAQ e risoluzione dei problemi →
Integrazione ESPHome — Home Assistant, Risoluzione dei problemi, Prossimi passi
Integrazione con Home Assistant, risoluzione dei problemi e piani di sviluppo.
Indice
5.1 Integrazione con Home Assistant
Rilevamento automatico
Dopo aver flashato l'ESP32, il dispositivo appare automaticamente in Home Assistant.
Verifica:
- Impostazioni -> Dispositivi e servizi
- Find the "New devices discovered" notification
- Oppure: ESPHome -> seleziona il dispositivo
Entità in Home Assistant
Utilizzando l' esempio standard, vengono create le seguenti entità:
| Entità | Tipo | Descrizione |
|---|---|---|
light.dimmerlink_light |
Light | Dimmer principale |
sensor.dimmerlink_ac_frequency |
Sensor | Frequenza di rete (50/60 Hz) |
sensor.dimmerlink_level |
Sensor | Livello attuale (%) |
select.dimmerlink_curve |
Select | Curva di dimmerizzazione |
binary_sensor.dimmerlink_ready |
Binary Sensor | Stato di disponibilità |
button.dimmerlink_restart_esp |
Button | Riavvio ESP |
Schede Lovelace
Scheda semplice
type: light
entity: light.dimmerlink_light
name: Living Room
Scheda estesa
type: vertical-stack
cards:
- type: light
entity: light.dimmerlink_light
name: Dimmer
- type: entities
entities:
- entity: select.dimmerlink_curve
name: Curve
- entity: sensor.dimmerlink_ac_frequency
name: Mains Frequency
- entity: binary_sensor.dimmerlink_ready
name: Status
Scheda con cursore (custom:slider-entity-row)
type: entities
entities:
- entity: light.dimmerlink_light
type: custom:slider-entity-row
name: Brightness
toggle: true
Automazioni
Accensione tramite sensore di movimento
automation:
- alias: "Light on Motion"
trigger:
- platform: state
entity_id: binary_sensor.motion_sensor
to: "on"
condition:
- condition: sun
after: sunset
action:
- service: light.turn_on
target:
entity_id: light.dimmerlink_light
data:
brightness_pct: 70
transition: 2
Spegnimento dopo 5 minuti
automation:
- alias: "Auto Turn Off"
trigger:
- platform: state
entity_id: binary_sensor.motion_sensor
to: "off"
for:
minutes: 5
action:
- service: light.turn_off
target:
entity_id: light.dimmerlink_light
data:
transition: 5
Modalità notte (luce attenuata)
automation:
- alias: "Night Mode"
trigger:
- platform: time
at: "23:00:00"
condition:
- condition: state
entity_id: light.dimmerlink_light
state: "on"
action:
- service: light.turn_on
target:
entity_id: light.dimmerlink_light
data:
brightness_pct: 20
transition: 10
Cambiare curva in base al tipo di carico
automation:
- alias: "Curve for LED"
trigger:
- platform: state
entity_id: input_select.lamp_type
to: "LED"
action:
- service: select.select_option
target:
entity_id: select.dimmerlink_curve
data:
option: "LOG"
- alias: "Curve for Incandescent"
trigger:
- platform: state
entity_id: input_select.lamp_type
to: "Incandescent"
action:
- service: select.select_option
target:
entity_id: select.dimmerlink_curve
data:
option: "RMS"
Script
Accensione graduale mattutina
script:
morning_light:
alias: "Morning Light"
sequence:
- service: light.turn_on
target:
entity_id: light.dimmerlink_light
data:
brightness_pct: 10
- delay:
seconds: 30
- service: light.turn_on
target:
entity_id: light.dimmerlink_light
data:
brightness_pct: 50
transition: 120 # 2 minutes
Simulazione di presenza
script:
presence_simulation:
alias: "Presence Simulation"
sequence:
- repeat:
count: 10
sequence:
- service: light.turn_on
target:
entity_id: light.dimmerlink_light
data:
brightness_pct: "{{ range(30, 80) | random }}"
- delay:
minutes: "{{ range(5, 20) | random }}"
- service: light.turn_off
target:
entity_id: light.dimmerlink_light
- delay:
minutes: "{{ range(10, 30) | random }}"
Scene
scene:
- name: "Movie"
entities:
light.dimmerlink_light:
state: on
brightness_pct: 15
- name: "Reading"
entities:
light.dimmerlink_light:
state: on
brightness_pct: 80
- name: "Romantic"
entities:
light.dimmerlink_light:
state: on
brightness_pct: 30
Gruppi
light:
- platform: group
name: "All Dimmers"
entities:
- light.dimmerlink_living_room
- light.dimmerlink_bedroom
- light.dimmerlink_kitchen
Sensore di potenza tramite template
Se la potenza della lampada è nota:
sensor:
- platform: template
sensors:
dimmer_power:
friendly_name: "Dimmer Power"
unit_of_measurement: "W"
value_template: >
{% set brightness = state_attr('light.dimmerlink_light', 'brightness') | default(0) %}
{% set max_power = 100 %}
{{ (brightness / 255 * max_power) | round(1) }}
Cronologia e statistiche
Aggiungere a configuration.yaml:
recorder:
include:
entities:
- light.dimmerlink_light
- sensor.dimmerlink_level
- sensor.dimmerlink_ac_frequency
history:
include:
entities:
- light.dimmerlink_light
5.2 Risoluzione dei problemi
Problemi I2C
Dispositivo non trovato (0x50)
Symptom: Logs don't show "Found i2c device at address 0x50"
Verifica:
| Verifica | Soluzione |
|---|---|
| DimmerLink in modalità I2C? | Passare tramite UART: 02 5B |
| Alimentazione collegata? | VCC -> 3,3V, GND -> GND |
| Cablaggio corretto? | SDA -> SDA, SCL -> SCL (senza incrociare!) |
| Resistenze di pull-up? | Aggiungere 4,7 kΩ su SDA e SCL verso 3,3V |
| Cavi sufficientemente corti? | I2C funziona fino a 30 cm |
Diagnostica:
# Add to configuration for debugging
i2c:
sda: GPIO21
scl: GPIO22
scan: true # Enable scanning
id: bus_a
logger:
level: DEBUG
logs:
i2c: DEBUG
Errori I2C intermittenti
Symptom: "I2C communication failed" from time to time
Soluzioni:
- Ridurre la frequenza:
yaml
i2c:
frequency: 50kHz # Invece di 100kHz
- Aggiungere ritardi:
yaml
output:
- platform: template
write_action:
- delay: 1ms # Prima della scrittura
- lambda: |-
// ... codice
- Verificare l'alimentazione — un'alimentazione instabile causa errori I2C
Problemi WiFi
ESP32 Doesn't Connect to WiFi
Verifica:
- SSID e password corretti in
secrets.yaml - WiFi on 2.4 GHz (ESP32 doesn't support 5 GHz)
- Il router non blocca i nuovi dispositivi
Soluzione — AP di riserva:
wifi:
ssid: !secret wifi_ssid
password: !secret wifi_password
ap:
ssid: "dimmerlink-fallback"
password: "12345678"
captive_portal:
If it doesn't connect to WiFi — it will create an access point for configuration.
Disconnessioni frequenti
wifi:
ssid: !secret wifi_ssid
password: !secret wifi_password
fast_connect: true
power_save_mode: NONE # Disable power saving
Problemi con Home Assistant
Device Doesn't Appear in HA
- Verificare che il componente aggiuntivo ESPHome sia in esecuzione
- Controllare la api key nella configurazione
- Riavviare Home Assistant
- Aggiungere manualmente: Impostazioni -> Integrazioni -> Aggiungi -> ESPHome
"Entity unavailable"
Causes:
- ESP32 offline
- WiFi issues
- API key mismatch
Verifica:
ping dimmerlink.local
Problemi di dimmerizzazione
La lampada sfarfalla
Cause e soluzioni:
| Causa | Soluzione |
|---|---|
| LED non dimmerabile | Use lamps marked "dimmable" |
| Carico troppo basso | Minimo 10–25 W per un funzionamento stabile |
| Curva sbagliata | Provare LOG per LED |
| Interferenze di rete | Aggiungere uno snubber RC all'uscita del dimmer |
Lamp Doesn't Turn Off Completely
DimmerLink disattiva completamente il TRIAC al livello level=0. Se la lampada continua a brillare:
- Problema nel dimmer o nel cablaggio
- Alcuni driver LED hanno corrente di dispersione
Gamma di luminosità troppo ridotta
Provare curve diverse:
# In Home Assistant Developer Tools
service: select.select_option
target:
entity_id: select.dimmerlink_curve
data:
option: "RMS" # or "LOG"
Problemi con ESPHome
Errore di compilazione
«lambda function not allowed»
Controllare l'indentazione in YAML — lambda deve avere l'indentazione corretta:
# Correct
write_action:
- lambda: |-
uint8_t data[2] = {0x10, 50};
id(bus_a).write(0x50, data, 2, true);
# Incorrect (missing "|-")
write_action:
- lambda:
uint8_t data[2] = {0x10, 50};
«id not found»
Assicurarsi che id: bus_a sia dichiarato nella sezione i2c:.
OTA non funziona
- Verificare che l'ESP32 sia sulla stessa rete
- Usare l'IP invece del nome host:
bash
esphome run dimmerlink.yaml --device 192.168.1.100
Comandi di diagnostica
Verifica I2C da ESPHome
Aggiungere un pulsante di diagnostica:
button:
- platform: template
name: "I2C Diagnostic"
on_press:
- lambda: |-
ESP_LOGI("diag", "=== I2C Diagnostic ===");
// Check connection
uint8_t reg = 0x00;
uint8_t status = 0;
auto err = id(bus_a).write(0x50, ®, 1, false);
ESP_LOGI("diag", "Write result: %d", err);
err = id(bus_a).read(0x50, &status, 1);
ESP_LOGI("diag", "Read result: %d, status: 0x%02X", err, status);
// Read version
reg = 0x03;
uint8_t version = 0;
id(bus_a).write(0x50, ®, 1, false);
id(bus_a).read(0x50, &version, 1);
ESP_LOGI("diag", "Firmware: %d", version);
// Read frequency
reg = 0x20;
uint8_t freq = 0;
id(bus_a).write(0x50, ®, 1, false);
id(bus_a).read(0x50, &freq, 1);
ESP_LOGI("diag", "AC Frequency: %d Hz", freq);
ESP_LOGI("diag", "=== Done ===");
Registrazione di tutte le operazioni
logger:
level: DEBUG
logs:
i2c: DEBUG
api: DEBUG
sensor: DEBUG
Ripristino alle impostazioni di fabbrica
ESP32
- Cancellare la memoria flash:
bash
esptool.py --port COM3 erase_flash
- Flashare nuovamente il firmware
DimmerLink
Inviare il comando RESET:
button:
- platform: template
name: "Factory Reset DimmerLink"
on_press:
- lambda: |-
uint8_t data[2] = {0x01, 0x01};
id(bus_a).write(0x50, data, 2, true);
- delay: 3s
Tabella dei codici di errore
| Codice | Nome | Causa | Soluzione |
|---|---|---|---|
| 0x00 | OK | — | — |
| 0xF9 | ERR_SYNTAX | Registro non valido | Verificare l'indirizzo del registro |
| 0xFC | ERR_NOT_READY | Non calibrato o errore FLASH | Attendere 2 sec dopo l'accensione |
| 0xFD | ERR_INDEX | Indice dimmer non valido | Usare 0 |
| 0xFE | ERR_PARAM | Parametro non valido | level <= 100, curve <= 2 |
5.3 Prossimi passi
Stato attuale
DimmerLink v1.0:
- I2C interface
- UART interface
- Basic dimming (0-100%)
- Three curves (LINEAR, RMS, LOG)
- Auto-detection of mains frequency
- I2C address change
ESPHome Integration v1.0:
- Light entity
- All sensors
- Curve selection
- Diagnostics
- Multi-device
Piani di sviluppo
DimmerLink v2.0 (in sviluppo)
| Funzione | Stato | Descrizione |
|---|---|---|
| Protezione termica | In sviluppo | Monitoraggio NTC, ventilatore PWM |
| FADE progressivo | In sviluppo | Dissolvenza hardware tramite comando |
| Multi-canale | Pianificato | Fino a 4 canali su un modulo |
| Impostazioni EEPROM | Pianificato | Salvataggio di livello e curva |
Integrazione ESPHome v2.0
| Funzione | Stato | Descrizione |
|---|---|---|
| Componente nativo | Disponibile | External Component |
| Monitoraggio temperatura | In sviluppo | Sensore di temperatura |
| Controllo ventilatore | In sviluppo | Gestione del raffreddamento |
| Monitoraggio energetico | Pianificato | Integrazione con ACS712/CT |
Componente nativo ESPHome
È ora disponibile un componente esterno nativo per ESPHome. Offre una configurazione YAML pulita senza codice lambda:
external_components:
- source: github://robotdyn-dimmer/DimmerLink@main
components: [dimmerlink]
dimmerlink:
id: dimmer1
address: 0x50
light:
- platform: dimmerlink
dimmerlink_id: dimmer1
name: "Light"
sensor:
- platform: dimmerlink
dimmerlink_id: dimmer1
ac_frequency:
name: "AC Frequency"
Progetti avanzati
Router solare
Utilizzo di DimmerLink per instradare l'energia solare in eccesso:
+---------------+ +---------------+ +---------------+
| Solar Panel |---->| CT Sensor |---->| ESP32 |
+---------------+ +---------------+ | + ESPHome |
| |
+---------------+ +---------------+ | |
| Heater |<----| DimmerLink |<----| |
+---------------+ +---------------+ +---------------+
Sistema multi-stanza
# Central controller for the whole house
substitutions:
# Dimmer addresses
living_room: "0x50"
bedroom: "0x51"
kitchen: "0x52"
bathroom: "0x53"
# 4 dimmers on one ESP32
Sveglia intelligente
# Gradual light turn on for waking up
automation:
- alias: "Sunrise Alarm"
trigger:
- platform: time
at: "07:00:00"
action:
- service: light.turn_on
target:
entity_id: light.bedroom_dimmer
data:
brightness_pct: 1
- repeat:
count: 30
sequence:
- delay: 60
- service: light.turn_on
target:
entity_id: light.bedroom_dimmer
data:
brightness_pct: "{{ repeat.index * 3 }}"
transition: 60
Feedback
Hai trovato un bug o hai un suggerimento?
- GitHub Issues: DimmerLink Repository
- Documentazione: rbdimmer.com/docs
Vuoi contribuire allo sviluppo?
- Test di nuove versioni
- Documentazione e traduzioni
- Esempi di utilizzo
Link utili
| Risorsa | Link |
|---|---|
| Documentazione DimmerLink | rbdimmer.com/docs |
| ESPHome | esphome.io |
| Home Assistant | home-assistant.io |
| ESPHome I2C | esphome.io/components/i2c |
| ESPHome Light | esphome.io/components/light |
| HACS | hacs.xyz |
Cronologia delle modifiche
| Versione | Data | Modifiche |
|---|---|---|
| 1.0 | 2026-02 | Versione iniziale |
← - Lambda Reference | Indice | Avanti: FAQ e risoluzione dei problemi →