Page 2 of 2

Re: Lua is not working anymore

Posted: Friday 24 November 2017 22:14
by Derik
@ Jos,

Thanks for the support first

I set you last script:

Code: Select all

2017-11-24 22:11:00.506 LUA: D.M.: IP Port check
2017-11-24 22:11:01.016 LUA: D.M.: ISP Checking Internet Tele2 VDSL
2017-11-24 22:11:01.073 LUA: debug: D.M.: IP Port check
2017-11-24 22:11:01.073 LUA: debug:nc -z -w 1 192.168.5.98 552
2017-11-24 22:11:01.093 LUA: debug: nil returned. status of Port: Schuurtje=Off
2017-11-24 22:11:01.093 LUA: debug:nc -z -w 1 192.168.5.99 555
2017-11-24 22:11:01.114 LUA: debug: nil returned. status of Port: Solarmeter=Off
2017-11-24 22:11:01.114 LUA: debug:nc -z -w 1 192.168.5.97 553
2017-11-24 22:11:01.134 LUA: debug: nil returned. status of Port: Dakrand=Off
2017-11-24 22:11:01.134 LUA: debug:nc -z -w 1 192.168.5.75 8081
2017-11-24 22:11:01.154 LUA: debug: nil returned. status of Port: Domoticz 1=Off
2017-11-24 22:11:01.154 LUA: debug:nc -z -w 1 192.168.5.3 8083
2017-11-24 22:11:01.175 Error: EventSystem: in Port test: [string "commandArray = {} ..."]:12: attempt to concatenate field '?' (a nil value)
2017-11-24 22:11:02.019 (D.M.: Xiaomi Gateway) Temp (X: Ter)
Only the ip port is alive:
ScreenShot069.png
ScreenShot069.png (81.5 KiB) Viewed 1069 times

Or do i need a reboot or something??

Re: Lua is not working anymore

Posted: Friday 24 November 2017 22:37
by jvdz
Doubt a reboot will help. You could just test with testing your domoticz ip and port just to see whether the script works.
I don't understand the error I see at the end in the log as that was fixed with the 2 changes. You are sure you have the whole script as I posted or could it be this devicename is wrong: "Port: Domoticz 3"?

Jos

Re: Lua is not working anymore

Posted: Saturday 25 November 2017 12:47
by Derik
mmm is it possible that you change the on and off???

This script is working ok now....:

Code: Select all

commandArray = {}

print ("debug: D.M.: IP Port check")

function update_portalive(name, ip, port)

    -- Windows https://joncraton.org/blog/46/netcat-for-windows/ untested

    s = "nc -z -w 1  " .. ip .." " .. tostring(port)
    print("debug:"..s)
    if (os.execute(s) == nil) then
        print("debug:  nil returned.  status of "..name.."="..otherdevices[name])
        if (otherdevices[name] == 'Off') then
            commandArray[name] = 'On'
            print(name .. " Dead")
        end
    else
        print("debug: Not nil returned.  status of "..name.."="..otherdevices[name])
        if (otherdevices[name] == 'Off') then
            print(name .. " Is a Alive")
            commandArray[name] = 'Off'
        end
    end
end


-- Fill in your services here  NAMEOFVIRTUALDEVICE    IP   PORT

update_portalive("Port: Schuurtje", "192.168.5.98", 552)
update_portalive("Port: Solarmeter", "192.168.5.99", 555)
update_portalive("Port: Dakrand", "192.168.5.97", 553)
update_portalive("Port: Domoticz 1", "192.168.5.75", 8081)
update_portalive("Port: Domoticz 3", "192.168.5.3", 8083)
update_portalive("Port: Domoticz 2", "192.168.5.147", 8082)
update_portalive("Port: Minecraft", "192.168.5.147", 22222)

return commandArray
No working oke... perhaps a other log message..
Only that is ok by me...
THANKS!!!!!

Re: Lua is not working anymore

Posted: Saturday 25 November 2017 13:05
by jvdz
You're welcome .... and i see the On-Off is sort of messed-up, did you figure out how to change it as that should be pretty strait forward?
My guess would be this is better but haven't tested it:

Code: Select all

commandArray = {}

print ("debug: D.M.: IP Port check")

function update_portalive(name, ip, port)

    -- Windows https://joncraton.org/blog/46/netcat-for-windows/ untested

    s = "nc -z -w 1  " .. ip .." " .. tostring(port)
    print("debug:"..s)
    if (os.execute(s) == nil) then
        -- unreachable so need to be Off
        print("debug:  nil returned.  status of "..name.."="..otherdevices[name])
        if (otherdevices[name] == 'On') then
            commandArray[name] = 'Off'
            print(name .. " Dead")
        end
    else
        -- reachable so need to be On
        print("debug: Not nil returned.  status of "..name.."="..otherdevices[name])
        if (otherdevices[name] == 'Off') then
            print(name .. " Is a Alive")
            commandArray[name] = 'On'
        end
    end
end

-- Fill in your services here  NAMEOFVIRTUALDEVICE    IP   PORT

update_portalive("Port: Schuurtje", "192.168.5.98", 552)
update_portalive("Port: Solarmeter", "192.168.5.99", 555)
update_portalive("Port: Dakrand", "192.168.5.97", 553)
update_portalive("Port: Domoticz 1", "192.168.5.75", 8081)
update_portalive("Port: Domoticz 3", "192.168.5.3", 8083)
update_portalive("Port: Domoticz 2", "192.168.5.147", 8082)
update_portalive("Port: Minecraft", "192.168.5.147", 22222)

return commandArray
Don't forget to comment the debug print statements when all is working to avoid filling up your logfile.

Jos

Re: Lua is not working anymore

Posted: Saturday 25 November 2017 18:11
by Derik
Jos,

Strange thing i use the latest script....
The device are now going not on or off any more...

1 ip is dead i now for sure.
Only domoticz says it is alive...

so i think there is something not working..

Re: Lua is not working anymore

Posted: Saturday 25 November 2017 18:35
by jvdz
Well.. as my crystal-ball is still in the workshop, I will have to depend on information you provide and have tested with. ;)
So, what is the latest script and what are the debug print statements producing for starters.

Jos

Re: Lua is not working anymore

Posted: Saturday 25 November 2017 18:45
by Derik
"mmm whas thinking that your ball was working.... sorry again "

The Script:

Code: Select all

commandArray = {}

print ("debug: D.M.: IP Port check")

function update_portalive(name, ip, port)

    -- Windows https://joncraton.org/blog/46/netcat-for-windows/ untested

    s = "nc -z -w 1  " .. ip .." " .. tostring(port)
    print("debug:"..s)
    if (os.execute(s) == nil) then
        -- unreachable so need to be Off
        print("debug:  nil returned.  status of "..name.."="..otherdevices[name])
        if (otherdevices[name] == 'Off') then
            commandArray[name] = 'On'
            print(name .. " Dead")
        end
    else
        -- reachable so need to be On
        print("debug: Not nil returned.  status of "..name.."="..otherdevices[name])
        if (otherdevices[name] == 'On') then
            print(name .. " Is a Alive")
            commandArray[name] = 'Off'
        end
    end
end

-- Fill in your services here  NAMEOFVIRTUALDEVICE    IP   PORT

--update_portalive("Port: Schuurtje", "192.168.5.98", 552)
--update_portalive("Port: Solarmeter", "192.168.5.99", 555)
update_portalive("Port: Dakrand", "192.168.5.97", 553)
--update_portalive("Port: Domoticz 1", "192.168.5.75", 8081)
--update_portalive("Port: Domoticz 3", "192.168.5.3", 8083)
--update_portalive("Port: Domoticz 2", "192.168.5.147", 8082)
--update_portalive("Port: Minecraft", "192.168.5.147", 22222)
--update_portalive("Port: Domoticz", "192.168.5.70", 8080)
--update_portalive("Port: Kachelrelais", "192.168.5.12", 17495)
--update_portalive("Port: Xiaomi gateway", "192.168.5.7", 9898)


return commandArray


The log:

Code: Select all

017-11-25 18:41:11.425 EventSystem: Event triggered: TER: Verlichting H/W_17
2017-11-25 18:41:11.445 OpenZWave: Domoticz has send a Switch command!, Level: 95, NodeID: 45 (0x2d)
2017-11-25 18:41:11.464 LUA: debug: D.M.: IP Port check
2017-11-25 18:41:11.464 LUA: debug:nc -z -w 1 192.168.5.97 553
2017-11-25 18:41:11.484 (D.M.: Zwave) Light/Switch (Zter: Mini Lampjes)
2017-11-25 18:41:11.485 LUA: debug: nil returned. status of Port: Dakrand=On
2017-11-25 18:41:11.520 LUA: D.M.: PS4 Internet
2017-11-25 18:41:11.551 LUA: Van D.M.:Dakrand Totaal, naar D.M.: Dakrand, voor totalen
The Ip:
ScreenShot070.png
ScreenShot070.png (25.82 KiB) Viewed 1038 times
And when i change the on and off by both of the setpoints...
The switch is gioing on.
Only also not going off wen the ip:port is dead.

Re: Lua is not working anymore

Posted: Saturday 25 November 2017 20:16
by jvdz
Ah... I see I got totally confused with your earlier post about the ON /OFF going wrong and made wrong changes to the script.
Does this one work better:

Code: Select all

commandArray = {}

print ("debug: D.M.: IP Port check")

function update_portalive(name, ip, port)

    -- Windows https://joncraton.org/blog/46/netcat-for-windows/ untested

    s = "nc -z -w 1  " .. ip .." " .. tostring(port)
    print("debug:"..s)
    if (os.execute(s) == nil) then
        -- unreachable so need to be Off
        print("debug:  nil returned.  status of "..name.."="..otherdevices[name])
        if (otherdevices[name] == 'On') then
            commandArray[name] = 'Off'
            print(name .. " Dead")
        end
    else
        -- reachable so need to be On
        print("debug: Not nil returned.  status of "..name.."="..otherdevices[name])
        if (otherdevices[name] == 'Off') then
            print(name .. " Is a Alive")
            commandArray[name] = 'On'
        end
    end
end

-- Fill in your services here  NAMEOFVIRTUALDEVICE    IP   PORT

--update_portalive("Port: Schuurtje", "192.168.5.98", 552)
--update_portalive("Port: Solarmeter", "192.168.5.99", 555)
update_portalive("Port: Dakrand", "192.168.5.97", 553)
--update_portalive("Port: Domoticz 1", "192.168.5.75", 8081)
--update_portalive("Port: Domoticz 3", "192.168.5.3", 8083)
--update_portalive("Port: Domoticz 2", "192.168.5.147", 8082)
--update_portalive("Port: Minecraft", "192.168.5.147", 22222)
--update_portalive("Port: Domoticz", "192.168.5.70", 8080)
--update_portalive("Port: Kachelrelais", "192.168.5.12", 17495)
--update_portalive("Port: Xiaomi gateway", "192.168.5.7", 9898)


return commandArray


Re: Lua is not working anymore

Posted: Saturday 25 November 2017 20:31
by Derik
thanks give it a try again..
Only 1 question
Can i check more then 1 device
Or do i need to make for every device a separate blockley?

Re: Lua is not working anymore

Posted: Saturday 25 November 2017 20:34
by jvdz
I would think it should work for multiple devices as you have already in the LUA script (Not Blockly!)
Doesn't that work? (Assuming one does wok now)

Jos

Re: Lua is not working anymore

Posted: Saturday 02 December 2017 14:47
by Derik
Dear,

Stil not working wel...

Code: Select all

2017-12-02 14:44:00.123 LUA: debug: D.M.: IP Port check
2017-12-02 14:44:00.123 LUA: debug:nc -z -w 1 192.168.5.98 552
2017-12-02 14:44:00.142 LUA: debug: nil returned. status of Port: Schuurtje=Off
2017-12-02 14:44:00.142 LUA: debug:nc -z -w 1 192.168.5.99 555
2017-12-02 14:44:00.162 LUA: debug: nil returned. status of Port: Solarmeter=Off
2017-12-02 14:44:00.162 LUA: debug:nc -z -w 1 192.168.5.97 553
2017-12-02 14:44:00.181 LUA: debug: nil returned. status of Port: Dakrand=Off
An i use this:

Code: Select all

commandArray = {}

print ("debug: D.M.: IP Port check")

function update_portalive(name, ip, port)

    -- Windows https://joncraton.org/blog/46/netcat-for-windows/ untested

    s = "nc -z -w 1  " .. ip .." " .. tostring(port)
    print("debug:"..s)
    if (os.execute(s) == nil) then
        -- unreachable so need to be Off
        print("debug:  nil returned.  status of "..name.."="..otherdevices[name])
        if (otherdevices[name] == 'On') then
            commandArray[name] = 'Off'
            print(name .. " Dead")
        end
    else
        -- reachable so need to be On
        print("debug: Not nil returned.  status of "..name.."="..otherdevices[name])
        if (otherdevices[name] == 'Off') then
            print(name .. " Is a Alive")
            commandArray[name] = 'On'
        end
    end
end

-- Fill in your services here  NAMEOFVIRTUALDEVICE    IP   PORT

update_portalive("Port: Schuurtje", "192.168.5.98", 552)
update_portalive("Port: Solarmeter", "192.168.5.99", 555)
update_portalive("Port: Dakrand", "192.168.5.97", 553)
--update_portalive("Port: Domoticz 1", "192.168.5.75", 8081)
--update_portalive("Port: Domoticz 3", "192.168.5.3", 8083)
--update_portalive("Port: Domoticz 2", "192.168.5.147", 8082)
--update_portalive("Port: Minecraft", "192.168.5.147", 22222)
--update_portalive("Port: Domoticz", "192.168.5.70", 8080)
--update_portalive("Port: Kachelrelais", "192.168.5.12", 17495)
--update_portalive("Port: Xiaomi gateway", "192.168.5.7", 9898)


return commandArray
The script says dead..
Only this 3 are alive