Anwesenheit per Wlan feststellen
Einklappen
X
-
-
ich habe noch Radiator-Heizung. von daher geht das aufheizen recht schnell.
Der Akkuverbrauch für Tasker ist realtiv gering. Man darf nur nicht im Task eine Pause einbauen, sondern muss den Auslöser mit Wiederholung definieren.
Dann wird die CPu nicht dauerhaft belastet.
Sicvher kann man das noch verfeinern ;-)Kommentar
-
hismastersvoice
Wie hast du den VI geschaltet, kannst du mir bitte einen Auszug aus dem Skript schicken? Ich beziehe mich auf den Post 28.
Vielen Dank.Kommentar
-
Man nutz dazu
use HTTP::Request::Common
Dann kann man mit
$ua = LWP::UserAgent->new;
$ua->request(GET 'http://'.$LOXUSER.':'.$LOXPASS.'@'.$LOXIP.'/dev/sps/io/'.$LOXVI.'/Ein');
den Eingang ein bzw. ausschalten.
Code:#!/usr/bin/perl -w use strict; use warnings; use LWP::Simple; use LWP::UserAgent; use XML::Simple; use Getopt::Long; use open qw(:std :utf8); use HTTP::Request::Common; # ------------- Konfiguration ------------- my $ip = "192.168.XXX.XXX"; #IP Fritzbox my $port = "49443"; #Port Fritzbox my @macs_to_check = ("aa:bb:cc:dd:ee:ff","aa:bb:cc:dd:ee:ff"); #MAC Adresse der Geraete, es können mehrere eingetragen werden my $LOXIP = "192.168.xxx.xxx"; #IP Miniserver my $LOXUSER = "admin"; #User MS my $LOXPASS = "xxxxxxxxx"; #Passwort MS my $LOXVI = "VI38"; #Virt. Eingang Lox # ---------------- Programm ---------------- $ENV{'PERL_LWP_SSL_VERIFY_HOSTNAME'} = 0; $ENV{HTTPS_DEBUG} = 1; my $ua = new LWP::UserAgent; $ua->default_headers; $ua->ssl_opts( verify_hostname => 0 ,SSL_verify_mode => 0x00); my $resp_discover = $ua->get("https://$ip:$port/tr64desc.xml"); my $xml_discover; if ( $resp_discover->is_success ) { $xml_discover = $resp_discover->decoded_content; } else { die $resp_discover->status_line; } my $discover = XMLin($xml_discover); print "$discover->{device}->{modelName} gefunden...\n"; my $control_url = "not set"; my $service_type = "not set"; my $service_command = "GetSpecificHostEntry"; foreach(@{$discover->{device}->{deviceList}->{device}->[0]->{serviceList}->{service}}){ if("urn:LanDeviceHosts-com:serviceId:Hosts1" =~ m/.*$_->{serviceId}.*/){ $control_url = $_->{controlURL}; $service_type = $_->{serviceType}; } } if ($control_url eq "not set" or $service_type eq "not set"){ die "control URL/service type not found. Cannot request host info!"; } $ua->default_header( 'SOAPACTION' => "$service_type#$service_command" ); my $xml_mac_resp; my $any_online = 0; foreach my $mac (@macs_to_check){ my $init_request = <<EOD; <?xml version="1.0" encoding="utf-8"?> <s:Envelope s:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/" xmlns:s="http://schemas.xmlsoap.org/soap/envelope/" > <s:Header> </s:Header> <s:Body> <u:$service_command xmlns:u="$service_type"> <NewMACAddress>$mac</NewMACAddress> </u:$service_command> </s:Body> </s:Envelope> EOD my $init_url = "https://$ip:$port$control_url"; my $resp_init = $ua->post($init_url, Content_Type => 'text/xml; charset=utf-8', Content => $init_request); $xml_mac_resp = XMLin($resp_init->decoded_content); if(exists $xml_mac_resp->{'s:Body'}->{'s:Fault'}){ if($xml_mac_resp->{'s:Body'}->{'s:Fault'}->{detail}->{UPnPError}->{errorCode} eq "714"){ print "MAC $mac nicht in der FritzBox gefunden!\n"; } } if(exists $xml_mac_resp->{'s:Body'}->{'u:GetSpecificHostEntryResponse'}){ if($xml_mac_resp->{'s:Body'}->{'u:GetSpecificHostEntryResponse'}->{NewActive} eq "1"){ my $name = $xml_mac_resp->{'s:Body'}->{'u:GetSpecificHostEntryResponse'}->{NewHostName}; my $ip = $xml_mac_resp->{'s:Body'}->{'u:GetSpecificHostEntryResponse'}->{NewIPAddress}; my $iftype = $xml_mac_resp->{'s:Body'}->{'u:GetSpecificHostEntryResponse'}->{NewInterfaceType}; print "MAC $mac ($name) ist online mit der IP $ip mit $iftype\n"; $any_online = 1; } if($xml_mac_resp->{'s:Body'}->{'u:GetSpecificHostEntryResponse'}->{NewActive} eq "0"){ my $name = $xml_mac_resp->{'s:Body'}->{'u:GetSpecificHostEntryResponse'}->{NewHostName}; print "MAC $mac ($name) ist offline\n"; } } } if ($any_online){ $ua = LWP::UserAgent->new; $ua->request(GET 'http://'.$LOXUSER.':'.$LOXPASS.'@'.$LOXIP.'/dev/sps/io/'.$LOXVI.'/Ein'); exit 1; } else{ $ua = LWP::UserAgent->new; $ua->request(GET 'http://'.$LOXUSER.':'.$LOXPASS.'@'.$LOXIP.'/dev/sps/io/'.$LOXVI.'/Aus'); exit 0; }
Zuletzt geändert von hismastersvoice; 08.02.2016, 09:50.Kein Support per PN!Kommentar
-
Was hier wieder mal spontan auffällt: Fritzbox wird per https ausgelesen und der MS kann nur http. Also Klartext auch für User/PW. Daher bevorzuge ich in solchen Fällen UDP. Vielleicht erkennt ja Loxone doch noch mal die Zeichen der Zeit. Auch wenn eine "Pro-Version" mit SSD und mehr Rechenpower ein paar € mehr kosten würde, ich würde das sofort aufrüsten.
-
-
Ich habe durch BSiege Hinweis (Verschicken von unverschlüsselten Kennwörtern im Netz) das ursprüngliche Skript angepasst und habe dabei auch die Idee hismastersvoice aufgenommen (http-request).
Ich habe das Skript nun dahingehend umgebaut, dass die Konfiguraition nur noch im oberen Block vorzunehmen ist und dass UDP-Werte an den Miniserver geschickt werden.
Code:#!/usr/bin/perl -w use strict; use warnings; use LWP::Simple; use LWP::UserAgent; use XML::Simple; use Getopt::Long; use open qw(:std :utf8); use HTTP::Request::Common; use IO::Socket::INET; # ------------- Konfiguration ------------- my $ip = "192.168.xxx.xxx"; # IP Fritzbox my $port = "49443"; # Port Fritzbox my @macs_to_check = ("AA:BB:CC:DD:EE:FF"); # MAC Adresse der Geraete, es können mehrere eingetragen werden my $LOXIP = "192.168.xxx.xxx"; # IP Miniserver my $udpport = "34435"; # UDP-Port my $online = "xxx-1"; # Person Online my $offline = "xxx-0"; # Person Offline # ---------------- Programm ---------------- $ENV{'PERL_LWP_SSL_VERIFY_HOSTNAME'} = 0; $ENV{HTTPS_DEBUG} = 1; my $ua = new LWP::UserAgent; $ua->default_headers; $ua->ssl_opts( verify_hostname => 0 ,SSL_verify_mode => 0x00); my $resp_discover = $ua->get("https://$ip:$port/tr64desc.xml"); my $xml_discover; if ( $resp_discover->is_success ) { $xml_discover = $resp_discover->decoded_content; } else { die $resp_discover->status_line; } my $discover = XMLin($xml_discover); print "$discover->{device}->{modelName} gefunden...\n"; my $control_url = "not set"; my $service_type = "not set"; my $service_command = "GetSpecificHostEntry"; foreach(@{$discover->{device}->{deviceList}->{device}->[0]->{serviceList}->{service}}){ if("urn:LanDeviceHosts-com:serviceId:Hosts1" =~ m/.*$_->{serviceId}.*/){ $control_url = $_->{controlURL}; $service_type = $_->{serviceType}; } } if ($control_url eq "not set" or $service_type eq "not set"){ die "control URL/service type not found. Cannot request host info!"; } $ua->default_header( 'SOAPACTION' => "$service_type#$service_command" ); my $xml_mac_resp; my $any_online = 0; foreach my $mac (@macs_to_check){ my $init_request = <<EOD; <?xml version="1.0" encoding="utf-8"?> <s:Envelope s:encodingStyle="[URL="http://schemas.xmlsoap.org/soap/encoding/"]http://schemas.xmlsoap.org/soap/encoding/"[/URL] xmlns:s="[URL="http://schemas.xmlsoap.org/soap/envelope/"]http://schemas.xmlsoap.org/soap/envelope/"[/URL] > <s:Header> </s:Header> <s:Body> <u:$service_command xmlns:u="$service_type"> <NewMACAddress>$mac</NewMACAddress> </u:$service_command> </s:Body> </s:Envelope> EOD my $init_url = "https://$ip:$port$control_url"; my $resp_init = $ua->post($init_url, Content_Type => 'text/xml; charset=utf-8', Content => $init_request); $xml_mac_resp = XMLin($resp_init->decoded_content); if(exists $xml_mac_resp->{'s:Body'}->{'s:Fault'}){ if($xml_mac_resp->{'s:Body'}->{'s:Fault'}->{detail}->{UPnPError}->{errorCode} eq "714"){ print "MAC $mac nicht in der FritzBox gefunden!\n"; } } if(exists $xml_mac_resp->{'s:Body'}->{'u:GetSpecificHostEntryResponse'}){ if($xml_mac_resp->{'s:Body'}->{'u:GetSpecificHostEntryResponse'}->{NewActive} eq "1"){ my $name = $xml_mac_resp->{'s:Body'}->{'u:GetSpecificHostEntryResponse'}->{NewHostName}; my $ip = $xml_mac_resp->{'s:Body'}->{'u:GetSpecificHostEntryResponse'}->{NewIPAddress}; my $iftype = $xml_mac_resp->{'s:Body'}->{'u:GetSpecificHostEntryResponse'}->{NewInterfaceType}; print "MAC $mac ($name) ist online mit der IP $ip mit $iftype\n"; $any_online = 1; } if($xml_mac_resp->{'s:Body'}->{'u:GetSpecificHostEntryResponse'}->{NewActive} eq "0"){ my $name = $xml_mac_resp->{'s:Body'}->{'u:GetSpecificHostEntryResponse'}->{NewHostName}; print "MAC $mac ($name) ist offline\n"; } } } if ($any_online){ my $sock = new IO::Socket::INET(PeerAddr => $LOXIP, PeerPort => $udpport, Proto => 'udp', Timeout => 1) or die('Error opening socket.'); print $sock $online; exit 1; } else{ my $sock = new IO::Socket::INET(PeerAddr => $LOXIP, PeerPort => $udpport, Proto => 'udp', Timeout => 1) or die('Error opening socket.'); print $sock $offline; exit 0; }
Kommentar
-
Nabend,
Ich habe die Anwesenheitserkennung aus dem Loxwiki auf meinem Server installiert
Jetzt habe ich nur ein Problem, mein iPhone 6 mit IOS 9.2.1 wird nicht angezeigt, das iPhone 6 von meiner Frau schon, sie hat noch IOS 8.4.1 mit JB auf ihrem iPhone.
Irgendwie scheint das mit dem IOS 9.2.1 zusammen zu hängen, da es auf meinem iPad air und air 2 auch nicht funktioniert!
Hat wer von euch eine Idee woran es liegen kann?
GrussKommentar
-
Also mein iPhone heisst Marcos-iPhone hat die Mac Adresse D4:F4:6F:96:FB:73
Das von meiner Frau heisst Daggys-iPhone und hat die Mac Adresse D4:F4:6F:9C:C13
Ich werde mal nachher wenn ich zuhause bin andere Namen versuchenZuletzt geändert von Marco Grasso; 10.03.2016, 08:41. -
Also am Namen liegt es nicht, die IP lässt sich nach Erneuerung des leasers anpingen!
Trotzdem wird es nicht angezeigt!
Hat noch jemand eine Idee? -
Poste doch mal dein Prog...
-
-
Ist genau das aus dem Loxwiki
#!/usr/bin/perl -w
################################################## ###
# Script zur Anwesenheitserkennung von WLAN-Geräten #
# an einer Fritz!Box 7490 in Verbindung mit einem #
# Loxone Miniserver #
# Version: 2016.02.27.15.09.14 #
################################################## ###
# Miniserver UDP Information
my $mshost = 'miniserver'; # Miniserver-IP oder Hostname
my $msport = 7007; # Miniserver UDP-Empfangsport
my $msprotocol = 'udp';
# Fritz!Box Information
my $ip = 'fritz.box'; # Fritz!Box-IP oder Hostname
my $port = 49443; # Fritz!Box Port
# Flushing to STDOUT after each write
$| = 1;
use strict;
use warnings;
use LWP::Simple;
use LWP::UserAgent;
use XML::Simple;
use Getopt::Long;
use open qw(:std :utf8);
use POSIX qw/ strftime /;
use IO::Socket;
# Check Command Line parameters
# Minumum 2 - Resident and at least one Phone-MAC address
my $num_args = $#ARGV + 1;
if ($num_args < 2)
{
print "Missing command line argument!";
print "\nUsage: fritzbox-bewohner.pl <BewohnerN> <Handy-MAC1> [<Handy-MACn>]";
print "\nExample: fritzbox-bewohner.pl Bewohner1 00:00:00:00:00:00\n";
exit;
}
# Alle MACs sammeln und im Array macs_to_check speichern
my @macs_to_check =($ARGV[1]);
my $bewohner = $ARGV[0];
print "Checking presence for User ".$bewohner." with MAC ".$ARGV[1];
for (my $mac=1; $mac <= $num_args-2; $mac++)
{
push @macs_to_check, $ARGV[$mac+1];
print " or MAC ".$ARGV[($mac+1)];
}
print " at " . $ip ." on port " . $port . "...\n";
# disable SSL checks. No signed certificate!
$ENV{'PERL_LWP_SSL_VERIFY_HOSTNAME'} = 0;
$ENV{HTTPS_DEBUG} = 1;
# Discover Service Parameters
my $ua = new LWP::UserAgent;
$ua->default_headers;
$ua->ssl_opts( verify_hostname => 0 ,SSL_verify_mode => 0x00);
# Read all available services
my $resp_discover = $ua->get(");
my $xml_discover;
if ( $resp_discover->is_success )
{
$xml_discover = $resp_discover->decoded_content;
}
else
{
die $resp_discover->status_line;
}
my $discover = XMLin($xml_discover);
print "$discover->{device}->{modelName} detected...\n";
# Parse XML service response, get needed parameters for LAN host service
my $control_url = "not set";
my $service_type = "not set";
my $service_command = "GetSpecificHostEntry"; # fixed command for requesting info of specific MAC
foreach(@{$discover->{device}->{deviceList}->{device}->[0]->{serviceList}->{service}})
{
if("urn:LanDeviceHosts-com:serviceId:Hosts1" =~ m/.*$_->{serviceId}.*/)
{
$control_url = $_->{controlURL};
$service_type = $_->{serviceType};
}
}
if ($control_url eq "not set" or $service_type eq "not set")
{
die "control URL/service type not found. Cannot request host info!";
}
# Prepare request for query LAN host
$ua->default_header( 'SOAPACTION' => "$service_type#$service_command" );
my $xml_mac_resp;
my $any_online = 0; # if arg any specified
foreach my $mac (@macs_to_check)
{
my $init_request = <<EOD;
<?xml version="1.0" encoding="utf-8"?>
<s:Envelope s:encodingStyle=" xmlns:s=" >
<s:Header>
</s:Header>
<s:Body>
<u:$service_command xmlns:u="$service_type">
<NewMACAddress>$mac</NewMACAddress>
</u:$service_command>
</s:Body>
</s:Envelope>
EOD
my $init_url = ";
my $resp_init = $ua->post($init_url, Content_Type => 'text/xml; charset=utf-8', Content => $init_request);
$xml_mac_resp = XMLin($resp_init->decoded_content);
if(exists $xml_mac_resp->{'s:Body'}->{'s:Fault'})
{
if($xml_mac_resp->{'s:Body'}->{'s:Fault'}->{detail}->{UPnPError}->{errorCode} eq "714")
{
print "Mac $mac not found in FritzBox Database!\n";
}
}
if(exists $xml_mac_resp->{'s:Body'}->{'u:GetSpecificHostEntryResponse'})
{
if($xml_mac_resp->{'s:Body'}->{'u:GetSpecificHostEntryResponse'}->{NewActive} eq "1")
{
my $name = $xml_mac_resp->{'s:Body'}->{'u:GetSpecificHostEntryResponse'}->{NewHostName};
my $ip = $xml_mac_resp->{'s:Body'}->{'u:GetSpecificHostEntryResponse'}->{NewIPAddress};
my $iftype = $xml_mac_resp->{'s:Body'}->{'u:GetSpecificHostEntryResponse'}->{NewInterfaceType};
print "Mac $mac ($name) is online with IP $ip on $iftype\n";
$any_online = 1;
}
if($xml_mac_resp->{'s:Body'}->{'u:GetSpecificHostEntryResponse'}->{NewActive} eq "0")
{
my $name = $xml_mac_resp->{'s:Body'}->{'u:GetSpecificHostEntryResponse'}->{NewHostName};
print "Mac $mac ($name) is offline\n";
}
}
}
# Creating UDP socket to Miniserver
my $client = IO::Socket::INET->new (
PeerAddr => $mshost,
PeerPort => $msport,
Proto => $msprotocol,
Type => SOCK_DGRAM
) or die "Socket could not be created, failed with error: $!\n";
print "Sending Data '".$bewohner.":".$any_online."' to $mshost on port $msport ...\n";
$client->send($bewohner.":".$any_online);
$client->close();
Kommentar
-
So ich habe es jetzt, es lag doch am Namen, alles was mit M anfängt oder mit iPhone zutun hat klappt nicht!
Mit Bananen-Handy geht es nun.............................Zuletzt geändert von Marco Grasso; 11.03.2016, 17:26.Kommentar
-
Kann ich nicht nachvollziehen... Das Handy meiner Frau heißt Marion-iPhone und geht.
Dan liegt es vieleicht echt an der Kombi iOS FritzOS????? -
Meine Frau hat Daggy-iPhone und Daggy-iPad, das geht auch aber Marco-iPhone und Marco-iPad geht nicht, nichtmal Marco-Handy oder M-iPhone oder M-Handy. Nur Handy geht. Da ist mir nur Bananen-Handy eingefallen!
Reift noch beim Benutzer....
-
Hallo,
ich habe mir ein kleines Programm gemacht mit dem die Anwesenheit festgestellt werden kann.
Programm:
Anwesenheit.Loxone
Kommentar
-
Kommentar
-
-
Nein. Bisher nur eine Loxone..... Erstmal baue ich das System mit dem auf und schaue später mal was mir noch fehlt.Kommentar
Kommentar