Domotique, atelier du jj/mm (à préciser)
L'atelier en préparation...
Objectif général : se familiariser avec un ESP32 sur HA, via ESPHome
Fournitures, un ESP32 standard, un ESP32 SIM800 (SMS et appels)
Les étapes,
- installation de ESPHome sur HA
- connexion d'un ESP32
- installation de programmes de test : serveur web, allumage d'une LED, envoi et réception de SMS, etc.
- création d'automatisations utilisant les ESP 32
Antisèche pour ESP32 SIM800
esphome: name: esp32-800 friendly_name: ESP32 800 esp32: board: esp-wrover-kit #remplace esp32dev framework: type: arduino # Enable logging logger: ota: password: "b22ec83a50a16926e258c8cb99ce9a43" wifi: ssid: !secret wifi_ssid password: !secret wifi_password # Enable fallback hotspot (captive portal) in case wifi connection fails ap: ssid: "Esp32-800 Fallback Hotspot" password: "AEQtghaRTjG5" captive_portal: # Home Assistant API # Enable Home Assistant API api: encryption: key: "yyhOhxam5Y7grXxgq0DfyDD36+E7aU1juuYXuMCgOnM=" services: - service: send_sms variables: recipient: string message: string then: - sim800l.send_sms: recipient: !lambda 'return recipient;' message: !lambda 'return message;' - lambda: id(esp_sim800_sms_message).publish_state(message); - service: dial variables: recipient: string then: - sim800l.dial: recipient: !lambda 'return recipient;' # Retourne le dernier message reçus au dernier expéditeut en y ajoutant OK - service: reply_sms_ok then: - text_sensor.template.publish: id: esp_sim800_sms_message state: !lambda |- return id(esp_sim800_sms_message).state + " OK"; - sim800l.send_sms: recipient: !lambda "return id(esp_sim800_sms_expediteur).state;" message: !lambda "return id(esp_sim800_sms_message).state;" uart: baud_rate: 9600 tx_pin: 27 rx_pin: 26 switch: - platform: gpio id: "key_pin" pin: 4 restore_mode: ALWAYS_OFF - platform: gpio id: "reset_pin" pin: 5 restore_mode: ALWAYS_ON - platform: gpio id: "power_pin" pin: 23 restore_mode: ALWAYS_ON - platform: gpio id: "Blue_Led800" pin: 13 restore_mode: ALWAYS_ON # Bouton de redémarrage button: - platform: restart id: esp_sim800_restart name: "ESP-SIM800 Redémarrage" sim800l: on_sms_received: - lambda: |- id(esp_sim800_sms_expediteur).publish_state(sender); id(esp_sim800_sms_message).publish_state(message); - logger.log: format: "Received '%s' from %s" args: [ 'message.c_str()', 'sender.c_str()' ] text_sensor: - platform: template id: esp_sim800_sms_expediteur name: "Sms Expediteur" - platform: template id: esp_sim800_sms_message name: "Sms Message" sensor: - platform: sim800l rssi: name: "ESP sim800 signal" binary_sensor: - platform: sim800l registered: name: "ESP sim800 status" # Example configuration entry web_server: port: 80 version: 1
Antisèche pour ESP32
esphome: name: esp32-wroom friendly_name: ESP32 Wroom esp32: board: esp32dev framework: type: arduino # Enable logging logger: # Enable Home Assistant API api: encryption: key: "pAUYEiM6r/qULEiwGBqwDCx+R7hun6ee6SYUmTtaMHI=" ota: password: "47a5f828dcfa7ccb984e418bfeee4d06" wifi: ssid: !secret wifi_ssid password: !secret wifi_password # Enable fallback hotspot (captive portal) in case wifi connection fails ap: ssid: "Esp32-Wroom Fallback Hotspot" password: "wsYS22L7axfh" # Example configuration entry web_server: port: 80 version: 1 # ajouté depuis cette page, https://www.hacf.fr/esphome-introduction/ binary_sensor: # statut - platform: status name: "Statut" sensor: # Qualité du signal - platform: wifi_signal name: "Signal Wifi" update_interval: 60s # Temps de fonctionnement - platform: uptime name: "Allumé depuis (s)" id: uptime_sec switch: # Bouton de redémarrage - platform: restart name: "Redémarrage" # LED bleue - platform: gpio name: "LedBleu2" pin: 2 # Transformation des secondes en jours text_sensor: - platform: template name: "Allumé depuis (j)" lambda: |- int seconds = (id(uptime_sec).state); int days = seconds / (24 * 3600); seconds = seconds % (24 * 3600); int hours = seconds / 3600; seconds = seconds % 3600; int minutes = seconds / 60; seconds = seconds % 60; return { (String(days) +"d " + String(hours) +"h " + String(minutes) +"m "+ String(seconds) +"s").c_str() }; icon: mdi:clock-start update_interval: 60s
Pour aller plus loin, ou en référence
https://www.youtube.com/watch?v=3GbyYQHQvV8&ab_channel=Abr%C3%A8ge
https://www.youtube.com/watch?v=AbRFvk2iZs8&ab_channel=HorizonDomotique
Et pour aller encore plus loin mais c'est juste pour se donner des idées,
https://www.youtube.com/watch?v=16UpLNC4pos&ab_channel=Abr%C3%A8ge
https://www.youtube.com/watch?v=XrAYduaWPj0&ab_channel=Abr%C3%A8ge