Something stupid , a dummy problem "actualWatt"

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

Moderator: leecollings

Post Reply
PeterRozenveld
Posts: 38
Joined: Sunday 15 October 2023 18:44
Target OS: Raspberry Pi / ODroid
Domoticz version:
Contact:

Something stupid , a dummy problem "actualWatt"

Post by PeterRozenveld »

I keep getting an error in line 21:
" Local kmptt = .... "
Does a Dummy (Watts) have different value names ?

And is it possible to use the IF and THEN statement several times in a row ?

Code: Select all

return
{
    on =
    {
        devices =
        {
            'Kookplaat_F1_(Rechts)',
            'Kookplaat_F3_(Links_Flexzone)',
            'Tot_Fornuis'
        },
    },

    logging =
    {
        level = domoticz.LOG_DEBUG,
        marker = 'Regulating Afz_350',
    },

    execute = function(dz, devices)

    local kpmtt = domoticz.devices('Tot_Fornuis')  -- Tot_Fornuis is a dummy. But .usage or .actualWatt doesn´t work !
       
        if kpmtt >= 100 and kmptt < 350  then 
                domoticz.openURL('192.168.2.171/light/0?turn=on&brightness=45')
        end
end
} 
User avatar
waltervl
Posts: 5394
Joined: Monday 28 January 2019 18:48
Target OS: Linux
Domoticz version: 2024.7
Location: NL
Contact:

Re: Something stupid , a dummy problem "actualWatt"

Post by waltervl »

Check the device type and see what are the available Dzvents properties for that device (dummy or not does not matter): https://wiki.domoticz.com/DzVents:_next ... ic_devices
Domoticz running on Udoo X86 (on Ubuntu)
Devices/plugins: ZigbeeforDomoticz (with Xiaomi, Ikea, Tuya devices), Nefit Easy, Midea Airco, Omnik Solar, Goodwe Solar
PeterRozenveld
Posts: 38
Joined: Sunday 15 October 2023 18:44
Target OS: Raspberry Pi / ODroid
Domoticz version:
Contact:

Re: Something stupid , a dummy problem "actualWatt"

Post by PeterRozenveld »

I tried the following
local kpmtt = domoticz.devices(‘Tot Stove’).Energy
local kpmtt = domoticz.devices(‘To-Stove’).Usage
local kpmtt = domoticz.devices(‘To-Stove’).actualWatt

none of them work....
And the translation in Domoticz from Dummy Hardware to Dutch is quite confusing !

Code: Select all

2025-01-20 15:55:44.526 Error: dzVents: Error: (3.1.8) Regulating Afz_350: An error occurred when calling event handler 12_Afzuigkap_Regulated_100-350
2025-01-20 15:55:44.526 Error: dzVents: Error: (3.1.8) Regulating Afz_350: ...nts/generated_scripts/12_Afzuigkap_Regulated_100-350.lua:21: attempt to index a nil value (global 'domoticz') 
User avatar
waltervl
Posts: 5394
Joined: Monday 28 January 2019 18:48
Target OS: Linux
Domoticz version: 2024.7
Location: NL
Contact:

Re: Something stupid , a dummy problem "actualWatt"

Post by waltervl »

Can you post a screenshot of the device widget (it shows the device type) or from the Dummy list tell what you have selected: https://wiki.domoticz.com/Dummy_for_virtual_Switches
Domoticz running on Udoo X86 (on Ubuntu)
Devices/plugins: ZigbeeforDomoticz (with Xiaomi, Ikea, Tuya devices), Nefit Easy, Midea Airco, Omnik Solar, Goodwe Solar
User avatar
boum
Posts: 135
Joined: Friday 18 January 2019 11:31
Target OS: Raspberry Pi / ODroid
Domoticz version: 4.10717
Location: France
Contact:

Re: Something stupid , a dummy problem "actualWatt"

Post by boum »

first fix the basic error between

Code: Select all

execute = function(dz, devices)
and

Code: Select all

    local kpmtt = domoticz.devices('Tot_Fornuis')  -- Tot_Fornuis is a dummy. But .usage or .actualWatt doesn´t work !
use either domoticz or dz everywhere but not a mix

then follow the advice and find the type of the device to determine which property to query
PeterRozenveld
Posts: 38
Joined: Sunday 15 October 2023 18:44
Target OS: Raspberry Pi / ODroid
Domoticz version:
Contact:

Re: Something stupid , a dummy problem "actualWatt"

Post by PeterRozenveld »

Ok thx!

Done

It's : Usage, Electricity and the property? is .POWER

but that seems not to work either.
User avatar
waltervl
Posts: 5394
Joined: Monday 28 January 2019 18:48
Target OS: Linux
Domoticz version: 2024.7
Location: NL
Contact:

Re: Something stupid , a dummy problem "actualWatt"

Post by waltervl »

That is the description. The dzvents options are:
Electric usage
.actualWatt: Number. Current Watt usage.
.WhActual: Number. Current Watt usage. (please use actualWatt)
.updateEnergy(energy): Function. In Watt.

But also make sure you do not mixup domoticz and dz references....
Domoticz running on Udoo X86 (on Ubuntu)
Devices/plugins: ZigbeeforDomoticz (with Xiaomi, Ikea, Tuya devices), Nefit Easy, Midea Airco, Omnik Solar, Goodwe Solar
User avatar
habahabahaba
Posts: 215
Joined: Saturday 18 March 2023 14:44
Target OS: Windows
Domoticz version: 2024.4
Contact:

Re: Something stupid , a dummy problem "actualWatt"

Post by habahabahaba »

Code: Select all

execute = function(domoticz, item)

        local kpmtt = domoticz.devices(113) --idx of Electric counter
        
        if kpmtt.actualWatt >= 100 and kpmtt.actualWatt < 350  then 
            
            domoticz.log('Current electricity usage:', domoticz.LOG_INFO)
            domoticz.log(kpmtt.actualWatt .. ' Watt', domoticz.LOG_INFO)
                
        end       

    end
PeterRozenveld
Posts: 38
Joined: Sunday 15 October 2023 18:44
Target OS: Raspberry Pi / ODroid
Domoticz version:
Contact:

Re: Something stupid , a dummy problem "actualWatt"

Post by PeterRozenveld »

sorry doesn´t seem to work.
User avatar
waltervl
Posts: 5394
Joined: Monday 28 January 2019 18:48
Target OS: Linux
Domoticz version: 2024.7
Location: NL
Contact:

Re: Something stupid , a dummy problem "actualWatt"

Post by waltervl »

PeterRozenveld wrote: Monday 20 January 2025 19:21 sorry doesn´t seem to work.
This is not the whole script. Please use common dzvents sense here :-)

And telling it does not work does also not help. Tell exactly what is not working...
Domoticz running on Udoo X86 (on Ubuntu)
Devices/plugins: ZigbeeforDomoticz (with Xiaomi, Ikea, Tuya devices), Nefit Easy, Midea Airco, Omnik Solar, Goodwe Solar
User avatar
habahabahaba
Posts: 215
Joined: Saturday 18 March 2023 14:44
Target OS: Windows
Domoticz version: 2024.4
Contact:

Re: Something stupid , a dummy problem "actualWatt"

Post by habahabahaba »

Show the full script and the log
PeterRozenveld
Posts: 38
Joined: Sunday 15 October 2023 18:44
Target OS: Raspberry Pi / ODroid
Domoticz version:
Contact:

Re: Something stupid , a dummy problem "actualWatt"

Post by PeterRozenveld »

I will be absent until Friday
Post Reply

Who is online

Users browsing this forum: No registered users and 0 guests