Split measured value  [Solved]

Easy to use, 100% Lua-based event scripting framework.

Moderator: leecollings

Post Reply
Knibor
Posts: 112
Joined: Sunday 20 May 2018 12:56
Target OS: Raspberry Pi / ODroid
Domoticz version: Stable
Location: NL
Contact:

Split measured value

Post by Knibor »

Hello,

I have a device called "Electric (Instant+Counter)". I want to create a new device that only shows the counter value. Can someone give me an example of how to do this in dzVents?

Thank you very much
User avatar
waaren
Posts: 6028
Joined: Tuesday 03 January 2017 14:18
Target OS: Linux
Domoticz version: Beta
Location: Netherlands
Contact:

Re: Split measured value

Post by waaren »

Knibor wrote: Friday 05 March 2021 17:32 I want to create a new device that only shows the counter value. Can someone give me an example of how to do this in dzVents?
What kind of device should the target be? A text device or a counter or a custom sensor or something else?
Debian buster, bullseye on RPI-4, Intel NUC.
dz Beta, Z-Wave, RFLink, RFXtrx433e, P1, Youless, Hue, Yeelight, Xiaomi, MQTT
==>> dzVents wiki
Knibor
Posts: 112
Joined: Sunday 20 May 2018 12:56
Target OS: Raspberry Pi / ODroid
Domoticz version: Stable
Location: NL
Contact:

Re: Split measured value

Post by Knibor »

Hi,

I currently have a device of the type "General, kWh".
This device gives me two values. The first is the current solar energy and the second is the value of today's total solar energy in kWh. I would like a separate device that only displays the kWh generated by the solar panels today. The device I would like to use is of the Text device.
User avatar
waaren
Posts: 6028
Joined: Tuesday 03 January 2017 14:18
Target OS: Linux
Domoticz version: Beta
Location: Netherlands
Contact:

Re: Split measured value  [Solved]

Post by waaren »

Knibor wrote: Saturday 06 March 2021 11:12 I currently have a device of the type "General, kWh".
I would like a separate device that only displays the kWh generated by the solar panels today. The device I would like to use is of the Text device.
Could look like script below

Code: Select all

return
{
    on =
    {
        devices =
        {
            2515, -- change to idx of your solar device
        },
    },

    logging =
    {
        level = domoticz.LOG_DEBUG, -- change to domoticz.LOG_ERROR when all is ok
        marker = 'solar to text',
    },

    execute = function(dz, item)
        local solar = dz.devices('solar energy today') -- change to name of your text device
        local currentText = solar.text

        local newtext = item.counterToday .. ' kWh'

        if currentText ~= newtext then
            solar.updateText(newtext)
        end
    end
}
Debian buster, bullseye on RPI-4, Intel NUC.
dz Beta, Z-Wave, RFLink, RFXtrx433e, P1, Youless, Hue, Yeelight, Xiaomi, MQTT
==>> dzVents wiki
Knibor
Posts: 112
Joined: Sunday 20 May 2018 12:56
Target OS: Raspberry Pi / ODroid
Domoticz version: Stable
Location: NL
Contact:

Re: Split measured value

Post by Knibor »

Hi,

Thanks a lot for the script. It works now.
Post Reply

Who is online

Users browsing this forum: No registered users and 1 guest