Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- substitutions:
- devicename: "zavlaha"
- upper_devicename: "Smart závlaha"
- esphome:
- name: $devicename
- platform: ESP8266
- board: esp01_1m
- wifi:
- networks:
- - ssid: 'wifi'
- password: 'password'
- ap:
- ssid: 'Zavlaha'
- password: 'password'
- captive_portal:
- # Enable logging
- logger:
- # Enable Home Assistant API
- api:
- password: "password"
- ota:
- password: "password"
- switch:
- - platform: restart
- name: ${upper_devicename} reštart
- - platform: gpio
- pin: GPIO12
- id: motor
- - platform: template
- id: motorTemplate
- name: "Spusti závlahu"
- icon: "mdi:water-pump"
- turn_on_action:
- - switch.template.publish:
- id: motorTemplate
- state: ON
- - switch.turn_on: motor
- - delay: 30s
- - switch.turn_off: motor
- turn_off_action:
- - switch.template.publish:
- id: motorTemplate
- state: OFF
- - switch.turn_off: motor
- text_sensor:
- - platform: template
- name: ${upper_devicename} uptime
- lambda: |-
- uint32_t dur = id(uptime_s).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: 30s
- sensor:
- - platform: uptime
- id: uptime_s
- internal: true
- update_interval: 30s
- - platform: wifi_signal
- name: ${upper_devicename} WiFi Signal
- update_interval: 60s
- binary_sensor:
- - platform: gpio
- id: tlacidlo
- pin:
- number: GPIO00
- inverted: no
- mode: INPUT_PULLUP
- filters:
- - delayed_on: 200ms
- - delayed_off: 200ms
- on_press:
- then:
- - switch.toggle: motorTemplate
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement