The setup works great with a Shelly Plus Uni, which has the advantage of using the ‘COUNT IN’ signal on Pin 8 to read impulses from an inductive sensor.
For my Sensus 620 water meter, I used a 3D-printed adapter (see here) to install it.
(Not the cleanest, but a quick setup. I also added a temperature sensor!)
EDIT:
By the way, I just remembered that I had to patch the Shelly integration, since the COUNT IN feature is only supported in the dev version of the integration (see here).
--- /usr/src/homeassistant/homeassistant/components/shelly/sensor.py.original
+++ /usr/src/homeassistant/homeassistant/components/shelly/sensor.py
@@ -960,6 +960,30 @@
native_unit_of_measurement=PERCENTAGE,
state_class=SensorStateClass.MEASUREMENT,
),
+ "analoginput_xpercent": RpcSensorDescription(
+ key="input",
+ sub_key="xpercent",
+ name="Analog value",
+ ),
+ "pulse_counter": RpcSensorDescription(
+ key="input",
+ sub_key="counts",
+ name="Pulse counter",
+ native_unit_of_measurement="pulse",
+ state_class=SensorStateClass.TOTAL,
+ value=lambda status, _: status["total"],
+ removal_condition=lambda config, _status, key: (config[key]["enable"] is False),
+ ),
+ "counter_value": RpcSensorDescription(
+ key="input",
+ sub_key="counts",
+ name="Counter value",
+ value=lambda status, _: status["xtotal"],
+ removal_condition=lambda config, status, key: (
+ config[key]["enable"] is False
+ or status[key]["counts"].get("xtotal") is None
+ ),
+ ),
}