Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- substitutions:
- board_name: shp2_socket_1
- ip_address: 192.168.1.124
- current_res: "0.00221"
- voltage_div: "945"
- esphome:
- name: ${board_name}
- platform: ESP8266
- board: esp8285
- # on_boot:
- # if:
- # condition:
- # wifi.connected:
- # then:
- # - light.turn_on: blue_led
- wifi:
- ssid: !secret wifi_ssid
- password: !secret wifi_pass
- domain: .localdomain
- reboot_timeout: 0s
- manual_ip:
- static_ip: ${ip_address}
- gateway: 192.168.1.1
- subnet: 255.255.255.0
- logger:
- api:
- reboot_timeout: 0s
- ota:
- web_server:
- port: 80
- binary_sensor:
- - platform: gpio
- name: ${board_name}_Button
- pin:
- number: GPIO3
- mode: INPUT_PULLUP
- inverted: True
- on_press:
- - switch.toggle: relay
- switch:
- - platform: gpio
- name: ${board_name}_Relay
- pin: GPIO14
- id: relay
- restore_mode: ALWAYS_ON
- on_turn_on:
- - switch.turn_on: blue_led
- - switch.turn_off: red_led
- on_turn_off:
- - switch.turn_off: blue_led
- - switch.turn_on: red_led
- - platform: gpio
- id: blue_led
- name: ${board_name}_LED_Blue
- icon: mdi:led-on
- restore_mode: ALWAYS_ON
- pin:
- number: GPIO1
- inverted: True
- - platform: gpio
- id: red_led
- name: ${board_name}_LED_Red
- icon: mdi:led-on
- restore_mode: ALWAYS_OFF
- pin:
- number: GPIO13
- inverted: True
- sensor:
- - platform: hlw8012
- sel_pin:
- number: GPIO12
- inverted: True
- cf_pin: GPIO04
- cf1_pin: GPIO05
- current_resistor: ${current_res}
- voltage_divider: ${voltage_div}
- current:
- name: ${board_name}_Current
- icon: mdi:current-ac
- unit_of_measurement: A
- voltage:
- name: ${board_name}_Voltage
- icon: mdi:flash-circle
- unit_of_measurement: V
- power:
- name: ${board_name}_Power
- icon: mdi:flash-outline
- unit_of_measurement: W
- change_mode_every: 8
- update_interval: 10s
- - platform: uptime
- name: ${board_name}_Uptime_s
- id: uptime_sensor
- - platform: wifi_signal
- name: ${board_name}_WiFi_RSSI
- update_interval: 60s
- text_sensor:
- - platform: template
- name: ${board_name}_Uptime
- lambda: |-
- uint32_t dur = id(uptime_sensor).state;
- int dys = 0;
- int hrs = 0;
- int mnts = 0;
- if (dur > 86399) {
- dys = trunc(dur / 86400);
- dur = dur - (dys * 86400);
- }
- if (dur > 3599) {
- hrs = trunc(dur / 3600);
- dur = dur - (hrs * 3600);
- }
- if (dur > 59) {
- mnts = trunc(dur / 60);
- dur = dur - (mnts * 60);
- }
- char buffer[17];
- sprintf(buffer, "%ud %02uh %02um %02us", dys, hrs, mnts, dur);
- return {buffer};
- icon: mdi:clock-start
- update_interval: 15s
- time:
- - platform: homeassistant
- id: homeassistant_time
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement