simont77 / fakegato-history

Module to emulate Elgato Eve history
MIT License
166 stars 17 forks source link

Eve Aqua - some working data #89

Closed n0rt0nthec4t closed 4 years ago

n0rt0nthec4t commented 4 years ago

So, been playing around with the coding I've developed to get my irrigation system data into Eve Home via using the Eve Aqua type. Based on the dumps in the wiki, and playing around, Ive managed to get my valve usage into Eve Home.

I'm assuming somewhere in the get string "0002230003021b04040c4156323248314130303036330602080007042a3000000b0200000501000204f82c00001401030f0400000000450505000000004609050000000e000042064411051c0005033c0000003a814b42a34d8c4047110594186d19071ad91ab40000003c00000048060500000000004a06050000000000d004 %s 9b04 %s 2f0e %s 00000000 00000000 %s 2d06 0000000000001e02300c",

Its encoded to mention schedules.

Need to have the Get and Set characteristics Characteristic.EveGetConfiguration.UUID = "E863F131-079E-48FF-8F27-9C2605A29F52"; Characteristic.EveSetConfiguration.UUID = "E863F11D-079E-48FF-8F27-9C2605A29F52";

With the the EveSetConfiguration, I have a callback to return the value passed in. This is an entry I get back under the set "471105301ce61c9c1d521e780000003c00000044110514000000580200003a814b42a34d8c40"

Perhaps some scheduling or something..

My function code for the callback on EveGetConfiguration is as follows:

HomeKitHistory.prototype.__EveAquaWaterDetails = function(history) {
    // returns an encoded valve formatted for an Eve Aqua device for water usage and last water time
    if (typeof history == "undefined") {
        var tempHistory = this.getHistory(Service.Valve.UUID, null);
    } else {
        // save us getting a histoy array if already passed in
        var tempHistory = history
    }

    // Calculate total water usage over history period
    var totalWater = 0;
    tempHistory.forEach(historyEntry => {
        if (historyEntry.status == 0) {
            // add to total water usage if we have a valve closed event
            totalWater += parseFloat(historyEntry.water);
        }
    });

    var lastTime = Math.floor(new Date() / 1000);
    if (tempHistory.length != 0) {
        lastTime = tempHistory[tempHistory.length - 1].time;
    }

    var value = util.format(
        "0002230003021b04040c4156323248314130303036330602080007042a3000000b0200000501000204f82c00001401030f0400000000450505000000004609050000000e000042064411051c0005033c0000003a814b42a34d8c4047110594186d19071ad91ab40000003c00000048060500000000004a06050000000000d004 %s 9b04 %s 2f0e %s 00000000 00000000 %s 2d06 0000000000001e02300c",
        numToHex(swap32(lastTime), 8),  // time of last event, 0 if never watered
        numToHex(swap32(Math.floor(new Date() / 1000)), 8), // "now" time, zero if never watered
        numToHex(swap32(totalWater * 1000), 8), // total water usage in ml
        numToHex(swap16(0), 4)); // water flux in ml/s. flow rate??
    return hexToBase64(value);
};

Hope someone finds this useful and perhaps code up a PR for fakegato

IMG_2011 IMG_2012 IMG_2009 IMG_2010

n0rt0nthec4t commented 4 years ago

AND.. Now with decoded schedules :-)