Gas Meter with Shelly Plus Uni

I decided to use the Shelly Plus Uni as a device to read the reed contact, which counts the impulses from my gas meter.

The first unit I received was unfortunately dead on arrival, but Shelly’s support was very helpful and quickly replaced it.

For the Home Assistant Shelly integration, I had to patch the sensor.py file to support the COUNT IN function (source 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
+        ),
+    ),
 }

After initial testing, everything is working fine and looks promising. Now I’m looking for a case to secure it more permanently to the gas meter. I found a 3D-printed case that fits everything well by wiring the outputs and inputs accordingly.

Now, the setup works perfectly, and I was even able to add a temperature and humidity sensor (DHT / 2302), so I’m quite happy with the results.

Let me know if you have any questions!