Pikabulastuser

Pikabulastuser

На Пикабу
Дата рождения: 28 сентября
1056 рейтинг 0 подписчиков 18 подписок 2 поста 0 в горячем
Награды:
5 лет на ПикабуС Днем рождения, Пикабу!
8

Автоматизация полива на ESPhome

esphome:

name: watering-controller

on_boot:

priority: -10

then:

- switch.turn_off: ball_valve

- switch.turn_off: water_pump

- logger.log: "System started. Safety shutdown initiated."

esp8266:

board: nodemcuv2

logger:

api:

encryption:

key: "6fJmeTpWUwYI1ild+BCDefxR7jzjgrXqRk+wYnQkvtc="

ota:

- platform: esphome

password: "990a849fc897e47a4de21d941c1dc328"

wifi:

ssid: !secret wifi_ssid

password: !secret wifi_password

ap:

ssid: "Kapustini Fallback Hotspot"

password: "88005553535"

captive_portal:

web_server:

port: 80

i2c:

sda: GPIO4

scl: GPIO5

scan: true

time:

- platform: ds1307

id: rtc_time

timezone: "Europe/Moscow"

sensor:

- platform: wifi_signal

name: "WiFi Signal"

id: wifi_signal_sensor

update_interval: 60s

interval:

- interval: 1min

then:

- if:

condition:

and:

- lambda: |-

auto now = id(rtc_time).now();

bool right_time = (now.hour == (int)id(w_hour).state && now.minute == (int)id(w_min).state);

bool day_match = false;

if (now.day_of_week == 1 && id(mon).state) day_match = true;

if (now.day_of_week == 2 && id(tue).state) day_match = true;

if (now.day_of_week == 3 && id(wed).state) day_match = true;

if (now.day_of_week == 4 && id(thu).state) day_match = true;

if (now.day_of_week == 5 && id(fri).state) day_match = true;

if (now.day_of_week == 6 && id(sat).state) day_match = true;

if (now.day_of_week == 7 && id(sun).state) day_match = true;

return right_time && day_match;

then:

- script.execute: watering_script

- if:

condition:

and:

- lambda: |-

auto now = id(rtc_time).now();

int s = id(p_start_hour).state;

int e = id(p_end_hour).state;

if (s <= e) return now.hour >= s && now.hour < e;

return now.hour >= s || now.hour < e;

- binary_sensor.is_off: tank_full

- switch.is_off: pump_error

- switch.is_off: water_pump

then:

- switch.turn_on: water_pump

- if:

condition:

and:

- switch.is_on: water_pump

- not:

lambda: |-

auto now = id(rtc_time).now();

int s = id(p_start_hour).state;

int e = id(p_end_hour).state;

if (s <= e) return now.hour >= s && now.hour < e;

return now.hour >= s || now.hour < e;

then:

- switch.turn_off: water_pump


script:

- id: watering_script

mode: restart

then:

- switch.turn_on: ball_valve

- delay: !lambda "return (int)id(w_duration).state * 60000;"

- switch.turn_off: ball_valve


- id: pump_safety_timeout

mode: restart

then:

- delay: !lambda "return (int)id(max_pump_time).state * 60000;"

- switch.turn_off: water_pump

- switch.turn_on: pump_error


number:

- platform: template

name: "Watering Hour"

id: w_hour

min_value: 0

max_value: 23

step: 1

initial_value: 20

restore_value: yes

optimistic: yes


- platform: template

name: "Watering Minute"

id: w_min

min_value: 0

max_value: 59

step: 1

initial_value: 0

restore_value: yes

optimistic: yes


- platform: template

name: "Watering Duration"

id: w_duration

min_value: 1

max_value: 120

step: 1

initial_value: 15

restore_value: yes

optimistic: yes


- platform: template

name: "Pump Start Hour"

id: p_start_hour

min_value: 0

max_value: 23

step: 1

initial_value: 23

restore_value: yes

optimistic: yes


- platform: template

name: "Pump Stop Hour"

id: p_end_hour

min_value: 0

max_value: 23

step: 1

initial_value: 7

restore_value: yes

optimistic: yes


- platform: template

name: "Pump Max Timeout"

id: max_pump_time

min_value: 1

max_value: 60

step: 1

initial_value: 30

restore_value: yes

optimistic: yes


switch:

- platform: template

name: "Mon"

id: mon

optimistic: yes

restore_mode: RESTORE_DEFAULT_OFF

- platform: template

name: "Tue"

id: tue

optimistic: yes

restore_mode: RESTORE_DEFAULT_OFF

- platform: template

name: "Wed"

id: wed

optimistic: yes

restore_mode: RESTORE_DEFAULT_OFF

- platform: template

name: "Thu"

id: thu

optimistic: yes

restore_mode: RESTORE_DEFAULT_OFF

- platform: template

name: "Fri"

id: fri

optimistic: yes

restore_mode: RESTORE_DEFAULT_OFF

- platform: template

name: "Sat"

id: sat

optimistic: yes

restore_mode: RESTORE_DEFAULT_OFF

- platform: template

name: "Sun"

id: sun

optimistic: yes

restore_mode: RESTORE_DEFAULT_OFF


- platform: template

name: "RESET PUMP ERROR"

id: pump_error

optimistic: yes

icon: "mdi:alert"

restore_mode: RESTORE_DEFAULT_OFF


- platform: gpio

pin: GPIO14

name: "Pump Relay"

id: water_pump

on_turn_on:

- if:

condition:

or:

- switch.is_on: pump_error

- binary_sensor.is_on: tank_full

then:

- switch.turn_off: water_pump

else:

- script.execute: pump_safety_timeout

on_turn_off:

- script.stop: pump_safety_timeout


- platform: gpio

pin: GPIO12

name: "Valve Relay"

id: ball_valve


binary_sensor:

- platform: gpio

pin: {number: GPIO13, mode: INPUT_PULLUP, inverted: true}

name: "Tank Full"

id: tank_full

on_press:

- switch.turn_off: water_pump


- platform: gpio

pin: {number: GPIO2, mode: INPUT_PULLUP, inverted: true}

name: "Overflow Alert"

id: overflow_sensor

on_press:

- switch.turn_off: water_pump


display:

- platform: lcd_pcf8574

address: 0x27

dimensions: 20x4

id: my_display

lambda: |-

int screen = (id(rtc_time).now().timestamp / 10) % 3;

it.strftime(0, 0, "Time: %H:%M:%S", id(rtc_time).now());

it.print(0, 1, "--------------------");

switch (screen) {

case 0:

it.print(0, 2, "PUMP:  ");

it.print(7, 2, id(water_pump).state ? ">> WORKING <<" : "  IDLE  ");

it.print(0, 3, "VALVE: ");

it.print(7, 3, id(ball_valve).state ? ">> OPENING <<" : "  CLOSED  ");

break;

case 1:

it.printf(0, 2, "Set: %02.0f:%02.0f", id(w_hour).state, id(w_min).state);

it.printf(0, 3, "Duration: %.0f min", id(w_duration).state);

break;

case 2:

if (id(pump_error).state) it.print(0, 2, "!!! PUMP ERROR !!!");

else if (id(tank_full).state) it.print(0, 2, "Status: TANK FULL");

else it.print(0, 2, "System: Healthy");


if (id(wifi_signal_sensor).has_state()) {

it.printf(0, 3, "WiFi: %.0f dBm", id(wifi_signal_sensor).state);

}

break;

}

Показать полностью 5
Отличная работа, все прочитано!

Темы

Политика

Теги

Популярные авторы

Сообщества

18+

Теги

Популярные авторы

Сообщества

Игры

Теги

Популярные авторы

Сообщества

Юмор

Теги

Популярные авторы

Сообщества

Отношения

Теги

Популярные авторы

Сообщества

Здоровье

Теги

Популярные авторы

Сообщества

Путешествия

Теги

Популярные авторы

Сообщества

Спорт

Теги

Популярные авторы

Сообщества

Хобби

Теги

Популярные авторы

Сообщества

Сервис

Теги

Популярные авторы

Сообщества

Природа

Теги

Популярные авторы

Сообщества

Бизнес

Теги

Популярные авторы

Сообщества

Транспорт

Теги

Популярные авторы

Сообщества

Общение

Теги

Популярные авторы

Сообщества

Юриспруденция

Теги

Популярные авторы

Сообщества

Наука

Теги

Популярные авторы

Сообщества

IT

Теги

Популярные авторы

Сообщества

Животные

Теги

Популярные авторы

Сообщества

Кино и сериалы

Теги

Популярные авторы

Сообщества

Экономика

Теги

Популярные авторы

Сообщества

Кулинария

Теги

Популярные авторы

Сообщества

История

Теги

Популярные авторы

Сообщества

Недвижимость и ремонт

Теги

Популярные авторы

Сообщества