afonsoIT

Untitled

Nov 5th, 2021
74
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.05 KB | None | 0 0
  1. esphome:
  2. name: teste
  3. platform: ESP8266
  4. board: esp01_1m
  5.  
  6. # Enable logging
  7. logger:
  8.  
  9. # Enable Home Assistant API
  10. api:
  11.  
  12. ota:
  13. password: !secret wifi_password
  14.  
  15. wifi:
  16. ssid: !secret wifi_ssd
  17. password: !secret wifi_password
  18.  
  19. # Enable fallback hotspot (captive portal) in case wifi connection fails
  20. ap:
  21. ssid: "Balança gás e sensor casinha"
  22. password: "mTKGr3ojOH0z"
  23.  
  24. captive_portal:
  25.  
  26. # MQ5 Gas Sensor leak
  27. sensor:
  28. - platform: adc
  29. pin: A0
  30. name: "Sensor de gás casinha"
  31. id: cazinha_gas_detector
  32. update_interval: 1s
  33. filters:
  34. - multiply: 100
  35. unit_of_measurement: "%"
  36. icon: "mdi:percent"
  37. on_value_range:
  38. - above: 15.2
  39. then:
  40. - logger.log: "Iniciando script!"
  41. - script.execute: my_script
  42. - below: 15.2
  43. then:
  44. - logger.log: "Parando script!"
  45. - script.stop: my_script
  46. - switch.turn_off: buzzer
  47. - switch.turn_on: led
  48.  
  49. binary_sensor:
  50. - platform: template
  51. name: "Alarme vazamento de gás"
  52. id: alarme_cazinha_gas
  53. lambda: |-
  54. if (id(cazinha_gas_detector).state >= 15.2) {
  55. return true;
  56. } else {
  57. return false;
  58. }
  59.  
  60. switch:
  61. - platform: gpio
  62. pin: GPIO16
  63. name: "Buzzer"
  64. id: buzzer
  65. internal: true
  66.  
  67. - platform: gpio
  68. pin: GPIO5
  69. name: "LED"
  70. id: led
  71. internal: true
  72.  
  73. - platform: gpio
  74. pin: GPIO10
  75. name: "TESTE"
  76. id: buzzerTeste
  77. on_turn_on:
  78. - script.execute: my_script
  79. on_turn_off:
  80. - script.stop: my_script
  81. - switch.turn_off: buzzer
  82. - switch.turn_on: led
  83.  
  84. script:
  85. - id: my_script
  86. then:
  87. - while:
  88. condition:
  89. lambda: 'return id(cazinha_gas_detector).state > 15;'
  90. then:
  91. - logger.log: "Rodando alerta!"
  92. - switch.turn_on: buzzer
  93. - switch.turn_on: led
  94. - delay: 1s
  95. - switch.turn_off: buzzer
  96. - switch.turn_off: led
  97. - delay: 1s
  98.  
Add Comment
Please, Sign In to add comment