diff --git a/aquapi_config.yaml b/aquapi_config.yaml index 97d69f3..529a519 100644 --- a/aquapi_config.yaml +++ b/aquapi_config.yaml @@ -10,6 +10,7 @@ packages: aquapi: !include common/aquapi.yaml # ota_https: !include common/ota_https.yaml dallas: !include common/temperature_dallas.yaml + optical: !include common/optical.yaml binary: !include common/binary.yaml # ir_receiver: !include common/ir_receiver.yaml # dht: !include common/dht.yaml @@ -24,5 +25,6 @@ packages: ezo_pmp: !include common/ezo_pmp.yaml # ezo_pmp_extra: !include common/ezo_pmp_extra.yaml ezo_pmp_duo: !include common/ezo_pmp_duo.yaml + # dac: !include common/dac.yaml # ezo_commands: !include common/ezo_commands.yaml # debug: !include common/debug.yaml diff --git a/common/binary.yaml b/common/binary.yaml index 7a72527..5920cf6 100644 --- a/common/binary.yaml +++ b/common/binary.yaml @@ -1,87 +1,28 @@ -substitutions: - # Optical_1 - opticalLowPin: "33" # yellow - opticalHighPin: "32" # blue - # AUX_1 - DAC - auxPin: "26" # yellow - - # Water Level - update_water: "60s" - -esphome: - on_boot: - priority: 200 - then: - - component.update: water_level +substitutions: + binary_1: "13" # yellow + binary_2: "27" # blue binary_sensor: - # Optical Sensor - LOW (yellow) - platform: gpio - id: os_low - # disabled_by_default: true + id: binary_1 pin: - number: ${opticalLowPin} + number: ${binary_1} inverted: true mode: input: true pullup: true - name: "Optical Sensor: Low" + name: "Binary 1" filters: - delayed_on_off: 30ms - on_state: - then: - component.update: water_level - # Optical Sensor - HIGH (blue) - platform: gpio - id: os_high - # disabled_by_default: true + id: binary_2 pin: - number: ${opticalHighPin} + number: ${binary_2} inverted: true mode: input: true pullup: true - name: "Optical Sensor: High" + name: "Binary 2" filters: - delayed_on_off: 30ms - on_state: - then: - component.update: water_level - - # Additional Pin 1 - - platform: gpio - id: aux_1 - disabled_by_default: true - pin: - number: ${auxPin} - inverted: true - mode: - input: true - pullup: true - name: Aux 1 - filters: - - delayed_on_off: 30ms - -text_sensor: - # Water Level - - platform: template - icon: mdi:waves-arrow-up - name: "Water Level" - id: water_level - update_interval: "${update_water}" - lambda: |- - if(id(os_high).state == true && id(os_low).state == true) { - // Water Level is High - return {"High"}; - } - if(id(os_high).state == false && id(os_low).state == false) { - // Water Level is Low - return {"Low"}; - } - if(id(os_high).state == false && id(os_low).state == true) { - // Water Level is Normal - return {"Normal"}; - } else { - return {"Uknown or Error"}; - } diff --git a/common/dac.yaml b/common/dac.yaml new file mode 100644 index 0000000..f8c4e35 --- /dev/null +++ b/common/dac.yaml @@ -0,0 +1,33 @@ +# TODO +substitutions: + dac_1: "26" # yellow + dac_2: "25" # blue + +binary_sensor: + # DAC Pin 1 + - platform: gpio + id: aux_1 + disabled_by_default: true + pin: + number: ${dac_1} + inverted: true + mode: + input: true + pullup: true + name: DAC 1 + filters: + - delayed_on_off: 30ms + + # DAC Pin 1 + - platform: gpio + id: aux_1 + disabled_by_default: true + pin: + number: ${dac_2} + inverted: true + mode: + input: true + pullup: true + name: DAC 1 + filters: + - delayed_on_off: 30ms diff --git a/common/optical.yaml b/common/optical.yaml new file mode 100644 index 0000000..a116e37 --- /dev/null +++ b/common/optical.yaml @@ -0,0 +1,71 @@ +substitutions: + # Optical_1 + opticalLowPin: "33" # yellow + opticalHighPin: "32" # blue + + # Water Level + update_water: "60s" + +esphome: + on_boot: + priority: 200 + then: + - component.update: water_level + +binary_sensor: + # Optical Sensor - LOW (yellow) + - platform: gpio + id: os_low + # disabled_by_default: true + pin: + number: ${opticalLowPin} + inverted: true + mode: + input: true + pullup: true + name: "Optical Sensor: Low" + filters: + - delayed_on_off: 30ms + on_state: + then: + component.update: water_level + + # Optical Sensor - HIGH (blue) + - platform: gpio + id: os_high + # disabled_by_default: true + pin: + number: ${opticalHighPin} + inverted: true + mode: + input: true + pullup: true + name: "Optical Sensor: High" + filters: + - delayed_on_off: 30ms + on_state: + then: + component.update: water_level + +text_sensor: + # Water Level + - platform: template + icon: mdi:waves-arrow-up + name: "Water Level" + id: water_level + update_interval: "${update_water}" + lambda: |- + if(id(os_high).state == true && id(os_low).state == true) { + // Water Level is High + return {"High"}; + } + if(id(os_high).state == false && id(os_low).state == false) { + // Water Level is Low + return {"Low"}; + } + if(id(os_high).state == false && id(os_low).state == true) { + // Water Level is Normal + return {"Normal"}; + } else { + return {"Uknown or Error"}; + }