Just need a nudge in the right direction please

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

Moderator: leecollings

Post Reply
Dave21w
Posts: 407
Joined: Sunday 29 November 2015 21:55
Target OS: Raspberry Pi / ODroid
Domoticz version: Stable
Location: UK
Contact:

Just need a nudge in the right direction please

Post by Dave21w »

Only just started with dzVents, have something very simple running to toggle the state of a switch every 15mins, now I would like to use my dual zigbee wireless switch to toggle the state of a lamp on each press, I have this
2020-11-03 20_30_05-Domoticz Home.jpg
2020-11-03 20_30_05-Domoticz Home.jpg (18.36 KiB) Viewed 534 times
But I get this error repeating in the log which I don't understand,

2020-11-03 20:25:24.253 Error: dzVents: Error: (3.0.2) error loading module 'Zigbee - Dual' from file '/home/pi/domoticz/scripts/dzVents/generated_scripts/Zigbee - Dual.lua':
2020-11-03 20:25:24.253 ...ticz/scripts/dzVents/generated_scripts/Zigbee - Dual.lua:7: ')' expected near '-'

TIA
Dave
User avatar
madpatrick
Posts: 761
Joined: Monday 26 December 2016 12:17
Target OS: Linux
Domoticz version: 2025.2
Location: Netherlands
Contact:

Re: Just need a nudge in the right direction please

Post by madpatrick »

There is - between Zigbee - Dual and not in line 4
Or the spaces between the words

Maybe this is the problem
-= HP server GEN11 =- ZwaveJS-=- Domoticz v2025.2 -=- Dashticz =-
-= Checkout https://github.com/MadPatrick for the plugins =-
Dave21w
Posts: 407
Joined: Sunday 29 November 2015 21:55
Target OS: Raspberry Pi / ODroid
Domoticz version: Stable
Location: UK
Contact:

Re: Just need a nudge in the right direction please

Post by Dave21w »

So there is, Duh!!!

I removed the - because I thought it might be an issue, I've correct my mistake, now the log says

2020-11-03 20:54:09.570 Error: dzVents: Error: (3.0.2) error loading module 'Zigbee Dual Switch' from file '/home/pi/domoticz/scripts/dzVents/generated_scripts/Zigbee Dual Switch.lua':
2020-11-03 20:54:09.570 ...scripts/dzVents/generated_scripts/Zigbee Dual Switch.lua:7: ')' expected near 'Dual'
User avatar
madpatrick
Posts: 761
Joined: Monday 26 December 2016 12:17
Target OS: Linux
Domoticz version: 2025.2
Location: Netherlands
Contact:

Re: Just need a nudge in the right direction please

Post by madpatrick »

And the spaces between “Zigbee Dual Switch”
-= HP server GEN11 =- ZwaveJS-=- Domoticz v2025.2 -=- Dashticz =-
-= Checkout https://github.com/MadPatrick for the plugins =-
User avatar
waaren
Posts: 6028
Joined: Tuesday 03 January 2017 14:18
Target OS: Linux
Domoticz version: Beta
Location: Netherlands
Contact:

Re: Just need a nudge in the right direction please

Post by waaren »

Dave21w wrote: Tuesday 03 November 2020 21:34 I get this error repeating in the log which I don't understand,
2020-11-03 20:25:24.253 Error: dzVents: Error: (3.0.2) error loading module 'Zigbee - Dual' from file '/home/pi/domoticz/scripts/dzVents/generated_scripts/Zigbee - Dual.lua':
2020-11-03 20:25:24.253 ...ticz/scripts/dzVents/generated_scripts/Zigbee - Dual.lua:7: ')' expected near '-'
If you share code or logs please post as text between code tags (it will make it easier to test and correct). Also if you are in develop / test phase it helps to set the script logging to domoticz.LOG_DEBUG
It could give you just enough extra information to help you find an issue that would otherwise might remain unseen.

In your script you refer to switch but you pass another object as second parameter in the execute function.
An if block need to be closed by an end

if <condition(s)> then
<action(s)>
end

Can you try this

Code: Select all

return
{
    on =
    {
        devices =
        {
            'Zigbee Dual Switch',
        },
    },

    logging =
    {
        level = domoticz.LOG_DEBUG, -- set to domoticz.LOG_ERROR when all OK
        marker = 'Zigbee toggle' ,
    },

    execute = function(dz, item)

        if item.state == 'B1' then
            dz.devices('L Zigbee').toggleSwitch()
        elseif item.state == 'B2' then
            dz.devices('R Zigbee').toggleSwitch()
        end

    end
}
Debian buster, bullseye on RPI-4, Intel NUC.
dz Beta, Z-Wave, RFLink, RFXtrx433e, P1, Youless, Hue, Yeelight, Xiaomi, MQTT
==>> dzVents wiki
User avatar
Dutchsea
Posts: 120
Joined: Tuesday 08 December 2015 13:22
Target OS: Raspberry Pi / ODroid
Domoticz version: v2023.2
Location: The Netherlands
Contact:

Re: Just need a nudge in the right direction please

Post by Dutchsea »

Also just a beginner but I think it will work if you replace the function to :
function(domoticz, item) or function(domoticz, devices)
Raspberry PI 3B on USB drive, Debian version: 12 (bookworm), Domoticz 2024.7
Aeon Z-Wave G5 stick, RFXCOM, Sonof Zigbee 3.0 Dongle plus E, Nefit Easy, Fritzbox, Buienradar, Sonos
Dave21w
Posts: 407
Joined: Sunday 29 November 2015 21:55
Target OS: Raspberry Pi / ODroid
Domoticz version: Stable
Location: UK
Contact:

Re: Just need a nudge in the right direction please

Post by Dave21w »

Thanks for your reply waaren, I now have the error log below, please don't think I'm being rude but what do you mean by "between code tags"


2020-11-03 21:09:00.182 Error: dzVents: Error: (3.0.2) error loading module 'Zigbee Dual Switch' from file '/home/pi/domoticz/scripts/dzVents/generated_scripts/Zigbee Dual Switch.lua':
2020-11-03 21:09:00.182 ...scripts/dzVents/generated_scripts/Zigbee Dual Switch.lua:14: '}' expected (to close '{' at line 12) near 'toggle'

TIA
Dave
User avatar
waaren
Posts: 6028
Joined: Tuesday 03 January 2017 14:18
Target OS: Linux
Domoticz version: Beta
Location: Netherlands
Contact:

Re: Just need a nudge in the right direction please

Post by waaren »

Dave21w wrote: Tuesday 03 November 2020 22:24 Thanks for your reply waaren, I now have the error log below, please don't think I'm being rude but what do you mean by "between code tags"


2020-11-03 21:09:00.182 Error: dzVents: Error: (3.0.2) error loading module 'Zigbee Dual Switch' from file '/home/pi/domoticz/scripts/dzVents/generated_scripts/Zigbee Dual Switch.lua':
2020-11-03 21:09:00.182 ...scripts/dzVents/generated_scripts/Zigbee Dual Switch.lua:14: '}' expected (to close '{' at line 12) near 'toggle'

TIA
Dave
Corrected by adding quotes around the marker string. This should do it

Code: Select all

return
{
    on =
    {
        devices =
        {
            'Zigbee Dual Switch',
        },
    },

    logging =
    {
        level = domoticz.LOG_DEBUG, -- set to domoticz.LOG_ERROR when all OK
        marker = 'Zigbee toggle' ,
    },

    execute = function(dz, item)

        if item.state == 'B1' then
            dz.devices('L Zigbee').toggleSwitch()
        elseif item.state == 'B2' then
            dz.devices('R Zigbee').toggleSwitch()
        end

    end
}

codeTags.png
codeTags.png (75.9 KiB) Viewed 515 times
Debian buster, bullseye on RPI-4, Intel NUC.
dz Beta, Z-Wave, RFLink, RFXtrx433e, P1, Youless, Hue, Yeelight, Xiaomi, MQTT
==>> dzVents wiki
Dave21w
Posts: 407
Joined: Sunday 29 November 2015 21:55
Target OS: Raspberry Pi / ODroid
Domoticz version: Stable
Location: UK
Contact:

Re: Just need a nudge in the right direction please

Post by Dave21w »

Thank you waaren, I wil try this when I get home tonight, sorry for not replying yesterday but I have early starts so was off to bed just after my last message.

Thanks
Dave
Dave21w
Posts: 407
Joined: Sunday 29 November 2015 21:55
Target OS: Raspberry Pi / ODroid
Domoticz version: Stable
Location: UK
Contact:

Re: Just need a nudge in the right direction please

Post by Dave21w »

Hi waaren, your script works a treat thank you, I will try and absorbe this information and not ask so many stupid questions in future (no promises though :D )

Thanks Again
Dave
Post Reply

Who is online

Users browsing this forum: No registered users and 1 guest