ff-akwarium-plug-01.yaml 2.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123
  1. substitutions:
  2. devicename: ff-akwarium-plug-01
  3. low_devicename: ff-akwarium-plug-01
  4. friendly_devicename: FF Akwarium Plug 01
  5. esphome:
  6. name: $devicename
  7. friendly_name: $friendly_devicename
  8. bk72xx:
  9. board: generic-bk7231t-qfn32-tuya
  10. #framework:
  11. # version: dev
  12. # Enable logging
  13. logger:
  14. web_server:
  15. port: 80
  16. # Enable Home Assistant API
  17. api:
  18. encryption:
  19. key: "ejeMnlF5M60w/yuYwAWn/kIBz701xLwVkUGf9iN8uLA="
  20. ota:
  21. password: "2c27af3ab81f992e23745c20ab5dfc02"
  22. wifi:
  23. ssid: !secret iot_ssid
  24. password: !secret iot_password
  25. domain: .int.mmax.cloud
  26. sensor:
  27. - platform: wifi_signal
  28. name: "WiFi Signal Sensor"
  29. update_interval: 60s
  30. - platform: uptime
  31. name: Uptime Sensor
  32. id: uptime_sensor
  33. update_interval: 60s
  34. on_raw_value:
  35. then:
  36. - text_sensor.template.publish:
  37. id: uptime_human
  38. state: !lambda |-
  39. int seconds = round(id(uptime_sensor).raw_state);
  40. int days = seconds / (24 * 3600);
  41. seconds = seconds % (24 * 3600);
  42. int hours = seconds / 3600;
  43. seconds = seconds % 3600;
  44. int minutes = seconds / 60;
  45. seconds = seconds % 60;
  46. return (
  47. (days ? to_string(days) + "d " : "") +
  48. (hours ? to_string(hours) + "h " : "") +
  49. (minutes ? to_string(minutes) + "m " : "") +
  50. (to_string(seconds) + "s")
  51. ).c_str();
  52. text_sensor:
  53. - platform: template
  54. name: Uptime Human Readable
  55. id: uptime_human
  56. icon: mdi:clock-start
  57. - platform: wifi_info
  58. ip_address:
  59. name: IP Address
  60. entity_category: diagnostic
  61. binary_sensor:
  62. - platform: status
  63. name: Status
  64. entity_category: diagnostic
  65. - platform: gpio
  66. pin:
  67. number: P7
  68. mode:
  69. input: true
  70. pullup: true
  71. inverted: true
  72. name: "Power Button"
  73. on_press:
  74. - switch.toggle: relay
  75. switch:
  76. - platform: gpio
  77. # RED
  78. id: led_1
  79. pin:
  80. number: P6
  81. inverted: false
  82. - platform: gpio
  83. # BLUE
  84. id: led_2
  85. pin:
  86. number: P26
  87. inverted: false
  88. - platform: gpio
  89. name: Switch
  90. pin: P8
  91. id: relay
  92. # Turn off red LED to show blue when turned on
  93. on_turn_on:
  94. - switch.turn_on: led_2
  95. - switch.turn_off: led_1
  96. # Turns on the red LED once the plug is turned off
  97. on_turn_off:
  98. - switch.turn_off: led_2
  99. - switch.turn_on: led_1
  100. button:
  101. - platform: restart
  102. id: restart_button
  103. name: Restart
  104. entity_category: diagnostic