ESPHome-Devices/pool_pumps.yaml
ChNussbaum fc5873c2cf Add front and living room lights
Add master bath fan, second light dimmer, and temp/humidity sensor
Fix occasional issue with tripping the over current on the pool pumps
2020-09-22 15:49:55 -05:00

258 lines
8.0 KiB
YAML

substitutions:
device_id: pool_pumps
device_name: Pool Pumps
platform: ESP8266
board: modwifi
ip_address: !secret pool_pumps_ip
ota_pwd: !secret pool_pumps_ota_pwd
api_pwd: !secret pool_pumps_api_pwd
ap_wifi_pwd: !secret pool_pumps_ap_wifi_pwd
esphome:
<<: !include common/esphome.yaml
<<: !include common/common.yaml
<<: !include common/logger/logger_debug_no_serial.yaml
binary_sensor:
- !include common/binary_sensor/status.yaml
i2c:
sda: GPIO12
scl: GPIO14
sensor:
- !include common/sensor/uptime.yaml
- !include common/sensor/wifi.yaml
- platform: ade7953
voltage:
name: ${device_name} Voltage
filters:
- multiply: 2
current_a:
name: Pool Cleaner Current
filters:
- lambda: |-
// Filter the initial high current spike when the motor starts to prevent tripping the on_value_range logic
static float last_cleaner_current = 0.0;
if (isnan(x))
{
return {};
}
if (last_cleaner_current <= 7 && x > 7)
{
last_cleaner_current = x;
return {};
}
return last_cleaner_current = x < .1 ? 0.0 : x;
on_value_range:
above: 7
then:
- switch.turn_off: pool_cleaner
current_b:
name: Pool Pump Current
filters:
- lambda: |-
// Filter the initial high current spike when the motor starts to prevent tripping the on_value_range logic
static float last_pump_current = 0.0;
if (isnan(x))
{
return {};
}
if (last_pump_current <= 8 && x > 8)
{
last_pump_current = x;
return {};
}
return last_pump_current = x < .1 ? 0.0 : x;
on_value_range:
above: 8
then:
- switch.turn_off: pool_pump
active_power_a:
name: Pool Cleaner Power
filters:
- lambda: "return x < .1 ? 0 : x * 2;"
active_power_b:
name: Pool Pump Power
filters:
- lambda: "return abs(x) < .1 ? 0 : abs(x) * 2;"
update_interval: 2s
- platform: ntc
sensor: temp_resistance_reading
name: ${device_name} Temperature
unit_of_measurement: "°C"
accuracy_decimals: 1
icon: "mdi:thermometer"
calibration:
b_constant: 3350
reference_resistance: 10kOhm
reference_temperature: 0°C
- platform: resistance
id: temp_resistance_reading
sensor: temp_analog_reading
configuration: DOWNSTREAM
resistor: 32kOhm
- platform: adc
id: temp_analog_reading
pin: A0
- platform: template
name: "Pool Mode Id"
id: pool_mode_id
internal: true
status_led:
pin:
number: GPIO0
inverted: yes
switch:
- !include common/switch/restart.yaml
- platform: gpio
pin: GPIO4
name: "Pool Pump"
id: pool_pump
icon: mdi:pump
on_turn_off:
then:
- switch.turn_off: pool_cleaner
- platform: gpio
pin: GPIO15
name: "Pool Cleaner"
id: pool_cleaner
icon: mdi:robot-vacuum
on_turn_on:
then:
- switch.turn_on: pool_pump
text_sensor:
- !include common/text_sensor/version.yaml
- !include common/text_sensor/wifi.yaml
- platform: homeassistant
name: "Pool Mode Text"
entity_id: input_select.pool_mode
on_value:
then:
- sensor.template.publish:
id: pool_mode_id
state: !lambda 'return x == "Off" ? 0 : x == "Normal" ? 1 : x == "Continuous Without Heat" ? 2 : x == "Continuous With Heat" ? 3 : id(pool_mode_id).state;'
time:
- platform: homeassistant
id: the_time
on_time:
seconds: 0
minutes: 0,15,30,45
then:
lambda: |-
if (id(pool_mode_id).state == 0)
{
auto ha_service = new api::HomeAssistantServiceCallAction<>(api_apiserver, false);
ha_service->set_service("switch.turn_off");
ha_service->add_data("entity_id", "switch.pool_heater");
ha_service->play();
id(pool_cleaner).turn_off();
id(pool_pump).turn_off();
}
else if (id(pool_mode_id).state == 1)
{
auto now = id(the_time).now();
int hour = now.hour;
int minute = now.minute;
if (hour == 4 && minute == 45)
{
auto ha_service = new api::HomeAssistantServiceCallAction<>(api_apiserver, false);
ha_service->set_service("switch.turn_off");
ha_service->add_data("entity_id", "switch.pool_heater");
ha_service->play();
id(pool_cleaner).turn_off();
id(pool_pump).turn_on();
}
else if (hour >= 5 && hour <= 6)
{
auto ha_service = new api::HomeAssistantServiceCallAction<>(api_apiserver, false);
ha_service->set_service("switch.turn_off");
ha_service->add_data("entity_id", "switch.pool_heater");
ha_service->play();
if (id(pool_pump).state)
{
id(pool_cleaner).turn_on();
}
else
{
id(pool_pump).turn_on();
}
}
else if (hour == 7)
{
auto ha_service = new api::HomeAssistantServiceCallAction<>(api_apiserver, false);
ha_service->set_service("switch.turn_on");
ha_service->add_data("entity_id", "switch.pool_heater");
ha_service->play();
id(pool_cleaner).turn_off();
id(pool_pump).turn_on();
}
else if (hour >= 8 && hour <= 21 && (minute == 0 || minute == 30))
{
id(pool_pump).turn_off();
}
else if (hour >= 8 && hour <= 21 && (minute == 15 || minute == 45))
{
auto ha_service = new api::HomeAssistantServiceCallAction<>(api_apiserver, false);
ha_service->set_service("switch.turn_on");
ha_service->add_data("entity_id", "switch.pool_heater");
ha_service->play();
id(pool_cleaner).turn_off();
id(pool_pump).turn_on();
}
else if (hour == 22 && minute == 0)
{
auto ha_service = new api::HomeAssistantServiceCallAction<>(api_apiserver, false);
ha_service->set_service("switch.turn_off");
ha_service->add_data("entity_id", "switch.pool_heater");
ha_service->play();
id(pool_cleaner).turn_off();
id(pool_pump).turn_on();
}
else
{
auto ha_service = new api::HomeAssistantServiceCallAction<>(api_apiserver, false);
ha_service->set_service("switch.turn_off");
ha_service->add_data("entity_id", "switch.pool_heater");
ha_service->play();
id(pool_cleaner).turn_off();
id(pool_pump).turn_off();
}
}
else if (id(pool_mode_id).state == 2)
{
auto ha_service = new api::HomeAssistantServiceCallAction<>(api_apiserver, false);
ha_service->set_service("switch.turn_off");
ha_service->add_data("entity_id", "switch.pool_heater");
ha_service->play();
if (id(pool_pump).state)
{
id(pool_cleaner).turn_on();
}
else
{
id(pool_pump).turn_on();
}
}
else if (id(pool_mode_id).state == 3)
{
auto ha_service = new api::HomeAssistantServiceCallAction<>(api_apiserver, false);
ha_service->set_service("switch.turn_on");
ha_service->add_data("entity_id", "switch.pool_heater");
ha_service->play();
if (id(pool_pump).state)
{
id(pool_cleaner).turn_on();
}
else
{
id(pool_pump).turn_on();
}
}