domoticz / domoticz

Open source Home Automation System
http://www.domoticz.com
GNU General Public License v3.0
3.5k stars 1.13k forks source link

Request for support: Youless LS120 now supports a water meter #6129

Closed mvdw closed 3 months ago

mvdw commented 3 months ago

The Youless LS120 now supports the water meter, too. It would be nice if Domoticz could add the water meter device.

See https://youless.nl/blogpost/items/ls120-fw160.html

Screenshot_youless

gizmocuz commented 3 months ago

Thanks for the heads up. Is it possible to post a result of a API call including this? Maybe another one after a few liters water has been usage

mvdw commented 3 months ago

Yes, I could give some more info.

Currently, I mimic the water meter with a dzvents script - I would like to get rid of this - it works though:

-- Youless parser for JSON handling data with the following structure
-- [{"tm":1694719686,"net": 4773.861,"pwr": 652,"ts0":1694616057,"cs0": 0.000,"ps0": 0,"p1": 1739.144,"p2": 3106.267,"n1": 43.085,"n2": 28.465,"gas": 614.907,"gts":2309142124,"wtr": 155.896,"wts":2309142125}]
-- A test with curl would be : curl -s http://10.0.3.44/e | jq '.[0] | .wtr'
-- The Water volume is "wtr" and it is a floating point number formatted like "155.902".
-- The Domoticz device is a Gas of type "P1 Smart Meter" with name "Water" - chosen because of the unit: m3.

return {
    on = {
        timer = {
            'every 5 minutes',
            -- 'every minute' -- for debug
        },
        httpResponses = {
            'PollYouLessWater' -- must match with the callback passed to the openURL command
        }
    },
    logging = {
        level = domoticz.LOG_ERROR,
        marker = 'PollYouLessWater',
    },
    execute = function(domoticz, item)

        if (item.isTimer) then
            domoticz.openURL({
                url = 'http://10.0.3.44/e',
                method = 'GET',
                callback = 'PollYouLessWater', -- see httpResponses above.
            })
        end

        if (item.isHTTPResponse) then

            if (item.ok) then
                if (item.isJSON) then

                    local wtr = item.json[1].wtr
                    domoticz.log('Fetching PollYouLessWater ' .. tostring(tr), domoticz.LOG_INFO)
                    -- update our device in Domoticz
                    domoticz.devices(408).updateGas(wtr * 1000) -- convert the value into dm3
                end
            else
                domoticz.log('There was a problem handling the request', domoticz.LOG_ERROR)
                domoticz.log(item, domoticz.LOG_ERROR)
            end

        end

    end
}

One of the problems with this "gas" device 408 that shows the water: the icon refuses to be shown as a water drop...

Result of the API call:

If I use my browser to go to http://10.0.3.44/e then I get this:

[{"tm":1722094789,"net": 5157.589,"pwr":-1569,"ts0":1714118210,"cs0": 0.000,"ps0": 0,"p1": 2804.286,"p2": 4714.609,"n1": 1698.252,"n2": 663.054,"gas": 1230.826,"gts":2407271735,"wtr": 314.282,"wts":2407271735}]

and a little bit later:

[{"tm":1722095106,"net": 5157.482,"pwr":-1070,"ts0":1714118210,"cs0": 0.000,"ps0": 0,"p1": 2804.286,"p2": 4714.609,"n1": 1698.252,"n2": 663.161,"gas": 1230.871,"gts":2407271740,"wtr": 314.306,"wts":2407271745}]
waltervl commented 3 months ago

You could have used a dummy Counter device, set to type Water, see wiki https://www.domoticz.com/wiki/Dummy_for_virtual_Switches#Counter

gizmocuz commented 3 months ago

@mvdw , Thanks for the JSON outputs!

Could you try beta 16167, you should now get a new (water) meter device. You can edit this device and set its type to Water

mvdw commented 3 months ago

Thanks! I changed the release channel to beta, did "check for update" in the setup menu, installed the 16167 version. Immediately, the following device appears in the device list - see screenshot. NewYoulessDevice

The water meter value is correct, the unit not yet: "kWh" should be "m3".

Then I renamed the device from "Water" to "Youless Water", and activated it. Now it appears in the Utility tab: Utility-YouLessWater

mvdw commented 3 months ago

And then edited the device, and set the type to Water. See screenshot: Utility-Y-Water The m3 should be 317,710, not 3177,100.

gizmocuz commented 3 months ago

Under settings/meters, the water divider is still set to default 1000? In this case, we need to divide the Youless value by 10, because now everything is 10x to high correct? (should also be 8 liters)

mvdw commented 3 months ago

No the divider setting is 100. I do not know why - I never changed this IIRC. WaterDividerSetting

gizmocuz commented 3 months ago

Sorry, default is indeed 100, I needed 1000 because I build my own ESP based meter. Okey perfect, so when you set this to 1000, it should be OK?

gizmocuz commented 3 months ago

But maybe it is best to get it working by using the default 100.... let me know what you prefer ... dividing the value from Youless or use 1000 in Domoticz

mvdw commented 3 months ago

Yes, with the setting changed, it gets correct: Setting-changed

gizmocuz commented 3 months ago

Perfect, then we keep using the original value of Youless. How does it connect to your water meter? My water meter has no related to my smart meter

mvdw commented 3 months ago

Thanks! The water meter connects wireless - there are no wires. At the time the 3 new meters were installed (el, water, gas - by 1 person), they were "paired" in some way. I have no idea what standard they follow. Only the electricity meter communicates (wireless) with the company. The gas and water meters communicate wireless with the electricity meter. FYI: this is what my water meter looks like: p1 p2

gizmocuz commented 3 months ago

Wow! Great watermeter! This could become the default one day....

mvdw commented 3 months ago

The LCD only shows something if you press the blue button. I wonder if that symbol with 2038 in it, is a battery ...

But anyhow - thanks for the help!

Maybe we should add some documentation about the Youless in the Domoticz wiki? There is no page for this device AFAIK.