ZRC-90

Moderator: leecollings

Post Reply
Mataresian
Posts: 11
Joined: Monday 24 September 2018 15:36
Target OS: -
Domoticz version:
Contact:

ZRC-90

Post 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
Last edited by Mataresian on Wednesday 31 October 2018 18:43, edited 1 time in total.
ben53252642
Posts: 543
Joined: Saturday 02 July 2016 5:17
Target OS: Linux
Domoticz version: Beta
Contact:

Re: ZRC-90

Post 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
Unless otherwise stated, all my code is released under GPL 3 license: https://www.gnu.org/licenses/gpl-3.0.en.html
ben53252642
Posts: 543
Joined: Saturday 02 July 2016 5:17
Target OS: Linux
Domoticz version: Beta
Contact:

Re: ZRC-90

Post by ben53252642 »

Did a few edits above, re-check that, the script should now work.
Unless otherwise stated, all my code is released under GPL 3 license: https://www.gnu.org/licenses/gpl-3.0.en.html
Mataresian
Posts: 11
Joined: Monday 24 September 2018 15:36
Target OS: -
Domoticz version:
Contact:

Re: ZRC-90

Post 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?
ben53252642
Posts: 543
Joined: Saturday 02 July 2016 5:17
Target OS: Linux
Domoticz version: Beta
Contact:

Re: ZRC-90

Post 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.
Unless otherwise stated, all my code is released under GPL 3 license: https://www.gnu.org/licenses/gpl-3.0.en.html
Mataresian
Posts: 11
Joined: Monday 24 September 2018 15:36
Target OS: -
Domoticz version:
Contact:

Re: ZRC-90

Post 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
Attachments
SWITCHNAME.png
SWITCHNAME.png (14.85 KiB) Viewed 811 times
Post Reply

Who is online

Users browsing this forum: No registered users and 1 guest