Pool pumps updates

Replace mdi:hotel with mdi:bed
This commit is contained in:
ChNussbaum 2020-07-22 20:27:19 -05:00
parent 09957f460c
commit 3077d3d944
2 changed files with 119 additions and 37 deletions

View File

@ -71,14 +71,11 @@ sensor:
- sensor.template.publish:
id: chris_bed_percent
state: !lambda 'return (1024 - x) / 1024 * 100;'
- binary_sensor.template.publish:
id: someone_in_bed
state: !lambda 'return !id(melissa_in_bed).state && !id(chris_in_bed).state && id(melissa_bed_percent).state > 40 && id(chris_bed_percent).state > 40;'
- platform: template
name: "Melissa Bed Percent"
id: melissa_bed_percent
icon: "mdi:hotel"
icon: "mdi:bed"
unit_of_measurement: "%"
accuracy_decimals: 0
on_value:
@ -92,7 +89,7 @@ sensor:
- platform: template
name: "Chris Bed Percent"
id: chris_bed_percent
icon: "mdi:hotel"
icon: "mdi:bed"
unit_of_measurement: "%"
accuracy_decimals: 0
on_value:
@ -108,7 +105,7 @@ sensor:
name: "Master Bed Count"
id: master_bed_count
accuracy_decimals: 0
icon: "mdi:hotel"
icon: "mdi:bed"
on_value:
then:
- text_sensor.template.publish:
@ -138,4 +135,4 @@ text_sensor:
- platform: template
name: "Master Bed Status"
id: master_bed_status
icon: "mdi:hotel"
icon: "mdi:bed"

View File

@ -27,18 +27,32 @@ sensor:
- platform: ade7953
voltage:
name: ${device_name} Voltage
filters:
- multiply: 2
current_a:
name: Pool Cleaner Current
filters:
- lambda: "return x < .1 ? 0 : x;"
on_value_range:
above: 10
then:
- switch.turn_off: pool_cleaner
current_b:
name: Pool Pump Current
filters:
- lambda: "return x < .1 ? 0 : x;"
on_value_range:
above: 8
then:
- switch.turn_off: pool_pump
active_power_a:
name: Pool Cleaner Power
filters:
- multiply: -1
- lambda: "return x < .1 ? 0 : x * 2;"
active_power_b:
name: Pool Pump Power
filters:
- multiply: -1
- lambda: "return abs(x) < .1 ? 0 : abs(x) * 2;"
update_interval: 2s
- platform: ntc
sensor: temp_resistance_reading
@ -49,7 +63,7 @@ sensor:
calibration:
b_constant: 3350
reference_resistance: 10kOhm
reference_temperature: 298.15K
reference_temperature: 0°C
- platform: resistance
id: temp_resistance_reading
sensor: temp_analog_reading
@ -74,6 +88,7 @@ switch:
pin: GPIO4
name: "Pool Pump"
id: pool_pump
icon: mdi:pump
on_turn_off:
then:
- switch.turn_off: pool_cleaner
@ -81,6 +96,7 @@ switch:
pin: GPIO15
name: "Pool Cleaner"
id: pool_cleaner
icon: mdi:robot-vacuum
on_turn_on:
then:
- switch.turn_on: pool_pump
@ -105,44 +121,113 @@ time:
minutes: 0,15,30,45
then:
lambda: |-
if (id(pool_mode_id).state == 1) {
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 == 5 && minute == 0) {
auto ha_service = new api::HomeAssistantServiceCallAction<>(api_apiserver);
if (hour == 4 && minute == 45)
{
auto ha_service = new api::HomeAssistantServiceCallAction<>(api_apiserver, false);
ha_service->set_service("switch.turn_off");
ha_service->set_data({api::KeyValuePair("entity_id", "switch.pool_heater")});
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 if (hour == 7 && minute == 0) {
else
{
id(pool_pump).turn_on();
id(pool_cleaner).turn_off();
auto ha_service = new api::HomeAssistantServiceCallAction<>(api_apiserver);
ha_service->set_service("switch.turn_on");
ha_service->set_data({api::KeyValuePair("entity_id", "switch.pool_heater")});
ha_service->play();
}
else if (hour >= 8 && hour <= 21 && (minute == 0 || minute == 30)) {
id(pool_pump).turn_off();
}
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 if (hour >= 8 && hour <= 21 && (minute == 15 || minute == 45)) {
else
{
id(pool_pump).turn_on();
id(pool_cleaner).turn_off();
auto ha_service = new api::HomeAssistantServiceCallAction<>(api_apiserver);
ha_service->set_service("switch.turn_on");
ha_service->set_data({api::KeyValuePair("entity_id", "switch.pool_heater")});
ha_service->play();
}
else if (hour == 22 && minute == 0) {
auto ha_service = new api::HomeAssistantServiceCallAction<>(api_apiserver);
ha_service->set_service("switch.turn_off");
ha_service->set_data({api::KeyValuePair("entity_id", "switch.pool_heater")});
ha_service->play();
id(pool_cleaner).turn_off();
id(pool_pump).turn_off();
}
}
}