Advertisement
-Teme-

Nous A1 ESPhome

May 24th, 2022 (edited)
169
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
YAML 3.88 KB | None | 0 0
  1. substitutions:
  2.   device_name: nousplug118
  3.   friendly_name: "nousPlug118"
  4.   # Higher value gives lower watt readout
  5.   current_res: "0.00280"
  6.   # Lower value gives lower voltage readout
  7.   voltage_div: "775"
  8.  
  9. esphome:
  10.   name: ${device_name}
  11.   platform: ESP8266
  12.   board: esp01_1m
  13.  
  14.  
  15. wifi:
  16.   ssid: !secret wifi_ssid
  17.   password: !secret wifi_password
  18.   fast_connect: true
  19.   manual_ip:
  20.     gateway: !secret iotgw
  21.     subnet: !secret iotsubnet
  22.     static_ip: !secret nousplug118
  23. # Enable fallback hotspot (captive portal) in case wifi connection fails
  24.   ap:
  25.     ssid: ${device_name} Hotspot
  26.     password: !secret hotspot_pass
  27.  
  28. ota:
  29.   password: !secret ota_pass
  30.  
  31. # Enable Home Assistant API
  32. api:
  33. captive_portal:
  34. # Enable Web server (optional).
  35. web_server:
  36.   port: 80
  37.  
  38. mqtt:
  39.   broker: !secret mqtt_broker
  40.   username: !secret mqtt_user
  41.   password: !secret mqtt_pass
  42.   topic_prefix: esphome
  43.  
  44. # Enable logging
  45. logger:
  46. # Text sensors with general information.
  47. text_sensor:
  48.  # Expose ESPHome version as sensor.
  49.   - platform: version
  50.     name: ${friendly_name} ESPHome Version
  51.   # Expose WiFi information as sensors.
  52.   - platform: wifi_info
  53.     ip_address:
  54.       name: ${friendly_name} IP
  55.     ssid:
  56.       name: ${friendly_name} SSID
  57.     bssid:
  58.       name: ${friendly_name} BSSID
  59.  
  60. # see: https://esphome.io/components/time.html
  61. time:
  62.   - platform: homeassistant
  63.     id: homeassistant_time
  64.  
  65.  
  66. # Sensors with general information.
  67. sensor:
  68.  # Uptime sensor.
  69.   - platform: uptime
  70.     name: ${friendly_name} Uptime
  71.     icon: mdi:clock-outline
  72.  
  73.   # WiFi Signal sensor.
  74.   - platform: wifi_signal
  75.     name: ${friendly_name} WiFi Signal
  76.     update_interval: 60s
  77.     icon: mdi:wifi
  78.    
  79. ###########################################
  80. # Device Specific Config
  81.  
  82.   - platform: total_daily_energy
  83.     name: ${friendly_name} - Todays Usage
  84.     power_id: "power_wattage"
  85.     filters:
  86.      # Multiplication factor from W to kW is 0.001
  87.       - multiply: 0.001
  88.     unit_of_measurement: kWh
  89.     icon: mdi:calendar-clock
  90.  
  91.   - platform: adc
  92.     pin: VCC
  93.     name: ${friendly_name} - VCC Volt
  94.     icon: mdi:flash-outline
  95.  
  96.   - platform: hlw8012
  97.     sel_pin:
  98.       number: GPIO12
  99.       inverted: True
  100.     cf_pin: GPIO05
  101.     cf1_pin: GPIO04
  102.     change_mode_every: 4
  103.     current_resistor: ${current_res}
  104.     voltage_divider: ${voltage_div}
  105.     update_interval: 60s
  106.  
  107.     current:
  108.       name: ${friendly_name} - Ampere
  109.       unit_of_measurement: A
  110.       accuracy_decimals: 3
  111.       icon: mdi:current-ac
  112.  
  113.     voltage:
  114.       name: ${friendly_name} - Volt
  115.       unit_of_measurement: V
  116.       accuracy_decimals: 1
  117.       icon: mdi:flash-outline
  118.       filters:
  119.     power:
  120.       name: ${friendly_name} - Watt
  121.       unit_of_measurement: W
  122.       id: "power_wattage"
  123.       icon: mdi:gauge
  124.       filters:
  125.       - calibrate_linear:
  126.          # Map 0.0 (from sensor) to 0.0 (true value)
  127.           - 0.0 -> 0.0
  128.           - 10.22 -> 10
  129.           - 50.4 -> 60.0
  130.           - 59.7 -> 70.0
  131.  
  132. binary_sensor:
  133.   - platform: status
  134.     name: ${friendly_name} - Status
  135.     device_class: connectivity
  136.    
  137.   # toggle relay on/off
  138.   - platform: gpio
  139.     pin:
  140.       number: GPIO13
  141.       mode: INPUT_PULLUP
  142.       inverted: True
  143.     id: ${device_name}_button_state
  144.     on_press:
  145.       - switch.toggle: button_switch
  146.      
  147. status_led:
  148.   pin:
  149.     number: GPIO02
  150.     inverted: true
  151.   id: led_blue
  152.  
  153. output:
  154.   - platform: gpio
  155.     pin: GPIO00
  156.     inverted: true
  157.     id: led_red
  158.  
  159. switch:
  160.   - platform: template
  161.     name: ${friendly_name} - Switch
  162.     icon: mdi:power
  163.     optimistic: true
  164.     restore_state: true
  165.     id: button_switch
  166.     on_turn_on:
  167.       - switch.turn_on: relay
  168.       - output.turn_off: led_red
  169.     on_turn_off:
  170.       - switch.turn_off: relay
  171.       - output.turn_on: led_red
  172.      
  173.   - platform: gpio
  174.     pin: GPIO15
  175.     id: relay
  176.     restore_mode: ALWAYS_ON
  177.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement