]> git.giorgioravera.it Git - esphome.git/commitdiff
Added relay interface and relay only project
authorGiorgio Ravera <giorgio.ravera@gmail.com>
Fri, 24 Sep 2021 18:46:39 +0000 (20:46 +0200)
committerGiorgio Ravera <giorgio.ravera@gmail.com>
Fri, 24 Sep 2021 18:46:39 +0000 (20:46 +0200)
.gitignore [new file with mode: 0644]
esp01-ro.yaml [new file with mode: 0644]
esp01.yaml

diff --git a/.gitignore b/.gitignore
new file mode 100644 (file)
index 0000000..0bbf89c
--- /dev/null
@@ -0,0 +1,10 @@
+# Gitignore settings for ESPHome
+# This is an example and may include too much for your use-case.
+# You can modify this file to suit your needs.
+/.esphome/
+**/.pioenvs/
+**/.piolibdeps/
+**/lib/
+**/src/
+**/platformio.ini
+/secrets.yaml
diff --git a/esp01-ro.yaml b/esp01-ro.yaml
new file mode 100644 (file)
index 0000000..f9a7026
--- /dev/null
@@ -0,0 +1,76 @@
+######################################################################
+# Substitutions
+######################################################################
+substitutions:
+  esp01_topic: "esphome/esp01"
+  esp01_version: "00.02-ro"
+  vitality_message: "hello, i'm alive!"
+
+######################################################################
+# ESPHome Configuration
+######################################################################
+esphome:
+  name: esp01-ro
+  comment: "Test esp01 relay only"
+  platform: ESP8266
+  board: esp01_1m
+
+######################################################################
+# WiFi
+######################################################################
+wifi:
+  ssid: !secret wifi_ssid
+  password: !secret wifi_password
+  domain: !secret domain
+
+  # Enable fallback hotspot (captive portal) in case wifi connection fails
+  ap:
+    ssid: "Esp01 Fallback Hotspot"
+    password: !secret hotspot_password
+
+captive_portal:
+
+# Enable logging
+#logger:
+
+# Enable Home Assistant API
+api:
+  password: !secret api_password
+
+ota:
+  password: !secret ota_password
+
+######################################################################
+# Web Server
+######################################################################
+web_server:
+  port: 80
+  auth:
+    username: !secret web_user
+    password: !secret web_password
+
+######################################################################
+# Switch
+######################################################################
+switch:
+  - platform: gpio
+    name: "Relay"
+    id: relay
+    internal: false
+    pin: GPIO0
+    inverted: yes
+    restore_mode: ALWAYS_OFF
+    
+######################################################################
+# Text Sensor
+######################################################################
+text_sensor:
+  - platform: version
+    name: "ESPHome Version"
+    icon: mdi:chip
+
+  - platform: template
+    name: "Application Version"
+    icon: mdi:chip
+    lambda: |-
+      return {"$esp01_version"};
index 569210bdab890fc578ca478968c852cd18c0c2be..0915f71d949dd1f0a362466bda48945fc90a8095 100644 (file)
@@ -2,16 +2,18 @@
 # Substitutions
 ######################################################################
 substitutions:
+  esp01_hostname: "esp01"
   esp01_topic: "esphome/esp01"
-  esp01_version: "00.01"
+  esp01_version: "00.02-full"
   vitality_message: "hello, i'm alive!"
+  update_interval: 120s
 
 ######################################################################
 # ESPHome Configuration
 ######################################################################
 esphome:
-  name: esp01
-  comment: "Test esp01"
+  name: $esp01_hostname
+  comment: "Test $esp01_hostname full version"
   platform: ESP8266
   board: esp01_1m
 
@@ -40,7 +42,7 @@ wifi:
 captive_portal:
 
 # Enable logging
-logger:
+#logger:
 
 # Enable Home Assistant API
 #api:
@@ -75,6 +77,24 @@ mqtt:
     topic: '$esp01_topic/status'
     payload: offline
   on_message:
+    - topic: $esp01_topic/switch/relay/command
+      qos: 0
+      then:
+        - if:
+            condition:
+              lambda: 'return (x=="on");'
+            then:
+              - switch.turn_on: relay
+        - if:
+            condition:
+              lambda: 'return (x=="off");'
+            then:
+              - switch.turn_off: relay
+        - if:
+            condition:
+              lambda: 'return (x=="toggle");'
+            then:
+              - switch.toggle: relay
     - topic: $esp01_topic/switch/led/command
       qos: 0
       then:
@@ -115,13 +135,22 @@ mqtt:
 # Switch
 ######################################################################
 switch:
+  - platform: gpio
+    name: "Relay"
+    id: relay
+    internal: false
+    pin: GPIO0
+    inverted: yes
+    restore_mode: ALWAYS_OFF
+    #state_topic: esp/esp01/relay/status
+
   - platform: gpio
     name: "Led"
     id: led
     internal: false
     pin: GPIO2
     inverted: yes
-    restore_mode: ALWAYS_ON
+    restore_mode: ALWAYS_OFF
     #state_topic: esp/esp01/led/status
 
   - platform: template
@@ -154,7 +183,7 @@ switch:
 sensor:
   - platform: wifi_signal
     name: "WiFi Signal"
-    update_interval: 60s
+    update_interval: $update_interval
     
 ######################################################################
 # Text Sensor
@@ -169,13 +198,13 @@ text_sensor:
     icon: mdi:chip
     lambda: |-
       return {"$esp01_version"};
-    update_interval: 60s
+    update_interval: $update_interval
 
 ######################################################################
 # Interval
 ######################################################################
 interval:
-  - interval: 60sec
+  - interval: $update_interval
     then:
       - script.execute: mqtt_update_msg