Page 1 of 1

ZRC-90

Posted: Wednesday 31 October 2018 15:41
by Mataresian
I have been trying to get the ZRC-90 working on more than 4 devices at the same time. I have tried to do it in blockly with variables includes, but without success as the remote just has the constant status of being On. So the switch constantly turns on and off.

I've tried using this one: viewtopic.php?t=13782
but I can't get the code working properly

Currently using: Version: 4.10022

Here is what I got

Code: Select all

-- Device Last Updates
t1 = os.time()
    devices = {
        "Remotec 1",
        "Remotec 2",
        "Remotec 3",
        "Remotec 4",
        "Computer",
        "Computerhok Printer",
        "Computerhok Licht 1",
        "Computerhok Licht 2""
        }
    for i = 1, #devices do
    s = otherdevices_lastupdate[devices[i]]
    year = string.sub(s, 1, 4)
    month = string.sub(s, 6, 7)
    day = string.sub(s, 9, 10)
    hour = string.sub(s, 12, 13)
    minutes = string.sub(s, 15, 16)
    seconds = string.sub(s, 18, 19)
    t2 = os.time{year=year, month=month, day=day, hour=hour, min=minutes, sec=seconds}
    str = (devices[i] .. "LastUpdate")
    str = str:gsub("%s+", "")
    str = string.gsub(str, "%s+", "")
    _G[str] = (os.difftime (t1, t2))
    end

commandArray = {}

-- Curtain button
if (devicechanged['Remotec 1'] == 'On' and otherdevices['Computer'] == 'Closed' and Remotec 1LastUpdate > 2) then
commandArray['Computer'] = 'On'
end

return commandArray

Re: ZRC-90

Posted: Wednesday 31 October 2018 17:10
by ben53252642
There is an extra quote on this line which shouldn't be present

"Computerhok Licht 2""

Also there should be no space only here:

Remotec 1LastUpdate

Should be

Remotec1LastUpdate

Eg:

Code: Select all

-- Device Last Updates
t1 = os.time()
devices = {
"Remotec 1",
"Remotec 2",
"Remotec 3",
"Remotec 4",
"Computer",
"Computerhok Printer",
"Computerhok Licht 1",
"Computerhok Licht 2"
}
for i = 1, #devices do
s = otherdevices_lastupdate[devices]
year = string.sub(s, 1, 4)
month = string.sub(s, 6, 7)
day = string.sub(s, 9, 10)
hour = string.sub(s, 12, 13)
minutes = string.sub(s, 15, 16)
seconds = string.sub(s, 18, 19)
t2 = os.time{year=year, month=month, day=day, hour=hour, min=minutes, sec=seconds}
str = (devices .. "LastUpdate")
str = str:gsub("%s+", "")
str = string.gsub(str, "%s+", "")
_G[str] = (os.difftime (t1, t2))
end

commandArray = {}

-- Curtain button
if (devicechanged['Remotec 1'] == 'On' and otherdevices['Computer'] == 'Closed' and Remotec1LastUpdate > 2) then
commandArray['Computer'] = 'On'
end

return commandArray

Re: ZRC-90

Posted: Wednesday 31 October 2018 17:16
by ben53252642
Did a few edits above, re-check that, the script should now work.

Re: ZRC-90

Posted: Wednesday 31 October 2018 18:22
by Mataresian
A response from the creator himself ^^ how great thanks for the quick response. I have tried the script you sent but the remote doesn't seem to respond to it. I have to put this in Events in Lua right? Anything else that I maybe should've made but didn't?

Re: ZRC-90

Posted: Thursday 01 November 2018 7:34
by ben53252642
Start with something simple eg:

Code: Select all

-- Device Last Updates
t1 = os.time()
devices = {
"Remotec 1"
}
for i = 1, #devices do
s = otherdevices_lastupdate[devices]
year = string.sub(s, 1, 4)
month = string.sub(s, 6, 7)
day = string.sub(s, 9, 10)
hour = string.sub(s, 12, 13)
minutes = string.sub(s, 15, 16)
seconds = string.sub(s, 18, 19)
t2 = os.time{year=year, month=month, day=day, hour=hour, min=minutes, sec=seconds}
str = (devices .. "LastUpdate")
str = str:gsub("%s+", "")
str = string.gsub(str, "%s+", "")
_G[str] = (os.difftime (t1, t2))
end

commandArray = {}

-- Curtain button
if (devicechanged['Remotec 1'] == 'On' and Remotec1LastUpdate > 2) then
commandArray['SWITCHNAME'] = 'On'
end

return commandArray
Try the above, change out SWITCHNAME for the name of an actual device (I suggest creating a virtual switch for testing), check the Domoticz log while controlling, post any error messages.

Very important, make sure the script is of the type Lua Device, not ALL.

Re: ZRC-90

Posted: Thursday 01 November 2018 19:53
by Mataresian
Error: EventSystem: in Remotec Test: [string "-- Device Last Updates..."]:8: bad argument #1 to 'sub' (string expected, got nil)
Error: EventSystem: in Remotec Test: [string "-- Device Last Updates..."]:8: bad argument #1 to 'sub' (string expected, got nil)
I didn't put it in Lua Device just Lua before but I changed that now.

I managed to create dummy hardware and then manually add the virtual switch (included in the picture)

I tried it with the different lua devices scripts but no in lua device instead of lua all with a simular result