Advertisement
ptr727

Untitled

Dec 11th, 2020
894
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
YAML 5.92 KB | None | 0 0
  1. # https://esphome.io/devices/sonoff.html#sonoff-th10-th16
  2. # https://templates.blakadder.com/sonoff_TH.html
  3. # https://tasmota.github.io/docs/devices/Sonoff-TH/
  4.  
  5. # Button: GPIO0, Inverted
  6. # Relay, Red LED: GPIO12
  7. # Blue LED: GPIO13, Inverted
  8. # UART Tx : GPIO1
  9. # UART Rx : GPIO3
  10. # Sensor 1 : GPIO4
  11. # Sensor 2 : GPIO14
  12. # EXP-LOG : GPIO2
  13.  
  14.  
  15. # https://www.superhouse.tv/21-six-sonoff-secrets/
  16. # https://tinkerman.cat/post/sonoff-th10-th16-sensors-displays-actuators/
  17.  
  18. # Tip : GPIO14 (BME280 SDA) (Red)
  19. # Ring 1 : GPIO4 (BME280 SCL) (White)
  20. # Ring 2 : GND (Green)
  21. # Sleeve : 3.3V (Black)
  22.  
  23.  
  24. # https://esphome.io/guides/configuration-types.html#substitutions
  25. substitutions:
  26.   device_name: sonoff_th10_hot_recirc_pump
  27.   device_comment: "Hot Water Recirculation Pump Controller"
  28.  
  29.  
  30. # https://esphome.io/components/esphome.html  
  31. esphome:
  32.   name: ${device_name}
  33.   comment: ${device_comment}
  34.   platform: ESP8266
  35.   board: esp8285
  36.   # Do not restore state from flash
  37.   esp8266_restore_from_flash: false
  38.  
  39.  
  40. # https://esphome.io/guides/configuration-types.html#packages
  41. packages:
  42.   common: !include templates/common.yaml
  43.   status_sensor: !include templates/status_sensor.yaml
  44.   version_sensor: !include templates/version_sensor.yaml
  45.   wifi_sensor: !include templates/wifi_sensor.yaml
  46.   uptime_sensor: !include templates/uptime_sensor.yaml
  47.   restart_switch: !include templates/restart_switch.yaml
  48.   # web_server: !include templates/web_server.yaml
  49.  
  50.  
  51. # https://esphome.io/components/debug.html
  52. debug:
  53.  
  54. # https://esphome.io/components/binary_sensor/index.html
  55. binary_sensor:
  56.   # https://esphome.io/components/binary_sensor/gpio.html
  57.   - platform: gpio
  58.     name: ${device_name}_button
  59.     device_class: power
  60.     pin:
  61.       number: GPIO0
  62.       inverted: true
  63.     on_press:
  64.      # Manual activation may interfere with the bangbang controller
  65.       - logger.log: "Button : Toggle Relay."
  66.       - switch.toggle: relay
  67.  
  68.      
  69. # https://esphome.io/components/switch/index.html
  70. switch:
  71.   # https://esphome.io/components/switch/gpio.html
  72.   - platform: gpio
  73.     name: ${device_name}_relay
  74.     id: relay
  75.     pin: GPIO12
  76.     # Always start in off state
  77.     restore_mode: ALWAYS_OFF
  78.     # Manual activation may interfere with the bangbang controller
  79.     #internal: true
  80.  
  81.  
  82. # https://esphome.io/components/status_led.html
  83. status_led:
  84.   pin:
  85.     number: GPIO13
  86.  
  87.  
  88. # https://esphome.io/components/sensor/dallas.html    
  89. dallas:
  90.   - pin: GPIO14
  91.     update_interval: 20s
  92.    
  93.  
  94. # https://esphome.io/components/sensor/index.html    
  95. sensor:
  96.   # https://esphome.io/components/sensor/dallas.html
  97.   - platform: dallas
  98.     address: 0x05011455296AAA28
  99.     name: ${device_name}_recirc_temp
  100.     id: recirc_temp
  101.     # https://esphome.io/components/sensor/index.html#sliding-window-moving-average-exponential-moving-average
  102.     filters:
  103.       - sliding_window_moving_average:
  104.           window_size: 3
  105.           send_every: 3
  106.           send_first_at: 3
  107.   - platform: dallas
  108.     address: 0x54011455087FAA28
  109.     name: ${device_name}_hot_temp
  110.     id: hot_temp
  111.     filters:
  112.       - sliding_window_moving_average:
  113.           window_size: 3
  114.           send_every: 3
  115.           send_first_at: 3
  116.   - platform: dallas
  117.     address: 0x5E01145529F7AA28
  118.     name: ${device_name}_cold_temp
  119.     id: cold_temp
  120.     filters:
  121.       - sliding_window_moving_average:
  122.           window_size: 3
  123.           send_every: 3
  124.           send_first_at: 3
  125.   - platform: dallas
  126.     address: 0xEC011454E099AA28
  127.     name: ${device_name}_ambient_temp
  128.     id: ambient_temp
  129.     filters:
  130.       - sliding_window_moving_average:
  131.           window_size: 3
  132.           send_every: 3
  133.           send_first_at: 3
  134.  
  135.  
  136. # https://esphome.io/components/climate/index.html
  137. climate:
  138.   # https://esphome.io/components/climate/bang_bang.html
  139.   - platform: bang_bang
  140.     name: ${device_name}_bangbang
  141.     id: bangbang
  142.     sensor: recirc_temp
  143.     default_target_temperature_low: 30 # ~85F
  144.     default_target_temperature_high: 40 # ~105F
  145.     heat_action:
  146.       - logger.log: "BangBang : Heat Action, Turning Relay On."
  147.       - switch.turn_on: relay
  148.     idle_action:
  149.       - logger.log: "BangBang : Idle Action, Turning Relay Off."
  150.       - switch.turn_off: relay
  151.     visual:
  152.       min_temperature: 20
  153.       max_temperature: 50
  154.       temperature_step: 0.5
  155.  
  156.  
  157. # https://esphome.io/guides/automations.html#interval
  158. interval:
  159.   # Pump sometimes stays on indefinitely, don't know why, try to work around issue
  160.   - interval: 5min
  161.     then:
  162.       - lambda: |-
  163.           // Get bang_bang object
  164.           auto bangbangObject = id(bangbang);
  165.           ESP_LOGD("VerifyTimer", "BangBang: Mode: %s, Action: %s, Current Temp: %.2f, Target Low: %.2f, Target High: %.2f", climate_mode_to_string(bangbangObject->mode), climate_action_to_string(bangbangObject->action), bangbangObject->current_temperature, bangbangObject->target_temperature_low, bangbangObject->target_temperature_high);
  166.           // Get relay object
  167.           auto relayObject = id(relay);
  168.           ESP_LOGD("VerifyTimer", "Relay: State: %d", relayObject->state);
  169.           // Make sure desired state matches current state
  170.           //desiredState ? relayObject->turn_on() : relayObject->turn_off();
  171.           //App.safe_reboot();
  172.  
  173.   # Periodic recirc interval
  174.   - interval: 30min
  175.     then:
  176.      # When ambient temperature is higher than recirc low temp threshold, recirc never turns on.
  177.       # Periodically circulate hot water even when recirc is not calling for heat, making sure water in lines are never cold.
  178.       - logger.log: "RecircTimer : Setting Pump to Heat."
  179.       - climate.control:
  180.           id: bangbang
  181.           mode: HEAT
  182.       - logger.log: "RecircTimer : Delay Start."
  183.       # Periodic recirc runtime
  184.       - delay: 2min
  185.       - logger.log: "RecircTimer : Delay End."
  186.       - logger.log: "RecircTimer : Setting Pump to Auto."
  187.       - climate.control:
  188.           id: bangbang
  189.           mode: AUTO
  190.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement