This commit is contained in:
@@ -2,10 +2,6 @@
|
||||
substitutions:
|
||||
devicename: watercontrol
|
||||
upper_devicename: Watercontrol
|
||||
pin_cold: D1
|
||||
init_cold: '216.08'
|
||||
pin_hot: D2
|
||||
init_hot: '112.3'
|
||||
water_open_pin: D5
|
||||
water_close_pin: D3
|
||||
ultrasonic_echo_pin: D6
|
||||
@@ -19,6 +15,10 @@ esphome:
|
||||
name: $devicename
|
||||
platform: ESP8266
|
||||
board: d1_mini
|
||||
libraries:
|
||||
- "Bounce2"
|
||||
includes:
|
||||
- water_counters.h
|
||||
|
||||
wifi:
|
||||
ssid: !secret wifi_24_name
|
||||
@@ -43,58 +43,25 @@ globals:
|
||||
type: bool
|
||||
restore_value: yes
|
||||
initial_value: 'true'
|
||||
- id: counter_cold_value
|
||||
type: float
|
||||
restore_value: yes
|
||||
initial_value: $init_cold
|
||||
- id: counter_hot_value
|
||||
type: float
|
||||
restore_value: yes
|
||||
initial_value: $init_hot
|
||||
|
||||
binary_sensor:
|
||||
- platform: gpio
|
||||
id: pulse_cold
|
||||
pin:
|
||||
number: $pin_cold
|
||||
mode: INPUT_PULLUP
|
||||
filters:
|
||||
- delayed_on: 1s
|
||||
- delayed_off: 1s
|
||||
on_press:
|
||||
then:
|
||||
- lambda: 'id(counter_cold_value) += 0.01;'
|
||||
|
||||
- platform: gpio
|
||||
id: pulse_hot
|
||||
pin:
|
||||
number: $pin_hot
|
||||
mode: INPUT_PULLUP
|
||||
filters:
|
||||
- delayed_on: 1s
|
||||
- delayed_off: 1s
|
||||
on_press:
|
||||
then:
|
||||
- lambda: 'id(counter_hot_value) += 0.01;'
|
||||
|
||||
#------------------------------------------------------------------------------
|
||||
sensor:
|
||||
- platform: uptime
|
||||
name: "$upper_devicename Uptime"
|
||||
|
||||
- platform: template
|
||||
name: "counter_hot"
|
||||
accuracy_decimals: 2
|
||||
#------------------------------------------------------------------------------
|
||||
- platform: custom
|
||||
lambda: |-
|
||||
return id(counter_hot_value);
|
||||
update_interval: 60s
|
||||
|
||||
- platform: template
|
||||
name: "counter_cold"
|
||||
accuracy_decimals: 2
|
||||
lambda: |-
|
||||
return id(counter_cold_value);
|
||||
update_interval: 60s
|
||||
auto my_sensor = new WaterCountersSensor();
|
||||
App.register_component(my_sensor);
|
||||
return {my_sensor->cold_sensor, my_sensor->hot_sensor};
|
||||
sensors:
|
||||
- name: "Counter Cold"
|
||||
accuracy_decimals: 2
|
||||
- name: "Counter Hot"
|
||||
accuracy_decimals: 2
|
||||
|
||||
#------------------------------------------------------------------------------
|
||||
- platform: ultrasonic
|
||||
trigger_pin: $ultrasonic_trig_pin
|
||||
echo_pin: $ultrasonic_echo_pin
|
||||
@@ -130,13 +97,4 @@ switch:
|
||||
- switch.turn_on: water_close
|
||||
- delay: 5s
|
||||
- switch.turn_off: water_close
|
||||
- lambda: 'id(water_state) = false;'
|
||||
|
||||
- platform: template
|
||||
name: "Reset"
|
||||
turn_on_action:
|
||||
- lambda: 'id(counter_cold_value) = 216.08;'
|
||||
- lambda: 'id(counter_hot_value) = 112.3;'
|
||||
turn_off_action:
|
||||
- lambda: 'id(counter_cold_value) = 216.08;'
|
||||
- lambda: 'id(counter_hot_value) = 112.3;'
|
||||
- lambda: 'id(water_state) = false;'
|
||||
Reference in New Issue
Block a user