arachnetech / homebridge-mqttthing

A plugin for Homebridge allowing the integration of many different accessory types using MQTT.
Apache License 2.0
466 stars 104 forks source link

Valve with history? (mimic Eve Aqua) #612

Open phloryan opened 1 year ago

phloryan commented 1 year ago

I'm trying to monitor my showering times and bought an Aqara Leak Sensor which is basically used "in reverse", when a leak is recognised it will switch the valve on, off when no leak is recognised. Because history: true doesn't work with valves I combined it with a contact sensor to see when it was on, here's my config for anyone interested:

{
    "accessory": "mqttthing",
    "type": "custom",
    "name": "AqaraWaterLeak",
    "url": "...",
    "logMqtt": true,
    "services": [
        {
            "type": "contactSensor",
            "name": "AqaraWaterLeak-2",
            "history": true,
            "topics": {
                "getContactSensorState": {
                    "topic": "zigbee2mqtt/...",
                    "apply": "return JSON.parse(message).water_leak || false"
                }
            }
        },
        {
            "type": "valve",
            "name": "AqaraWaterLeak-1",
            "valveType": "shower",
            "topics": {
                "setActive": {
                    "topic": "zigbee2mqtt/...",
                    "apply": "return JSON.stringify({water_leak: !message})"
                },
                "getActive": {
                    "topic": "zigbee2mqtt/...",
                    "apply": "return JSON.parse(message).water_leak ? 1 : 0"
                },
                "getInUse": {
                    "topic": "zigbee2mqtt/...",
                    "apply": "return JSON.parse(message).water_leak ? 1 : 0"
                },
                "getBatteryLevel": {
                    "topic": "zigbee2mqtt/...",
                    "apply": "return parseInt(JSON.parse(message).battery, 10)"
                }
            },
            "integerValue": true
        }
    ]
}

And it works as intended. However, I saw that Eve Aqua has a nice history: https://www.evehome.com/en/blog/eve-aqua-all-features (last watered and estimated consumption). fakegato-history seems to support it as well: https://github.com/simont77/fakegato-history/wiki/Services-and-characteristics-for-Elgato-Eve-devices#elgato-eve-aqua

So any chance to support history here too? Would be awesome!