Advertisement
Guest User

Smart zavlaha ESPhome firmware

a guest
Nov 2nd, 2020
157
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 2.06 KB | None | 0 0
  1. substitutions:
  2.   devicename: "zavlaha"
  3.   upper_devicename: "Smart závlaha"
  4.  
  5. esphome:
  6.   name: $devicename
  7.   platform: ESP8266
  8.   board: esp01_1m
  9.  
  10. wifi:
  11.   networks:
  12.   - ssid: 'wifi'
  13.     password: 'password'
  14.   ap:
  15.     ssid: 'Zavlaha'
  16.     password: 'password'
  17.  
  18. captive_portal:
  19.  
  20. # Enable logging
  21. logger:
  22.  
  23. # Enable Home Assistant API
  24. api:
  25.   password: "password"
  26.  
  27. ota:
  28.   password: "password"
  29.  
  30. switch:
  31.   - platform: restart
  32.     name: ${upper_devicename} reštart
  33.  
  34.   - platform: gpio
  35.     pin: GPIO12
  36.     id: motor
  37.   - platform: template
  38.     id: motorTemplate
  39.     name: "Spusti závlahu"
  40.     icon: "mdi:water-pump"
  41.     turn_on_action:
  42.     - switch.template.publish:
  43.         id: motorTemplate
  44.         state: ON
  45.     - switch.turn_on: motor
  46.     - delay: 30s
  47.     - switch.turn_off: motor
  48.     turn_off_action:
  49.     - switch.template.publish:
  50.         id: motorTemplate
  51.         state: OFF
  52.     - switch.turn_off: motor
  53.  
  54. text_sensor:
  55.   - platform: template
  56.     name: ${upper_devicename} uptime
  57.     lambda: |-
  58.       uint32_t dur = id(uptime_s).state;
  59.       int dys = 0;
  60.       int hrs = 0;
  61.       int mnts = 0;
  62.       if (dur > 86399) {
  63.         dys = trunc(dur / 86400);
  64.         dur = dur - (dys * 86400);
  65.       }
  66.       if (dur > 3599) {
  67.         hrs = trunc(dur / 3600);
  68.         dur = dur - (hrs * 3600);
  69.       }
  70.       if (dur > 59) {
  71.         mnts = trunc(dur / 60);
  72.         dur = dur - (mnts * 60);
  73.       }
  74.       char buffer[17];
  75.       sprintf(buffer, "%ud %02uh %02um %02us", dys, hrs, mnts, dur);
  76.       return {buffer};
  77.     icon: mdi:clock-start
  78.     update_interval: 30s
  79.  
  80. sensor:
  81.   - platform: uptime
  82.     id: uptime_s
  83.     internal: true
  84.     update_interval: 30s
  85.  
  86.   - platform: wifi_signal
  87.     name: ${upper_devicename} WiFi Signal
  88.     update_interval: 60s  
  89.  
  90. binary_sensor:
  91.   - platform: gpio
  92.     id: tlacidlo
  93.     pin:
  94.       number: GPIO00
  95.       inverted: no
  96.       mode: INPUT_PULLUP
  97.     filters:
  98.       - delayed_on: 200ms
  99.       - delayed_off: 200ms
  100.     on_press:
  101.       then:
  102.         - switch.toggle: motorTemplate      
  103.  
  104.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement