Page 1 of 1

Just need a nudge in the right direction please

Posted: Tuesday 03 November 2020 21:34
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 533 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

Re: Just need a nudge in the right direction please

Posted: Tuesday 03 November 2020 21:44
by madpatrick
There is - between Zigbee - Dual and not in line 4
Or the spaces between the words

Maybe this is the problem

Re: Just need a nudge in the right direction please

Posted: Tuesday 03 November 2020 21:55
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'

Re: Just need a nudge in the right direction please

Posted: Tuesday 03 November 2020 21:57
by madpatrick
And the spaces between “Zigbee Dual Switch”

Re: Just need a nudge in the right direction please

Posted: Tuesday 03 November 2020 21:59
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
}

Re: Just need a nudge in the right direction please

Posted: Tuesday 03 November 2020 22:01
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)

Re: Just need a nudge in the right direction please

Posted: Tuesday 03 November 2020 22:24
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

Re: Just need a nudge in the right direction please

Posted: Tuesday 03 November 2020 22:55
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 514 times

Re: Just need a nudge in the right direction please

Posted: Wednesday 04 November 2020 8:39
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

Re: Just need a nudge in the right direction please

Posted: Wednesday 04 November 2020 19:09
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