After some update, using the same pin is no longer possible. Use the copy component.
Ran into this issue with my gas meter, that uses a reed switch, with pulse_counter and pulse_meter both using the same reed switch / PIN. See the function of:
allow_other_uses: true
as used below:
- platform: pulse_counter
name: "Gas - Pulse Counter"
id: gas_pulse_counter
pin:
number: 32
allow_other_uses: true
inverted: true
mode:
input: true
pullup: true
- platform: pulse_meter
name: 'Gas - Flow Rate'
id: "gas_flow_rate"
unit_of_measurement: "L/min" # "m³/h"
state_class: measurement
# device_class: volume # Disabled to stop this being recorded in HA
icon: "mdi:pump"
accuracy_decimals: 3
pin:
number: 32
allow_other_uses: true
inverted: true
mode:
input: true
pullup: true
internal_filter_mode: PULSE
internal_filter: 100ms
timeout: 3min
filters:
- multiply: 10.0 # 1 pulse = 10L
Sorry I didn’t notice your using an ultrasonic sensor. Best option is to use a proper liquid pressure sensor, as used in commercial solutions, especially as your talking ~USD$25 now for one.
If of interest, see: https://www.aliexpress.com/item/33003863661.html just needs the 0-5V version and choose the ‘smallest’ range to suit your tank, as this makes it more accurate. i.e. If you have a 1.2m tall tank get a 2m range model, 2.8m tank get a 3m range model… if you have a 1m tank and get a 5m range model, it will work but it will have less level of granularity.
https://www.aliexpress.com/item/33003863661.html
With this you just need to connect it into an ADC, or just buy a board that’s ready to connect it to, such as: https://www.aliexpress.com/item/1005006976454212.html
If its of use to anyone I can assemble a config you can paste into a device yaml, that pulls all the different senors and packages to give a water tank device with either a ds18b20 (temp) or BME280 (temp/humidity/pressure) sensor. Output is like: