NMAP problems

Moderator: leecollings

Post Reply
Lebo2d9
Posts: 139
Joined: Tuesday 06 September 2016 20:39
Target OS: Raspberry Pi / ODroid
Domoticz version: L stab
Location: Belgium
Contact:

NMAP problems

Post by Lebo2d9 »

Hi,

I have a script using NMAP to detect if a device is online of off line. This script runs every minute.
Some times I get a "falls off" and the next minute the device is back online.

Now i want to create sort of delay that waits 65 sec to turn off the virtual switch.

I dont know how to implement this.
I there someone who can help me to sort this out?

Kind regards

Koen Deschepper
Domoicz on RPI3 (wifi) directly connected 3x ds18b20 for CV temp, Evohome (9 zone), 1 remote 220V switch based on ESP-12. RFXtrx433E, 16x AMST-606, 5 Somfy RTS motors
Domoticz on RPI3(wifi) as slave for terraruim control
More to come
triton
Posts: 15
Joined: Monday 03 April 2017 15:01
Target OS: Linux
Domoticz version: 4.9701
Location: Netherlands
Contact:

Re: NMAP problems

Post by triton »

Don't know if this is useful. I'm checking if my TV is on first by detecting a change in the power consumption. Second I don't know if the TV is on or the Receiver I use the tcp_connect function below to try and connect to port 80 on the tv. If i can connect the TV is on and I switch a device on. Same in reverse, if I can't connect the TV must be off.

You need the socket lib, see instructions here: http://www.domoticz.com/wiki/Upload_ene ... et_library

Second, I'm using this function:

Code: Select all

function tcp_connect(host, port)
    -- v1.0. 2017-03-21
    -- attempt TCP connection to a host and port
    -- USAGE   : succes = tcp_connect(localhost, 8080)
    -- RETURNS : nil or tcp socket
    --
    local socket = require("socket")
    local tcp = socket.tcp()
    tcp:settimeout(2) -- 2s timeout, domoticz timewindow is 10 seconds.
    local client = tcp:connect(host, port)
    return client
end
To get an idea for the usage (ignore the watts, just the idea of the tcp_connect function):

Code: Select all

if (watts > 150 and otherdevices['TV'] == 'Off') then
   local result = tcp_connect('192.168.0.18', 80)
   if (result) then
      commandArray['TV'] = 'On'
   end
end      
aalwash
Posts: 6
Joined: Saturday 06 January 2018 11:17
Target OS: Raspberry Pi / ODroid
Domoticz version: 3.9168
Contact:

Re: NMAP problems

Post by aalwash »

Just an idea

Maybe add a variable, that is updated when the "first" time the TV is been detected "not responding"
The second time, you check the if the variable is on "Off" and when did this happen (timestamp).
If this is longer then 65sec ago, then put the switch to 'Off'.

If not, don't do anything, the next run will do the same check.
RPi3 , Xiaomi Door Window sensors, Xiaomi Temp+Humidity sensors, Zigbee2MQTT (Zigbee CC2531), Hacked Toon
Post Reply

Who is online

Users browsing this forum: No registered users and 0 guests