ebaauw / homebridge-rpi

Homebridge plugin for Raspberry Pi.
Apache License 2.0
308 stars 18 forks source link

Flow Sensor for water consumption #41

Closed ih8ra1N closed 4 years ago

ih8ra1N commented 4 years ago

Hi, how do I integrate ab waterfowl Sensor for measuring water consumption per Liter. BR Flo

ebaauw commented 4 years ago

I have no idea. How do you connect the sensor?

ih8ra1N commented 4 years ago

Hi, it’s connected with an YF-S201 Chip on GPIO pin and switched by relay. I haven’t found a metric/ type to measure the water consumption. Here my current config:

"accessories": [
    {
        "type": "airPressureSensor",
        "name": "flowsensor",
        "url": "http://192.168.1.5:1883",
        "mqttPubOptions": {
            "retain": false
        },
        "topics": {
            "getCurrentRelativeHumidity": "/Garden.Pi/WaterFlow",
            "getInUse": "/Garden.Pi/WaterFlow"
        },
        "startPub": [
            {
                "topic": "/Garden.Pi/WaterFlow"
            }
        ],
        "integerValue": true,
        "history": true,
        "accessory": "mqttthing"
    }
],
"platforms": [
    {
        "name": "RPi",
        "hosts": [
            {
                "host": "localhost",
                "name": "Raspberry",
                "devices": [
                    {
                        "device": "valve",
                        "name": "Pumpe",
                        "gpio": 23,
                        "reversed": true
                    },
                    {
                        "device": "switch",
                        "name": "Flow Sensor",
                        "gpio": 13,
                        "reversed": true
                    }
                ]
            }
        ],
        "platform": "RPi"
ebaauw commented 4 years ago

I take it, the valve device is the relay to switch the pump on and off? That should already work?

switch is an output device (like valve), so that won't work with a sensor. Could you try and configure a button device for the flow sensor? You should see the button activate on each pulse sent by the YF-S201. I have no idea what rate of pulses to expect, the button has a hardcoded debounce time of 20ms, so it should work as long as the rate is (well) below 50 pulses per second.

If that works, we would have to convert the pulses to litres for total water consumption. I suppose that would be a config.json parameter. I don't think HomeKit defines any standard characteristic for water consumption. I'm not sure I understand the Eve Aqua well enough to expose the sensor as such. Alternatively, I could expose abuse Total Consumption for electricity (as I do for the Gas meter in Homebridge P1). This will cause Eve to show kWh instead of l, but it will expose history.

ebaauw commented 4 years ago

Closing since I don't get the asked info.