diff --git a/fhem/FHEM/72_FRITZBOX.pm b/fhem/FHEM/72_FRITZBOX.pm index 83b00cdf6..2f38935f8 100644 --- a/fhem/FHEM/72_FRITZBOX.pm +++ b/fhem/FHEM/72_FRITZBOX.pm @@ -45,7 +45,7 @@ use warnings; use Blocking; use HttpUtils; -my $ModulVersion = "07.57.13d"; +my $ModulVersion = "08.00.00"; my $missingModul = ""; my $FRITZBOX_TR064pwd; my $FRITZBOX_TR064user; @@ -70,6 +70,10 @@ eval "use SOAP::Lite;1" or $missingModul .= "Soap::Lite "; # $Data::Dumper::Sortkeys = 1; eval "use Data::Dumper;1" or $missingModul .= "Data::Dumper "; +#use JSON::Parse 'parse_json'; +#use HTML::Make; +#binmode STDOUT, ":encoding(utf8)"; + sub FRITZBOX_Log($$$); sub FRITZBOX_DebugLog($$$$;$); sub FRITZBOX_dbgLogInit($@); @@ -78,6 +82,9 @@ sub FRITZBOX_Initialize($); # Sub, die den nonBlocking Timer umsetzen sub FRITZBOX_Readout_Start($); sub FRITZBOX_Readout_Run_Web($); +sub FRITZBOX_Readout_Run_Web_LuaQuery($$$$); +sub FRITZBOX_Readout_Run_Web_LuaData($$$$); +sub FRITZBOX_Readout_Run_Web_TR064($$$$); sub FRITZBOX_Readout_Response($$$@); sub FRITZBOX_Readout_Done($); sub FRITZBOX_Readout_Process($$); @@ -103,8 +110,10 @@ sub FRITZBOX_Set_lock_Landevice_OnOffRt($); sub FRITZBOX_Set_enable_VPNshare_OnOff($); sub FRITZBOX_Set_wake_Up_Call($); sub FRITZBOX_Set_Wlan_Log_Ext_OnOff($); +sub FRITZBOX_Set_Wlan_Guest_Params($); # Sub, die einen Get Befehl nonBlocking umsetzen +sub FRITZBOX_Get_MobileInfo($); sub FRITZBOX_Get_WLAN_globalFilters($); sub FRITZBOX_Get_LED_Settings($); sub FRITZBOX_Get_VPN_Shares_List($); @@ -137,6 +146,7 @@ sub FRITZBOX_call_Lua_Query($$@); sub FRITZBOX_read_LuaData($$$@); # Sub, die Helferfunktionen bereit stellen +sub FRITZBOX_Helper_make_TableRow($@); sub FRITZBOX_Helper_process_JSON($$$@); sub FRITZBOX_Helper_analyse_Lua_Result($$;@); @@ -148,6 +158,101 @@ sub FRITZBOX_Helper_html2txt($); sub FRITZBOX_Helper_store_Password($$); sub FRITZBOX_Helper_read_Password($); sub FRITZBOX_Helper_Url_Regex; +# sub FRITZBOX_Helper_Json2HTML($); + +my %LuaQueryCmd = ( + box_uptimeHours => { cmd => "uimodlogic:status/uptime_hours"}, + box_uptimeMinutes => { cmd => "uimodlogic:status/uptime_minutes"}, + box_fwVersion_neu => { cmd => "uimodlogic:status/nspver"}, + + box_fwVersion => { cmd => "logic:status/nspver"}, + box_fwUpdate => { cmd => "updatecheck:status/update_available_hint"}, + + box_powerRate => { cmd => "power:status/rate_sumact"}, + box_cpuTemp => { cmd => "power:status/act_temperature"}, + + box_tr064 => { cmd => "tr064:settings/enabled"}, + box_tr069 => { cmd => "tr069:settings/enabled"}, + + box_upnp => { cmd => "box:settings/upnp_activated"}, + box_upnpCtrl => { cmd => "box:settings/upnp_control_activated"}, + + lanDevice => { cmd => "landevice:settings/landevice/list(mac,ip,ethernet,ethernet_port,ethernetport,guest,name,active,online,wlan,speed,UID,static_dhcp)"}, + lanDeviceNew => { cmd => "landevice:settings/landevice/list(mac,ip,ethernet,guest,name,active,online,wlan,speed,UID)"}, + + box_is_double_wlan => { cmd => "wlan:settings/feature_flags/DBDC"}, + box_wlan_24GHz => { cmd => "wlan:settings/ap_enabled"}, + box_wlan_5GHz => { cmd => "wlan:settings/ap_enabled_scnd"}, + box_guestWlan => { cmd => "wlan:settings/guest_ap_enabled"}, + box_guestWlanRemain => { cmd => "wlan:settings/guest_time_remain"}, + box_macFilter_active => { cmd => "wlan:settings/is_macfilter_active"}, + wlanList => { cmd => "wlan:settings/wlanlist/list(mac,speed,speed_rx,rssi,is_guest,is_remote,is_repeater,is_ap)"}, + wlanListNew => { cmd => "wlan:settings/wlanlist/list(mac,speed,rssi)"}, + + box_dect => { cmd => "dect:settings/enabled"}, + handsetCount => { cmd => "dect:settings/Handset/count"}, + handset => { cmd => "dect:settings/Handset/list(User,Manufacturer,Model,FWVersion,Productname)"}, + + box_stdDialPort => { cmd => "telcfg:settings/DialPort"}, + init => { cmd => "telcfg:settings/Foncontrol"}, + dectUser => { cmd => "telcfg:settings/Foncontrol/User/list(Id,Name,Intern,IntRingTone,AlarmRingTone0,RadioRingID,ImagePath,G722RingTone,G722RingToneName,NoRingTime,RingAllowed,NoRingTimeFlags,NoRingWithNightSetting)"}, + fonPort => { cmd => "telcfg:settings/MSN/Port/list(Name,MSN)"}, + ringGender => { cmd => "telcfg:settings/VoiceRingtoneGender"}, + diversity => { cmd => "telcfg:settings/Diversity/list(MSN,Active,Destination)"}, + box_moh => { cmd => "telcfg:settings/MOHType"}, + dectUser => { cmd => "telcfg:settings/Foncontrol/User/list(Id,Name,Intern,IntRingTone,AlarmRingTone0,RadioRingID,ImagePath,G722RingTone,G722RingToneName,NoRingTime,RingAllowed,NoRingTimeFlags,NoRingWithNightSetting)"}, + fonPort => { cmd => "telcfg:settings/MSN/Port/list(Name,MSN)"}, + alarmClock => { cmd => "telcfg:settings/AlarmClock/list(Name,Active,Time,Number,Weekdays)"}, + + tam => { cmd => "tam:settings/TAM/list(Name,Display,Active,NumNewMessages,NumOldMessages)"}, + + TodayBytesReceivedHigh => { cmd => "inetstat:status/Today/BytesReceivedHigh"}, + TodayBytesReceivedLow => { cmd => "inetstat:status/Today/BytesReceivedLow"}, + TodayBytesSentHigh => { cmd => "inetstat:status/Today/BytesSentHigh"}, + TodayBytesSentLow => { cmd => "inetstat:status/Today/BytesSentLow"}, + + userProfil => { cmd => "user:settings/user/list(name,filter_profile_UID,this_month_time,today_time,type)"}, + userProfilNew => { cmd => "user:settings/user/list(name,type)"}, + userTicket => { cmd => "userticket:settings/ticket/list(id)"}, + + radio => { cmd => "configd:settings/WEBRADIO/list(Name)"}, + + dslStatGlobalIn => { cmd => "dslstatglobal:status/in"}, + dslStatGlobalOut => { cmd => "dslstatglobal:status/out"}, + + sip_info => { cmd => "sip:settings/sip/list(activated,displayname,connect)"}, + + vpn_info => { cmd => "vpn:settings/connection/list(remote_ip,activated,name,state,access_type,connected_since)"}, + + GSM_RSSI => { cmd => "gsm:settings/RSSI"}, + GSM_NetworkState => { cmd => "gsm:settings/NetworkState"}, + GSM_AcT => { cmd => "gsm:settings/AcT"}, +# GSM_MaxUL => { cmd => "gsm:settings/MaxUL"}, +# GSM_MaxDL => { cmd => "gsm:settings/MaxDL"}, +# GSM_CurrentUL => { cmd => "gsm:settings/CurrentUL"}, +# GSM_CurrentDL => { cmd => "gsm:settings/CurrentDL"}, +# GSM_Established => { cmd => "gsm:settings/Established"}, +# GSM_BER => { cmd => "gsm:settings/BER"}, +# GSM_Manufacturer => { cmd => "gsm:settings/Manufacturer"}, +# GSM_Model => { cmd => "gsm:settings/Model"}, +# GSM_Operator => { cmd => "gsm:settings/Operator"}, +# GSM_PIN_State => { cmd => "gsm:settings/PIN_State"}, +# GSM_Trycount => { cmd => "gsm:settings/Trycount"}, +# GSM_ModemPresent => { cmd => "gsm:settings/ModemPresent"}, +# GSM_AllowRoaming => { cmd => "gsm:settings/AllowRoaming"}, +# GSM_VoiceStatus => { cmd => "gsm:settings/VoiceStatus"}, +# GSM_SubscriberNumber => { cmd => "gsm:settings/SubscriberNumber"}, +# GSM_InHomeZone => { cmd => "gsm:settings/InHomeZone"}, + + UMTS_enabled => { cmd => "umts:settings/enabled"} # if last item change, change last comma +# UMTS_name => { cmd => "umts:settings/name"}, +# UMTS_provider => { cmd => "umts:settings/provider"}, +# UMTS_idle => { cmd => "umts:settings/idle"}, +# UMTS_backup_enable => { cmd => "umts:settings/backup_enable"}, +# UMTS_backup_downtime => { cmd => "umts:settings/backup_downtime"}, +# UMTS_backup_reverttime => { cmd => "umts:settings/backup_reverttime"}, +# UMTS_backup_reverttime => { cmd => "umts:settings/backup_reverttime"}, +); my %FB_Model = ( '7590 AX' => "7.57" # 04.09.2023 @@ -498,6 +603,7 @@ sub FRITZBOX_Initialize($) $hash->{AttrList} = "boxUser " ."disable:0,1 " ."nonblockingTimeOut:30,35,40,50,75,100,125 " + ."userAgentTimeOut " ."INTERVAL " ."reConnectInterval " ."maxSIDrenewErrCnt " @@ -509,7 +615,7 @@ sub FRITZBOX_Initialize($) ."enableUserInfo:0,1 " ."enableAlarmInfo:0,1 " ."enableWLANneighbors:0,1 " - ."enableMobileModem:0,1 " + ."enableMobileInfo:0,1 " ."wlanNeighborsPrefix " ."disableHostIPv4check:0,1 " ."disableDectInfo:0,1 " @@ -523,20 +629,26 @@ sub FRITZBOX_Initialize($) ."shdeviceID_model,shdeviceID_status,shdeviceID_tempOffset,shdeviceID_temperature,shdeviceID_type," ."shdeviceID_voltage,shdeviceID_power,shdeviceID_current,shdeviceID_consumtion,shdeviceSD_ledState,shdeviceSH_state " ."enableBoxReadings:multiple-strict," - ."box_energyMode,box_globalFilter,box_led,box_vdsl " + ."box_energyMode,box_globalFilter,box_led,box_vdsl,box_dns_Srv " + ."enableLogReadings:multiple-strict," + ."box_sys_Log,box_wlan_Log,box_fon_Log " ."disableBoxReadings:multiple-strict," ."box_connect,box_connection_Type,box_cpuTemp,box_dect,box_dns_Server,box_dsl_downStream,box_dsl_upStream," - ."box_fon_LogNewest,box_guestWlan,box_guestWlanCount,box_guestWlanRemain," + ."box_guestWlan,box_guestWlanCount,box_guestWlanRemain," ."box_ipv4_Extern,box_ipv6_Extern,box_ipv6_Prefix,box_last_connect_err,box_mac_Address,box_macFilter_active," - ."box_moh,box_powerRate,box_rateDown,box_rateUp,box_stdDialPort,box_sys_LogNewest,box_tr064,box_tr069," + ."box_moh,box_powerRate,box_rateDown,box_rateUp,box_stdDialPort,box_tr064,box_tr069," ."box_upnp,box_upnp_control_activated,box_uptime,box_uptimeConnect,box_wan_AccessType," - ."box_wlan_Count,box_wlan_2.4GHz,box_wlan_5GHz,box_wlan_Active,box_wlan_LogExtended,box_wlan_LogNewest " + ."box_wlan_Count,box_wlan_2.4GHz,box_wlan_5GHz,box_wlan_Active,box_wlan_LogExtended " ."deviceInfo:sortable,ipv4,name,uid,connection,speed,rssi,statIP,_noDefInf_ " ."disableTableFormat:multiple-strict,border(8),cellspacing(10),cellpadding(20) " ."FhemLog3Std:0,1 " ."lanDeviceReading:mac,ip " .$readingFnAttributes; + $hash->{AttrRenameMap} = { "enableMobileModem" => "enableMobileInfo" + }; + + } # end FRITZBOX_Initialize @@ -606,8 +718,9 @@ sub FRITZBOX_Define($$) return $msg; } + readingsSingleUpdate( $hash, "state", "initializing", 1 ); + # INTERNALS - $hash->{STATE} = "Initializing"; $hash->{INTERVAL} = 300; $hash->{TIMEOUT} = 55; $hash->{SID_RENEW_ERR_CNT} = 0; @@ -615,6 +728,8 @@ sub FRITZBOX_Define($$) $hash->{fhem}{LOCAL} = 0; $hash->{fhem}{is_double_wlan} = -1; + $hash->{fhem}{fwVersion} = 0; + $hash->{fhem}{fwVersionStr} = 0.0; $hash->{helper}{TimerReadout} = $name.".Readout"; $hash->{helper}{TimerCmd} = $name.".Cmd"; @@ -625,6 +740,13 @@ sub FRITZBOX_Define($$) $hash->{fhem}{sidErrCount} = 0; $hash->{fhem}{sidNewCount} = 0; + # $hash->{LuaQueryCmd} = \%LuaQueryCmd; + foreach my $key (keys %LuaQueryCmd) { + $hash->{LuaQueryCmd}{$key}{cmd} = $LuaQueryCmd{$key}{cmd}; + $hash->{LuaQueryCmd}{$key}{active} = 1; + $hash->{LuaQueryCmd}{$key}{AttrVal} = 1; + } + # Check APIs after fhem.cfg is processed $hash->{APICHECKED} = 0; $hash->{WEBCONNECT} = 0; @@ -718,11 +840,6 @@ sub FRITZBOX_Attr($@) my $URL_MATCH = FRITZBOX_Helper_Url_Regex(); - my @fwV = split(/\./, ReadingsVal($name, "box_fwVersion", "0.0.0.error")); - - my $FW1 = substr($fwV[1],0,2); - my $FW2 = substr($fwV[2],0,2); - if ($aName eq "nonblockingTimeOut") { if ($cmd eq "set") { return "the non BlockingCall timeout ($aVal sec) should be less than the INTERVAL timer ($hash->{INTERVAL} sec)" if $aVal > $hash->{INTERVAL}; @@ -735,6 +852,12 @@ sub FRITZBOX_Attr($@) } } + if ($aName eq "userAgentTimeOut") { + if ($cmd eq "set") { + return "the userAgentTimeOut should be equal or graeter than 10 and equal or less than 200." if $aVal < 10 || $aVal > 200; + } + } + if ($aName eq "reConnectInterval") { if ($cmd eq "set") { return "the reConnectInterval timer ($aVal sec) should be graeter than 10 sec." if $aVal < 55; @@ -781,7 +904,46 @@ sub FRITZBOX_Attr($@) if ($aName eq "enableBoxReadings") { my $inList = AttrVal($name, "enableBoxReadings", ""); - my @reading_list = split(/\,/, "box_led,box_energyMode,box_globalFilter,box_vdsl"); + my @reading_list = split(/\,/, "box_led,box_energyMode,box_globalFilter,box_vdsl,box_dns_Srv"); + if ($cmd eq "set") { + if ( ("box_dns_Srv" =~ /$aVal/) && $hash->{fhem}{fwVersion} <= 731 ) { + return "box_dns_Srv not available for Fritz!OS: $hash->{fhem}{fwVersionStr}"; + } + if ( ("box_led" =~ /$aVal/) && ($hash->{fhem}{fwVersion} < 680) ) { + return "box_led not available for Fritz!OS: $hash->{fhem}{fwVersionStr}"; + } + if ( ("box_energyMode" =~ /$aVal/) && $hash->{fhem}{fwVersion} < 721 ) { + return "box_energyMode not available for Fritz!OS: $hash->{fhem}{fwVersionStr}"; + } + if ( ("box_globalFilter" =~ /$aVal/) && $hash->{fhem}{fwVersion} < 721 ) { + return "box_globalFilter not available for Fritz!OS: $hash->{fhem}{fwVersionStr}"; + } + if ( ("box_vdsl" =~ /$aVal/) && $hash->{fhem}{fwVersion} < 680 ) { + return "box_vdsl not available for Fritz!OS: $hash->{fhem}{fwVersionStr}"; + } + + foreach ( @reading_list ) { + if ( $_ !~ /$inList/ ) { + my $boxDel = $_; + foreach (keys %{ $hash->{READINGS} }) { + readingsDelete($hash, $_) if $_ =~ /^${boxDel}.*/ && defined $hash->{READINGS}{$_}{VAL}; + } + } + } + } + if ($cmd eq "del") { + foreach ( @reading_list ) { + my $boxDel = $_; + foreach (keys %{ $hash->{READINGS} }) { + readingsDelete($hash, $_) if $_ =~ /^${boxDel}.*/ && defined $hash->{READINGS}{$_}{VAL}; + } + } + } + } + + if ($aName eq "enableLogReadings") { + my $inList = AttrVal($name, "enableLogReadings", ""); + my @reading_list = split(/\,/, "box_sys_Log,box_wlan_Log,box_fon_Log"); if ($cmd eq "set") { foreach ( @reading_list ) { if ( $_ !~ /$inList/ ) { @@ -854,6 +1016,7 @@ sub FRITZBOX_Attr($@) if ($aName eq "enableVPNShares") { if ($cmd eq "set") { return "$aName: $aVal. Valid is 0 or 1." if $aVal !~ /[0-1]/; + $hash->{LuaQueryCmd}{vpn_info}{AttrVal} = $aVal; } if ($cmd eq "del" || $aVal == 0) { foreach (keys %{ $hash->{READINGS} }) { @@ -877,6 +1040,8 @@ sub FRITZBOX_Attr($@) if ($aName eq "enableUserInfo") { if ($cmd eq "set") { return "$aName: $aVal. Valid is 0 or 1." if $aVal !~ /[0-1]/; + $hash->{LuaQueryCmd}{userProfil}{AttrVal} = $aVal; + $hash->{LuaQueryCmd}{userProfilNew}{AttrVal} = $aVal; } if ($cmd eq "del" || $aVal == 0) { foreach (keys %{ $hash->{READINGS} }) { @@ -888,6 +1053,7 @@ sub FRITZBOX_Attr($@) if ($aName eq "enableAlarmInfo") { if ($cmd eq "set") { return "$aName: $aVal. Valid is 0 or 1." if $aVal !~ /[0-1]/; + $hash->{LuaQueryCmd}{alarmClock}{AttrVal} = $aVal; } if ($cmd eq "del" || $aVal == 0) { foreach (keys %{ $hash->{READINGS} }) { @@ -946,7 +1112,7 @@ sub FRITZBOX_Attr($@) } } - if ($aName eq "enableMobileModem") { + if ($aName eq "enableMobileInfo") { if ($cmd eq "set") { return "$aName: $aVal. Valid is 0 or 1." if $aVal !~ /[0-1]/; } @@ -957,7 +1123,7 @@ sub FRITZBOX_Attr($@) } if ($cmd eq "set" && $hash->{APICHECKED} == 1) { - return "only available for Fritz!OS equal or greater than 7.50" unless ($FW1 >= 7 && $FW2 >= 50); + return "only available for Fritz!OS equal or greater than 7.50" if $hash->{fhem}{fwVersion} < 750; } } @@ -975,6 +1141,7 @@ sub FRITZBOX_Attr($@) if ($aName eq "disableFonInfo") { if ($cmd eq "set") { return "$aName: $aVal. Valid is 0 or 1." if $aVal !~ /[0-1]/; + $hash->{LuaQueryCmd}{fonPort}{AttrVal} = $aVal; } if ($cmd eq "del" || $aVal == 1) { foreach (keys %{ $hash->{READINGS} }) { @@ -1004,11 +1171,13 @@ sub FRITZBOX_Attr($@) } if ( ( $hash->{APICHECKED} == 1) || $aName =~ /disable|INTERVAL|nonblockingTimeOut/ ) { - FRITZBOX_Log $hash, 4, "Attr $cmd $aName -> Neustart internal Timer"; + FRITZBOX_Log $hash, 3, "Attr $cmd $aName -> Neustart internal Timer - APICHECKED = $hash->{APICHECKED}"; $hash->{APICHECKED} = 0; $hash->{WEBCONNECT} = 0; - RemoveInternalTimer($hash->{helper}{TimerReadout}); - InternalTimer(gettimeofday()+1, "FRITZBOX_Readout_Start", $hash->{helper}{TimerReadout}, 1); + $hash->{fhem}{LOCAL} = 1; + FRITZBOX_Readout_Start($hash->{helper}{TimerReadout}); + $hash->{fhem}{LOCAL} = 0; + # InternalTimer(gettimeofday()+1, "FRITZBOX_Readout_Start", $hash->{helper}{TimerReadout}, 1); # FRITZBOX_Readout_Start($hash->{helper}{TimerReadout}); } @@ -1022,11 +1191,6 @@ sub FRITZBOX_Set($$@) my $resultStr = ""; my $mesh = ReadingsVal($name, "box_meshRole", "master"); - my @fwV = split(/\./, ReadingsVal($name, "box_fwVersion", "0.0.0.error")); - - my $FW1 = substr($fwV[1],0,2); - my $FW2 = substr($fwV[2],0,2); - my $list = " checkAPIs:noArg" . " password" . " update:noArg" @@ -1085,10 +1249,11 @@ sub FRITZBOX_Set($$@) } # end update elsif ( lc $cmd eq 'inactive') { - return "ERROR: for active arguments. Required on|off" if (int @val != 1) || $val[0] != /on|off/; + return "ERROR: for active arguments. Required on|off" if (int @val != 1) || $val[0] !~ /on|off/; if ($val[0] eq "on") { $hash->{helper}{timerInActive} = 1; + readingsSingleUpdate( $hash, "state", "inactiv", 1 ); } else { $hash->{helper}{timerInActive} = 0; FRITZBOX_Log $hash, 4, "set $name $cmd -> Neustart internal Timer"; @@ -1104,7 +1269,7 @@ sub FRITZBOX_Set($$@) } #end active - # available, if passwor is set correctly + # available, if password is set correctly if ($hash->{WEBCONNECT}) { # set abhängig von TR064 $list .= " reboot" @@ -1130,7 +1295,7 @@ sub FRITZBOX_Set($$@) if ($hash->{LUADATA} == 1) && defined ($hash->{MODEL}) && ($hash->{MODEL} =~ "Box") && $hash->{TR064} == 1 && $hash->{SECPORT} && $mesh eq "master"; $list .= " enableVPNshare" - if ($hash->{LUADATA} == 1) && defined ($hash->{MODEL}) && ($hash->{MODEL} =~ "Box") && $hash->{TR064} == 1 && $hash->{SECPORT} && $mesh eq "master" && $FW1 == 7 && $FW2 >= 21; + if ($hash->{LUADATA} == 1) && defined ($hash->{MODEL}) && ($hash->{MODEL} =~ "Box") && $hash->{TR064} == 1 && $hash->{SECPORT} && $mesh eq "master" && ($hash->{fhem}{fwVersion} >= 721); $list .= " phoneBookEntry" if defined ($hash->{MODEL}) && ($hash->{MODEL} =~ "Box") && $hash->{TR064} == 1 && $hash->{SECPORT}; @@ -1148,16 +1313,17 @@ sub FRITZBOX_Set($$@) . " dectRingblock" . " blockIncomingPhoneCall" . " smartHome" - if ($hash->{LUADATA} == 1) && defined ($hash->{MODEL}) && ($hash->{MODEL} =~ "Box" && $FW1 == 7 && $FW2 >= 21); + if ($hash->{LUADATA} == 1) && defined ($hash->{MODEL}) && ($hash->{MODEL} =~ "Box") && ($hash->{fhem}{fwVersion} >= 721); $list .= " ledSetting" - if ($hash->{LUADATA} == 1) && $FW1 == 7 && $FW2 >= 21; + if ($hash->{LUADATA} == 1) && ($hash->{fhem}{fwVersion} >= 721); $list .= " energyMode:default,eco" - if ($hash->{LUADATA} == 1) && defined ($hash->{MODEL}) && ($hash->{MODEL} =~ "Box" && $FW1 == 7 && $FW2 >= 50); + if ($hash->{LUADATA} == 1) && defined ($hash->{MODEL}) && ($hash->{MODEL} =~ "Box") && ($hash->{fhem}{fwVersion} >= 750); $list .= " rescanWLANneighbors:noArg" . " wlanLogExtended:on,off" + . " wlanGuestParams" if ($hash->{LUADATA} == 1); if ( lc $cmd eq 'smarthome') { @@ -1281,6 +1447,10 @@ sub FRITZBOX_Set($$@) } #end smarthome elsif ( lc $cmd eq 'call' && $mesh eq "master") { + + return "At least one parameter must be defined." unless int @val; + return "Parameter '$val[0]' not a valid phone number" unless $val[0] =~ /^[\d\*\#+,]+$/; + if (int @val >= 0 && int @val <= 2) { FRITZBOX_Log $hash, 3, "set $name $cmd " . join(" ", @val); push @cmdBuffer, "call " . join(" ", @val); @@ -1288,7 +1458,7 @@ sub FRITZBOX_Set($$@) } } # end call - elsif ( (lc $cmd eq 'blockincomingphonecall') && ($hash->{LUADATA} == 1) && defined ($hash->{MODEL}) && ($hash->{MODEL} =~ "Box") && $FW1 == 7 && $FW2 >= 21 ) { + elsif ( (lc $cmd eq 'blockincomingphonecall') && ($hash->{LUADATA} == 1) && defined ($hash->{MODEL}) && ($hash->{MODEL} =~ "Box") && ($hash->{fhem}{fwVersion} >= 721) ) { # set blockIncomingPhoneCall # set blockIncomingPhoneCall @@ -1369,7 +1539,7 @@ sub FRITZBOX_Set($$@) push @webCmdArray, "lang" => "de"; push @webCmdArray, "page" => "dectSet"; - FRITZBOX_Log $hash, 5, "set $name $cmd \n" . join(" ", @webCmdArray); + FRITZBOX_Log $hash, 4, "set $name $cmd \n" . join(" ", @webCmdArray); my $result = FRITZBOX_read_LuaData($hash, "data", \@webCmdArray); @@ -1392,11 +1562,11 @@ sub FRITZBOX_Set($$@) } } # end dect - elsif ( lc $cmd eq 'dectringblock' && $mesh eq "master" && $FW1 == 7 && $FW2 >= 21) { + elsif ( lc $cmd eq 'dectringblock' && $mesh eq "master" && $hash->{fhem}{fwVersion} >= 721) { FRITZBOX_Log $hash, 3, "set $name $cmd " . join(" ", @val); - if ($FW1 <= 7 && $FW2 < 21) { + if ($hash->{fhem}{fwVersion} < 721) { FRITZBOX_Log $hash, 2, "FritzOS version must be greater than 7.20"; return "ERROR: FritzOS version must be greater than 7.20."; } @@ -1494,7 +1664,7 @@ sub FRITZBOX_Set($$@) push @webCmdArray, "lang" => "de"; push @webCmdArray, "page" => "edit_dect_ring_block"; - FRITZBOX_Log $hash, 5, "set $name $cmd \n" . join(" ", @webCmdArray); + FRITZBOX_Log $hash, 4, "set $name $cmd \n" . join(" ", @webCmdArray); my $result = FRITZBOX_read_LuaData($hash, "data", \@webCmdArray) ; @@ -1538,7 +1708,7 @@ sub FRITZBOX_Set($$@) } # end diversity elsif ( lc $cmd eq 'energymode') { - if ( $hash->{TR064} != 1 || !($FW1 == 7 && $FW2 >= 50) ) { #tr064 + if ( $hash->{TR064} != 1 || ($hash->{fhem}{fwVersion} < 750) ) { #tr064 FRITZBOX_Log $hash, 2, "'set ... energyMode' is not supported by the limited interfaces of your Fritz!Box firmware."; return "ERROR: 'set ... energyMode' is not supported by the limited interfaces of your Fritz!Box firmware."; } @@ -1637,7 +1807,7 @@ sub FRITZBOX_Set($$@) # led:on|off brightness:1..2 ledenv:on|off - unless ( ($hash->{LUADATA} == 1) && $FW1 == 7 && $FW2 >= 21) { + unless ( ($hash->{LUADATA} == 1) && ($hash->{fhem}{fwVersion} >= 721)) { FRITZBOX_Log $hash, 2, "'set ... ledsetting' is not supported by the limited interfaces of your Fritz!Box firmware."; return "error: 'set ... ledsetting' is not supported by the limited interfaces of your Fritz!Box firmware."; } @@ -1707,7 +1877,7 @@ sub FRITZBOX_Set($$@) push @webCmdArray, "lang" => "de"; push @webCmdArray, "page" => "led"; - FRITZBOX_Log $hash, 5, "set $name $cmd \n" . join(" ", @webCmdArray); + FRITZBOX_Log $hash, 4, "set $name $cmd \n" . join(" ", @webCmdArray); $result = FRITZBOX_read_LuaData($hash, "data", \@webCmdArray) ; @@ -1791,7 +1961,7 @@ sub FRITZBOX_Set($$@) eval { foreach my $key (keys %$views) { - FRITZBOX_Log $hash, 5, "Kid Profiles: " . $key; + FRITZBOX_Log $hash, 4, "Kid Profiles: " . $key; if ($profileName eq $resultData->{data}->{kidProfiles}->{$key}{Name}) { $profileID = $resultData->{data}->{kidProfiles}->{$key}{Id}; @@ -2154,7 +2324,7 @@ sub FRITZBOX_Set($$@) } else { FRITZBOX_Log $hash, 3, "set $name $cmd " . join(" ", @val); - if ( $hash->{TR064}==1 ) { #tr064 + if ( $hash->{TR064} == 1 ) { #tr064 readingsSingleUpdate($hash, "box_lastFhemReboot", strftime("%d.%m.%Y %H:%M:%S", localtime(time() + ($val[0] * 60))), 1 ); # my @tr064CmdArray = (["DeviceConfig:1", "deviceconfig", "Reboot"] ); # FRITZBOX_call_TR064_Cmd ($hash, 0, \@tr064CmdArray); @@ -2181,10 +2351,17 @@ sub FRITZBOX_Set($$@) #set Ring elsif ( lc $cmd eq 'ring' && $mesh eq "master") { + return "At least one parameter must be defined." unless int @val; + if (int @val > 0) { + + # Check if 1st parameter are comma separated numbers + return "Parameter '$val[0]' not a (list) of number(s) (only commas (,) are allowed to separate phone numbers)" unless $val[0] =~ /^[\d,]+$/; + FRITZBOX_Log $hash, 3, "set $name $cmd " . join(" ", @val); push @cmdBuffer, "ring ".join(" ", @val); return FRITZBOX_Readout_SetGet_Start $hash->{helper}{TimerCmd}; + } } # end ring @@ -2193,7 +2370,7 @@ sub FRITZBOX_Set($$@) if (int @val == 1 && $val[0] =~ /^(provider|other)$/) { FRITZBOX_Log $hash, 3, "set $name $cmd " . join(" ", @val); - if ($FW1 <= 7 && $FW2 < 21) { + if ($hash->{fhem}{fwVersion} < 721) { FRITZBOX_Log $hash, 2, "FritzOS version must be greater than 7.20"; return "ERROR: FritzOS version must be greater than 7.20."; } @@ -2221,7 +2398,7 @@ sub FRITZBOX_Set($$@) } FRITZBOX_Log $hash, 4, "DNS IPv4 set to ".$val[0]; - return "DNS IPv4 set to ".$val[0]; + return "DNS IPv4 set to " . $val[0]; } elsif ( $val[0] eq "other") { @@ -2303,13 +2480,13 @@ sub FRITZBOX_Set($$@) } } # end tam - elsif ( lc $cmd eq 'enablevpnshare' && $mesh eq "master" && $FW1 == 7 && $FW2 >= 21) { + elsif ( lc $cmd eq 'enablevpnshare' && $mesh eq "master" && ($hash->{fhem}{fwVersion} >= 721)) { if ( int @val == 2 && $val[1] =~ /^(on|off)$/ ) { FRITZBOX_Log $hash, 3, "INFO: set $name $cmd " . join(" ", @val); - if ($FW1 <= 7 && $FW2 < 21) { + if ($hash->{fhem}{fwVersion} < 721 ) { FRITZBOX_Log $hash, 2, "ERROR: FritzOS version must be greater than 7.20"; return "ERROR: FritzOS version must be greater than 7.20."; } @@ -2340,7 +2517,7 @@ sub FRITZBOX_Set($$@) } # end enablevpnshare - elsif ( (lc $cmd eq 'wakeupcall') && ($hash->{LUADATA} == 1) && defined ($hash->{MODEL}) && ($hash->{MODEL} =~ "Box") && $FW1 == 7 && $FW2 >= 21 ) { + elsif ( (lc $cmd eq 'wakeupcall') && ($hash->{LUADATA} == 1) && defined ($hash->{MODEL}) && ($hash->{MODEL} =~ "Box") && ($hash->{fhem}{fwVersion} >= 721) ) { # xhr 1 lang de page alarm xhrId all / get Info # xhr: 1 @@ -2417,7 +2594,7 @@ sub FRITZBOX_Set($$@) elsif ( lc $cmd eq 'wlan') { if (int @val == 1 && $val[0] =~ /^(on|off)$/) { FRITZBOX_Log $hash, 3, "set $name $cmd " . join(" ", @val); - push @cmdBuffer, "wlan ".join(" ", @val); + push @cmdBuffer, "wlan " . join(" ", @val); return FRITZBOX_Readout_SetGet_Start $hash->{helper}{TimerCmd}; } } # end wlan @@ -2433,10 +2610,55 @@ sub FRITZBOX_Set($$@) elsif ( lc $cmd eq 'wlanlogextended') { if (int @val == 1 && $val[0] =~ /^(on|off)$/) { FRITZBOX_Log $hash, 3, "set $name $cmd " . join(" ", @val); - push @cmdBuffer, "wlanlogextended ".join(" ", @val); + push @cmdBuffer, "wlanlogextended " . join(" ", @val); return FRITZBOX_Readout_SetGet_Start $hash->{helper}{TimerCmd}; } } # end wlanlogextended + + elsif ( lc $cmd eq 'wlanguestparams') { + + # getting Parameters + my %paraPos; + my $lastPos = (int @val) - 1; + my $returnStr = ""; + + for (my $i = (int @val) - 1; $i >= 0; $i--) { + if ($val[$i] =~ /ssid:|pwd:|wlan:|mode:|tmo:|tmoActive:|tmoNoForcedOff:/) { + my $para = $val[$i]; + $para =~ s/\:.*//; + + my $paraValue = join(' ', @val[$i..$lastPos]); + $paraValue =~ s/.*?\://; + + if ($para =~ /ssid/ && ((substr($paraValue,0,1) eq " ") || $paraValue !~ /[A-Za-z0-9 _!"#%&',:;<=>@`~\-\$\(\)\*\+\.\?\[\]\^\{\|\}\\]{8,63}/) ) { + return "wlanguestparams: SSID - wrong number of characters (8 - 63) or not allowed characters: $paraValue.\nSee also: 'https://fritzhelp.avm.de/help/de/FRITZ-Box-7590/1und1/021/hilfe_zeichen_fuer_kennwoerter'"; + + } elsif ($para =~ /pwd/ && ((substr($paraValue,0,4) eq '$$$$') || (substr($paraValue,0,1) eq " ") || ($paraValue !~ /[A-Za-z0-9 _!"#%&',:;<=>@`~\-\$\(\)\*\+\.\?\[\]\^\{\|\}\\]{8,32}/)) ) { + return "wlanguestparams: Password - wrong number of characters (8 - 63) or not allowed characters: " . $paraValue . ".\nSee also: 'https://fritzhelp.avm.de/help/de/FRITZ-Box-7590/1und1/021/hilfe_zeichen_fuer_kennwoerter'"; + + } elsif ($para =~ /wlan|tmoActive|tmoNoForcedOff/ && ($paraValue !~ /on|off/) ) { + return "wlanguestparams: $val[0] - not allowed command: $paraValue. Recommended: on or off"; + + } elsif ($para =~ /tmo/ && ($paraValue !~ /[0-9]{2,4}/ || $paraValue < 15 || $paraValue > 4320) ) { + return "wlanguestparams: tmo (timeout) - not allowed command: $paraValue. Recommended: number in between 15 - 4320 minutes"; + + } elsif ($para =~ /mode/ && ($paraValue !~ /private|public/) ) { + return "wlanguestparams: MODE - not allowed command: $paraValue. Recommended: private or public"; + } + + $returnStr .= $para . ":" . $paraValue . "\n"; + + $lastPos = $i - 1; + } + } + + return "wlanguestparams: no valid command. Please use ssid:|pwd:|wlan:|mode:|tmo:|tmoActive:|tmoNoForcedOff: as commands" if $returnStr eq ""; + + FRITZBOX_Log $hash, 3, "set $name $cmd " . join(" ", @val); + push @cmdBuffer, "wlanguestparams " . join(" ", @val); + return FRITZBOX_Readout_SetGet_Start $hash->{helper}{TimerCmd}; + + } # end wlanguestparams } return "Unknown argument $cmd or wrong parameter(s), choose one of $list"; @@ -2449,15 +2671,10 @@ sub FRITZBOX_Get($@) my ($hash, $name, $cmd, @val) = @_; my $returnStr; - my @fwV = split(/\./, ReadingsVal($name, "box_fwVersion", "0.0.0.error")); - - my $FW1 = substr($fwV[1],0,2); - my $FW2 = substr($fwV[2],0,2); - my $avmModel = InternalVal($name, "MODEL", "FRITZ!Box"); my $mesh = ReadingsVal($name, "box_meshRole", "master"); - # available, if passwor is set correctly + # available, if password is set correctly if ($hash->{WEBCONNECT}) { if( lc $cmd eq "luaquery" && $hash->{LUAQUERY} == 1) { @@ -2467,8 +2684,9 @@ sub FRITZBOX_Get($@) return "Wrong number of arguments, usage: get $name luaQuery " if int @val !=1; - $returnStr = "Result of query = '$val[0]'\n"; - $returnStr .= "----------------------------------------------------------------------\n"; + $returnStr = "Result of query = '$val[0]'\n"; + $returnStr .= "----------------------------------------------------------------------\n"; + my $queryStr = "&result=".$val[0]; my $result = FRITZBOX_call_Lua_Query( $hash, $queryStr) ; @@ -2496,7 +2714,7 @@ sub FRITZBOX_Get($@) my $mode = ""; - if ($val[0] eq "json") { + if ($val[0] =~ /json/) { return "Wrong number of arguments, usage: get $name hash argName1 argValue1 [argName2 argValue2] ..." if int @val < 3 || (int(@val) - 1) %2 == 1; $mode = shift (@val); # remove 1st element and store it. } else { @@ -2523,6 +2741,10 @@ sub FRITZBOX_Get($@) return to_json( $result, { pretty => 0 } ); } +# if ($mode eq "html") { +# return FRITZBOX_Helper_Json2HTML(parse_json(to_json( $result, { pretty => 0 } ))); +# } + $returnStr = "Result of data = " . $queryStr . "\n"; $returnStr .= "----------------------------------------------------------------------\n"; @@ -2575,7 +2797,7 @@ sub FRITZBOX_Get($@) FRITZBOX_Log $hash, 3, "get $name $cmd " . join(" ", @val); - if (($FW1 <= 7 && $FW2 < 21) || ($FW1 <= 6)) { + if ($hash->{fhem}{fwVersion} < 721) { FRITZBOX_Log $hash, 2, "FritzOS version must be greater than 7.20"; return "FritzOS version must be greater than 7.20."; } @@ -2605,7 +2827,7 @@ sub FRITZBOX_Get($@) FRITZBOX_Log $hash, 4, "get $name $cmd [" . int(@val) . "] " . join(" ", @val); - if (($FW1 <= 7 && $FW2 < 21) || ($FW1 <= 6)) { + if ($hash->{fhem}{fwVersion} < 721) { FRITZBOX_Log $hash, 2, "FritzOS version must be greater than 7.20"; return "FritzOS version must be greater than 7.20."; } @@ -2614,7 +2836,10 @@ sub FRITZBOX_Get($@) my $avmModel = InternalVal($name, "MODEL", "FRITZ!Box"); - if ( $val[0] eq "smartHome" && $hash->{LUADATA} == 1) { + if ( $val[0] eq "mobileInfo" && $hash->{LUADATA} == 1) { + $returnStr = FRITZBOX_Get_MobileInfo($hash); + + } elsif ( $val[0] eq "smartHome" && $hash->{LUADATA} == 1) { $returnStr = FRITZBOX_Get_SmartHome_Devices_List($hash); } elsif ( $val[0] eq "lanDevices" && $hash->{LUADATA} == 1) { @@ -2718,15 +2943,15 @@ sub FRITZBOX_Get($@) $list .= " luaFunction" if $hash->{LUAQUERY} == 1; # luaData - if (($hash->{LUADATA} == 1 || $hash->{LUAQUERY} == 1) && ($FW1 >= 7) ){ + if (($hash->{LUADATA} == 1 || $hash->{LUAQUERY} == 1) && ($hash->{fhem}{fwVersion} >= 700) ){ $list .= " luaInfo:"; $list .= "lanDevices,ledSettings,vpnShares,wlanNeighborhood" if $hash->{LUADATA} == 1; - $list .= ",globalFilters,smartHome" if $hash->{LUADATA} == 1 && ($avmModel =~ "Box"); + $list .= ",mobileInfo,globalFilters,smartHome" if $hash->{LUADATA} == 1 && ($avmModel =~ "Box"); $list .= ",kidProfiles,userInfos" if $hash->{LUAQUERY} == 1; $list .= ",docsisInformation" if $hash->{LUADATA} == 1 && ($avmModel =~ "Box") && (lc($avmModel) =~ "6[4,5,6][3,6,9][0,1]"); } - $list .= " fritzLog" if $hash->{LUADATA} == 1 && (($FW1 >= 6 && $FW2 >= 80) || ($FW1 >= 7)); + $list .= " fritzLog" if $hash->{LUADATA} == 1 && ($hash->{fhem}{fwVersion} >= 680); $list .= " lanDeviceInfo" if $hash->{LUADATA} == 1; @@ -2748,14 +2973,9 @@ sub FRITZBOX_SetGet_Proof_Params($@) { my ($hash, $name, $cmd, $mysearch, @val) = @_; $mysearch = "" unless( defined $mysearch); - my @fwV = split(/\./, ReadingsVal($name, "box_fwVersion", "0.0.0.error")); + FRITZBOX_Log $hash, 4, "set $name $cmd (Fritz!OS: $hash->{fhem}{fwVersionStr})"; - my $FW1 = substr($fwV[1],0,2); - my $FW2 = substr($fwV[2],0,2); - - FRITZBOX_Log $hash, 4, "set $name $cmd (Fritz!OS: $FW1.$FW2)"; - - if ($FW1 <= 7 && $FW2 < 21) { + if ($hash->{fhem}{fwVersion} < 721) { FRITZBOX_Log $hash, 2, "FritzOS version must be greater than 7.20"; return "ERROR: FritzOS version must be greater than 7.20."; } @@ -2845,19 +3065,28 @@ sub FRITZBOX_Readout_Start($) $hash->{SID_RENEW_CNT} += $hash->{fhem}{sidNewCount} if defined $hash->{fhem}{sidNewCount}; if( defined $hash->{fhem}{sidErrCount} && $hash->{fhem}{sidErrCount} >= AttrVal($name, "maxSIDrenewErrCnt", 5) ) { - FRITZBOX_Log $hash, 2, "stopped while to many authentication errors"; RemoveInternalTimer($hash->{helper}{TimerReadout}); - readingsSingleUpdate( $hash, "state", "stopped while to many authentication errors", 1 ); + + if ($hash->{APICHECKED} == -1) { + readingsSingleUpdate( $hash, "state", "stopped while to many network errors", 1 ); + FRITZBOX_Log $hash, 2, "stopped while to many network errors"; + } else { + readingsSingleUpdate( $hash, "state", "stopped while to many authentication errors", 1 ); + FRITZBOX_Log $hash, 2, "stopped while to many API errors"; + } + return undef; } if( $hash->{helper}{timerInActive} && $hash->{fhem}{LOCAL} != 1) { + FRITZBOX_Log $hash, 2, "stopped while timerInActive and LOCAL != 1"; RemoveInternalTimer($hash->{helper}{TimerReadout}); readingsSingleUpdate( $hash, "state", "inactive", 1 ); return undef; } if( AttrVal( $name, "disable", 0 ) == 1 && $hash->{fhem}{LOCAL} != 1) { + FRITZBOX_Log $hash, 2, "stopped while disabled and LOCAL != 1"; RemoveInternalTimer($hash->{helper}{TimerReadout}); readingsSingleUpdate( $hash, "state", "disabled", 1 ); return undef; @@ -2869,22 +3098,24 @@ sub FRITZBOX_Readout_Start($) my $interval = $hash->{INTERVAL}; -# Set Ttimeout for BlockinCall +# Set timeout for BlockinCall $hash->{TIMEOUT} = AttrVal( $name, "nonblockingTimeOut", 55 ); $hash->{TIMEOUT} = $interval - 10 if $hash->{TIMEOUT} > $hash->{INTERVAL}; + $hash->{AGENTTMOUT} = AttrVal( $name, "userAgentTimeOut", $hash->{TIMEOUT} - 5); + $hash->{AGENTTMOUT} = $hash->{TIMEOUT} - 5 if $hash->{AGENTTMOUT} > $hash->{TIMEOUT}; my $timeout = $hash->{TIMEOUT}; # First run is an API check if ( $hash->{APICHECKED} == 0 ) { $interval = 65; - $timeout = 50; - $hash->{STATE} = "Check APIs"; + $timeout = 60; + readingsSingleUpdate( $hash, "state", "check APIs", 1 ); $runFn = "FRITZBOX_Set_check_APIs"; } elsif ( $hash->{APICHECKED} < 0 ) { $interval = AttrVal( $name, "reConnectInterval", 180 ) < 55 ? 55 : AttrVal( $name, "reConnectInterval", 180 ); - $timeout = 50; - $hash->{STATE} = "recheck APIs every $interval seconds"; + $timeout = 60; + readingsSingleUpdate( $hash, "state", "recheck APIs every $interval seconds", 1 ); $runFn = "FRITZBOX_Set_check_APIs"; } # Run shell or web api, restrict interval @@ -2911,7 +3142,7 @@ sub FRITZBOX_Readout_Start($) $hash->{helper}{READOUT_RUNNING_PID} = BlockingCall($runFn, $name, "FRITZBOX_Readout_Done", $timeout, "FRITZBOX_Readout_Aborted", $hash); -# $hash->{helper}{READOUT_RUNNING_PID}->{loglevel} = GetVerbose($name); + $hash->{helper}{READOUT_RUNNING_PID}->{loglevel} = GetVerbose($name); FRITZBOX_Log $hash, 4, "Fork process $runFn"; } else { @@ -2924,6 +3155,8 @@ sub FRITZBOX_Readout_Start($) # Ab hier alle Sub, die für den nonBlocking Timer zuständig sind ############################################################################################################################################## + + # Starts the data capturing and sets the new timer ####################################################################### sub FRITZBOX_Readout_Run_Web($) @@ -2931,15 +3164,71 @@ sub FRITZBOX_Readout_Run_Web($) my ($name) = @_; my $hash = $defs{$name}; + my @roReadings; + my $returnStr = ""; + my $sid = ""; + my $sidNew = 0; + + my $avmModel = InternalVal($name, "MODEL", "FRITZ!Box"); + + my $startTime = time(); + + $returnStr = FRITZBOX_Readout_Run_Web_LuaQuery($name, \@roReadings, \$sidNew, \$sid); + return $returnStr if $returnStr =~/Error\|/; + +# if ( (($FW1 == 6 && $FW2 >= 80) || ($FW1 >= 7 && $FW2 >= 21)) && $hash->{LUADATA} == 1) { + + if ( $hash->{fhem}{fwVersion} >= 680 && $hash->{LUADATA} == 1) { + $returnStr = FRITZBOX_Readout_Run_Web_LuaData($name, \@roReadings, \$sidNew, \$sid); + return $returnStr if $returnStr =~/Error\|/; + } else { + FRITZBOX_Log $hash, 4, "wrong Fritz!OS: $hash->{fhem}{fwVersionStr} or data.lua not available"; + } + + if ( $hash->{TR064} == 1 && $hash->{SECPORT} ) { + $returnStr = FRITZBOX_Readout_Run_Web_TR064($name, \@roReadings, \$sidNew, \$sid); + return $returnStr if $returnStr =~/Error\|/; + } else { + FRITZBOX_Log $hash, 4, "TR064: $hash->{TR064} or secure Port:" . ($hash->{SECPORT} ? $hash->{SECPORT} : "none") . " not available or wrong Fritz!OS: $hash->{fhem}{fwVersionStr}."; + } + + FRITZBOX_Readout_Add_Reading ($hash, \@roReadings, "->HINWEIS_BOXUSER", ""); + FRITZBOX_Readout_Add_Reading ($hash, \@roReadings, "->HINWEIS_PASSWORD", ""); + + # Ende und Rückkehr zum Hauptprozess + + FRITZBOX_Readout_Add_Reading $hash, \@roReadings, ".calledFrom", "runWeb"; + + push @roReadings, "readoutTime", sprintf( "%.2f", time()-$startTime); + + FRITZBOX_Readout_Add_Reading $hash, \@roReadings, "fhem->sid", $sid if $sid ne ""; + FRITZBOX_Readout_Add_Reading $hash, \@roReadings, "fhem->sidTime", time(); + FRITZBOX_Readout_Add_Reading $hash, \@roReadings, "fhem->sidErrCount", 0; + FRITZBOX_Readout_Add_Reading $hash, \@roReadings, "fhem->sidNewCount", $sidNew; + FRITZBOX_Readout_Add_Reading $hash, \@roReadings, "->WEBCONNECT", 1; + + push @roReadings, "readoutTime", sprintf( "%.2f", time()-$startTime); + $returnStr = join('|', @roReadings ); + + FRITZBOX_Log $hash, 4, "Captured " . @roReadings . " values"; + FRITZBOX_Log $hash, 4, "Handover to main process (" . length ($returnStr) . "): " . $returnStr; + return $name."|".encode_base64($returnStr,""); + +} # End FRITZBOX_Readout_Run_Web + +####################################################################### +# @{$roReadings} +sub FRITZBOX_Readout_Run_Web_LuaQuery($$$$) { + + my ($name, $roReadings, $sidNew, $sid) = @_; + my $hash = $defs{$name}; + my $result; my $rName; - my @roReadings; my %dectFonID; my %fonFonID; my $startTime = time(); my $runNo; - my $sid; - my $sidNew = 0; my $host = $hash->{HOST}; my $Tag; my $Std; @@ -2950,10 +3239,6 @@ sub FRITZBOX_Readout_Run_Web($) my $nbViews; my $avmModel = InternalVal($name, "MODEL", "FRITZ!Box"); - my @fwV = split(/\./, ReadingsVal($name, "box_fwVersion", "0.0.0.error")); - - my $FW1 = substr($fwV[1],0,2); - my $FW2 = substr($fwV[2],0,2); my $mesh = ReadingsVal($name, "box_meshRole", "master"); @@ -2961,131 +3246,37 @@ sub FRITZBOX_Readout_Run_Web($) my $resultData; my $tmpData; + FRITZBOX_Log $hash, 4, "luaQuery - start getting data"; + my $disableBoxReadings = AttrVal($name, "disableBoxReadings", ""); -#Start update - FRITZBOX_Log $hash, 4, "Prepare query string for luaQuery."; + my $queryStr = ""; - my $queryStr = "&radio=configd:settings/WEBRADIO/list(Name)"; # Webradio - - #queryStr .= "&box_dectRingTone=dect:settings/ServerRingtone/list(UID,Name)"; #settings/LastSetServerRingtoneState - #queryStr .= "&box_dectNightTime=dect:settings/NightTime"; - $queryStr .= "&box_dect=dect:settings/enabled"; # DECT Sender - - $queryStr .= "&handsetCount=dect:settings/Handset/count"; # Anzahl Handsets - $queryStr .= "&handset=dect:settings/Handset/list(User,Manufacturer,Model,FWVersion,Productname)"; # DECT Handsets - - $queryStr .= "&wlanList=wlan:settings/wlanlist/list(mac,speed,speed_rx,rssi,is_guest,is_remote,is_repeater,is_ap)"; # WLAN devices - $queryStr .= "&wlanListNew=wlan:settings/wlanlist/list(mac,speed,rssi)"; # WLAN devices fw>=6.69 and <7 - - $queryStr .= "&lanDevice=landevice:settings/landevice/list(mac,ip,ethernet,ethernet_port,ethernetport,guest,name,active,online,wlan,speed,UID,static_dhcp)"; # LAN devices - $queryStr .= "&lanDeviceNew=landevice:settings/landevice/list(mac,ip,ethernet,guest,name,active,online,wlan,speed,UID)"; # LAN devices fw>=6.69 and <7 - - $queryStr .= "&init=telcfg:settings/Foncontrol"; # Init - $queryStr .= "&box_stdDialPort=telcfg:settings/DialPort"; #Dial Port - -# unless (AttrVal( $name, "disableDectInfo", "0")) { - $queryStr .= "&dectUser=telcfg:settings/Foncontrol/User/list(Id,Name,Intern,IntRingTone,AlarmRingTone0,RadioRingID,ImagePath,G722RingTone,G722RingToneName,NoRingTime,RingAllowed,NoRingTimeFlags,NoRingWithNightSetting)"; # DECT Numbers -# } - - unless (AttrVal( $name, "disableFonInfo", "0")) { - $queryStr .= "&fonPort=telcfg:settings/MSN/Port/list(Name,MSN)"; # Fon ports + if ($hash->{LuaQueryCmd}{sip_info}{active} && ReadingsNum($name, "box_model", "3490") ne "3490" && AttrVal( $name, "enableSIP", "0")) { + $hash->{LuaQueryCmd}{sip_info}{AttrVal} = 1; + } else { + $hash->{LuaQueryCmd}{sip_info}{AttrVal} = 0; } - if (AttrVal( $name, "enableAlarmInfo", "0")) { - $queryStr .= "&alarmClock=telcfg:settings/AlarmClock/list(Name,Active,Time,Number,Weekdays)"; # Alarm Clock + foreach my $key (keys %{ $hash->{LuaQueryCmd} }) { + FRITZBOX_Log $hash, 4, $key . ": " . $hash->{LuaQueryCmd}{$key}{active}; + $queryStr .= "&" . $key . "=" . $hash->{LuaQueryCmd}{$key}{cmd} if $hash->{LuaQueryCmd}{$key}{active} && $hash->{LuaQueryCmd}{$key}{AttrVal}; } -# $queryStr .= "&ringGender=telcfg:settings/VoiceRingtoneGender"; # >= 7.39 - - $queryStr .= "&diversity=telcfg:settings/Diversity/list(MSN,Active,Destination)"; # Diversity (Rufumleitung) - $queryStr .= "&box_moh=telcfg:settings/MOHType"; # Music on Hold - $queryStr .= "&box_uptimeHours=uimodlogic:status/uptime_hours"; # hours - $queryStr .= "&box_uptimeMinutes=uimodlogic:status/uptime_minutes"; # hours - $queryStr .= "&box_fwVersion=logic:status/nspver"; # FW Version #uimodlogic:status/nspver - $queryStr .= "&box_fwVersion_neu=uimodlogic:status/nspver"; # FW Version - $queryStr .= "&box_powerRate=power:status/rate_sumact"; # Power Rate - $queryStr .= "&tam=tam:settings/TAM/list(Name,Display,Active,NumNewMessages,NumOldMessages)"; # TAM - $queryStr .= "&box_cpuTemp=power:status/act_temperature"; # Box CPU Temperatur - - #$queryStr .= "&box_ipv4_Extern=connection0:status/ip"; # Externe IP-Adresse - #$queryStr .= "&box_connect=connection0:status/connect"; # Internet connection state - - $queryStr .= "&box_tr064=tr064:settings/enabled"; # TR064 - $queryStr .= "&box_tr069=tr069:settings/enabled"; # TR069 - $queryStr .= "&box_upnp=box:settings/upnp_activated"; #UPNP - $queryStr .= "&box_upnpCtrl=box:settings/upnp_control_activated"; - $queryStr .= "&box_fwUpdate=updatecheck:status/update_available_hint"; - - if (AttrVal( $name, "enableUserInfo", "0")) { - $queryStr .= "&userProfil=user:settings/user/list(name,filter_profile_UID,this_month_time,today_time,type)"; # User profiles - $queryStr .= "&userProfilNew=user:settings/user/list(name,type)"; # User profiles fw>=6.69 - } - - $queryStr .= "&is_double_wlan=wlan:settings/feature_flags/DBDC"; # Box Feature - $queryStr .= "&box_wlan_24GHz=wlan:settings/ap_enabled"; # WLAN - $queryStr .= "&box_wlan_5GHz=wlan:settings/ap_enabled_scnd"; # 2nd WLAN - $queryStr .= "&box_guestWlan=wlan:settings/guest_ap_enabled"; # Gäste WLAN - $queryStr .= "&box_guestWlanRemain=wlan:settings/guest_time_remain"; - $queryStr .= "&box_macFilter_active=wlan:settings/is_macfilter_active"; - $queryStr .= "&TodayBytesReceivedHigh=inetstat:status/Today/BytesReceivedHigh"; - $queryStr .= "&TodayBytesReceivedLow=inetstat:status/Today/BytesReceivedLow"; - $queryStr .= "&TodayBytesSentHigh=inetstat:status/Today/BytesSentHigh"; - $queryStr .= "&TodayBytesSentLow=inetstat:status/Today/BytesSentLow"; - $queryStr .= "&GSM_RSSI=gsm:settings/RSSI"; - $queryStr .= "&GSM_NetworkState=gsm:settings/NetworkState"; - $queryStr .= "&GSM_AcT=gsm:settings/AcT"; - $queryStr .= "&UMTS_enabled=umts:settings/enabled"; - $queryStr .= "&userTicket=userticket:settings/ticket/list(id)"; - - if ($mesh ne "slave") { - $queryStr .= "&dslStatGlobalIn=dslstatglobal:status/in"; - $queryStr .= "&dslStatGlobalOut=dslstatglobal:status/out"; - } - - if (ReadingsNum($name, "box_model", "3490") ne "3490" && AttrVal( $name, "enableSIP", "0")) { - $queryStr .= "&sip_info=sip:settings/sip/list(activated,displayname,connect)"; - } - - if (AttrVal( $name, "enableVPNShares", "0")) { - $queryStr .= "&vpn_info=vpn:settings/connection/list(remote_ip,activated,name,state,access_type,connected_since)"; - } - - # $queryStr .= "&GSM_MaxUL=gsm:settings/MaxUL"; - # $queryStr .= "&GSM_MaxDL=gsm:settings/MaxDL"; - # $queryStr .= "&GSM_CurrentUL=gsm:settings/CurrentUL"; - # $queryStr .= "&GSM_CurrentDL=gsm:settings/CurrentDL"; - # $queryStr .= "&GSM_Established=gsm:settings/Established"; - # $queryStr .= "&GSM_BER=gsm:settings/BER"; - # $queryStr .= "&GSM_Manufacturer=gsm:settings/Manufacturer"; - # $queryStr .= "&GSM_Model=gsm:settings/Model"; - # $queryStr .= "&GSM_Operator=gsm:settings/Operator"; - # $queryStr .= "&GSM_PIN_State=gsm:settings/PIN_State"; - # $queryStr .= "&GSM_Trycount=gsm:settings/Trycount"; - # $queryStr .= "&GSM_ModemPresent=gsm:settings/ModemPresent"; - # $queryStr .= "&GSM_AllowRoaming=gsm:settings/AllowRoaming"; - # $queryStr .= "&GSM_VoiceStatus=gsm:settings/VoiceStatus"; - # $queryStr .= "&GSM_SubscriberNumber=gsm:settings/SubscriberNumber"; - # $queryStr .= "&GSM_InHomeZone=gsm:settings/InHomeZone"; - # $queryStr .= "&UMTS_enabled=umts:settings/enabled"; - # $queryStr .= "&UMTS_name=umts:settings/name"; - # $queryStr .= "&UMTS_provider=umts:settings/provider"; - # $queryStr .= "&UMTS_idle=umts:settings/idle"; - # $queryStr .= "&UMTS_backup_enable=umts:settings/backup_enable"; - # $queryStr .= "&UMTS_backup_downtime=umts:settings/backup_downtime"; - # $queryStr .= "&UMTS_backup_reverttime=umts:settings/backup_reverttime"; - FRITZBOX_Log $hash, 4, "ReadOut gestartet: $queryStr"; $result = FRITZBOX_call_Lua_Query( $hash, $queryStr, "", "luaQuery") ; # Abbruch wenn Fehler beim Lesen der Fritzbox-Antwort - return FRITZBOX_Readout_Response($hash, $result, \@roReadings) if ( defined $result->{Error} || defined $result->{AuthorizationRequired}); + return FRITZBOX_Readout_Response($hash, $result, $roReadings) if ( defined $result->{Error} || defined $result->{AuthorizationRequired}); - $sidNew += $result->{sidNew} if defined $result->{sidNew}; + $$sidNew += $result->{sidNew} if defined $result->{sidNew}; + $$sid = $result->{sid} if $result->{sid}; # !!! copes with fw >=6.69 and fw < 7 !!! if ( ref $result->{wlanList} ne 'ARRAY' ) { + FRITZBOX_Log $hash, 4, "Recognized query answer of firmware >=6.69 and < 7"; + my $result2; my $newQueryPart; @@ -3096,13 +3287,13 @@ sub FRITZBOX_Readout_Run_Web($) if (length($queryStr . $newQueryPart) < 4050) { $queryStr .= $newQueryPart; } else { - FRITZBOX_Log $hash, 5, "getting WLAN speed for firmware >=6.69 and < 7: " . $queryStr; + FRITZBOX_Log $hash, 4, "getting WLAN speed for firmware >=6.69 and < 7: " . $queryStr; $result2 = FRITZBOX_call_Lua_Query( $hash, $queryStr ); # Abbruch wenn Fehler beim Lesen der Fritzbox-Antwort - return FRITZBOX_Readout_Response($hash, $result2, \@roReadings) if ( defined $result2->{Error} || defined $result2->{AuthorizationRequired}); + return FRITZBOX_Readout_Response($hash, $result2, $roReadings) if ( defined $result2->{Error} || defined $result2->{AuthorizationRequired}); - # $sidNew += $result2->{sidNew} if defined $result2->{sidNew}; + # $$sidNew += $result2->{sidNew} if defined $result2->{sidNew}; %{$result} = ( %{$result}, %{$result2 } ); $queryStr = $newQueryPart; @@ -3116,13 +3307,13 @@ sub FRITZBOX_Readout_Run_Web($) $queryStr .= $newQueryPart; } else { - FRITZBOX_Log $hash, 5, "getting LAN-Port for firmware >=6.69 and < 7: " . $queryStr; + FRITZBOX_Log $hash, 4, "getting LAN-Port for firmware >=6.69 and < 7: " . $queryStr; $result2 = FRITZBOX_call_Lua_Query( $hash, $queryStr ); # Abbruch wenn Fehler beim Lesen der Fritzbox-Antwort - return FRITZBOX_Readout_Response($hash, $result2, \@roReadings) if ( defined $result2->{Error} || defined $result2->{AuthorizationRequired}); + return FRITZBOX_Readout_Response($hash, $result2, $roReadings) if ( defined $result2->{Error} || defined $result2->{AuthorizationRequired}); - # $sidNew += $result2->{sidNew} if defined $result2->{sidNew}; + # $$sidNew += $result2->{sidNew} if defined $result2->{sidNew}; %{$result} = ( %{$result}, %{$result2 } ); $queryStr = $newQueryPart; @@ -3138,13 +3329,13 @@ sub FRITZBOX_Readout_Run_Web($) $queryStr .= $newQueryPart; } else { - FRITZBOX_Log $hash, 3, "getting user-field for firmware >=6.69 and < 7: " . $queryStr; + FRITZBOX_Log $hash, 4, "getting user-field for firmware >=6.69 and < 7: " . $queryStr; $result2 = FRITZBOX_call_Lua_Query( $hash, $queryStr ); # Abbruch wenn Fehler beim Lesen der Fritzbox-Antwort - return FRITZBOX_Readout_Response($hash, $result2, \@roReadings) if ( defined $result2->{Error} || defined $result2->{AuthorizationRequired}); + return FRITZBOX_Readout_Response($hash, $result2, $roReadings) if ( defined $result2->{Error} || defined $result2->{AuthorizationRequired}); - # $sidNew += $result2->{sidNew} if defined $result2->{sidNew}; + # $$sidNew += $result2->{sidNew} if defined $result2->{sidNew}; %{$result} = ( %{$result}, %{$result2 } ); $queryStr = $newQueryPart; @@ -3152,13 +3343,13 @@ sub FRITZBOX_Readout_Run_Web($) } # Final Web-Query - FRITZBOX_Log $hash, 5, "final web-query for firmware >=6.69 and < 7: " . $queryStr; + FRITZBOX_Log $hash, 4, "final web-query for firmware >=6.69 and < 7: " . $queryStr; $result2 = FRITZBOX_call_Lua_Query( $hash, $queryStr ); # Abbruch wenn Fehler beim Lesen der Fritzbox-Antwort - return FRITZBOX_Readout_Response($hash, $result2, \@roReadings) if ( defined $result2->{Error} || defined $result2->{AuthorizationRequired}); + return FRITZBOX_Readout_Response($hash, $result2, $roReadings) if ( defined $result2->{Error} || defined $result2->{AuthorizationRequired}); - # $sidNew += $result2->{sidNew} if defined $result2->{sidNew}; + # $$sidNew += $result2->{sidNew} if defined $result2->{sidNew}; %{$result} = ( %{$result}, %{$result2 } ); @@ -3194,7 +3385,11 @@ sub FRITZBOX_Readout_Run_Web($) } my $noDect = AttrVal( $name, "disableDectInfo", "0"); - if ( $result->{handsetCount} =~ /[1-9]/ ) { + + if ( defined $result->{handsetCount} && $result->{handsetCount} =~ /[1-9]/ ) { + + FRITZBOX_Log $hash, 4, "luaQuery - start getting data: Dect device list"; + $runNo = 0; foreach ( @{ $result->{dectUser} } ) { my $intern = $_->{Intern}; @@ -3202,16 +3397,16 @@ sub FRITZBOX_Readout_Run_Web($) my $id = $_->{Id}; if ($intern) { unless ($noDect) { - FRITZBOX_Readout_Add_Reading $hash, \@roReadings, "dect".$runNo, $_->{Name} ; - FRITZBOX_Readout_Add_Reading $hash, \@roReadings, "dect".$runNo."_intern", $intern ; - FRITZBOX_Readout_Add_Reading $hash, \@roReadings, "dect".$runNo."_alarmRingTone", $_->{AlarmRingTone0}, "ringtone" ; - FRITZBOX_Readout_Add_Reading $hash, \@roReadings, "dect".$runNo."_intRingTone", $_->{IntRingTone}, "ringtone" ; - FRITZBOX_Readout_Add_Reading $hash, \@roReadings, "dect".$runNo."_radio", $_->{RadioRingID}, "radio" ; - FRITZBOX_Readout_Add_Reading $hash, \@roReadings, "dect".$runNo."_custRingTone", $_->{G722RingTone} ; - FRITZBOX_Readout_Add_Reading $hash, \@roReadings, "dect".$runNo."_custRingToneName", $_->{G722RingToneName} ; - FRITZBOX_Readout_Add_Reading $hash, \@roReadings, "dect".$runNo."_imagePath", $_->{ImagePath} ; - FRITZBOX_Readout_Add_Reading $hash, \@roReadings, "dect".$runNo."_NoRingWithNightSetting", $_->{NoRingWithNightSetting}, "onoff"; - FRITZBOX_Readout_Add_Reading $hash, \@roReadings, "dect".$runNo."_NoRingTimeFlags" , $_->{NoRingTimeFlags}; + FRITZBOX_Readout_Add_Reading $hash, $roReadings, "dect".$runNo, $_->{Name} ; + FRITZBOX_Readout_Add_Reading $hash, $roReadings, "dect".$runNo."_intern", $intern ; + FRITZBOX_Readout_Add_Reading $hash, $roReadings, "dect".$runNo."_alarmRingTone", $_->{AlarmRingTone0}, "ringtone" ; + FRITZBOX_Readout_Add_Reading $hash, $roReadings, "dect".$runNo."_intRingTone", $_->{IntRingTone}, "ringtone" ; + FRITZBOX_Readout_Add_Reading $hash, $roReadings, "dect".$runNo."_radio", $_->{RadioRingID}, "radio" ; + FRITZBOX_Readout_Add_Reading $hash, $roReadings, "dect".$runNo."_custRingTone", $_->{G722RingTone} ; + FRITZBOX_Readout_Add_Reading $hash, $roReadings, "dect".$runNo."_custRingToneName", $_->{G722RingToneName} ; + FRITZBOX_Readout_Add_Reading $hash, $roReadings, "dect".$runNo."_imagePath", $_->{ImagePath} ; + FRITZBOX_Readout_Add_Reading $hash, $roReadings, "dect".$runNo."_NoRingWithNightSetting", $_->{NoRingWithNightSetting}, "onoff"; + FRITZBOX_Readout_Add_Reading $hash, $roReadings, "dect".$runNo."_NoRingTimeFlags" , $_->{NoRingTimeFlags}; # telcfg:settings/Foncontrol/User/list(Name,NoRingTime,RingAllowed,NoRingTimeFlags,NoRingWithNightSetting) if ($_->{NoRingTime}) { @@ -3233,18 +3428,21 @@ sub FRITZBOX_Readout_Run_Web($) substr($NoRingTime, 5, 0) = "-"; substr($NoRingTime, 8, 0) = ":"; - FRITZBOX_Readout_Add_Reading $hash, \@roReadings, "dect".$runNo."_NoRingTime", $notAllowed . " " . $NoRingTime; + FRITZBOX_Readout_Add_Reading $hash, $roReadings, "dect".$runNo."_NoRingTime", $notAllowed . " " . $NoRingTime; } else { - FRITZBOX_Readout_Add_Reading $hash, \@roReadings, "dect".$runNo."_NoRingTime", "not defined"; + FRITZBOX_Readout_Add_Reading $hash, $roReadings, "dect".$runNo."_NoRingTime", "not defined"; } - FRITZBOX_Readout_Add_Reading $hash, \@roReadings, "fhem->$intern->id", $id ; - FRITZBOX_Readout_Add_Reading $hash, \@roReadings, "fhem->$intern->userId", $runNo; + FRITZBOX_Readout_Add_Reading $hash, $roReadings, "fhem->$intern->id", $id ; + FRITZBOX_Readout_Add_Reading $hash, $roReadings, "fhem->$intern->userId", $runNo; } + $dectFonID{$id}{Intern} = $intern; $dectFonID{$id}{User} = $runNo; $dectFonID{$name} = $runNo; + FRITZBOX_Readout_Add_Reading $hash, $roReadings, "helper->dectFonID->$name", $runNo ; + foreach (keys %oldDECTDevice) { delete $oldDECTDevice{$_} if $_ =~ /^dect${runNo}_|^dect${runNo}/ && defined $oldDECTDevice{$_}; } @@ -3263,13 +3461,13 @@ sub FRITZBOX_Readout_Run_Web($) my $intern = $dectFonID{$dectUserID}{Intern}; if ($dectUser) { - FRITZBOX_Readout_Add_Reading $hash, \@roReadings, "dect".$dectUser."_manufacturer", $_->{Manufacturer}; -# FRITZBOX_Readout_Add_Reading $hash, \@roReadings, "dect".$dectUser."_model", $_->{Model}, "model"; - FRITZBOX_Readout_Add_Reading $hash, \@roReadings, "dect".$dectUser."_model", $_->{Productname}; - FRITZBOX_Readout_Add_Reading $hash, \@roReadings, "dect".$dectUser."_fwVersion", $_->{FWVersion}; + FRITZBOX_Readout_Add_Reading $hash, $roReadings, "dect".$dectUser."_manufacturer", $_->{Manufacturer}; +# FRITZBOX_Readout_Add_Reading $hash, $roReadings, "dect".$dectUser."_model", $_->{Model}, "model"; + FRITZBOX_Readout_Add_Reading $hash, $roReadings, "dect".$dectUser."_model", $_->{Productname}; + FRITZBOX_Readout_Add_Reading $hash, $roReadings, "dect".$dectUser."_fwVersion", $_->{FWVersion}; - FRITZBOX_Readout_Add_Reading $hash, \@roReadings, "fhem->$intern->brand", $_->{Manufacturer}; - FRITZBOX_Readout_Add_Reading $hash, \@roReadings, "fhem->$intern->model", $_->{Model}, "model"; + FRITZBOX_Readout_Add_Reading $hash, $roReadings, "fhem->$intern->brand", $_->{Manufacturer}; + FRITZBOX_Readout_Add_Reading $hash, $roReadings, "fhem->$intern->model", $_->{Model}, "model"; } } } @@ -3278,29 +3476,37 @@ sub FRITZBOX_Readout_Run_Web($) foreach ( keys %oldDECTDevice) { # set the sip readings to 'inactive' and delete at next readout if ( $oldDECTDevice{$_} ne "inactive" ) { - FRITZBOX_Readout_Add_Reading $hash, \@roReadings, $_, "inactive"; + FRITZBOX_Readout_Add_Reading $hash, $roReadings, $_, "inactive"; } else { - FRITZBOX_Readout_Add_Reading $hash, \@roReadings, $_, ""; + FRITZBOX_Readout_Add_Reading $hash, $roReadings, $_, ""; } } + + FRITZBOX_Log $hash, 4, "luaQuery - end getting data: Dect device list"; } #------------------------------------------------------------------------------------- # phone device list unless (AttrVal( $name, "disableFonInfo", "0")) { + + FRITZBOX_Log $hash, 4, "luaQuery - start getting data: FonInfo"; + $runNo=1; foreach ( @{ $result->{fonPort} } ) { if ( $_->{Name} ) { my $name = $_->{Name}; - FRITZBOX_Readout_Add_Reading $hash, \@roReadings, "fon".$runNo, $_->{Name}; - FRITZBOX_Readout_Add_Reading $hash, \@roReadings, "fon".$runNo."_out", $_->{MSN}; - FRITZBOX_Readout_Add_Reading $hash, \@roReadings, "fon".$runNo."_intern", $runNo; + FRITZBOX_Readout_Add_Reading $hash, $roReadings, "fon".$runNo, $_->{Name}; + FRITZBOX_Readout_Add_Reading $hash, $roReadings, "fon".$runNo."_out", $_->{MSN}; + FRITZBOX_Readout_Add_Reading $hash, $roReadings, "fon".$runNo."_intern", $runNo; $fonFonID{$name} = $runNo; + FRITZBOX_Readout_Add_Reading $hash, $roReadings, "helper->fonFonID->$name", $runNo ; } $runNo++; } + + FRITZBOX_Log $hash, 4, "luaQuery - end getting data: FonInfo"; } #------------------------------------------------------------------------------------- @@ -3308,12 +3514,12 @@ sub FRITZBOX_Readout_Run_Web($) $runNo = 0; $rName = "radio00"; foreach ( @{ $result->{radio} } ) { - FRITZBOX_Readout_Add_Reading $hash, \@roReadings, $rName, $_->{Name}; - FRITZBOX_Readout_Add_Reading $hash, \@roReadings, "fhem->radio->".$runNo, $_->{Name}; + FRITZBOX_Readout_Add_Reading $hash, $roReadings, $rName, $_->{Name}; + FRITZBOX_Readout_Add_Reading $hash, $roReadings, "fhem->radio->".$runNo, $_->{Name}; $runNo++; $rName = sprintf ("radio%02d",$runNo); } - FRITZBOX_Readout_Add_Reading $hash, \@roReadings, "fhem->radioCount", $runNo; + FRITZBOX_Readout_Add_Reading $hash, $roReadings, "fhem->radioCount", $runNo; #------------------------------------------------------------------------------------- # SIP Lines @@ -3322,6 +3528,8 @@ sub FRITZBOX_Readout_Run_Web($) if ($boxModel ne "3490" && AttrVal( $name, "enableSIP", "0")) { + FRITZBOX_Log $hash, 4, "luaQuery - start getting data: SIPInfo"; + my $sip_in_error = 0; my $sip_active = 0; my $sip_inactive = 0; @@ -3341,25 +3549,25 @@ sub FRITZBOX_Readout_Run_Web($) if ($_->{activated} == 1) { # sip activated und registriert if ($_->{connect} == 2) { # sip activated und registriert - FRITZBOX_Readout_Add_Reading $hash, \@roReadings, $rName, "active"; + FRITZBOX_Readout_Add_Reading $hash, $roReadings, $rName, "active"; delete $oldSIPDevice{$rName} if exists $oldSIPDevice{$rName}; $sip_active ++; FRITZBOX_Log $hash, 4, "$rName -> registration ok"; } if ($_->{connect} == 0) { # sip not activated - FRITZBOX_Readout_Add_Reading $hash, \@roReadings, $rName, "inactive"; + FRITZBOX_Readout_Add_Reading $hash, $roReadings, $rName, "inactive"; delete $oldSIPDevice{$rName} if exists $oldSIPDevice{$rName}; $sip_inactive ++; FRITZBOX_Log $hash, 4, "$rName -> not active"; } if ($_->{connect} == 1) { # error condition for aktivated and unregistrated sips - FRITZBOX_Readout_Add_Reading $hash, \@roReadings, $rName, "not registered"; + FRITZBOX_Readout_Add_Reading $hash, $roReadings, $rName, "not registered"; delete $oldSIPDevice{$rName} if exists $oldSIPDevice{$rName}; $sip_in_error++; FRITZBOX_Log $hash, 2, "$rName -> not registered"; } } else { - FRITZBOX_Readout_Add_Reading $hash, \@roReadings, $rName, "not in use"; + FRITZBOX_Readout_Add_Reading $hash, $roReadings, $rName, "not in use"; delete $oldSIPDevice{$rName} if exists $oldSIPDevice{$rName}; FRITZBOX_Log $hash, 4, "$rName -> not in use"; } @@ -3372,16 +3580,18 @@ sub FRITZBOX_Readout_Run_Web($) foreach ( keys %oldSIPDevice) { # set the sip readings to 'inactive' and delete at next readout if ( $oldSIPDevice{$_} ne "inactive" ) { - FRITZBOX_Readout_Add_Reading $hash, \@roReadings, $_, "inactive"; + FRITZBOX_Readout_Add_Reading $hash, $roReadings, $_, "inactive"; } else { - FRITZBOX_Readout_Add_Reading $hash, \@roReadings, $_, ""; + FRITZBOX_Readout_Add_Reading $hash, $roReadings, $_, ""; } } FRITZBOX_Log $hash, 4, "end"; - FRITZBOX_Readout_Add_Reading $hash, \@roReadings, "sip_error", $sip_in_error; - FRITZBOX_Readout_Add_Reading $hash, \@roReadings, "sip_active", $sip_active; - FRITZBOX_Readout_Add_Reading $hash, \@roReadings, "sip_inactive", $sip_inactive; + FRITZBOX_Readout_Add_Reading $hash, $roReadings, "sip_error", $sip_in_error; + FRITZBOX_Readout_Add_Reading $hash, $roReadings, "sip_active", $sip_active; + FRITZBOX_Readout_Add_Reading $hash, $roReadings, "sip_inactive", $sip_inactive; + + FRITZBOX_Log $hash, 4, "luaQuery - end getting data: SIPInfo"; } # end ($boxModel ne "3490") @@ -3389,6 +3599,9 @@ sub FRITZBOX_Readout_Run_Web($) # VPN shares if ( AttrVal( $name, "enableVPNShares", "0")) { + + FRITZBOX_Log $hash, 4, "luaQuery - start getting data: VPNShares"; + my %oldVPNDevice; #collect current vpn-readings (to delete the ones that are inactive or disappeared) foreach (keys %{ $hash->{READINGS} }) { @@ -3404,27 +3617,27 @@ sub FRITZBOX_Readout_Run_Web($) FRITZBOX_Log $hash, 4, "vpn->info: $rName " . $_->{_node} . ": " . $_->{activated} . ": " . $_->{state}; - FRITZBOX_Readout_Add_Reading $hash, \@roReadings, $rName, $_->{name}; + FRITZBOX_Readout_Add_Reading $hash, $roReadings, $rName, $_->{name}; delete $oldVPNDevice{$rName} if exists $oldVPNDevice{$rName}; - FRITZBOX_Readout_Add_Reading $hash, \@roReadings, $rName . "_access_type", "Corp VPN" if $_->{access_type} == 1; - FRITZBOX_Readout_Add_Reading $hash, \@roReadings, $rName . "_access_type", "User VPN" if $_->{access_type} == 2; - FRITZBOX_Readout_Add_Reading $hash, \@roReadings, $rName . "_access_type", "Lan2Lan VPN" if $_->{access_type} == 3; - FRITZBOX_Readout_Add_Reading $hash, \@roReadings, $rName . "_access_type", "Wireguard Simple" if $_->{access_type} == 4; + FRITZBOX_Readout_Add_Reading $hash, $roReadings, $rName . "_access_type", "Corp VPN" if $_->{access_type} == 1; + FRITZBOX_Readout_Add_Reading $hash, $roReadings, $rName . "_access_type", "User VPN" if $_->{access_type} == 2; + FRITZBOX_Readout_Add_Reading $hash, $roReadings, $rName . "_access_type", "Lan2Lan VPN" if $_->{access_type} == 3; + FRITZBOX_Readout_Add_Reading $hash, $roReadings, $rName . "_access_type", "Wireguard Simple" if $_->{access_type} == 4; delete $oldVPNDevice{$rName . "_access_type"} if exists $oldVPNDevice{$rName . "_access_type"}; - FRITZBOX_Readout_Add_Reading $hash, \@roReadings, $rName . "_remote_ip", $_->{remote_ip} eq "" ? "....":$_->{remote_ip}; + FRITZBOX_Readout_Add_Reading $hash, $roReadings, $rName . "_remote_ip", $_->{remote_ip} eq "" ? "....":$_->{remote_ip}; delete $oldVPNDevice{$rName . "_remote_ip"} if exists $oldVPNDevice{$rName . "_remote_ip"}; - FRITZBOX_Readout_Add_Reading $hash, \@roReadings, $rName . "_activated", $_->{activated}; + FRITZBOX_Readout_Add_Reading $hash, $roReadings, $rName . "_activated", $_->{activated}; delete $oldVPNDevice{$rName . "_activated"} if exists $oldVPNDevice{$rName . "_activated"}; - FRITZBOX_Readout_Add_Reading $hash, \@roReadings, $rName . "_state", $_->{state} eq "" ? "none":$_->{state}; + FRITZBOX_Readout_Add_Reading $hash, $roReadings, $rName . "_state", $_->{state} eq "" ? "none":$_->{state}; delete $oldVPNDevice{$rName . "_state"} if exists $oldVPNDevice{$rName . "_state"}; if ($_->{access_type} <= 3) { if ($_->{connected_since} == 0) { - FRITZBOX_Readout_Add_Reading $hash, \@roReadings, $rName . "_connected_since", "none"; + FRITZBOX_Readout_Add_Reading $hash, $roReadings, $rName . "_connected_since", "none"; } else { $Sek = $_->{connected_since}; @@ -3436,15 +3649,15 @@ sub FRITZBOX_Readout_Run_Web($) $Std = substr("0".$Std,-2); $Min = substr("0".$Min,-2); $Sek = substr("0".$Sek,-2); - FRITZBOX_Readout_Add_Reading $hash, \@roReadings, $rName . "_connected_since", $_->{connected_since} . " sec = " . $Tag . "T $Std:$Min:$Sek"; + FRITZBOX_Readout_Add_Reading $hash, $roReadings, $rName . "_connected_since", $_->{connected_since} . " sec = " . $Tag . "T $Std:$Min:$Sek"; } delete $oldVPNDevice{$rName . "_connected_since"} if exists $oldVPNDevice{$rName . "_connected_since"}; } else { if ($_->{connected_since} == 0) { - FRITZBOX_Readout_Add_Reading $hash, \@roReadings, $rName . "_last_negotiation", "none"; + FRITZBOX_Readout_Add_Reading $hash, $roReadings, $rName . "_last_negotiation", "none"; } else { $Sek = (int(time) - $_->{connected_since}); - FRITZBOX_Readout_Add_Reading $hash, \@roReadings, $rName . "_last_negotiation", (strftime "%d-%m-%Y %H:%M:%S", localtime($_->{connected_since})); + FRITZBOX_Readout_Add_Reading $hash, $roReadings, $rName . "_last_negotiation", (strftime "%d-%m-%Y %H:%M:%S", localtime($_->{connected_since})); } delete $oldVPNDevice{$rName . "_last_negotiation"} if exists $oldVPNDevice{$rName . "_last_negotiation"}; } @@ -3455,12 +3668,15 @@ sub FRITZBOX_Readout_Run_Web($) foreach ( keys %oldVPNDevice) { # set the vpn readings to 'inactive' and delete at next readout if ( $oldVPNDevice{$_} ne "inactive" ) { - FRITZBOX_Readout_Add_Reading $hash, \@roReadings, $_, "inactive"; + FRITZBOX_Readout_Add_Reading $hash, $roReadings, $_, "inactive"; } else { - FRITZBOX_Readout_Add_Reading $hash, \@roReadings, $_, ""; + FRITZBOX_Readout_Add_Reading $hash, $roReadings, $_, ""; } } + + FRITZBOX_Log $hash, 4, "luaQuery - end getting data: VPNShares"; + } #------------------------------------------------------------------------------------- @@ -3468,7 +3684,11 @@ sub FRITZBOX_Readout_Run_Web($) my %wlanList; #to keep compatibility with firmware <= v3.67 and >=7 + if ( ref $result->{wlanList} eq 'ARRAY' ) { + + FRITZBOX_Log $hash, 4, "luaQuery - start getting data: wlanList"; + foreach ( @{ $result->{wlanList} } ) { my $mac = $_->{mac}; $mac =~ s/:/_/g; @@ -3478,10 +3698,12 @@ sub FRITZBOX_Readout_Run_Web($) #$wlanList{$mac}{speed_rx} = $result_lan->{$_->{_node}}; $wlanList{$mac}{rssi} = $_->{rssi} if ! defined $wlanList{$mac}{rssi} || $_->{rssi} ne "0"; $wlanList{$mac}{is_guest} = $_->{is_guest} if ! defined $wlanList{$mac}{is_guest} || $_->{is_guest} ne "0"; - FRITZBOX_Readout_Add_Reading $hash, \@roReadings, "fhem->wlanDevice->".$mac."->speed", $_->{speed}; - FRITZBOX_Readout_Add_Reading $hash, \@roReadings, "fhem->wlanDevice->".$mac."->speed_rx", $wlanList{$mac}{speed_rx}; - FRITZBOX_Readout_Add_Reading $hash, \@roReadings, "fhem->wlanDevice->".$mac."->rssi", $_->{rssi}; + FRITZBOX_Readout_Add_Reading $hash, $roReadings, "fhem->wlanDevice->".$mac."->speed", $_->{speed}; + FRITZBOX_Readout_Add_Reading $hash, $roReadings, "fhem->wlanDevice->".$mac."->speed_rx", $wlanList{$mac}{speed_rx}; + FRITZBOX_Readout_Add_Reading $hash, $roReadings, "fhem->wlanDevice->".$mac."->rssi", $_->{rssi}; } + + FRITZBOX_Log $hash, 4, "luaQuery - end getting data: wlanList"; } #------------------------------------------------------------------------------------- @@ -3507,7 +3729,6 @@ sub FRITZBOX_Readout_Run_Web($) } } $oldLanDevice{$_} .= $hash->{READINGS}{$_}{VAL}; -# FRITZBOX_Log $hash, 3, "deviceInfo -> $oldLanDevice{$_} -> $_"; } } @@ -3517,8 +3738,10 @@ sub FRITZBOX_Readout_Run_Web($) if ( ref $result->{lanDevice} eq 'ARRAY' ) { #Ipv4,IPv6,lanName,devName,Mbit,RSSI " - # iPad-Familie [landevice810] (WLAN: 142 / 72 Mbit/s RSSI: -53) + + FRITZBOX_Log $hash, 4, "luaQuery - start getting data: lanDevice"; + my $deviceInfo = AttrVal($name, "deviceInfo", "_defDef_,name,[uid],(connection: speedcomma rssi) statIP"); $deviceInfo =~ s/\n//g; @@ -3544,7 +3767,7 @@ sub FRITZBOX_Readout_Run_Web($) $sep =~ s/space/ /g; $sep =~ s/comma/\,/g; - FRITZBOX_Log $hash, 5, "deviceInfo -> " . $deviceInfo; + FRITZBOX_Log $hash, 4, "deviceInfo -> " . $deviceInfo; foreach ( @{ $result->{lanDevice} } ) { my $dIp = $_->{ip}; # IP Adress @@ -3553,8 +3776,8 @@ sub FRITZBOX_Readout_Run_Web($) my $dhcp = $_->{static_dhcp} eq "0" ? "statIP:off" : "statIP:on" if defined $_->{static_dhcp}; # IP is defined as static / dynamic - FRITZBOX_Readout_Add_Reading $hash, \@roReadings, "fhem->landevice->$dIp", $dName; - FRITZBOX_Readout_Add_Reading $hash, \@roReadings, "fhem->landevice->$UID", $dName; + FRITZBOX_Readout_Add_Reading $hash, $roReadings, "fhem->landevice->$dIp", $dName; + FRITZBOX_Readout_Add_Reading $hash, $roReadings, "fhem->landevice->$UID", $dName; $landevice{$dIp} = $dName; $landevice{$UID} = $dName; @@ -3575,7 +3798,7 @@ sub FRITZBOX_Readout_Run_Web($) $mac =~ s/:/_/g; $mac = $UID if $mac eq ""; - FRITZBOX_Readout_Add_Reading $hash, \@roReadings, "fhem->landevice->$mac", $UID . "|" . $dIp; + FRITZBOX_Readout_Add_Reading $hash, $roReadings, "fhem->landevice->$mac", $UID . "|" . $dIp; $landevice{$mac} = $UID; # Copes with fw >= 7 @@ -3644,15 +3867,18 @@ sub FRITZBOX_Readout_Run_Web($) $rName .= "pas_" if $allowPassiv && $_->{active} == 0; $rName .= $lDevName eq "mac" ? $mac : $dIp; - FRITZBOX_Readout_Add_Reading $hash, \@roReadings, $rName, $srTmp ; + FRITZBOX_Readout_Add_Reading $hash, $roReadings, $rName, $srTmp ; # Remove mac address from oldLanDevice-List delete $oldLanDevice{$rName} if exists $oldLanDevice{$rName}; } } + + FRITZBOX_Log $hash, 4, "luaQuery - end getting data: lanDevice"; + } - FRITZBOX_Readout_Add_Reading ($hash, \@roReadings, "box_wlan_Count", $wlanCount); - FRITZBOX_Readout_Add_Reading ($hash, \@roReadings, "box_guestWlanCount", $gWlanCount); + FRITZBOX_Readout_Add_Reading ($hash, $roReadings, "box_wlan_Count", $wlanCount); + FRITZBOX_Readout_Add_Reading ($hash, $roReadings, "box_guestWlanCount", $gWlanCount); # Remove inactive or non existing mac-readings in two steps foreach ( keys %oldLanDevice ) { @@ -3663,49 +3889,40 @@ sub FRITZBOX_Readout_Run_Web($) $ip .= $1; } - FRITZBOX_Readout_Add_Reading $hash, \@roReadings, $_, "inactive" . $ip; -# FRITZBOX_Log $hash, 3, "deviceInfo -> $oldLanDevice{$_} -> inactive" . $ip; + FRITZBOX_Readout_Add_Reading $hash, $roReadings, $_, "inactive" . $ip; } else { - FRITZBOX_Readout_Add_Reading $hash, \@roReadings, $_, ""; -# FRITZBOX_Log $hash, 3, "deviceInfo -> $oldLanDevice{$_} -> deleted"; + FRITZBOX_Readout_Add_Reading $hash, $roReadings, $_, ""; } } #------------------------------------------------------------------------------------- # WLANs - FRITZBOX_Readout_Add_Reading $hash, \@roReadings, "box_wlan_2.4GHz", $result->{box_wlan_24GHz}, "onoff"; - FRITZBOX_Readout_Add_Reading $hash, \@roReadings, "box_wlan_5GHz", $result->{box_wlan_5GHz}, "onoff"; - FRITZBOX_Readout_Add_Reading $hash, \@roReadings, "box_guestWlan", $result->{box_guestWlan}, "onoff"; - FRITZBOX_Readout_Add_Reading $hash, \@roReadings, "box_guestWlanRemain", $result->{box_guestWlanRemain}; - FRITZBOX_Readout_Add_Reading $hash, \@roReadings, "box_macFilter_active", $result->{box_macFilter_active}, "onoff"; + FRITZBOX_Readout_Add_Reading $hash, $roReadings, "box_wlan_2.4GHz", $result->{box_wlan_24GHz}, "onoff"; + FRITZBOX_Readout_Add_Reading $hash, $roReadings, "box_wlan_5GHz", $result->{box_wlan_5GHz}, "onoff"; + FRITZBOX_Readout_Add_Reading $hash, $roReadings, "box_guestWlan", $result->{box_guestWlan}, "onoff"; + FRITZBOX_Readout_Add_Reading $hash, $roReadings, "box_guestWlanRemain", $result->{box_guestWlanRemain}; + FRITZBOX_Readout_Add_Reading $hash, $roReadings, "box_macFilter_active", $result->{box_macFilter_active}, "onoff"; #------------------------------------------------------------------------------------- # Dect - FRITZBOX_Readout_Add_Reading $hash, \@roReadings, "box_dect", $result->{box_dect}, "onoff"; + FRITZBOX_Readout_Add_Reading $hash, $roReadings, "box_dect", $result->{box_dect}, "onoff"; #------------------------------------------------------------------------------------- # Music on Hold - FRITZBOX_Readout_Add_Reading $hash, \@roReadings, "box_moh", $result->{box_moh}, "mohtype"; + FRITZBOX_Readout_Add_Reading $hash, $roReadings, "box_moh", $result->{box_moh}, "mohtype"; #------------------------------------------------------------------------------------- # Power Rate - FRITZBOX_Readout_Add_Reading $hash, \@roReadings, "box_powerRate", $result->{box_powerRate}; + FRITZBOX_Readout_Add_Reading $hash, $roReadings, "box_powerRate", $result->{box_powerRate}; #------------------------------------------------------------------------------------- # Box Features - FRITZBOX_Readout_Add_Reading $hash, \@roReadings, "fhem->is_double_wlan", $result->{is_double_wlan}, "01"; + FRITZBOX_Readout_Add_Reading $hash, $roReadings, "fhem->is_double_wlan", $result->{box_is_double_wlan}, "01"; #------------------------------------------------------------------------------------- # Box model, firmware and uptimes - # Informationen über DSL Verbindung - # xhr 1 - # lang de - # page dslOv - # xhrId all - # xhr 1 lang de page dslOv xhrId all - if($result->{box_uptimeHours} && $result->{box_uptimeHours} ne "no-emu") { $Tag = int($result->{box_uptimeHours} / 24); $Std = int($result->{box_uptimeHours} - (24 * $Tag)); @@ -3714,54 +3931,66 @@ sub FRITZBOX_Readout_Run_Web($) $Std = substr("0" . $Std,-2); $Min = substr("0" . $result->{box_uptimeMinutes},-2); - FRITZBOX_Readout_Add_Reading $hash, \@roReadings, "box_uptime", $Sek . " sec = " . $Tag . "T " . $Std . ":" . $Min . ":00"; + FRITZBOX_Readout_Add_Reading $hash, $roReadings, "box_uptime", $Sek . " sec = " . $Tag . "T " . $Std . ":" . $Min . ":00"; } else { - FRITZBOX_Readout_Add_Reading $hash, \@roReadings, "box_uptime", "no-emu"; + FRITZBOX_Readout_Add_Reading $hash, $roReadings, "box_uptime", "no-emu"; } + my @fwV = split(/\./, ReadingsVal($name, "box_fwVersion", "0.0.0.error")); if ($result->{box_fwVersion}) { - FRITZBOX_Readout_Add_Reading $hash, \@roReadings, "box_fwVersion", $result->{box_fwVersion}; + FRITZBOX_Readout_Add_Reading $hash, $roReadings, "box_fwVersion", $result->{box_fwVersion}; + @fwV = split(/\./, $result->{box_fwVersion}); } else { # Ab Version 6.90 - FRITZBOX_Readout_Add_Reading $hash, \@roReadings, "box_fwVersion", $result->{box_fwVersion_neu}; + FRITZBOX_Readout_Add_Reading $hash, $roReadings, "box_fwVersion", $result->{box_fwVersion_neu}; + @fwV = split(/\./, $result->{box_fwVersion_neu}); + } + FRITZBOX_Readout_Add_Reading $hash, $roReadings, "fhem->fwVersion", substr($fwV[1],0,2) * 100 + substr($fwV[2],0,2); + FRITZBOX_Readout_Add_Reading $hash, $roReadings, "fhem->fwVersionStr", substr($fwV[1],0,2) . "." . substr($fwV[2],0,2); + + FRITZBOX_Readout_Add_Reading $hash, $roReadings, "box_fwUpdate", $result->{box_fwUpdate}; + + # Sonderbehandlung für FRITZ!Smart Gateway + if($avmModel =~ /Smart Gateway/) { + FRITZBOX_Readout_Add_Reading $hash, $roReadings, "box_tr064", 0, "onoff"; + } else { + FRITZBOX_Readout_Add_Reading $hash, $roReadings, "box_tr064", $result->{box_tr064}, "onoff"; } - FRITZBOX_Readout_Add_Reading $hash, \@roReadings, "box_fwUpdate", $result->{box_fwUpdate}; - FRITZBOX_Readout_Add_Reading $hash, \@roReadings, "box_tr064", $result->{box_tr064}, "onoff"; - FRITZBOX_Readout_Add_Reading $hash, \@roReadings, "box_tr069", $result->{box_tr069}, "onoff"; - FRITZBOX_Readout_Add_Reading $hash, \@roReadings, "box_upnp", $result->{box_upnp}, "onoff"; - FRITZBOX_Readout_Add_Reading $hash, \@roReadings, "box_upnp_control_activated", $result->{box_upnpCtrl}, "onoff"; - FRITZBOX_Readout_Add_Reading $hash, \@roReadings, "->UPNP", $result->{box_upnp}; - FRITZBOX_Readout_Add_Reading $hash, \@roReadings, "box_stdDialPort", $result->{box_stdDialPort}, "dialport"; - FRITZBOX_Readout_Add_Reading $hash, \@roReadings, "box_cpuTemp", $result->{box_cpuTemp}; + FRITZBOX_Readout_Add_Reading $hash, $roReadings, "box_tr069", $result->{box_tr069}, "onoff"; + FRITZBOX_Readout_Add_Reading $hash, $roReadings, "box_upnp", $result->{box_upnp}, "onoff"; + FRITZBOX_Readout_Add_Reading $hash, $roReadings, "box_upnp_control_activated", $result->{box_upnpCtrl}, "onoff"; + FRITZBOX_Readout_Add_Reading $hash, $roReadings, "->UPNP", $result->{box_upnp}; + FRITZBOX_Readout_Add_Reading $hash, $roReadings, "box_stdDialPort", $result->{box_stdDialPort}, "dialport"; + FRITZBOX_Readout_Add_Reading $hash, $roReadings, "box_cpuTemp", $result->{box_cpuTemp}; - # FRITZBOX_Readout_Add_Reading $hash, \@roReadings, "box_ipv4_Extern", $result->{box_ipExtern}; - # FRITZBOX_Readout_Add_Reading $hash, \@roReadings, "box_connect", $result->{box_connect}; + # FRITZBOX_Readout_Add_Reading $hash, $roReadings, "box_ipv4_Extern", $result->{box_ipExtern}; + # FRITZBOX_Readout_Add_Reading $hash, $roReadings, "box_connect", $result->{box_connect}; if ($mesh ne "slave") { if ( defined ($result->{dslStatGlobalOut}) && looks_like_number($result->{dslStatGlobalOut}) ) { - FRITZBOX_Readout_Add_Reading $hash, \@roReadings, "box_dsl_upStream", sprintf ("%.3f", $result->{dslStatGlobalOut}/1000000); + FRITZBOX_Readout_Add_Reading $hash, $roReadings, "box_dsl_upStream", sprintf ("%.3f", $result->{dslStatGlobalOut}/1000000); } if ( defined ($result->{dslStatGlobalIn}) && looks_like_number($result->{dslStatGlobalIn}) ) { - FRITZBOX_Readout_Add_Reading $hash, \@roReadings, "box_dsl_downStream", sprintf ("%.3f", $result->{dslStatGlobalIn}/1000000); + FRITZBOX_Readout_Add_Reading $hash, $roReadings, "box_dsl_downStream", sprintf ("%.3f", $result->{dslStatGlobalIn}/1000000); } } else { - FRITZBOX_Readout_Add_Reading $hash, \@roReadings, "box_dsl_upStream", ""; - FRITZBOX_Readout_Add_Reading $hash, \@roReadings, "box_dsl_downStream", ""; + FRITZBOX_Readout_Add_Reading $hash, $roReadings, "box_dsl_upStream", ""; + FRITZBOX_Readout_Add_Reading $hash, $roReadings, "box_dsl_downStream", ""; } #------------------------------------------------------------------------------------- # GSM -#FRITZBOX_Readout_Add_Reading $hash, \@roReadings, "gsm_modem", $result->{GSM_ModemPresent}; +#FRITZBOX_Readout_Add_Reading $hash, $roReadings, "gsm_modem", $result->{GSM_ModemPresent}; if (defined $result->{GSM_NetworkState} && $result->{GSM_NetworkState} ne "0") { - FRITZBOX_Readout_Add_Reading $hash, \@roReadings, "gsm_rssi", $result->{GSM_RSSI}; - FRITZBOX_Readout_Add_Reading $hash, \@roReadings, "gsm_state", $result->{GSM_NetworkState}, "gsmnetstate"; - FRITZBOX_Readout_Add_Reading $hash, \@roReadings, "gsm_technology", $result->{GSM_AcT}, "gsmact"; - FRITZBOX_Readout_Add_Reading $hash, \@roReadings, "gsm_internet", $result->{UMTS_enabled}; + FRITZBOX_Readout_Add_Reading $hash, $roReadings, "gsm_rssi", $result->{GSM_RSSI}; + FRITZBOX_Readout_Add_Reading $hash, $roReadings, "gsm_state", $result->{GSM_NetworkState}, "gsmnetstate"; + FRITZBOX_Readout_Add_Reading $hash, $roReadings, "gsm_technology", $result->{GSM_AcT}, "gsmact"; + FRITZBOX_Readout_Add_Reading $hash, $roReadings, "gsm_internet", $result->{UMTS_enabled}; } else { - FRITZBOX_Readout_Add_Reading $hash, \@roReadings, "gsm_rssi", ""; - FRITZBOX_Readout_Add_Reading $hash, \@roReadings, "gsm_state", ""; - FRITZBOX_Readout_Add_Reading $hash, \@roReadings, "gsm_technology", ""; - FRITZBOX_Readout_Add_Reading $hash, \@roReadings, "gsm_internet", ""; + FRITZBOX_Readout_Add_Reading $hash, $roReadings, "gsm_rssi", ""; + FRITZBOX_Readout_Add_Reading $hash, $roReadings, "gsm_state", ""; + FRITZBOX_Readout_Add_Reading $hash, $roReadings, "gsm_technology", ""; + FRITZBOX_Readout_Add_Reading $hash, $roReadings, "gsm_internet", ""; } #------------------------------------------------------------------------------------- @@ -3769,11 +3998,11 @@ sub FRITZBOX_Readout_Run_Web($) $runNo = 1; foreach ( @{ $result->{alarmClock} } ) { next if $_->{Name} eq "er"; - FRITZBOX_Readout_Add_Reading $hash, \@roReadings, "alarm".$runNo, $_->{Name}; - FRITZBOX_Readout_Add_Reading $hash, \@roReadings, "alarm".$runNo."_state", $_->{Active}, "onoff"; - FRITZBOX_Readout_Add_Reading $hash, \@roReadings, "alarm".$runNo."_time", $_->{Time}, "altime"; - FRITZBOX_Readout_Add_Reading $hash, \@roReadings, "alarm".$runNo."_target", $_->{Number}, "alnumber"; - FRITZBOX_Readout_Add_Reading $hash, \@roReadings, "alarm".$runNo."_wdays", $_->{Weekdays}, "aldays"; + FRITZBOX_Readout_Add_Reading $hash, $roReadings, "alarm".$runNo, $_->{Name}; + FRITZBOX_Readout_Add_Reading $hash, $roReadings, "alarm".$runNo."_state", $_->{Active}, "onoff"; + FRITZBOX_Readout_Add_Reading $hash, $roReadings, "alarm".$runNo."_time", $_->{Time}, "altime"; + FRITZBOX_Readout_Add_Reading $hash, $roReadings, "alarm".$runNo."_target", $_->{Number}, "alnumber"; + FRITZBOX_Readout_Add_Reading $hash, $roReadings, "alarm".$runNo."_wdays", $_->{Weekdays}, "aldays"; $runNo++; } @@ -3784,18 +4013,18 @@ sub FRITZBOX_Readout_Run_Web($) $rName = "tam".$runNo; if ($_->{Display} eq "1") { - FRITZBOX_Readout_Add_Reading $hash, \@roReadings, $rName, $_->{Name}; - FRITZBOX_Readout_Add_Reading $hash, \@roReadings, $rName."_state", $_->{Active}, "onoff"; - FRITZBOX_Readout_Add_Reading $hash, \@roReadings, $rName."_newMsg", $_->{NumNewMessages}; - FRITZBOX_Readout_Add_Reading $hash, \@roReadings, $rName."_oldMsg", $_->{NumOldMessages}; + FRITZBOX_Readout_Add_Reading $hash, $roReadings, $rName, $_->{Name}; + FRITZBOX_Readout_Add_Reading $hash, $roReadings, $rName."_state", $_->{Active}, "onoff"; + FRITZBOX_Readout_Add_Reading $hash, $roReadings, $rName."_newMsg", $_->{NumNewMessages}; + FRITZBOX_Readout_Add_Reading $hash, $roReadings, $rName."_oldMsg", $_->{NumOldMessages}; } # Löchen ausgeblendeter TAMs elsif (defined $hash->{READINGS}{$rName} ) { - FRITZBOX_Readout_Add_Reading $hash, \@roReadings, $rName,""; - FRITZBOX_Readout_Add_Reading $hash, \@roReadings, $rName."_state", ""; - FRITZBOX_Readout_Add_Reading $hash, \@roReadings, $rName."_newMsg",""; - FRITZBOX_Readout_Add_Reading $hash, \@roReadings, $rName."_oldMsg",""; + FRITZBOX_Readout_Add_Reading $hash, $roReadings, $rName,""; + FRITZBOX_Readout_Add_Reading $hash, $roReadings, $rName."_state", ""; + FRITZBOX_Readout_Add_Reading $hash, $roReadings, $rName."_newMsg",""; + FRITZBOX_Readout_Add_Reading $hash, $roReadings, $rName."_oldMsg",""; } $runNo++; } @@ -3812,17 +4041,18 @@ sub FRITZBOX_Readout_Run_Web($) my $UID = "landevice".$1; $_->{name} = $landevice{$UID}; } - FRITZBOX_Readout_Add_Reading $hash, \@roReadings, $rName, $_->{name}, "deviceip"; - FRITZBOX_Readout_Add_Reading $hash, \@roReadings, $rName."_thisMonthTime", $_->{this_month_time}, "secondsintime"; - FRITZBOX_Readout_Add_Reading $hash, \@roReadings, $rName."_todayTime", $_->{today_time}, "secondsintime"; - FRITZBOX_Readout_Add_Reading $hash, \@roReadings, $rName."_todaySeconds", $_->{today_time}; - FRITZBOX_Readout_Add_Reading $hash, \@roReadings, $rName."_type", $_->{type}, "usertype"; + FRITZBOX_Readout_Add_Reading $hash, $roReadings, $rName, $_->{name}, "deviceip"; + FRITZBOX_Readout_Add_Reading $hash, $roReadings, $rName."_thisMonthTime", $_->{this_month_time}, "secondsintime"; + FRITZBOX_Readout_Add_Reading $hash, $roReadings, $rName."_todayTime", $_->{today_time}, "secondsintime"; + FRITZBOX_Readout_Add_Reading $hash, $roReadings, $rName."_todaySeconds", $_->{today_time}; + FRITZBOX_Readout_Add_Reading $hash, $roReadings, $rName."_type", $_->{type}, "usertype"; } $runNo++; $rName = sprintf ("user%02d",$runNo); } } +#------------------------------------------------------------------------------------- # user ticket (extension of online time) if ( ref $result->{userTicket} eq 'ARRAY' ) { $runNo=1; @@ -3830,266 +4060,368 @@ sub FRITZBOX_Readout_Run_Web($) $rName = "userTicket01"; foreach ( @{ $result->{userTicket} } ) { last if $runNo > $maxTickets; - FRITZBOX_Readout_Add_Reading $hash, \@roReadings, $rName, $_->{id}; + FRITZBOX_Readout_Add_Reading $hash, $roReadings, $rName, $_->{id}; $runNo++; $rName = sprintf ("userTicket%02d",$runNo); } } - # Diversity +#------------------------------------------------------------------------------------- +# Diversity $runNo=1; $rName = "diversity1"; foreach ( @{ $result->{diversity} } ) { - FRITZBOX_Readout_Add_Reading $hash, \@roReadings, $rName, $_->{MSN}; - FRITZBOX_Readout_Add_Reading $hash, \@roReadings, $rName."_state", $_->{Active}, "onoff" ; - FRITZBOX_Readout_Add_Reading $hash, \@roReadings, $rName."_dest", $_->{Destination}; + FRITZBOX_Readout_Add_Reading $hash, $roReadings, $rName, $_->{MSN}; + FRITZBOX_Readout_Add_Reading $hash, $roReadings, $rName."_state", $_->{Active}, "onoff" ; + FRITZBOX_Readout_Add_Reading $hash, $roReadings, $rName."_dest", $_->{Destination}; $runNo++; $rName = "diversity".$runNo; } #------------------------------------------------------------------------------------- # attr global showInternalValues 0 - FRITZBOX_Readout_Add_Reading $hash, \@roReadings, ".box_TodayBytesReceivedHigh", $result->{TodayBytesReceivedHigh}; - FRITZBOX_Readout_Add_Reading $hash, \@roReadings, ".box_TodayBytesReceivedLow", $result->{TodayBytesReceivedLow}; - FRITZBOX_Readout_Add_Reading $hash, \@roReadings, ".box_TodayBytesSentHigh", $result->{TodayBytesSentHigh}; - FRITZBOX_Readout_Add_Reading $hash, \@roReadings, ".box_TodayBytesSentLow", $result->{TodayBytesSentLow}; + FRITZBOX_Readout_Add_Reading $hash, $roReadings, ".box_TodayBytesReceivedHigh", $result->{TodayBytesReceivedHigh}; + FRITZBOX_Readout_Add_Reading $hash, $roReadings, ".box_TodayBytesReceivedLow", $result->{TodayBytesReceivedLow}; + FRITZBOX_Readout_Add_Reading $hash, $roReadings, ".box_TodayBytesSentHigh", $result->{TodayBytesSentHigh}; + FRITZBOX_Readout_Add_Reading $hash, $roReadings, ".box_TodayBytesSentLow", $result->{TodayBytesSentLow}; -# informations depending on TR064 or data.lua + FRITZBOX_Log $hash, 4, "luaQuery - end getting data"; + + return ""; + +} # End FRITZBOX_Readout_Run_Web_LuaQuery + + +# informations depending on data.lua #------------------------------------------------------------------------------------- - if ( (($FW1 == 6 && $FW2 >= 80) || ($FW1 >= 7 && $FW2 >= 21)) && $hash->{LUADATA} == 1) { +####################################################################### +sub FRITZBOX_Readout_Run_Web_LuaData($$$$) +{ + my ($name, $roReadings, $sidNew, $sid) = @_; + my $hash = $defs{$name}; - #------------------------------------------------------------------------------------- - # Getting phone WakeUpCall Device Nr - # uses $dectFonID (# Dect device list) and $dectFonID (phone device list) + my $result; + my $rName; + my $startTime = time(); + my $runNo; + my $host = $hash->{HOST}; + my $Tag; + my $Std; + my $Min; + my $Sek; - # xhr 1 lang de page alarm xhrId all + my $views; + my $nbViews; + + my $avmModel = InternalVal($name, "MODEL", "FRITZ!Box"); + + my $mesh = ReadingsVal($name, "box_meshRole", "master"); + + my $logFilter = AttrVal($name, "enableLogReadings", ""); + my $enableBoxReading = AttrVal($name, "enableBoxReadings", ""); + my $disableBoxReading = AttrVal($name, "disableBoxReadings", ""); + + my @webCmdArray; + my $resultData; + my $tmpData; + + #------------------------------------------------------------------------------------- + # getting Mesh Role + + FRITZBOX_Log $hash, 4, "mesh_role - start getting data"; + + # xhr 1 lang de page wlanmesh xhrId all + @webCmdArray = (); + push @webCmdArray, "xhr" => "1"; + push @webCmdArray, "lang" => "de"; + push @webCmdArray, "page" => "wlanmesh"; + push @webCmdArray, "xhrId" => "all"; + + $resultData = FRITZBOX_read_LuaData($hash, "data", \@webCmdArray) ; + + # Abbruch wenn Fehler beim Lesen der Fritzbox-Antwort + return FRITZBOX_Readout_Response($hash, $resultData, $roReadings) if ( defined $resultData->{Error} || defined $resultData->{AuthorizationRequired}); + + $$sidNew += $resultData->{sidNew} if defined $resultData->{sidNew}; + + FRITZBOX_Log $hash, 5, "\n" . Dumper ($resultData->{data}->{vars}); + + if (defined $resultData->{data}->{vars}->{role}->{value}) { + FRITZBOX_Readout_Add_Reading $hash, $roReadings, "box_meshRole", $resultData->{data}->{vars}->{role}->{value}; + + if ($resultData->{data}->{vars}->{role}->{value} ne "slave") { + FRITZBOX_Readout_Add_Reading $hash, $roReadings, "LuaQueryCmd->dslStatGlobalIn->AttrVal", 1; + FRITZBOX_Readout_Add_Reading $hash, $roReadings, "LuaQueryCmd->dslStatGlobalOut->AttrVal", 1; + + $hash->{LuaQueryCmd}{dslStatGlobalIn}{AttrVal} = 1; + $hash->{LuaQueryCmd}{dslStatGlobalOut}{AttrVal} = 1; + } else { + FRITZBOX_Readout_Add_Reading $hash, $roReadings, "LuaQueryCmd->dslStatGlobalIn->AttrVal", 0; + FRITZBOX_Readout_Add_Reading $hash, $roReadings, "LuaQueryCmd->dslStatGlobalOut->AttrVal", 0; + + $hash->{LuaQueryCmd}{dslStatGlobalIn}{AttrVal} = 0; + $hash->{LuaQueryCmd}{dslStatGlobalOut}{AttrVal} = 0; + } + + } elsif (defined $resultData->{data}->{rep_data}->{is_repeater}) { + + my $meshRole = $resultData->{data}->{rep_data}->{is_repeater} ? "slave" : "master"; + + FRITZBOX_Readout_Add_Reading $hash, $roReadings, "box_meshRole", $meshRole; + + if ($meshRole ne "slave") { + FRITZBOX_Readout_Add_Reading $hash, $roReadings, "LuaQueryCmd->dslStatGlobalIn->AttrVal", 1; + FRITZBOX_Readout_Add_Reading $hash, $roReadings, "LuaQueryCmd->dslStatGlobalOut->AttrVal", 1; + + $hash->{LuaQueryCmd}{dslStatGlobalIn}{AttrVal} = 1; + $hash->{LuaQueryCmd}{dslStatGlobalOut}{AttrVal} = 1; + } else { + FRITZBOX_Readout_Add_Reading $hash, $roReadings, "LuaQueryCmd->dslStatGlobalIn->AttrVal", 0; + FRITZBOX_Readout_Add_Reading $hash, $roReadings, "LuaQueryCmd->dslStatGlobalOut->AttrVal", 0; + + $hash->{LuaQueryCmd}{dslStatGlobalIn}{AttrVal} = 0; + $hash->{LuaQueryCmd}{dslStatGlobalOut}{AttrVal} = 0; + } + } else { + FRITZBOX_Readout_Add_Reading $hash, $roReadings, "LuaQueryCmd->dslStatGlobalIn->AttrVal", 1; + FRITZBOX_Readout_Add_Reading $hash, $roReadings, "LuaQueryCmd->dslStatGlobalOut->AttrVal", 1; + + $hash->{LuaQueryCmd}{dslStatGlobalIn}{AttrVal} = 1; + $hash->{LuaQueryCmd}{dslStatGlobalOut}{AttrVal} = 1; + } + + FRITZBOX_Log $hash, 4, "mesh_role - end getting data"; + + #------------------------------------------------------------------------------------- + # Getting phone WakeUpCall Device Nr + # uses $dectFonID (# Dect device list) and $dectFonID (phone device list) + + # xhr 1 lang de page alarm xhrId all + + FRITZBOX_Log $hash, 4, "WakeUpCall - start getting data"; + + @webCmdArray = (); + push @webCmdArray, "xhr" => "1"; + push @webCmdArray, "lang" => "de"; + push @webCmdArray, "page" => "alarm"; + push @webCmdArray, "xhrId" => "all"; + + $resultData = FRITZBOX_read_LuaData($hash, "data", \@webCmdArray) ; + + # Abbruch wenn Fehler beim Lesen der Fritzbox-Antwort + return FRITZBOX_Readout_Response($hash, $resultData, $roReadings) if ( defined $resultData->{Error} || defined $resultData->{AuthorizationRequired}); + + $$sidNew += $resultData->{sidNew} if defined $resultData->{sidNew}; + + FRITZBOX_Log $hash, 5, "\n" . Dumper ($resultData->{data}); + + $nbViews = 0; + if (defined $resultData->{data}->{phonoptions}) { + $views = $resultData->{data}->{phonoptions}; + $nbViews = scalar @$views; + } + + my $devname; + my $device; + my %devID; + + if ($nbViews > 0) { + # proof on redundant phone names + eval { + for(my $i = 0; $i <= $nbViews - 1; $i++) { + $devname = $resultData->{data}->{phonoptions}->[$i]->{text}; + $device = $resultData->{data}->{phonoptions}->[$i]->{value}; + + if ($devID{$devname}) { + my $defNewName = $devname . "[" . $devID{$devname} ."] redundant name in FB:" . $devname; + $devID{$defNewName} = $devID{$devname}; + $devID{$devname} = ""; + $defNewName = $devname . "[" . $device ."] redundant name in FB:" . $devname; + $devID{$defNewName} = $device; + } else { + $devID{$devname} = $device; + } + } + }; + + my $fonDisable = AttrVal( $name, "disableFonInfo", "0"); + my $dectDisable = AttrVal( $name, "disableDectInfo", "0"); + + for(keys %devID) { + + next if $devID{$_} eq ""; + $devname = $_; + $device = $devID{$_}; + + my $dectFonID = $hash->{helper}{dectFonID}{$devname}; + my $fonFonID = $hash->{helper}{fonFonID}{$devname}; + + FRITZBOX_Readout_Add_Reading $hash, $roReadings, "dect" . $dectFonID . "_device", $device if $dectFonID && !$dectDisable; + FRITZBOX_Readout_Add_Reading $hash, $roReadings, "fon" . $fonFonID . "_device", $device if $fonFonID && !$fonDisable; + + if (!$fonFonID && !$dectFonID && !$fonDisable) { + FRITZBOX_Readout_Add_Reading $hash, $roReadings, "fon" . $device, $devname ; + FRITZBOX_Readout_Add_Reading $hash, $roReadings, "fon" . $device . "_device", $device ; + } + + $devname =~ s/\|/|/g; + + my $fd_devname = "fdn_" . $devname; + FRITZBOX_Readout_Add_Reading $hash, $roReadings, "fhem->$fd_devname", $device; + + my $fd_device = "fd_" . $device; + FRITZBOX_Readout_Add_Reading $hash, $roReadings, "fhem->$fd_device", $devname; + } + } + + FRITZBOX_Log $hash, 4, "WakeUpCall - end getting data"; + + #------------------------------------------------------------------------------------- + # WLAN neighbors + + # "xhr 1 lang de page chan xhrId environment useajax 1; + + if ( AttrVal( $name, "enableWLANneighbors", "0") ) { + + FRITZBOX_Log $hash, 4, "enableWLANneighbors - start getting data"; @webCmdArray = (); push @webCmdArray, "xhr" => "1"; push @webCmdArray, "lang" => "de"; - push @webCmdArray, "page" => "alarm"; - push @webCmdArray, "xhrId" => "all"; - + push @webCmdArray, "page" => "chan"; + push @webCmdArray, "xhrId" => "environment"; + $resultData = FRITZBOX_read_LuaData($hash, "data", \@webCmdArray) ; # Abbruch wenn Fehler beim Lesen der Fritzbox-Antwort - return FRITZBOX_Readout_Response($hash, $resultData, \@roReadings) if ( defined $resultData->{Error} || defined $resultData->{AuthorizationRequired}); + return FRITZBOX_Readout_Response($hash, $resultData, $roReadings) if ( defined $resultData->{Error} || defined $resultData->{AuthorizationRequired}); - $sidNew += $result->{sidNew} if defined $result->{sidNew}; + $$sidNew += $resultData->{sidNew} if defined $resultData->{sidNew}; - FRITZBOX_Log $hash, 5, "\n" . Dumper ($resultData->{data}); + FRITZBOX_Log $hash, 5, "\n" . Dumper ($resultData->{data}->{scanlist}); + + my $nbhPrefix = AttrVal( $name, "wlanNeighborsPrefix", "nbh_" ); + my %oldWanDevice; + + #collect current mac-readings (to delete the ones that are inactive or disappeared) + foreach (keys %{ $hash->{READINGS} }) { + $oldWanDevice{$_} = $hash->{READINGS}{$_}{VAL} if $_ =~ /^${nbhPrefix}/ && defined $hash->{READINGS}{$_}{VAL}; + } $nbViews = 0; - if (defined $resultData->{data}->{phonoptions}) { - $views = $resultData->{data}->{phonoptions}; + if (defined $resultData->{data}->{scanlist}) { + $views = $resultData->{data}->{scanlist}; $nbViews = scalar @$views; } - my $devname; - my $device; - my %devID; - if ($nbViews > 0) { - # proof on redundant phone names + eval { for(my $i = 0; $i <= $nbViews - 1; $i++) { - $devname = $resultData->{data}->{phonoptions}->[$i]->{text}; - $device = $resultData->{data}->{phonoptions}->[$i]->{value}; - - if ($devID{$devname}) { - my $defNewName = $devname . "[" . $devID{$devname} ."] redundant name in FB:" . $devname; - $devID{$defNewName} = $devID{$devname}; - $devID{$devname} = ""; - $defNewName = $devname . "[" . $device ."] redundant name in FB:" . $devname; - $devID{$defNewName} = $device; - } else { - $devID{$devname} = $device; + my $dName = $resultData->{data}->{scanlist}->[$i]->{ssid}; + $dName .= " (Kanal: " . $resultData->{data}->{scanlist}->[$i]->{channel}; + if ($hash->{fhem}{fwVersion} < 750) { + $dName .= ", Band: " . $resultData->{data}->{scanlist}->[$i]->{bandId}; + $dName =~ s/24ghz/2.4 GHz/; + $dName =~ s/5ghz/5 GHz/; } + $dName .= ")"; + + $rName = $resultData->{data}->{scanlist}->[$i]->{mac}; + $rName =~ s/:/_/g; + $rName = $nbhPrefix . $rName; + FRITZBOX_Readout_Add_Reading $hash, $roReadings, $rName, $dName; + delete $oldWanDevice{$rName} if exists $oldWanDevice{$rName}; } }; - my $fonDisable = AttrVal( $name, "disableFonInfo", "0"); - my $dectDisable = AttrVal( $name, "disableDectInfo", "0"); + $rName = "box_wlan_lastScanTime"; + FRITZBOX_Readout_Add_Reading $hash, $roReadings, $rName, $resultData->{data}->{lastScantime}; + delete $oldWanDevice{$rName} if exists $oldWanDevice{$rName}; + } - for(keys %devID) { - - next if $devID{$_} eq ""; - $devname = $_; - $device = $devID{$_}; - - FRITZBOX_Readout_Add_Reading $hash, \@roReadings, "dect".$dectFonID{$devname}."_device", $device if $dectFonID{$devname} && !$dectDisable; - FRITZBOX_Readout_Add_Reading $hash, \@roReadings, "fon".$fonFonID{$devname}."_device", $device if $fonFonID{$devname} && !$fonDisable; - - if (!$fonFonID{$devname} && !$dectFonID{$devname} && !$fonDisable) { - FRITZBOX_Readout_Add_Reading $hash, \@roReadings, "fon".$device, $devname ; - FRITZBOX_Readout_Add_Reading $hash, \@roReadings, "fon".$device."_device", $device ; - } - - $devname =~ s/\|/|/g; - - my $fd_devname = "fdn_" . $devname; - FRITZBOX_Readout_Add_Reading $hash, \@roReadings, "fhem->$fd_devname", $device; - - my $fd_device = "fd_" . $device; - FRITZBOX_Readout_Add_Reading $hash, \@roReadings, "fhem->$fd_device", $devname; + # Remove inactive or non existing wan-readings in two steps + foreach ( keys %oldWanDevice ) { + # set the wan readings to 'inactive' and delete at next readout + if ( $oldWanDevice{$_} ne "inactive" ) { + FRITZBOX_Readout_Add_Reading $hash, $roReadings, $_, "inactive"; + } else { + FRITZBOX_Readout_Add_Reading $hash, $roReadings, $_, ""; } } - - #------------------------------------------------------------------------------------- - # getting Mesh Role - # xhr 1 lang de page wlanmesh xhrId all - @webCmdArray = (); + FRITZBOX_Log $hash, 4, "enableWLANneighbors - end getting data"; + + } else { + FRITZBOX_Readout_Add_Reading $hash, $roReadings, "box_wlan_lastScanTime", ""; + } + + #------------------------------------------------------------------------------------- + # kid profiles + # xhr 1 lang de page kidPro + + if (AttrVal( $name, "enableKidProfiles", "0") ) { + + FRITZBOX_Log $hash, 4, "enableKidProfiles - start getting data"; + + my %oldKidDevice; + + #collect current kid-readings (to delete the ones that are inactive or disappeared) + foreach (keys %{ $hash->{READINGS} }) { + $oldKidDevice{$_} = $hash->{READINGS}{$_}{VAL} if $_ =~ /^kidprofile/ && defined $hash->{READINGS}{$_}{VAL}; + } + + my @webCmdArray; push @webCmdArray, "xhr" => "1"; push @webCmdArray, "lang" => "de"; - push @webCmdArray, "page" => "wlanmesh"; - push @webCmdArray, "xhrId" => "all"; + push @webCmdArray, "page" => "kidPro"; - $resultData = FRITZBOX_read_LuaData($hash, "data", \@webCmdArray) ; + my $resultData = FRITZBOX_read_LuaData($hash, "data", \@webCmdArray) ; # Abbruch wenn Fehler beim Lesen der Fritzbox-Antwort - return FRITZBOX_Readout_Response($hash, $resultData, \@roReadings) if ( defined $resultData->{Error} || defined $resultData->{AuthorizationRequired}); + return FRITZBOX_Readout_Response($hash, $resultData, $roReadings) if ( defined $resultData->{Error} || defined $resultData->{AuthorizationRequired}); - $sidNew += $result->{sidNew} if defined $result->{sidNew}; + $$sidNew += $resultData->{sidNew} if defined $resultData->{sidNew}; - FRITZBOX_Log $hash, 5, "\n" . Dumper ($resultData->{data}->{vars}); + FRITZBOX_Readout_Add_Reading $hash, $roReadings, "kidprofile2", "unbegrenzt [filtprof3]"; - if (defined $resultData->{data}->{vars}->{role}->{value}) { - FRITZBOX_Readout_Add_Reading $hash, \@roReadings, "box_meshRole", $resultData->{data}->{vars}->{role}->{value}; - } + my $views = $resultData->{data}->{kidProfiles}; - #------------------------------------------------------------------------------------- - # WLAN neighbors + eval { + foreach my $key (keys %$views) { + FRITZBOX_Log $hash, 4, "Kid Profiles: " . $key; - # "xhr 1 lang de page chan xhrId environment useajax 1; + my $kProfile = $resultData->{data}->{kidProfiles}->{$key}{Name} . " [" . $resultData->{data}->{kidProfiles}->{$key}{Id} ."]"; - if ( AttrVal( $name, "enableWLANneighbors", "0") ) { - - @webCmdArray = (); - push @webCmdArray, "xhr" => "1"; - push @webCmdArray, "lang" => "de"; - push @webCmdArray, "page" => "chan"; - push @webCmdArray, "xhrId" => "environment"; - - $resultData = FRITZBOX_read_LuaData($hash, "data", \@webCmdArray) ; - - # Abbruch wenn Fehler beim Lesen der Fritzbox-Antwort - return FRITZBOX_Readout_Response($hash, $resultData, \@roReadings) if ( defined $resultData->{Error} || defined $resultData->{AuthorizationRequired}); - - $sidNew += $result->{sidNew} if defined $result->{sidNew}; - - FRITZBOX_Log $hash, 5, "\n" . Dumper ($resultData->{data}->{scanlist}); - - my $nbhPrefix = AttrVal( $name, "wlanNeighborsPrefix", "nbh_" ); - my %oldWanDevice; - - #collect current mac-readings (to delete the ones that are inactive or disappeared) - foreach (keys %{ $hash->{READINGS} }) { - $oldWanDevice{$_} = $hash->{READINGS}{$_}{VAL} if $_ =~ /^${nbhPrefix}/ && defined $hash->{READINGS}{$_}{VAL}; + FRITZBOX_Readout_Add_Reading $hash, $roReadings, "kid" . $key, $kProfile; + delete $oldKidDevice{"kid" . $key} if exists $oldKidDevice{"kid" . $key}; } + }; - $nbViews = 0; - if (defined $resultData->{data}->{scanlist}) { - $views = $resultData->{data}->{scanlist}; - $nbViews = scalar @$views; - } - - if ($nbViews > 0) { - - eval { - for(my $i = 0; $i <= $nbViews - 1; $i++) { - my $dName = $resultData->{data}->{scanlist}->[$i]->{ssid}; - $dName .= " (Kanal: " . $resultData->{data}->{scanlist}->[$i]->{channel}; - if (($FW1 == 7 && $FW2 < 50)) { - $dName .= ", Band: " . $resultData->{data}->{scanlist}->[$i]->{bandId}; - $dName =~ s/24ghz/2.4 GHz/; - $dName =~ s/5ghz/5 GHz/; - } - $dName .= ")"; - - $rName = $resultData->{data}->{scanlist}->[$i]->{mac}; - $rName =~ s/:/_/g; - $rName = $nbhPrefix . $rName; - FRITZBOX_Readout_Add_Reading $hash, \@roReadings, $rName, $dName; - delete $oldWanDevice{$rName} if exists $oldWanDevice{$rName}; - } - }; - $rName = "box_wlan_lastScanTime"; - FRITZBOX_Readout_Add_Reading $hash, \@roReadings, $rName, $resultData->{data}->{lastScantime}; - delete $oldWanDevice{$rName} if exists $oldWanDevice{$rName}; - } - - # Remove inactive or non existing wan-readings in two steps - foreach ( keys %oldWanDevice ) { - # set the wan readings to 'inactive' and delete at next readout - if ( $oldWanDevice{$_} ne "inactive" ) { - FRITZBOX_Readout_Add_Reading $hash, \@roReadings, $_, "inactive"; - } else { - FRITZBOX_Readout_Add_Reading $hash, \@roReadings, $_, ""; - } - } - - } else { - FRITZBOX_Readout_Add_Reading $hash, \@roReadings, "box_wlan_lastScanTime", ""; - } - - #------------------------------------------------------------------------------------- - # kid profiles - # xhr 1 lang de page kidPro - - if (AttrVal( $name, "enableKidProfiles", "0") ) { - - my %oldKidDevice; - - #collect current kid-readings (to delete the ones that are inactive or disappeared) - foreach (keys %{ $hash->{READINGS} }) { - $oldKidDevice{$_} = $hash->{READINGS}{$_}{VAL} if $_ =~ /^kidprofile/ && defined $hash->{READINGS}{$_}{VAL}; - } - - my @webCmdArray; - push @webCmdArray, "xhr" => "1"; - push @webCmdArray, "lang" => "de"; - push @webCmdArray, "page" => "kidPro"; - - my $resultData = FRITZBOX_read_LuaData($hash, "data", \@webCmdArray) ; - - # Abbruch wenn Fehler beim Lesen der Fritzbox-Antwort - return FRITZBOX_Readout_Response($hash, $resultData, \@roReadings) if ( defined $resultData->{Error} || defined $resultData->{AuthorizationRequired}); - - $sidNew += $result->{sidNew} if defined $result->{sidNew}; - - FRITZBOX_Readout_Add_Reading $hash, \@roReadings, "kidprofile2", "unbegrenzt [filtprof3]"; - - my $views = $resultData->{data}->{kidProfiles}; - - eval { - foreach my $key (keys %$views) { - FRITZBOX_Log $hash, 5, "Kid Profiles: " . $key; - - my $kProfile = $resultData->{data}->{kidProfiles}->{$key}{Name} . " [" . $resultData->{data}->{kidProfiles}->{$key}{Id} ."]"; - - FRITZBOX_Readout_Add_Reading $hash, \@roReadings, "kid" . $key, $kProfile; - delete $oldKidDevice{"kid" . $key} if exists $oldKidDevice{"kid" . $key}; - } - }; - - # Remove inactive or non existing kid-readings in two steps - foreach ( keys %oldKidDevice ) { - # set the wan readings to 'inactive' and delete at next readout - if ( $oldKidDevice{$_} ne "inactive" ) { - FRITZBOX_Readout_Add_Reading $hash, \@roReadings, $_, "inactive"; - } else { - FRITZBOX_Readout_Add_Reading $hash, \@roReadings, $_, ""; - } + # Remove inactive or non existing kid-readings in two steps + foreach ( keys %oldKidDevice ) { + # set the wan readings to 'inactive' and delete at next readout + if ( $oldKidDevice{$_} ne "inactive" ) { + FRITZBOX_Readout_Add_Reading $hash, $roReadings, $_, "inactive"; + } else { + FRITZBOX_Readout_Add_Reading $hash, $roReadings, $_, ""; } } - #------------------------------------------------------------------------------------- - # WLAN log expanded status + FRITZBOX_Log $hash, 4, "enableKidProfiles - end getting data"; - # xhr 1 lang de page log xhrId log filter wlan + } + + #------------------------------------------------------------------------------------- + # WLAN log expanded status + + # xhr 1 lang de page log xhrId log filter wlan + + if ($logFilter =~ /box_wlan_Log/) { + + FRITZBOX_Log $hash, 4, "LOG_WLAN - start getting data: $logFilter"; @webCmdArray = (); push @webCmdArray, "xhr" => "1"; @@ -4097,47 +4429,54 @@ sub FRITZBOX_Readout_Run_Web($) push @webCmdArray, "page" => "log"; push @webCmdArray, "xhrId" => "log"; - if (($FW1 == 6 && $FW2 >= 80) || ($FW1 == 7 && $FW2 < 50)) { + if ($hash->{fhem}{fwVersion} >= 680 && $hash->{fhem}{fwVersion} < 750) { push @webCmdArray, "filter" => "4"; - } elsif ($FW1 >= 7 && $FW2 >= 50) { + } elsif ($hash->{fhem}{fwVersion} >= 750) { push @webCmdArray, "filter" => "wlan"; } $resultData = FRITZBOX_read_LuaData($hash, "data", \@webCmdArray) ; # Abbruch wenn Fehler beim Lesen der Fritzbox-Antwort - return FRITZBOX_Readout_Response($hash, $resultData, \@roReadings) if ( defined $resultData->{Error} || defined $resultData->{AuthorizationRequired}); + return FRITZBOX_Readout_Response($hash, $resultData, $roReadings) if ( defined $resultData->{Error} || defined $resultData->{AuthorizationRequired}); - $sidNew += $result->{sidNew} if defined $result->{sidNew}; + $$sidNew += $resultData->{sidNew} if defined $resultData->{sidNew}; $tmpData = $resultData->{data}->{wlan} ? "on" : "off"; - FRITZBOX_Log $hash, 5, "wlanLogExtended -> " . $tmpData; - FRITZBOX_Readout_Add_Reading $hash, \@roReadings, "box_wlan_LogExtended", $tmpData; + FRITZBOX_Log $hash, 4, "wlanLogExtended -> " . $tmpData; + FRITZBOX_Readout_Add_Reading $hash, $roReadings, "box_wlan_LogExtended", $tmpData; - if (($FW1 == 6 && $FW2 >= 80) || ($FW1 == 7 && $FW2 < 50)) { + if ($hash->{fhem}{fwVersion} >= 680 && $hash->{fhem}{fwVersion} < 750) { if ( defined $resultData->{data}->{filter} && $resultData->{data}->{filter} eq "4" && defined $resultData->{data}->{log}->[0]) { $tmpData = $resultData->{data}->{log}->[0][3] . " " . $resultData->{data}->{log}->[0][0] . " " . $resultData->{data}->{log}->[0][1] ; - FRITZBOX_Log $hash, 5, "wlanLogLast -> " . $tmpData; - FRITZBOX_Readout_Add_Reading $hash, \@roReadings, "box_wlan_LogNewest", $tmpData; + FRITZBOX_Log $hash, 4, "wlanLogLast -> " . $tmpData; + FRITZBOX_Readout_Add_Reading $hash, $roReadings, "box_wlan_LogNewest", $tmpData; } else { - FRITZBOX_Log $hash, 5, "wlanLogLast -> none"; - FRITZBOX_Readout_Add_Reading $hash, \@roReadings, "box_wlan_LogNewest", "none"; + FRITZBOX_Log $hash, 4, "wlanLogLast -> none"; + FRITZBOX_Readout_Add_Reading $hash, $roReadings, "box_wlan_LogNewest", "none"; } - } elsif ($FW1 >= 7 && $FW2 >= 50) { + } elsif ($hash->{fhem}{fwVersion} >= 750) { if ( defined $resultData->{data}->{filter} && $resultData->{data}->{filter} eq "wlan" && defined $resultData->{data}->{log}->[0]) { $tmpData = $resultData->{data}->{log}->[0]->{id} . " " . $resultData->{data}->{log}->[0]->{date} . " " . $resultData->{data}->{log}->[0]->{time} ; - FRITZBOX_Log $hash, 5, "wlanLogLast -> " . $tmpData; - FRITZBOX_Readout_Add_Reading $hash, \@roReadings, "box_wlan_LogNewest", $tmpData; + FRITZBOX_Log $hash, 4, "wlanLogLast -> " . $tmpData; + FRITZBOX_Readout_Add_Reading $hash, $roReadings, "box_wlan_LogNewest", $tmpData; } else { - FRITZBOX_Log $hash, 5, "wlanLogLast -> none"; - FRITZBOX_Readout_Add_Reading $hash, \@roReadings, "box_wlan_LogNewest", "none"; + FRITZBOX_Log $hash, 4, "wlanLogLast -> none"; + FRITZBOX_Readout_Add_Reading $hash, $roReadings, "box_wlan_LogNewest", "none"; } } - #------------------------------------------------------------------------------------- - # SYS log + FRITZBOX_Log $hash, 4, "LOG_WLAN - end getting data: $logFilter"; + } - # xhr 1 lang de page log xhrId log filter sys + #------------------------------------------------------------------------------------- + # SYS log + + # xhr 1 lang de page log xhrId log filter sys + + if ($logFilter =~ /box_sys_Log/) { + + FRITZBOX_Log $hash, 4, "LOG_SYS - start getting data: $logFilter"; @webCmdArray = (); push @webCmdArray, "xhr" => "1"; @@ -4145,193 +4484,351 @@ sub FRITZBOX_Readout_Run_Web($) push @webCmdArray, "page" => "log"; push @webCmdArray, "xhrId" => "log"; - if (($FW1 == 6 && $FW2 >= 80) || ($FW1 == 7 && $FW2 < 50)) { + if ($hash->{fhem}{fwVersion} >= 680 && $hash->{fhem}{fwVersion} < 750) { push @webCmdArray, "filter" => "1"; - } elsif ($FW1 >= 7 && $FW2 >= 50) { + } elsif ($hash->{fhem}{fwVersion} >= 750) { push @webCmdArray, "filter" => "sys"; } $resultData = FRITZBOX_read_LuaData($hash, "data", \@webCmdArray) ; # Abbruch wenn Fehler beim Lesen der Fritzbox-Antwort - return FRITZBOX_Readout_Response($hash, $resultData, \@roReadings) if ( defined $resultData->{Error} || defined $resultData->{AuthorizationRequired}); + return FRITZBOX_Readout_Response($hash, $resultData, $roReadings) if ( defined $resultData->{Error} || defined $resultData->{AuthorizationRequired}); - $sidNew += $result->{sidNew} if defined $result->{sidNew}; + $$sidNew += $result->{sidNew} if defined $result->{sidNew}; - if (($FW1 == 6 && $FW2 >= 80) || ($FW1 == 7 && $FW2 < 50)) { + if ($hash->{fhem}{fwVersion} >= 680 && $hash->{fhem}{fwVersion} < 750) { if ( defined $resultData->{data}->{filter} && $resultData->{data}->{filter} eq "1" && defined $resultData->{data}->{log}->[0]) { $tmpData = $resultData->{data}->{log}->[0][3] . " " . $resultData->{data}->{log}->[0][0] . " " . $resultData->{data}->{log}->[0][1] ; - FRITZBOX_Log $hash, 5, "wlanLogLast -> " . $tmpData; - FRITZBOX_Readout_Add_Reading $hash, \@roReadings, "box_sys_LogNewest", $tmpData; + FRITZBOX_Log $hash, 4, "wlanLogLast -> " . $tmpData; + FRITZBOX_Readout_Add_Reading $hash, $roReadings, "box_sys_LogNewest", $tmpData; } else { - FRITZBOX_Log $hash, 5, "wlanLogLast -> none"; - FRITZBOX_Readout_Add_Reading $hash, \@roReadings, "box_sys_LogNewest", "none"; + FRITZBOX_Log $hash, 4, "wlanLogLast -> none"; + FRITZBOX_Readout_Add_Reading $hash, $roReadings, "box_sys_LogNewest", "none"; } - } elsif ($FW1 >= 7 && $FW2 >= 50) { + } elsif ($hash->{fhem}{fwVersion} >= 750) { if ( defined $resultData->{data}->{filter} && $resultData->{data}->{filter} eq "sys" && defined $resultData->{data}->{log}->[0]) { $tmpData = $resultData->{data}->{log}->[0]->{id} . " " . $resultData->{data}->{log}->[0]->{date} . " " . $resultData->{data}->{log}->[0]->{time} ; - FRITZBOX_Log $hash, 5, "wlanLogLast -> " . $tmpData; - FRITZBOX_Readout_Add_Reading $hash, \@roReadings, "box_sys_LogNewest", $tmpData; + FRITZBOX_Log $hash, 4, "wlanLogLast -> " . $tmpData; + FRITZBOX_Readout_Add_Reading $hash, $roReadings, "box_sys_LogNewest", $tmpData; } else { - FRITZBOX_Log $hash, 5, "wlanLogLast -> none"; - FRITZBOX_Readout_Add_Reading $hash, \@roReadings, "box_sys_LogNewest", "none"; + FRITZBOX_Log $hash, 4, "wlanLogLast -> none"; + FRITZBOX_Readout_Add_Reading $hash, $roReadings, "box_sys_LogNewest", "none"; } } + FRITZBOX_Log $hash, 4, "LOG_SYS - end getting data: $logFilter"; + } + + #------------------------------------------------------------------------------------- + # info about LED settings + + if ( $enableBoxReading =~ /box_led/ && ($hash->{fhem}{fwVersion} >= 700) ) { + + FRITZBOX_Log $hash, 4, "BOX_LED - start getting data: $enableBoxReading"; + + # "xhr 1 lang de page led xhrId all; + + @webCmdArray = (); + push @webCmdArray, "xhr" => "1"; + push @webCmdArray, "lang" => "de"; + push @webCmdArray, "page" => "led"; + push @webCmdArray, "xhrId" => "all"; + + $resultData = FRITZBOX_read_LuaData($hash, "data", \@webCmdArray) ; + + # Abbruch wenn Fehler beim Lesen der Fritzbox-Antwort + return FRITZBOX_Readout_Response($hash, $resultData, $roReadings) if ( defined $resultData->{Error} || defined $resultData->{AuthorizationRequired}); + + $$sidNew += $result->{sidNew} if defined $result->{sidNew}; + + FRITZBOX_Log $hash, 5, "\n" . Dumper ($resultData->{data}->{ledSettings}); + + FRITZBOX_Readout_Add_Reading $hash, $roReadings, "box_ledDisplay", $resultData->{data}->{ledSettings}->{ledDisplay}?"off":"on"; + FRITZBOX_Readout_Add_Reading $hash, $roReadings, "box_ledHasEnv", $resultData->{data}->{ledSettings}->{hasEnv}?"yes":"no"; + FRITZBOX_Readout_Add_Reading $hash, $roReadings, "box_ledEnvLight", $resultData->{data}->{ledSettings}->{envLight}?"on":"off" if $resultData->{data}->{ledSettings}->{hasEnv}; + FRITZBOX_Readout_Add_Reading $hash, $roReadings, "box_ledCanDim", $resultData->{data}->{ledSettings}->{canDim}?"yes":"no"; + FRITZBOX_Readout_Add_Reading $hash, $roReadings, "box_ledDimValue", $resultData->{data}->{ledSettings}->{dimValue} if $resultData->{data}->{ledSettings}->{canDim}; + + FRITZBOX_Log $hash, 4, "BOX_LED - end getting data: $enableBoxReading"; + + } + # end info about LED settings + + + if ( $avmModel !~ /Smart/) { + #------------------------------------------------------------------------------------- + #------------------------------------------------------------------------------------- - # info about LED settings + # WLAN Gastzugang - my $globalFilter = AttrVal($name, "enableBoxReadings", ""); - - if ($globalFilter =~ /box_led/) { + # xhr 1 + # lang de + # page wGuest + # xhrId all + # xhr 1 lang de page wGuest xhrId all - # "xhr 1 lang de page led xhrId all; + if ( $hash->{fhem}{fwVersion} >= 680) { + + FRITZBOX_Log $hash, 4, "WLAN detailed info - start getting data"; @webCmdArray = (); push @webCmdArray, "xhr" => "1"; push @webCmdArray, "lang" => "de"; - push @webCmdArray, "page" => "led"; + push @webCmdArray, "page" => "wGuest"; push @webCmdArray, "xhrId" => "all"; $resultData = FRITZBOX_read_LuaData($hash, "data", \@webCmdArray) ; # Abbruch wenn Fehler beim Lesen der Fritzbox-Antwort - return FRITZBOX_Readout_Response($hash, $resultData, \@roReadings) if ( defined $resultData->{Error} || defined $resultData->{AuthorizationRequired}); + return FRITZBOX_Readout_Response($hash, $resultData, $roReadings) if ( defined $resultData->{Error} || defined $resultData->{AuthorizationRequired}); - $sidNew += $result->{sidNew} if defined $result->{sidNew}; + $$sidNew += $resultData->{sidNew} if defined $resultData->{sidNew}; - FRITZBOX_Log $hash, 5, "\n" . Dumper ($resultData->{data}->{ledSettings}); + FRITZBOX_Readout_Add_Reading $hash, $roReadings, "box_guestWlan_SSID", $resultData->{data}->{guestAccess}->{ssid}; + FRITZBOX_Readout_Add_Reading $hash, $roReadings, "box_guestWlan_defPubSSID", $resultData->{data}->{guestAccess}->{defaultSsid}->{public}; + FRITZBOX_Readout_Add_Reading $hash, $roReadings, "box_guestWlan_defPrivSSID", $resultData->{data}->{guestAccess}->{defaultSsid}->{private}; + FRITZBOX_Readout_Add_Reading $hash, $roReadings, "box_guestWlan_groupAccess", $resultData->{data}->{guestAccess}->{guestGroupAccess}, "onoff"; + FRITZBOX_Readout_Add_Reading $hash, $roReadings, "box_guestWlan_tmoActive", $resultData->{data}->{guestAccess}->{isTimeoutActive}, "onoff"; + + FRITZBOX_Readout_Add_Reading $hash, $roReadings, "box_powerLine", $resultData->{data}->{guestAccess}->{isPowerline}, "onoff"; + + FRITZBOX_Log $hash, 4, "WLAN detailed info - end getting data"; + } else { + + FRITZBOX_Log $hash, 4, "wrong Fritz!OS for Guest WLAN detailed informations: $hash->{fhem}{fwVersionStr}"; - FRITZBOX_Readout_Add_Reading $hash, \@roReadings, "box_ledDisplay", $resultData->{data}->{ledSettings}->{ledDisplay}?"off":"on"; - FRITZBOX_Readout_Add_Reading $hash, \@roReadings, "box_ledHasEnv", $resultData->{data}->{ledSettings}->{hasEnv}?"yes":"no"; - FRITZBOX_Readout_Add_Reading $hash, \@roReadings, "box_ledEnvLight", $resultData->{data}->{ledSettings}->{envLight}?"on":"off" if $resultData->{data}->{ledSettings}->{hasEnv}; - FRITZBOX_Readout_Add_Reading $hash, \@roReadings, "box_ledCanDim", $resultData->{data}->{ledSettings}->{canDim}?"yes":"no"; - FRITZBOX_Readout_Add_Reading $hash, \@roReadings, "box_ledDimValue", $resultData->{data}->{ledSettings}->{dimValue} if $resultData->{data}->{ledSettings}->{canDim}; } - # end info about LED settings - if ( $avmModel =~ "Box") { + } + + if ( $avmModel =~ /Box|Smart/) { + #------------------------------------------------------------------------------------- + #------------------------------------------------------------------------------------- + # get list of SmartHome groups / devices - #------------------------------------------------------------------------------------- - # get list of SmartHome groups / devices + my $SmartHome = AttrVal($name, "enableSmartHome", "off"); - my $SmartHome = AttrVal($name, "enableSmartHome", "off"); - if ($SmartHome ne "off" && ($FW1 >= 7 && $FW2 >= 0) ) { + if ($SmartHome ne "off" && ($hash->{fhem}{fwVersion} >= 700) ) { - my %oldSmartDevice; + FRITZBOX_Log $hash, 4, "SmartHome - start getting data: $SmartHome"; - #collect current dect-readings (to delete the ones that are inactive or disappeared) - foreach (keys %{ $hash->{READINGS} }) { - $oldSmartDevice{$_} = $hash->{READINGS}{$_}{VAL} if $_ =~ /^shdevice(\d+)|^shgroup(\d+)/ && defined $hash->{READINGS}{$_}{VAL}; + my %oldSmartDevice; + + #collect current dect-readings (to delete the ones that are inactive or disappeared) + foreach (keys %{ $hash->{READINGS} }) { + $oldSmartDevice{$_} = $hash->{READINGS}{$_}{VAL} if $_ =~ /^shdevice(\d+)|^shgroup(\d+)/ && defined $hash->{READINGS}{$_}{VAL}; + } + + # xhr 1 lang de page sh_dev xhrid all + @webCmdArray = (); + push @webCmdArray, "xhr" => "1"; + push @webCmdArray, "lang" => "de"; + push @webCmdArray, "page" => "sh_dev"; + push @webCmdArray, "xhrId" => "all"; + + $resultData = FRITZBOX_read_LuaData($hash, "data", \@webCmdArray) ; + + # Abbruch wenn Fehler beim Lesen der Fritzbox-Antwort + return FRITZBOX_Readout_Response($hash, $resultData, $roReadings) if ( defined $resultData->{Error} || defined $resultData->{AuthorizationRequired}); + + $$sidNew += $result->{sidNew} if defined $result->{sidNew}; + + if ($SmartHome =~ /all|group/) { + + $nbViews = 0; + + if (defined $resultData->{data}->{groups}) { + $views = $resultData->{data}->{groups}; + $nbViews = scalar @$views; } - # xhr 1 lang de page sh_dev xhrid all - @webCmdArray = (); - push @webCmdArray, "xhr" => "1"; - push @webCmdArray, "lang" => "de"; - push @webCmdArray, "page" => "sh_dev"; - push @webCmdArray, "xhrId" => "all"; + if ($nbViews > 0) { - $resultData = FRITZBOX_read_LuaData($hash, "data", \@webCmdArray) ; + for(my $i = 0; $i <= $nbViews - 1; $i++) { + my $id = $resultData->{data}->{groups}->[$i]->{id}; + FRITZBOX_Readout_Add_Reading $hash, $roReadings, "shgroup" . $id, $resultData->{data}->{groups}->[$i]->{displayName}; + FRITZBOX_Readout_Add_Reading $hash, $roReadings, "shgroup" . $id . "_device", $resultData->{data}->{groups}->[$i]->{id}; + FRITZBOX_Readout_Add_Reading $hash, $roReadings, "shgroup" . $id . "_type", $resultData->{data}->{groups}->[$i]->{type}; + FRITZBOX_Readout_Add_Reading $hash, $roReadings, "shgroup" . $id . "_category", $resultData->{data}->{groups}->[$i]->{category}; - # Abbruch wenn Fehler beim Lesen der Fritzbox-Antwort - return FRITZBOX_Readout_Response($hash, $resultData, \@roReadings) if ( defined $resultData->{Error} || defined $resultData->{AuthorizationRequired}); - - $sidNew += $result->{sidNew} if defined $result->{sidNew}; - - if ($SmartHome =~ /all|group/) { - - $nbViews = 0; - - if (defined $resultData->{data}->{groups}) { - $views = $resultData->{data}->{groups}; - $nbViews = scalar @$views; - } - - if ($nbViews > 0) { - - for(my $i = 0; $i <= $nbViews - 1; $i++) { - my $id = $resultData->{data}->{groups}->[$i]->{id}; - FRITZBOX_Readout_Add_Reading $hash, \@roReadings, "shgroup" . $id, $resultData->{data}->{groups}->[$i]->{displayName}; - FRITZBOX_Readout_Add_Reading $hash, \@roReadings, "shgroup" . $id . "_device", $resultData->{data}->{groups}->[$i]->{id}; - FRITZBOX_Readout_Add_Reading $hash, \@roReadings, "shgroup" . $id . "_type", $resultData->{data}->{groups}->[$i]->{type}; - FRITZBOX_Readout_Add_Reading $hash, \@roReadings, "shgroup" . $id . "_category", $resultData->{data}->{groups}->[$i]->{category}; - - foreach (keys %oldSmartDevice) { - delete $oldSmartDevice{$_} if $_ =~ /^shgroup${id}_|^shgroup${id}/ && defined $oldSmartDevice{$_}; - } + foreach (keys %oldSmartDevice) { + delete $oldSmartDevice{$_} if $_ =~ /^shgroup${id}_|^shgroup${id}/ && defined $oldSmartDevice{$_}; } } } + } - if ($SmartHome =~ /all|device/ ) { - $nbViews = 0; + if ($SmartHome =~ /all|device/ ) { + $nbViews = 0; - if (defined $resultData->{data}->{devices}) { - $views = $resultData->{data}->{devices}; - $nbViews = scalar @$views; - } + if (defined $resultData->{data}->{devices}) { + $views = $resultData->{data}->{devices}; + $nbViews = scalar @$views; + } - if ($nbViews > 0) { + if ($nbViews > 0) { - for(my $i = 0; $i <= $nbViews - 1; $i++) { - my $id = $resultData->{data}->{devices}->[$i]->{id}; - FRITZBOX_Readout_Add_Reading $hash, \@roReadings, "shdevice" . $id, $resultData->{data}->{devices}->[$i]->{displayName}; - FRITZBOX_Readout_Add_Reading $hash, \@roReadings, "shdevice" . $id . "_device", $resultData->{data}->{devices}->[$i]->{id}; - FRITZBOX_Readout_Add_Reading $hash, \@roReadings, "shdevice" . $id . "_type", $resultData->{data}->{devices}->[$i]->{type}; - FRITZBOX_Readout_Add_Reading $hash, \@roReadings, "shdevice" . $id . "_category", $resultData->{data}->{devices}->[$i]->{category}; - FRITZBOX_Readout_Add_Reading $hash, \@roReadings, "shdevice" . $id . "_manufacturer", $resultData->{data}->{devices}->[$i]->{manufacturer}->{name}; - FRITZBOX_Readout_Add_Reading $hash, \@roReadings, "shdevice" . $id . "_model", $resultData->{data}->{devices}->[$i]->{model}; - FRITZBOX_Readout_Add_Reading $hash, \@roReadings, "shdevice" . $id . "_firmwareVersion", $resultData->{data}->{devices}->[$i]->{firmwareVersion}->{current}; - FRITZBOX_Readout_Add_Reading $hash, \@roReadings, "shdevice" . $id . "_status", $resultData->{data}->{devices}->[$i]->{masterConnectionState}; + for(my $i = 0; $i <= $nbViews - 1; $i++) { + my $id = $resultData->{data}->{devices}->[$i]->{id}; + FRITZBOX_Readout_Add_Reading $hash, $roReadings, "shdevice" . $id, $resultData->{data}->{devices}->[$i]->{displayName}; + FRITZBOX_Readout_Add_Reading $hash, $roReadings, "shdevice" . $id . "_device", $resultData->{data}->{devices}->[$i]->{id}; + FRITZBOX_Readout_Add_Reading $hash, $roReadings, "shdevice" . $id . "_type", $resultData->{data}->{devices}->[$i]->{type}; + FRITZBOX_Readout_Add_Reading $hash, $roReadings, "shdevice" . $id . "_category", $resultData->{data}->{devices}->[$i]->{category}; + FRITZBOX_Readout_Add_Reading $hash, $roReadings, "shdevice" . $id . "_manufacturer", $resultData->{data}->{devices}->[$i]->{manufacturer}->{name}; + FRITZBOX_Readout_Add_Reading $hash, $roReadings, "shdevice" . $id . "_model", $resultData->{data}->{devices}->[$i]->{model}; + FRITZBOX_Readout_Add_Reading $hash, $roReadings, "shdevice" . $id . "_firmwareVersion", $resultData->{data}->{devices}->[$i]->{firmwareVersion}->{current}; + FRITZBOX_Readout_Add_Reading $hash, $roReadings, "shdevice" . $id . "_status", $resultData->{data}->{devices}->[$i]->{masterConnectionState}; - if ( $resultData->{data}->{devices}->[$i]->{units} ) { - my $units = $resultData->{data}->{devices}->[$i]->{units}; - for my $unit (0 .. scalar @{$units} - 1) { - if( $units->[$unit]->{'type'} eq 'THERMOSTAT' ) { + if ( $resultData->{data}->{devices}->[$i]->{units} ) { + my $units = $resultData->{data}->{devices}->[$i]->{units}; + for my $unit (0 .. scalar @{$units} - 1) { + if( $units->[$unit]->{'type'} eq 'THERMOSTAT' ) { - } elsif ( $units->[$unit]->{'type'} eq 'TEMPERATURE_SENSOR' ) { - FRITZBOX_Readout_Add_Reading $hash, \@roReadings, "shdevice" . $id . "_temperature", $units->[$unit]->{skills}->[0]->{currentInCelsius}; - FRITZBOX_Readout_Add_Reading $hash, \@roReadings, "shdevice" . $id . "_tempOffset", $units->[$unit]->{skills}->[0]->{offset}; + } elsif ( $units->[$unit]->{'type'} eq 'TEMPERATURE_SENSOR' ) { + FRITZBOX_Readout_Add_Reading $hash, $roReadings, "shdevice" . $id . "_temperature", $units->[$unit]->{skills}->[0]->{currentInCelsius}; + FRITZBOX_Readout_Add_Reading $hash, $roReadings, "shdevice" . $id . "_tempOffset", $units->[$unit]->{skills}->[0]->{offset}; - } elsif ( $units->[$unit]->{'type'} eq 'BATTERY' ) { - FRITZBOX_Readout_Add_Reading $hash, \@roReadings, "shdevice" . $id . "_battery", $units->[$unit]->{skills}->[0]->{chargeLevelInPercent}; + } elsif ( $units->[$unit]->{'type'} eq 'BATTERY' ) { + FRITZBOX_Readout_Add_Reading $hash, $roReadings, "shdevice" . $id . "_battery", $units->[$unit]->{skills}->[0]->{chargeLevelInPercent}; - } elsif ( $units->[$unit]->{'type'} eq 'SOCKET' ) { - FRITZBOX_Readout_Add_Reading $hash, \@roReadings, "shdevice" . $id . "_voltage", $units->[$unit]->{skills}->[0]->{voltageInVolt}; - FRITZBOX_Readout_Add_Reading $hash, \@roReadings, "shdevice" . $id . "_power", $units->[$unit]->{skills}->[0]->{powerPerHour}; - FRITZBOX_Readout_Add_Reading $hash, \@roReadings, "shdevice" . $id . "_current", $units->[$unit]->{skills}->[0]->{electricCurrentInAmpere}; - FRITZBOX_Readout_Add_Reading $hash, \@roReadings, "shdevice" . $id . "_consumtion", $units->[$unit]->{skills}->[0]->{powerConsumptionInWatt}; - FRITZBOX_Readout_Add_Reading $hash, \@roReadings, "shdevice" . $id . "_ledState", $units->[$unit]->{skills}->[1]->{ledState}; - FRITZBOX_Readout_Add_Reading $hash, \@roReadings, "shdevice" . $id . "_state", $units->[$unit]->{skills}->[2]->{state}; - } + } elsif ( $units->[$unit]->{'type'} eq 'SOCKET' ) { + FRITZBOX_Readout_Add_Reading $hash, $roReadings, "shdevice" . $id . "_voltage", $units->[$unit]->{skills}->[0]->{voltageInVolt}; + FRITZBOX_Readout_Add_Reading $hash, $roReadings, "shdevice" . $id . "_power", $units->[$unit]->{skills}->[0]->{powerPerHour}; + FRITZBOX_Readout_Add_Reading $hash, $roReadings, "shdevice" . $id . "_current", $units->[$unit]->{skills}->[0]->{electricCurrentInAmpere}; + FRITZBOX_Readout_Add_Reading $hash, $roReadings, "shdevice" . $id . "_consumtion", $units->[$unit]->{skills}->[0]->{powerConsumptionInWatt}; + FRITZBOX_Readout_Add_Reading $hash, $roReadings, "shdevice" . $id . "_ledState", $units->[$unit]->{skills}->[1]->{ledState}; + FRITZBOX_Readout_Add_Reading $hash, $roReadings, "shdevice" . $id . "_state", $units->[$unit]->{skills}->[2]->{state}; + + } elsif ( $units->[$unit]->{'type'} eq 'DETECTOR' ) { } } + } - foreach (keys %oldSmartDevice) { - delete $oldSmartDevice{$_} if $_ =~ /^shdevice${id}_|^shdevice${id}/ && defined $oldSmartDevice{$_}; - } + foreach (keys %oldSmartDevice) { + delete $oldSmartDevice{$_} if $_ =~ /^shdevice${id}_|^shdevice${id}/ && defined $oldSmartDevice{$_}; } } } - # Remove inactive or non existing sip-readings in two steps + } + # Remove inactive or non existing sip-readings in two steps + + foreach ( keys %oldSmartDevice) { + # set the sip readings to 'inactive' and delete at next readout + if ( $oldSmartDevice{$_} ne "inactive" ) { + FRITZBOX_Readout_Add_Reading $hash, $roReadings, $_, "inactive"; + } else { + FRITZBOX_Readout_Add_Reading $hash, $roReadings, $_, ""; + } + } + + FRITZBOX_Log $hash, 4, "SmartHome - end getting data: $SmartHome"; + + } + } + + if ( $avmModel =~ "Box") { + #------------------------------------------------------------------------------------- + + #------------------------------------------------------------------------------------- + # DSL Verbindungsinformationen + + # xhr 1 + # lang de + # page dslOv + # xhrId all + # xhr 1 lang de page dslOv xhrId all + + #------------------------------------------------------------------------------------- + # INET Monitor + + # xhr 1 + # lang de + # page netMoni + # xhrId all + # xhr 1 lang de page netMoni xhrId all + + if ( ($hash->{fhem}{fwVersion} >= 731) && ($enableBoxReading =~ /box_dns_Srv/)) { + + FRITZBOX_Log $hash, 4, "NET_Monitor - start getting data"; + + @webCmdArray = (); + push @webCmdArray, "xhr" => "1"; + push @webCmdArray, "lang" => "de"; + push @webCmdArray, "page" => "netMoni"; + push @webCmdArray, "xhrId" => "all"; + + $resultData = FRITZBOX_read_LuaData($hash, "data", \@webCmdArray) ; + + # Abbruch wenn Fehler beim Lesen der Fritzbox-Antwort + return FRITZBOX_Readout_Response($hash, $resultData, $roReadings) if ( defined $resultData->{Error} || defined $resultData->{AuthorizationRequired}); + + $$sidNew += $resultData->{sidNew} if defined $resultData->{sidNew}; + + $nbViews = 0; + if (defined $resultData->{data}->{connections}) { + $views = $resultData->{data}->{connections}; + $nbViews = scalar @$views; + } + + if ($nbViews > 0) { + my $i = 0; + my $j = 0; + + eval { + for( $i = 0; $i <= $nbViews - 1; $i++) { + + my $nbViews2nd = 0; + + if (defined $resultData->{data}->{connections}->[$i]->{ipv4}->{dns}) { + $views = $resultData->{data}->{connections}->[$i]->{ipv4}->{dns}; + $nbViews2nd = scalar @$views; + } + + if ($nbViews2nd > 0) { + + eval { + for(my $j = 0; $j <= $nbViews2nd - 1; $j++) { + FRITZBOX_Readout_Add_Reading $hash, $roReadings, "box_dns_Srv" . $i . "_used_IPv4_" .$j, $resultData->{data}->{connections}->[$i]->{ipv4}->{dns}->[$j]->{ip}; + } + } + } + + if (defined $resultData->{data}->{connections}->[$i]->{ipv6}->{dns}) { + $views = $resultData->{data}->{connections}->[$i]->{ipv6}->{dns}; + $nbViews2nd = scalar @$views; + } + + if ($nbViews2nd > 0) { + + eval { + for($j = 0; $j <= $nbViews2nd - 1; $j++) { + FRITZBOX_Readout_Add_Reading $hash, $roReadings, "box_dns_Srv" . $i . "_used_IPv6_" .$j, $resultData->{data}->{connections}->[$i]->{ipv6}->{dns}->[$j]->{ip}; + } + } + } - foreach ( keys %oldSmartDevice) { - # set the sip readings to 'inactive' and delete at next readout - if ( $oldSmartDevice{$_} ne "inactive" ) { - FRITZBOX_Readout_Add_Reading $hash, \@roReadings, $_, "inactive"; - } else { - FRITZBOX_Readout_Add_Reading $hash, \@roReadings, $_, ""; } } } - #------------------------------------------------------------------------------------- - # FON log + FRITZBOX_Log $hash, 4, "NET_Monitor - end getting data"; + } else { - # xhr 1 lang de page log xhrId log filter fon + FRITZBOX_Log $hash, 4, "wrong Fritz!OS for active DNS servers: $hash->{fhem}{fwVersionStr}" if $enableBoxReading =~ /box_dns_Srv/; + + } + + #------------------------------------------------------------------------------------- + # FON log + + # xhr 1 lang de page log xhrId log filter fon + + if ($logFilter =~ /box_fon_Log/) { + + FRITZBOX_Log $hash, 4, "LOG_FON - start getting data: $logFilter"; @webCmdArray = (); push @webCmdArray, "xhr" => "1"; @@ -4339,390 +4836,456 @@ sub FRITZBOX_Readout_Run_Web($) push @webCmdArray, "page" => "log"; push @webCmdArray, "xhrId" => "log"; - if (($FW1 == 6 && $FW2 >= 80) || ($FW1 == 7 && $FW2 < 50)) { + if ($hash->{fhem}{fwVersion} >= 680 && $hash->{fhem}{fwVersion} < 750) { push @webCmdArray, "filter" => "3"; - } elsif ($FW1 >= 7 && $FW2 >= 50) { + } elsif ($hash->{fhem}{fwVersion} >= 750) { push @webCmdArray, "filter" => "fon"; } $resultData = FRITZBOX_read_LuaData($hash, "data", \@webCmdArray) ; # Abbruch wenn Fehler beim Lesen der Fritzbox-Antwort - return FRITZBOX_Readout_Response($hash, $resultData, \@roReadings) if ( defined $resultData->{Error} || defined $resultData->{AuthorizationRequired}); + return FRITZBOX_Readout_Response($hash, $resultData, $roReadings) if ( defined $resultData->{Error} || defined $resultData->{AuthorizationRequired}); - $sidNew += $result->{sidNew} if defined $result->{sidNew}; + $$sidNew += $resultData->{sidNew} if defined $resultData->{sidNew}; - if (($FW1 == 6 && $FW2 >= 80) || ($FW1 == 7 && $FW2 < 50)) { + if ($hash->{fhem}{fwVersion} >= 680 && $hash->{fhem}{fwVersion} < 750) { if ( defined $resultData->{data}->{filter} && $resultData->{data}->{filter} eq "3" && defined $resultData->{data}->{log}->[0]) { $tmpData = $resultData->{data}->{log}->[0][3] . " " . $resultData->{data}->{log}->[0][0] . " " . $resultData->{data}->{log}->[0][1] ; - FRITZBOX_Log $hash, 5, "wlanLogLast -> " . $tmpData; - FRITZBOX_Readout_Add_Reading $hash, \@roReadings, "box_fon_LogNewest", $tmpData; + FRITZBOX_Log $hash, 4, "wlanLogLast -> " . $tmpData; + FRITZBOX_Readout_Add_Reading $hash, $roReadings, "box_fon_LogNewest", $tmpData; } else { - FRITZBOX_Log $hash, 5, "wlanLogLast -> none"; - FRITZBOX_Readout_Add_Reading $hash, \@roReadings, "box_fon_LogNewest", "none"; + FRITZBOX_Log $hash, 4, "wlanLogLast -> none"; + FRITZBOX_Readout_Add_Reading $hash, $roReadings, "box_fon_LogNewest", "none"; } - } elsif ($FW1 >= 7 && $FW2 >= 50) { + } elsif ($hash->{fhem}{fwVersion} >= 750) { if ( defined $resultData->{data}->{filter} && $resultData->{data}->{filter} eq "fon" && defined $resultData->{data}->{log}->[0]) { $tmpData = $resultData->{data}->{log}->[0]->{id} . " " . $resultData->{data}->{log}->[0]->{date} . " " . $resultData->{data}->{log}->[0]->{time} ; - FRITZBOX_Log $hash, 5, "wlanLogLast -> " . $tmpData; - FRITZBOX_Readout_Add_Reading $hash, \@roReadings, "box_fon_LogNewest", $tmpData; + FRITZBOX_Log $hash, 4, "wlanLogLast -> " . $tmpData; + FRITZBOX_Readout_Add_Reading $hash, $roReadings, "box_fon_LogNewest", $tmpData; } else { - FRITZBOX_Log $hash, 5, "wlanLogLast -> none"; - FRITZBOX_Readout_Add_Reading $hash, \@roReadings, "box_fon_LogNewest", "none"; + FRITZBOX_Log $hash, 4, "wlanLogLast -> none"; + FRITZBOX_Readout_Add_Reading $hash, $roReadings, "box_fon_LogNewest", "none"; } } - #------------------------------------------------------------------------------------- - if ( ($FW1 >= 7 && $FW2 >= 21) ) { + FRITZBOX_Log $hash, 4, "LOG_FON - end getting data: $logFilter "; + } - #------------------------------------------------------------------------------------- - # get list of global filters - - my $globalFilter = AttrVal($name, "enableBoxReadings", ""); - - if ($globalFilter =~ /box_globalFilter/) { - - # "xhr 1 lang de page trafapp xhrId all; - - @webCmdArray = (); - push @webCmdArray, "xhr" => "1"; - push @webCmdArray, "lang" => "de"; - push @webCmdArray, "page" => "trafapp"; - push @webCmdArray, "xhrId" => "all"; - - $resultData = FRITZBOX_read_LuaData($hash, "data", \@webCmdArray) ; - - # Abbruch wenn Fehler beim Lesen der Fritzbox-Antwort - return FRITZBOX_Readout_Response($hash, $resultData, \@roReadings) if ( defined $resultData->{Error} || defined $resultData->{AuthorizationRequired}); - - $sidNew += $result->{sidNew} if defined $result->{sidNew}; - - FRITZBOX_Log $hash, 5, "\n" . Dumper ($resultData->{data}->{filterList}); - - FRITZBOX_Readout_Add_Reading $hash, \@roReadings, "box_globalFilterStealth", $resultData->{data}->{filterList}->{isGlobalFilterStealth}?"on":"off"; - FRITZBOX_Readout_Add_Reading $hash, \@roReadings, "box_globalFilterSmtp", $resultData->{data}->{filterList}->{isGlobalFilterSmtp}?"on":"off"; - FRITZBOX_Readout_Add_Reading $hash, \@roReadings, "box_globalFilterNetbios", $resultData->{data}->{filterList}->{isGlobalFilterNetbios}?"on":"off"; - FRITZBOX_Readout_Add_Reading $hash, \@roReadings, "box_globalFilterTeredo", $resultData->{data}->{filterList}->{isGlobalFilterTeredo}?"on":"off"; - FRITZBOX_Readout_Add_Reading $hash, \@roReadings, "box_globalFilterWpad", $resultData->{data}->{filterList}->{isGlobalFilterWpad}?"on":"off"; - } - # end FRITZBOX_Get_WLAN_globalFilters - - #------------------------------------------------------------------------------------- - # getting energy status - - my $eStatus = AttrVal($name, "enableBoxReadings", ""); - - if ($eStatus =~ /box_energyMode/) { - - # xhr 1 lang de page save_energy xhrId all - @webCmdArray = (); - push @webCmdArray, "xhr" => "1"; - push @webCmdArray, "lang" => "de"; - push @webCmdArray, "page" => "save_energy"; - push @webCmdArray, "xhrId" => "all"; - - $resultData = FRITZBOX_read_LuaData($hash, "data", \@webCmdArray) ; - - # Abbruch wenn Fehler beim Lesen der Fritzbox-Antwort - return FRITZBOX_Readout_Response($hash, $resultData, \@roReadings) if ( defined $resultData->{Error} || defined $resultData->{AuthorizationRequired}); - - $sidNew += $result->{sidNew} if defined $result->{sidNew}; - - FRITZBOX_Log $hash, 5, "\n" . Dumper ($resultData->{data}); - - if (defined $resultData->{data}->{mode}) { - FRITZBOX_Readout_Add_Reading $hash, \@roReadings, "box_energyMode", $resultData->{data}->{mode}; - FRITZBOX_Readout_Add_Reading $hash, \@roReadings, "box_energyModeWLAN_Timer", $resultData->{data}->{wlan}{timerActive}?"on":"off"; - my $eTime = $resultData->{data}->{wlan}{dailyStart}{hour} ? $resultData->{data}->{wlan}{dailyStart}{hour} : "__"; - $eTime .= ":"; - $eTime .= $resultData->{data}->{wlan}{dailyStart}{minute} ? $resultData->{data}->{wlan}{dailyStart}{minute} : "__"; - $eTime .= "-"; - $eTime .= $resultData->{data}->{wlan}{dailyEnd}{hour} ? $resultData->{data}->{wlan}{dailyEnd}{hour} : "__"; - $eTime .= ":"; - $eTime .= $resultData->{data}->{wlan}{dailyEnd}{minute} ? $resultData->{data}->{wlan}{dailyEnd}{minute} : "__"; - - FRITZBOX_Readout_Add_Reading $hash, \@roReadings, "box_energyModeWLAN_Time", $eTime; - FRITZBOX_Readout_Add_Reading $hash, \@roReadings, "box_energyModeWLAN_Repetition", $resultData->{data}->{wlan}{timerMode}; - FRITZBOX_Readout_Add_Reading $hash, \@roReadings, "box_wlan_Active", $resultData->{data}->{wlan}{enabled} == 1? "on":"off"; - } - } - } # end getting energy status + #------------------------------------------------------------------------------------- + if ( $hash->{fhem}{fwVersion} >= 721 ) { #------------------------------------------------------------------------------------- - # USB Mobilfunk-Modem Konfiguration + # get list of global filters - # xhr 1 lang de page mobile # xhrId modemSettings useajax 1 + if ($enableBoxReading =~ /box_globalFilter/) { - if (AttrVal($name, "enableMobileModem", 0) && ($FW1 >= 7 && $FW2 >= 50) ) { + FRITZBOX_Log $hash, 4, "globalFilter - start getting data: $enableBoxReading"; + + # "xhr 1 lang de page trafapp xhrId all; @webCmdArray = (); push @webCmdArray, "xhr" => "1"; push @webCmdArray, "lang" => "de"; - push @webCmdArray, "page" => "mobile"; + push @webCmdArray, "page" => "trafapp"; push @webCmdArray, "xhrId" => "all"; $resultData = FRITZBOX_read_LuaData($hash, "data", \@webCmdArray) ; # Abbruch wenn Fehler beim Lesen der Fritzbox-Antwort - return FRITZBOX_Readout_Response($hash, $resultData, \@roReadings) if ( defined $resultData->{Error} || defined $resultData->{AuthorizationRequired}); + return FRITZBOX_Readout_Response($hash, $resultData, $roReadings) if ( defined $resultData->{Error} || defined $resultData->{AuthorizationRequired}); - $sidNew += $result->{sidNew} if defined $result->{sidNew}; + $$sidNew += $resultData->{sidNew} if defined $resultData->{sidNew}; - eval { - FRITZBOX_Readout_Add_Reading $hash, \@roReadings, "usbMobile_voipOverMobile", $resultData->{data}->{voipOverMobile}, "onoff" - if $resultData->{data}->{voipOverMobile}; + FRITZBOX_Log $hash, 5, "\n" . Dumper ($resultData->{data}->{filterList}); - FRITZBOX_Readout_Add_Reading $hash, \@roReadings, "usbMobile_wds", $resultData->{data}->{wds}, "onoff" - if $resultData->{data}->{wds}; + FRITZBOX_Readout_Add_Reading $hash, $roReadings, "box_globalFilterStealth", $resultData->{data}->{filterList}->{isGlobalFilterStealth}?"on":"off"; + FRITZBOX_Readout_Add_Reading $hash, $roReadings, "box_globalFilterSmtp", $resultData->{data}->{filterList}->{isGlobalFilterSmtp}?"on":"off"; + FRITZBOX_Readout_Add_Reading $hash, $roReadings, "box_globalFilterNetbios", $resultData->{data}->{filterList}->{isGlobalFilterNetbios}?"on":"off"; + FRITZBOX_Readout_Add_Reading $hash, $roReadings, "box_globalFilterTeredo", $resultData->{data}->{filterList}->{isGlobalFilterTeredo}?"on":"off"; + FRITZBOX_Readout_Add_Reading $hash, $roReadings, "box_globalFilterWpad", $resultData->{data}->{filterList}->{isGlobalFilterWpad}?"on":"off"; - FRITZBOX_Readout_Add_Reading $hash, \@roReadings, "usbMobile_activation", $resultData->{data}->{activation} - if $resultData->{data}->{activation}; + FRITZBOX_Log $hash, 4, "globalFilter - end getting data: $enableBoxReading"; - FRITZBOX_Readout_Add_Reading $hash, \@roReadings, "usbMobile_config_dsl", $resultData->{data}->{config}->{dsl}, "onoff" - if $resultData->{data}->{config}->{dsl}; - - FRITZBOX_Readout_Add_Reading $hash, \@roReadings, "usbMobile_config_cable", $resultData->{data}->{config}->{cable}, "onoff" - if $resultData->{data}->{config}->{cable}; - - FRITZBOX_Readout_Add_Reading $hash, \@roReadings, "usbMobile_progress_refreshNeeded", $resultData->{data}->{progress}->{refreshNeeded}, "onoff" - if $resultData->{data}->{progress}->{refreshNeeded}; - - FRITZBOX_Readout_Add_Reading $hash, \@roReadings, "usbMobile_progress_error", $resultData->{data}->{progress}->{error} - if $resultData->{data}->{progress}->{error}; - - FRITZBOX_Readout_Add_Reading $hash, \@roReadings, "usbMobile_fallback_enableable", $resultData->{data}->{fallback}->{enableable}, "onoff" - if $resultData->{data}->{fallback}->{enableable}; - - FRITZBOX_Readout_Add_Reading $hash, \@roReadings, "usbMobile_fallback_possible", $resultData->{data}->{fallback}->{possible}, "onoff" - if $resultData->{data}->{fallback}->{possible}; - - FRITZBOX_Readout_Add_Reading $hash, \@roReadings, "usbMobile_ipclient", $resultData->{data}->{ipclient}, "onoff" - if $resultData->{data}->{ipclient}; - - FRITZBOX_Readout_Add_Reading $hash, \@roReadings, "usbMobile_sipNumberCount", ""; -# FRITZBOX_Readout_Add_Reading $hash, \@roReadings, "usbMobile_sipNumberCount", $resultData->{data}->{sipNumberCount} -# if $resultData->{data}->{sipNumberCount}; - - FRITZBOX_Readout_Add_Reading $hash, \@roReadings, "usbMobile_compatibilityMode_enabled", $resultData->{data}->{compatibilityMode}->{enabled}, "onoff" - if $resultData->{data}->{data}->{compatibilityMode}->{enabled}; - - FRITZBOX_Readout_Add_Reading $hash, \@roReadings, "usbMobile_compatibilityMode_enableable", $resultData->{data}->{compatibilityMode}->{enableable}, "onoff" - if $resultData->{data}->{data}->{compatibilityMode}->{enableable}; - - FRITZBOX_Readout_Add_Reading $hash, \@roReadings, "usbMobile_capabilities", $resultData->{data}->{capabilities}->{voice}, "onoff" - if $resultData->{data}->{capabilities}->{voice}; - }; - - } else { - FRITZBOX_Log $hash, 4, "wrong Fritz!OS for usb mobile: $FW1.$FW2" if AttrVal($name, "enableMobileModem", 0); } + # end FRITZBOX_Get_WLAN_globalFilters #------------------------------------------------------------------------------------- - # DOCSIS Informationen FB Cable + # getting energy status - if ( ( lc($avmModel) =~ "6[4,5,6][3,6,9][0,1]") && ($FW1 >= 7) && ($FW2 >= 21) ) { # FB Cable -# if (1==1) { - my $returnStr; + if ($enableBoxReading =~ /box_energyMode/) { - my $powerLevels; - my $frequencys; - my $modulations; - my $modType; - my $latencys; - my $corrErrors; - my $nonCorrErrors; - my $mses; + FRITZBOX_Log $hash, 4, "energyStatus - start getting data: $enableBoxReading"; - my %oldDocDevice; - - # xhr 1 lang de page docInfo xhrId all no_sidrenew nop + # xhr 1 lang de page save_energy xhrId all @webCmdArray = (); push @webCmdArray, "xhr" => "1"; push @webCmdArray, "lang" => "de"; - push @webCmdArray, "page" => "docInfo"; + push @webCmdArray, "page" => "save_energy"; push @webCmdArray, "xhrId" => "all"; - push @webCmdArray, "no_sidrenew" => ""; -# for debugging -# my $TestSIS = '{"pid":"docInfo","hide":{"mobile":true,"ssoSet":true,"liveTv":true},"time":[],"data":{"channelDs":{"docsis31":[{"powerLevel":"-1.6","type":"4K","channel":1,"channelID":0,"frequency":"751 - 861"},{"powerLevel":"7.7","type":"4K","channel":2,"channelID":1,"frequency":"175 - 237"}],"docsis30":[{"type":"256QAM","corrErrors":92890,"mse":"-36.4","powerLevel":"5.1","channel":1,"nonCorrErrors":9773,"latency":0.32,"channelID":7,"frequency":"538"},{"type":"256QAM","corrErrors":20553,"mse":"-37.4","powerLevel":"10.2","channel":2,"nonCorrErrors":9420,"latency":0.32,"channelID":26,"frequency":"698"},{"type":"256QAM","corrErrors":28673,"mse":"-37.6","powerLevel":"10.0","channel":3,"nonCorrErrors":140,"latency":0.32,"channelID":25,"frequency":"690"},{"type":"256QAM","corrErrors":25930,"mse":"-37.6","powerLevel":"10.0","channel":4,"nonCorrErrors":170,"latency":0.32,"channelID":27,"frequency":"706"},{"type":"256QAM","corrErrors":98698,"mse":"-36.6","powerLevel":"8.8","channel":5,"nonCorrErrors":9151,"latency":0.32,"channelID":30,"frequency":"746"},{"type":"256QAM","corrErrors":24614,"mse":"-37.4","powerLevel":"9.4","channel":6,"nonCorrErrors":9419,"latency":0.32,"channelID":28,"frequency":"730"},{"type":"256QAM","corrErrors":25882,"mse":"-37.4","powerLevel":"9.9","channel":7,"nonCorrErrors":9308,"latency":0.32,"channelID":24,"frequency":"682"},{"type":"256QAM","corrErrors":33817,"mse":"-37.4","powerLevel":"9.8","channel":8,"nonCorrErrors":146,"latency":0.32,"channelID":23,"frequency":"674"},{"type":"256QAM","corrErrors":112642,"mse":"-37.6","powerLevel":"7.8","channel":9,"nonCorrErrors":7783,"latency":0.32,"channelID":3,"frequency":"490"},{"type":"256QAM","corrErrors":41161,"mse":"-37.6","powerLevel":"9.8","channel":10,"nonCorrErrors":203,"latency":0.32,"channelID":21,"frequency":"658"},{"type":"256QAM","corrErrors":33219,"mse":"-37.4","powerLevel":"8.8","channel":11,"nonCorrErrors":10962,"latency":0.32,"channelID":18,"frequency":"634"},{"type":"256QAM","corrErrors":32680,"mse":"-37.6","powerLevel":"9.2","channel":12,"nonCorrErrors":145,"latency":0.32,"channelID":19,"frequency":"642"},{"type":"256QAM","corrErrors":33001,"mse":"-37.4","powerLevel":"9.8","channel":13,"nonCorrErrors":7613,"latency":0.32,"channelID":22,"frequency":"666"},{"type":"256QAM","corrErrors":42666,"mse":"-37.4","powerLevel":"8.1","channel":14,"nonCorrErrors":172,"latency":0.32,"channelID":17,"frequency":"626"},{"type":"256QAM","corrErrors":41023,"mse":"-37.4","powerLevel":"9.3","channel":15,"nonCorrErrors":10620,"latency":0.32,"channelID":20,"frequency":"650"},{"type":"256QAM","corrErrors":106921,"mse":"-37.6","powerLevel":"7.4","channel":16,"nonCorrErrors":356,"latency":0.32,"channelID":4,"frequency":"498"},{"type":"256QAM","corrErrors":86650,"mse":"-36.4","powerLevel":"4.9","channel":17,"nonCorrErrors":85,"latency":0.32,"channelID":12,"frequency":"578"},{"type":"256QAM","corrErrors":91838,"mse":"-36.4","powerLevel":"4.8","channel":18,"nonCorrErrors":168,"latency":0.32,"channelID":8,"frequency":"546"},{"type":"256QAM","corrErrors":110719,"mse":"-35.8","powerLevel":"4.5","channel":19,"nonCorrErrors":103,"latency":0.32,"channelID":10,"frequency":"562"},{"type":"256QAM","corrErrors":111846,"mse":"-37.6","powerLevel":"8.2","channel":20,"nonCorrErrors":247,"latency":0.32,"channelID":2,"frequency":"482"},{"type":"256QAM","corrErrors":668242,"mse":"-36.6","powerLevel":"5.8","channel":21,"nonCorrErrors":6800,"latency":0.32,"channelID":5,"frequency":"522"},{"type":"256QAM","corrErrors":104070,"mse":"-36.6","powerLevel":"5.3","channel":22,"nonCorrErrors":149,"latency":0.32,"channelID":6,"frequency":"530"},{"type":"256QAM","corrErrors":120994,"mse":"-35.8","powerLevel":"4.4","channel":23,"nonCorrErrors":10240,"latency":0.32,"channelID":9,"frequency":"554"},{"type":"256QAM","corrErrors":59145,"mse":"-36.4","powerLevel":"5.3","channel":24,"nonCorrErrors":9560,"latency":0.32,"channelID":11,"frequency":"570"},{"type":"256QAM","corrErrors":118271,"mse":"-37.6","powerLevel":"8.4","channel":25,"nonCorrErrors":810,"latency":0.32,"channelID":1,"frequency":"474"},{"type":"256QAM","corrErrors":40255,"mse":"-37.4","powerLevel":"6.5","channel":26,"nonCorrErrors":13474,"latency":0.32,"channelID":15,"frequency":"602"},{"type":"256QAM","corrErrors":62716,"mse":"-36.4","powerLevel":"5.3","channel":27,"nonCorrErrors":9496,"latency":0.32,"channelID":13,"frequency":"586"},{"type":"256QAM","corrErrors":131364,"mse":"-36.6","powerLevel":"8.9","channel":28,"nonCorrErrors":12238,"latency":0.32,"channelID":29,"frequency":"738"}]},"oem":"lgi","readyState":"ready","channelUs":{"docsis31":[],"docsis30":[{"powerLevel":"43.0","type":"64QAM","channel":1,"multiplex":"ATDMA","channelID":4,"frequency":"51"},{"powerLevel":"44.3","type":"64QAM","channel":2,"multiplex":"ATDMA","channelID":2,"frequency":"37"},{"powerLevel":"43.8","type":"64QAM","channel":3,"multiplex":"ATDMA","channelID":3,"frequency":"45"},{"powerLevel":"45.8","type":"64QAM","channel":4,"multiplex":"ATDMA","channelID":1,"frequency":"31"}]}},"sid":"14341afbc7d83b4c"}'; -# my $TestSIS = '{"pid":"docInfo","hide":{"mobile":true,"ssoSet":true,"liveTv":true},"time":[],"data":{"channelDs":{"docsis30":[{"type":"256QAM","corrErrors":92890,"mse":"-36.4","powerLevel":"5.1","channel":1,"nonCorrErrors":9773,"latency":0.32,"channelID":7,"frequency":"538"},{"type":"256QAM","corrErrors":20553,"mse":"-37.4","powerLevel":"10.2","channel":2,"nonCorrErrors":9420,"latency":0.32,"channelID":26,"frequency":"698"},{"type":"256QAM","corrErrors":28673,"mse":"-37.6","powerLevel":"10.0","channel":3,"nonCorrErrors":140,"latency":0.32,"channelID":25,"frequency":"690"},{"type":"256QAM","corrErrors":25930,"mse":"-37.6","powerLevel":"10.0","channel":4,"nonCorrErrors":170,"latency":0.32,"channelID":27,"frequency":"706"},{"type":"256QAM","corrErrors":98698,"mse":"-36.6","powerLevel":"8.8","channel":5,"nonCorrErrors":9151,"latency":0.32,"channelID":30,"frequency":"746"},{"type":"256QAM","corrErrors":24614,"mse":"-37.4","powerLevel":"9.4","channel":6,"nonCorrErrors":9419,"latency":0.32,"channelID":28,"frequency":"730"},{"type":"256QAM","corrErrors":25882,"mse":"-37.4","powerLevel":"9.9","channel":7,"nonCorrErrors":9308,"latency":0.32,"channelID":24,"frequency":"682"},{"type":"256QAM","corrErrors":33817,"mse":"-37.4","powerLevel":"9.8","channel":8,"nonCorrErrors":146,"latency":0.32,"channelID":23,"frequency":"674"},{"type":"256QAM","corrErrors":112642,"mse":"-37.6","powerLevel":"7.8","channel":9,"nonCorrErrors":7783,"latency":0.32,"channelID":3,"frequency":"490"},{"type":"256QAM","corrErrors":41161,"mse":"-37.6","powerLevel":"9.8","channel":10,"nonCorrErrors":203,"latency":0.32,"channelID":21,"frequency":"658"},{"type":"256QAM","corrErrors":33219,"mse":"-37.4","powerLevel":"8.8","channel":11,"nonCorrErrors":10962,"latency":0.32,"channelID":18,"frequency":"634"},{"type":"256QAM","corrErrors":32680,"mse":"-37.6","powerLevel":"9.2","channel":12,"nonCorrErrors":145,"latency":0.32,"channelID":19,"frequency":"642"},{"type":"256QAM","corrErrors":33001,"mse":"-37.4","powerLevel":"9.8","channel":13,"nonCorrErrors":7613,"latency":0.32,"channelID":22,"frequency":"666"},{"type":"256QAM","corrErrors":42666,"mse":"-37.4","powerLevel":"8.1","channel":14,"nonCorrErrors":172,"latency":0.32,"channelID":17,"frequency":"626"},{"type":"256QAM","corrErrors":41023,"mse":"-37.4","powerLevel":"9.3","channel":15,"nonCorrErrors":10620,"latency":0.32,"channelID":20,"frequency":"650"},{"type":"256QAM","corrErrors":106921,"mse":"-37.6","powerLevel":"7.4","channel":16,"nonCorrErrors":356,"latency":0.32,"channelID":4,"frequency":"498"},{"type":"256QAM","corrErrors":86650,"mse":"-36.4","powerLevel":"4.9","channel":17,"nonCorrErrors":85,"latency":0.32,"channelID":12,"frequency":"578"},{"type":"256QAM","corrErrors":91838,"mse":"-36.4","powerLevel":"4.8","channel":18,"nonCorrErrors":168,"latency":0.32,"channelID":8,"frequency":"546"},{"type":"256QAM","corrErrors":110719,"mse":"-35.8","powerLevel":"4.5","channel":19,"nonCorrErrors":103,"latency":0.32,"channelID":10,"frequency":"562"},{"type":"256QAM","corrErrors":111846,"mse":"-37.6","powerLevel":"8.2","channel":20,"nonCorrErrors":247,"latency":0.32,"channelID":2,"frequency":"482"},{"type":"256QAM","corrErrors":668242,"mse":"-36.6","powerLevel":"5.8","channel":21,"nonCorrErrors":6800,"latency":0.32,"channelID":5,"frequency":"522"},{"type":"256QAM","corrErrors":104070,"mse":"-36.6","powerLevel":"5.3","channel":22,"nonCorrErrors":149,"latency":0.32,"channelID":6,"frequency":"530"},{"type":"256QAM","corrErrors":120994,"mse":"-35.8","powerLevel":"4.4","channel":23,"nonCorrErrors":10240,"latency":0.32,"channelID":9,"frequency":"554"},{"type":"256QAM","corrErrors":59145,"mse":"-36.4","powerLevel":"5.3","channel":24,"nonCorrErrors":9560,"latency":0.32,"channelID":11,"frequency":"570"},{"type":"256QAM","corrErrors":118271,"mse":"-37.6","powerLevel":"8.4","channel":25,"nonCorrErrors":810,"latency":0.32,"channelID":1,"frequency":"474"},{"type":"256QAM","corrErrors":40255,"mse":"-37.4","powerLevel":"6.5","channel":26,"nonCorrErrors":13474,"latency":0.32,"channelID":15,"frequency":"602"},{"type":"256QAM","corrErrors":62716,"mse":"-36.4","powerLevel":"5.3","channel":27,"nonCorrErrors":9496,"latency":0.32,"channelID":13,"frequency":"586"},{"type":"256QAM","corrErrors":131364,"mse":"-36.6","powerLevel":"8.9","channel":28,"nonCorrErrors":12238,"latency":0.32,"channelID":29,"frequency":"738"}]},"oem":"lgi","readyState":"ready","channelUs":{"docsis30":[{"powerLevel":"43.0","type":"64QAM","channel":1,"multiplex":"ATDMA","channelID":4,"frequency":"51"},{"powerLevel":"44.3","type":"64QAM","channel":2,"multiplex":"ATDMA","channelID":2,"frequency":"37"},{"powerLevel":"43.8","type":"64QAM","channel":3,"multiplex":"ATDMA","channelID":3,"frequency":"45"},{"powerLevel":"45.8","type":"64QAM","channel":4,"multiplex":"ATDMA","channelID":1,"frequency":"31"}]}},"sid":"14341afbc7d83b4c"}'; -# my $resultData = FRITZBOX_Helper_process_JSON($hash, $TestSIS, "14341afbc7d83b4c", ""); ; - $resultData = FRITZBOX_read_LuaData($hash, "data", \@webCmdArray) ; # Abbruch wenn Fehler beim Lesen der Fritzbox-Antwort - return FRITZBOX_Readout_Response($hash, $resultData, \@roReadings) if ( defined $resultData->{Error} || defined $resultData->{AuthorizationRequired}); + return FRITZBOX_Readout_Response($hash, $resultData, $roReadings) if ( defined $resultData->{Error} || defined $resultData->{AuthorizationRequired}); - $sidNew += $result->{sidNew} if defined $result->{sidNew}; + $$sidNew += $resultData->{sidNew} if defined $resultData->{sidNew}; FRITZBOX_Log $hash, 5, "\n" . Dumper ($resultData->{data}); + + if (defined $resultData->{data}->{mode}) { + FRITZBOX_Readout_Add_Reading $hash, $roReadings, "box_energyMode", $resultData->{data}->{mode}; + FRITZBOX_Readout_Add_Reading $hash, $roReadings, "box_energyModeWLAN_Timer", $resultData->{data}->{wlan}{timerActive}?"on":"off"; + my $eTime = $resultData->{data}->{wlan}{dailyStart}{hour} ? $resultData->{data}->{wlan}{dailyStart}{hour} : "__"; + $eTime .= ":"; + $eTime .= $resultData->{data}->{wlan}{dailyStart}{minute} ? $resultData->{data}->{wlan}{dailyStart}{minute} : "__"; + $eTime .= "-"; + $eTime .= $resultData->{data}->{wlan}{dailyEnd}{hour} ? $resultData->{data}->{wlan}{dailyEnd}{hour} : "__"; + $eTime .= ":"; + $eTime .= $resultData->{data}->{wlan}{dailyEnd}{minute} ? $resultData->{data}->{wlan}{dailyEnd}{minute} : "__"; + + FRITZBOX_Readout_Add_Reading $hash, $roReadings, "box_energyModeWLAN_Time", $eTime; + FRITZBOX_Readout_Add_Reading $hash, $roReadings, "box_energyModeWLAN_Repetition", $resultData->{data}->{wlan}{timerMode}; + FRITZBOX_Readout_Add_Reading $hash, $roReadings, "box_wlan_Active", $resultData->{data}->{wlan}{enabled} == 1? "on":"off"; + } + + FRITZBOX_Log $hash, 4, "energyStatus - end getting data: $enableBoxReading"; + + } # end getting energy status + } + + #------------------------------------------------------------------------------------- + # USB Mobilfunk-Modem Konfiguration + + # xhr 1 lang de page mobile # xhrId modemSettings useajax 1 + + if (AttrVal($name, "enableMobileInfo", 0) && ($hash->{fhem}{fwVersion} >= 750) ) { + + FRITZBOX_Log $hash, 4, "MobileInfo - start getting data"; + + @webCmdArray = (); + push @webCmdArray, "xhr" => "1"; + push @webCmdArray, "lang" => "de"; + push @webCmdArray, "page" => "mobile"; + push @webCmdArray, "xhrId" => "all"; + + $resultData = FRITZBOX_read_LuaData($hash, "data", \@webCmdArray) ; + + # Abbruch wenn Fehler beim Lesen der Fritzbox-Antwort + return FRITZBOX_Readout_Response($hash, $resultData, $roReadings) if ( defined $resultData->{Error} || defined $resultData->{AuthorizationRequired}); + + $$sidNew += $resultData->{sidNew} if defined $resultData->{sidNew}; + + eval { + FRITZBOX_Readout_Add_Reading $hash, $roReadings, "mobileInfo_simOk", $resultData->{data}->{simOk}, "onoff" + if $resultData->{data}->{simOk}; + + FRITZBOX_Readout_Add_Reading $hash, $roReadings, "mobileInfo_activation", $resultData->{data}->{activation} + if $resultData->{data}->{activation}; + + if ($resultData->{data}->{fallback}) { + FRITZBOX_Readout_Add_Reading $hash, $roReadings, "mobileInfo_fallback_possible", $resultData->{data}->{fallback}->{possible}, "onoff" + if $resultData->{data}->{fallback}->{possible}; + + FRITZBOX_Readout_Add_Reading $hash, $roReadings, "mobileInfo_fallback_enableable", $resultData->{data}->{fallback}->{enableable}, "onoff" + if $resultData->{data}->{fallback}->{enableable}; + } + + if ($resultData->{data}->{config}) { + FRITZBOX_Readout_Add_Reading $hash, $roReadings, "mobileInfo_config_dsl", $resultData->{data}->{config}->{dsl} + if $resultData->{data}->{config}->{dsl}; + + FRITZBOX_Readout_Add_Reading $hash, $roReadings, "mobileInfo_config_fiber", $resultData->{data}->{config}->{fiber} + if $resultData->{data}->{config}->{fiber}; + + FRITZBOX_Readout_Add_Reading $hash, $roReadings, "mobileInfo_config_cable", $resultData->{data}->{config}->{cable} + if $resultData->{data}->{config}->{cable}; + + } + + if ($resultData->{data}->{connection}) { + FRITZBOX_Readout_Add_Reading $hash, $roReadings, "mobileInfo_conn_operator", $resultData->{data}->{connection}->{operator} + if $resultData->{data}->{connection}->{operator}; + + FRITZBOX_Readout_Add_Reading $hash, $roReadings, "mobileInfo_conn_state", $resultData->{data}->{connection}->{state} + if $resultData->{data}->{connection}->{state}; + + FRITZBOX_Readout_Add_Reading $hash, $roReadings, "mobileInfo_conn_quality", $resultData->{data}->{connection}->{quality} + if $resultData->{data}->{connection}->{quality}; + + FRITZBOX_Readout_Add_Reading $hash, $roReadings, "mobileInfo_conn_accessTechnology", $resultData->{data}->{connection}->{accessTechnology} + if $resultData->{data}->{connection}->{accessTechnology}; + } + + FRITZBOX_Readout_Add_Reading $hash, $roReadings, "mobileInfo_voipOverMobile", $resultData->{data}->{voipOverMobile}, "onoff" + if $resultData->{data}->{voipOverMobile}; + + FRITZBOX_Readout_Add_Reading $hash, $roReadings, "mobileInfo_wds", $resultData->{data}->{wds}, "onoff" + if $resultData->{data}->{wds}; + + FRITZBOX_Readout_Add_Reading $hash, $roReadings, "mobileInfo_progress_refreshNeeded", $resultData->{data}->{progress}->{refreshNeeded}, "onoff" + if $resultData->{data}->{progress}->{refreshNeeded}; + + FRITZBOX_Readout_Add_Reading $hash, $roReadings, "mobileInfo_progress_error", $resultData->{data}->{progress}->{error} + if $resultData->{data}->{progress}->{error}; + + FRITZBOX_Readout_Add_Reading $hash, $roReadings, "mobileInfo_ipclient", $resultData->{data}->{ipclient}, "onoff" + if $resultData->{data}->{ipclient}; + + FRITZBOX_Readout_Add_Reading $hash, $roReadings, "mobileInfo_sipNumberCount", ""; +# FRITZBOX_Readout_Add_Reading $hash, $roReadings, "mobileInfo_sipNumberCount", $resultData->{data}->{sipNumberCount} +# if $resultData->{data}->{sipNumberCount}; + + FRITZBOX_Readout_Add_Reading $hash, $roReadings, "mobileInfo_compatibilityMode_enabled", $resultData->{data}->{compatibilityMode}->{enabled}, "onoff" + if $resultData->{data}->{compatibilityMode}->{enabled}; + + FRITZBOX_Readout_Add_Reading $hash, $roReadings, "mobileInfo_compatibilityMode_enableable", $resultData->{data}->{compatibilityMode}->{enableable}, "onoff" + if $resultData->{data}->{compatibilityMode}->{enableable}; + + FRITZBOX_Readout_Add_Reading $hash, $roReadings, "mobileInfo_capabilities", $resultData->{data}->{capabilities}->{voice}, "onoff" + if $resultData->{data}->{capabilities}->{voice}; + }; + + FRITZBOX_Log $hash, 4, "MobileInfo - end getting data"; + + } else { + FRITZBOX_Log $hash, 4, "wrong Fritz!OS for usb mobile: $hash->{fhem}{fwVersionStr}" if AttrVal($name, "enableMobileInfo", 0); + } + + #------------------------------------------------------------------------------------- + # DOCSIS Informationen FB Cable + + if ( ( lc($avmModel) =~ "6[4,5,6][3,6,9][0,1]") && $hash->{fhem}{fwVersion} >= 721 ) { # FB Cable +# if (1==1) { + my $returnStr; + + my $powerLevels; + my $frequencys; + my $modulations; + my $modType; + my $latencys; + my $corrErrors; + my $nonCorrErrors; + my $mses; + + my %oldDocDevice; + + # xhr 1 lang de page docInfo xhrId all no_sidrenew nop + @webCmdArray = (); + push @webCmdArray, "xhr" => "1"; + push @webCmdArray, "lang" => "de"; + push @webCmdArray, "page" => "docInfo"; + push @webCmdArray, "xhrId" => "all"; + push @webCmdArray, "no_sidrenew" => ""; + +# for debugging +# my $TestSIS = '{"pid":"docInfo","hide":{"mobile":true,"ssoSet":true,"liveTv":true},"time":[],"data":{"channelDs":{"docsis31":[{"powerLevel":"-1.6","type":"4K","channel":1,"channelID":0,"frequency":"751 - 861"},{"powerLevel":"7.7","type":"4K","channel":2,"channelID":1,"frequency":"175 - 237"}],"docsis30":[{"type":"256QAM","corrErrors":92890,"mse":"-36.4","powerLevel":"5.1","channel":1,"nonCorrErrors":9773,"latency":0.32,"channelID":7,"frequency":"538"},{"type":"256QAM","corrErrors":20553,"mse":"-37.4","powerLevel":"10.2","channel":2,"nonCorrErrors":9420,"latency":0.32,"channelID":26,"frequency":"698"},{"type":"256QAM","corrErrors":28673,"mse":"-37.6","powerLevel":"10.0","channel":3,"nonCorrErrors":140,"latency":0.32,"channelID":25,"frequency":"690"},{"type":"256QAM","corrErrors":25930,"mse":"-37.6","powerLevel":"10.0","channel":4,"nonCorrErrors":170,"latency":0.32,"channelID":27,"frequency":"706"},{"type":"256QAM","corrErrors":98698,"mse":"-36.6","powerLevel":"8.8","channel":5,"nonCorrErrors":9151,"latency":0.32,"channelID":30,"frequency":"746"},{"type":"256QAM","corrErrors":24614,"mse":"-37.4","powerLevel":"9.4","channel":6,"nonCorrErrors":9419,"latency":0.32,"channelID":28,"frequency":"730"},{"type":"256QAM","corrErrors":25882,"mse":"-37.4","powerLevel":"9.9","channel":7,"nonCorrErrors":9308,"latency":0.32,"channelID":24,"frequency":"682"},{"type":"256QAM","corrErrors":33817,"mse":"-37.4","powerLevel":"9.8","channel":8,"nonCorrErrors":146,"latency":0.32,"channelID":23,"frequency":"674"},{"type":"256QAM","corrErrors":112642,"mse":"-37.6","powerLevel":"7.8","channel":9,"nonCorrErrors":7783,"latency":0.32,"channelID":3,"frequency":"490"},{"type":"256QAM","corrErrors":41161,"mse":"-37.6","powerLevel":"9.8","channel":10,"nonCorrErrors":203,"latency":0.32,"channelID":21,"frequency":"658"},{"type":"256QAM","corrErrors":33219,"mse":"-37.4","powerLevel":"8.8","channel":11,"nonCorrErrors":10962,"latency":0.32,"channelID":18,"frequency":"634"},{"type":"256QAM","corrErrors":32680,"mse":"-37.6","powerLevel":"9.2","channel":12,"nonCorrErrors":145,"latency":0.32,"channelID":19,"frequency":"642"},{"type":"256QAM","corrErrors":33001,"mse":"-37.4","powerLevel":"9.8","channel":13,"nonCorrErrors":7613,"latency":0.32,"channelID":22,"frequency":"666"},{"type":"256QAM","corrErrors":42666,"mse":"-37.4","powerLevel":"8.1","channel":14,"nonCorrErrors":172,"latency":0.32,"channelID":17,"frequency":"626"},{"type":"256QAM","corrErrors":41023,"mse":"-37.4","powerLevel":"9.3","channel":15,"nonCorrErrors":10620,"latency":0.32,"channelID":20,"frequency":"650"},{"type":"256QAM","corrErrors":106921,"mse":"-37.6","powerLevel":"7.4","channel":16,"nonCorrErrors":356,"latency":0.32,"channelID":4,"frequency":"498"},{"type":"256QAM","corrErrors":86650,"mse":"-36.4","powerLevel":"4.9","channel":17,"nonCorrErrors":85,"latency":0.32,"channelID":12,"frequency":"578"},{"type":"256QAM","corrErrors":91838,"mse":"-36.4","powerLevel":"4.8","channel":18,"nonCorrErrors":168,"latency":0.32,"channelID":8,"frequency":"546"},{"type":"256QAM","corrErrors":110719,"mse":"-35.8","powerLevel":"4.5","channel":19,"nonCorrErrors":103,"latency":0.32,"channelID":10,"frequency":"562"},{"type":"256QAM","corrErrors":111846,"mse":"-37.6","powerLevel":"8.2","channel":20,"nonCorrErrors":247,"latency":0.32,"channelID":2,"frequency":"482"},{"type":"256QAM","corrErrors":668242,"mse":"-36.6","powerLevel":"5.8","channel":21,"nonCorrErrors":6800,"latency":0.32,"channelID":5,"frequency":"522"},{"type":"256QAM","corrErrors":104070,"mse":"-36.6","powerLevel":"5.3","channel":22,"nonCorrErrors":149,"latency":0.32,"channelID":6,"frequency":"530"},{"type":"256QAM","corrErrors":120994,"mse":"-35.8","powerLevel":"4.4","channel":23,"nonCorrErrors":10240,"latency":0.32,"channelID":9,"frequency":"554"},{"type":"256QAM","corrErrors":59145,"mse":"-36.4","powerLevel":"5.3","channel":24,"nonCorrErrors":9560,"latency":0.32,"channelID":11,"frequency":"570"},{"type":"256QAM","corrErrors":118271,"mse":"-37.6","powerLevel":"8.4","channel":25,"nonCorrErrors":810,"latency":0.32,"channelID":1,"frequency":"474"},{"type":"256QAM","corrErrors":40255,"mse":"-37.4","powerLevel":"6.5","channel":26,"nonCorrErrors":13474,"latency":0.32,"channelID":15,"frequency":"602"},{"type":"256QAM","corrErrors":62716,"mse":"-36.4","powerLevel":"5.3","channel":27,"nonCorrErrors":9496,"latency":0.32,"channelID":13,"frequency":"586"},{"type":"256QAM","corrErrors":131364,"mse":"-36.6","powerLevel":"8.9","channel":28,"nonCorrErrors":12238,"latency":0.32,"channelID":29,"frequency":"738"}]},"oem":"lgi","readyState":"ready","channelUs":{"docsis31":[],"docsis30":[{"powerLevel":"43.0","type":"64QAM","channel":1,"multiplex":"ATDMA","channelID":4,"frequency":"51"},{"powerLevel":"44.3","type":"64QAM","channel":2,"multiplex":"ATDMA","channelID":2,"frequency":"37"},{"powerLevel":"43.8","type":"64QAM","channel":3,"multiplex":"ATDMA","channelID":3,"frequency":"45"},{"powerLevel":"45.8","type":"64QAM","channel":4,"multiplex":"ATDMA","channelID":1,"frequency":"31"}]}},"sid":"14341afbc7d83b4c"}'; +# my $TestSIS = '{"pid":"docInfo","hide":{"mobile":true,"ssoSet":true,"liveTv":true},"time":[],"data":{"channelDs":{"docsis30":[{"type":"256QAM","corrErrors":92890,"mse":"-36.4","powerLevel":"5.1","channel":1,"nonCorrErrors":9773,"latency":0.32,"channelID":7,"frequency":"538"},{"type":"256QAM","corrErrors":20553,"mse":"-37.4","powerLevel":"10.2","channel":2,"nonCorrErrors":9420,"latency":0.32,"channelID":26,"frequency":"698"},{"type":"256QAM","corrErrors":28673,"mse":"-37.6","powerLevel":"10.0","channel":3,"nonCorrErrors":140,"latency":0.32,"channelID":25,"frequency":"690"},{"type":"256QAM","corrErrors":25930,"mse":"-37.6","powerLevel":"10.0","channel":4,"nonCorrErrors":170,"latency":0.32,"channelID":27,"frequency":"706"},{"type":"256QAM","corrErrors":98698,"mse":"-36.6","powerLevel":"8.8","channel":5,"nonCorrErrors":9151,"latency":0.32,"channelID":30,"frequency":"746"},{"type":"256QAM","corrErrors":24614,"mse":"-37.4","powerLevel":"9.4","channel":6,"nonCorrErrors":9419,"latency":0.32,"channelID":28,"frequency":"730"},{"type":"256QAM","corrErrors":25882,"mse":"-37.4","powerLevel":"9.9","channel":7,"nonCorrErrors":9308,"latency":0.32,"channelID":24,"frequency":"682"},{"type":"256QAM","corrErrors":33817,"mse":"-37.4","powerLevel":"9.8","channel":8,"nonCorrErrors":146,"latency":0.32,"channelID":23,"frequency":"674"},{"type":"256QAM","corrErrors":112642,"mse":"-37.6","powerLevel":"7.8","channel":9,"nonCorrErrors":7783,"latency":0.32,"channelID":3,"frequency":"490"},{"type":"256QAM","corrErrors":41161,"mse":"-37.6","powerLevel":"9.8","channel":10,"nonCorrErrors":203,"latency":0.32,"channelID":21,"frequency":"658"},{"type":"256QAM","corrErrors":33219,"mse":"-37.4","powerLevel":"8.8","channel":11,"nonCorrErrors":10962,"latency":0.32,"channelID":18,"frequency":"634"},{"type":"256QAM","corrErrors":32680,"mse":"-37.6","powerLevel":"9.2","channel":12,"nonCorrErrors":145,"latency":0.32,"channelID":19,"frequency":"642"},{"type":"256QAM","corrErrors":33001,"mse":"-37.4","powerLevel":"9.8","channel":13,"nonCorrErrors":7613,"latency":0.32,"channelID":22,"frequency":"666"},{"type":"256QAM","corrErrors":42666,"mse":"-37.4","powerLevel":"8.1","channel":14,"nonCorrErrors":172,"latency":0.32,"channelID":17,"frequency":"626"},{"type":"256QAM","corrErrors":41023,"mse":"-37.4","powerLevel":"9.3","channel":15,"nonCorrErrors":10620,"latency":0.32,"channelID":20,"frequency":"650"},{"type":"256QAM","corrErrors":106921,"mse":"-37.6","powerLevel":"7.4","channel":16,"nonCorrErrors":356,"latency":0.32,"channelID":4,"frequency":"498"},{"type":"256QAM","corrErrors":86650,"mse":"-36.4","powerLevel":"4.9","channel":17,"nonCorrErrors":85,"latency":0.32,"channelID":12,"frequency":"578"},{"type":"256QAM","corrErrors":91838,"mse":"-36.4","powerLevel":"4.8","channel":18,"nonCorrErrors":168,"latency":0.32,"channelID":8,"frequency":"546"},{"type":"256QAM","corrErrors":110719,"mse":"-35.8","powerLevel":"4.5","channel":19,"nonCorrErrors":103,"latency":0.32,"channelID":10,"frequency":"562"},{"type":"256QAM","corrErrors":111846,"mse":"-37.6","powerLevel":"8.2","channel":20,"nonCorrErrors":247,"latency":0.32,"channelID":2,"frequency":"482"},{"type":"256QAM","corrErrors":668242,"mse":"-36.6","powerLevel":"5.8","channel":21,"nonCorrErrors":6800,"latency":0.32,"channelID":5,"frequency":"522"},{"type":"256QAM","corrErrors":104070,"mse":"-36.6","powerLevel":"5.3","channel":22,"nonCorrErrors":149,"latency":0.32,"channelID":6,"frequency":"530"},{"type":"256QAM","corrErrors":120994,"mse":"-35.8","powerLevel":"4.4","channel":23,"nonCorrErrors":10240,"latency":0.32,"channelID":9,"frequency":"554"},{"type":"256QAM","corrErrors":59145,"mse":"-36.4","powerLevel":"5.3","channel":24,"nonCorrErrors":9560,"latency":0.32,"channelID":11,"frequency":"570"},{"type":"256QAM","corrErrors":118271,"mse":"-37.6","powerLevel":"8.4","channel":25,"nonCorrErrors":810,"latency":0.32,"channelID":1,"frequency":"474"},{"type":"256QAM","corrErrors":40255,"mse":"-37.4","powerLevel":"6.5","channel":26,"nonCorrErrors":13474,"latency":0.32,"channelID":15,"frequency":"602"},{"type":"256QAM","corrErrors":62716,"mse":"-36.4","powerLevel":"5.3","channel":27,"nonCorrErrors":9496,"latency":0.32,"channelID":13,"frequency":"586"},{"type":"256QAM","corrErrors":131364,"mse":"-36.6","powerLevel":"8.9","channel":28,"nonCorrErrors":12238,"latency":0.32,"channelID":29,"frequency":"738"}]},"oem":"lgi","readyState":"ready","channelUs":{"docsis30":[{"powerLevel":"43.0","type":"64QAM","channel":1,"multiplex":"ATDMA","channelID":4,"frequency":"51"},{"powerLevel":"44.3","type":"64QAM","channel":2,"multiplex":"ATDMA","channelID":2,"frequency":"37"},{"powerLevel":"43.8","type":"64QAM","channel":3,"multiplex":"ATDMA","channelID":3,"frequency":"45"},{"powerLevel":"45.8","type":"64QAM","channel":4,"multiplex":"ATDMA","channelID":1,"frequency":"31"}]}},"sid":"14341afbc7d83b4c"}'; +# my $resultData = FRITZBOX_Helper_process_JSON($hash, $TestSIS, "14341afbc7d83b4c", ""); ; + + $resultData = FRITZBOX_read_LuaData($hash, "data", \@webCmdArray) ; + + # Abbruch wenn Fehler beim Lesen der Fritzbox-Antwort + return FRITZBOX_Readout_Response($hash, $resultData, $roReadings) if ( defined $resultData->{Error} || defined $resultData->{AuthorizationRequired}); + + $$sidNew += $resultData->{sidNew} if defined $resultData->{sidNew}; + + FRITZBOX_Log $hash, 5, "\n" . Dumper ($resultData->{data}); - #collect current mac-readings (to delete the ones that are inactive or disappeared) - foreach (keys %{ $hash->{READINGS} }) { - $oldDocDevice{$_} = $hash->{READINGS}{$_}{VAL} if $_ =~ /^box_docsis/ && defined $hash->{READINGS}{$_}{VAL}; - } - - $nbViews = 0; - if (defined $resultData->{data}->{channelUs}->{docsis30}) { - $views = $resultData->{data}->{channelUs}->{docsis30}; - $nbViews = scalar @$views; - } - - if ($nbViews > 0) { - - $powerLevels = ""; - $frequencys = ""; - $modulations = ""; - - $modType = $resultData->{data}->{channelUs}->{docsis30}->[0]->{type}?"type":"modulation"; - - eval { - for(my $i = 0; $i <= $nbViews - 1; $i++) { - $powerLevels .= $resultData->{data}->{channelUs}->{docsis30}->[$i]->{powerLevel} . " "; - $frequencys .= $resultData->{data}->{channelUs}->{docsis30}->[$i]->{frequency} . " "; - $modulations .= $1 if($resultData->{data}->{channelUs}->{docsis30}->[$i]->{$modType} =~ /(\d+)/); - $modulations .= " "; - } - - FRITZBOX_Readout_Add_Reading $hash, \@roReadings, "box_docsis30_Us_powerLevels", substr($powerLevels,0,-1); - FRITZBOX_Readout_Add_Reading $hash, \@roReadings, "box_docsis30_Us_frequencys", substr($frequencys,0,-1); - FRITZBOX_Readout_Add_Reading $hash, \@roReadings, "box_docsis30_Us_modulations", substr($modulations,0,-1); - delete $oldDocDevice{box_docsis30_Us_powerLevels} if exists $oldDocDevice{box_docsis30_Us_powerLevels}; - delete $oldDocDevice{box_docsis30_Us_frequencys} if exists $oldDocDevice{box_docsis30_Us_frequencys}; - delete $oldDocDevice{box_docsis30_Us_modulations} if exists $oldDocDevice{box_docsis30_Us_modulations}; - }; - } - - $nbViews = 0; - if (defined $resultData->{data}->{channelUs}->{docsis31}) { - $views = $resultData->{data}->{channelUs}->{docsis31}; - $nbViews = scalar @$views; - } - - if ($nbViews > 0) { - - $powerLevels = ""; - $frequencys = ""; - $modulations = ""; - - $modType = $resultData->{data}->{channelUs}->{docsis31}->[0]->{type}?"type":"modulation"; - - eval { - for(my $i = 0; $i <= $nbViews - 1; $i++) { - $powerLevels .= $resultData->{data}->{channelUs}->{docsis31}->[$i]->{powerLevel} . " "; - $frequencys .= $resultData->{data}->{channelUs}->{docsis31}->[$i]->{frequency} . " "; - $modulations .= $1 if($resultData->{data}->{channelUs}->{docsis31}->[$i]->{$modType} =~ /(\d+)/); - $modulations .= " "; - } - FRITZBOX_Readout_Add_Reading $hash, \@roReadings, "box_docsis31_Us_powerLevels", substr($powerLevels,0,-1); - FRITZBOX_Readout_Add_Reading $hash, \@roReadings, "box_docsis31_Us_frequencys", substr($frequencys,0,-1); - FRITZBOX_Readout_Add_Reading $hash, \@roReadings, "box_docsis31_Us_modulations", substr($modulations,0,-1); - delete $oldDocDevice{box_docsis31_Us_powerLevels} if exists $oldDocDevice{box_docsis31_Us_powerLevels}; - delete $oldDocDevice{box_docsis31_Us_frequencys} if exists $oldDocDevice{box_docsis31_Us_frequencys}; - delete $oldDocDevice{box_docsis31_Us_modulations} if exists $oldDocDevice{box_docsis31_Us_modulations}; - }; - - } - - $nbViews = 0; - if (defined $resultData->{data}->{channelDs}->{docsis30}) { - $views = $resultData->{data}->{channelDs}->{docsis30}; - $nbViews = scalar @$views; - } - - if ($nbViews > 0) { - - $powerLevels = ""; - $latencys = ""; - $frequencys = ""; - $corrErrors = ""; - $nonCorrErrors = ""; - $mses = ""; - $modulations = ""; - - $modType = $resultData->{data}->{channelDs}->{docsis30}->[0]->{type}?"type":"modulation"; - - eval { - for(my $i = 0; $i <= $nbViews - 1; $i++) { - $powerLevels .= $resultData->{data}->{channelDs}->{docsis30}->[$i]->{powerLevel} . " "; - $latencys .= $resultData->{data}->{channelDs}->{docsis30}->[$i]->{latency} . " "; - $frequencys .= $resultData->{data}->{channelDs}->{docsis30}->[$i]->{frequency} . " "; - $corrErrors .= $resultData->{data}->{channelDs}->{docsis30}->[$i]->{corrErrors} . " "; - $nonCorrErrors .= $resultData->{data}->{channelDs}->{docsis30}->[$i]->{nonCorrErrors} . " "; - $mses .= $resultData->{data}->{channelDs}->{docsis30}->[$i]->{mse} . " "; - $modulations .= $1 if($resultData->{data}->{channelDs}->{docsis30}->[$i]->{$modType} =~ /(\d+)/); - $modulations .= " "; - } - FRITZBOX_Readout_Add_Reading $hash, \@roReadings, "box_docsis30_Ds_powerLevels", substr($powerLevels,0,-1); - FRITZBOX_Readout_Add_Reading $hash, \@roReadings, "box_docsis30_Ds_latencys", substr($latencys,0,-1); - FRITZBOX_Readout_Add_Reading $hash, \@roReadings, "box_docsis30_Ds_frequencys", substr($frequencys,0,-1); - FRITZBOX_Readout_Add_Reading $hash, \@roReadings, "box_docsis30_Ds_corrErrors", substr($corrErrors,0,-1); - FRITZBOX_Readout_Add_Reading $hash, \@roReadings, "box_docsis30_Ds_nonCorrErrors", substr($latencys,0,-1); - FRITZBOX_Readout_Add_Reading $hash, \@roReadings, "box_docsis30_Ds_mses", substr($mses,0,-1); - FRITZBOX_Readout_Add_Reading $hash, \@roReadings, "box_docsis30_Ds_modulations", substr($modulations,0,-1); - delete $oldDocDevice{box_docsis30_Ds_powerLevels} if exists $oldDocDevice{box_docsis30_Ds_powerLevels}; - delete $oldDocDevice{box_docsis30_Ds_latencys} if exists $oldDocDevice{box_docsis30_Ds_latencys}; - delete $oldDocDevice{box_docsis30_Ds_frequencys} if exists $oldDocDevice{box_docsis30_Ds_frequencys}; - delete $oldDocDevice{box_docsis30_Ds_corrErrors} if exists $oldDocDevice{box_docsis30_Ds_corrErrors}; - delete $oldDocDevice{box_docsis30_Ds_nonCorrErrors} if exists $oldDocDevice{box_docsis30_Ds_nonCorrErrors}; - delete $oldDocDevice{box_docsis30_Ds_mses} if exists $oldDocDevice{box_docsis30_Ds_mses}; - delete $oldDocDevice{box_docsis30_Ds_modulations} if exists $oldDocDevice{box_docsis30_Ds_modulations}; - }; - - } - - $nbViews = 0; - if (defined $resultData->{data}->{channelDs}->{docsis31}) { - $views = $resultData->{data}->{channelDs}->{docsis31}; - $nbViews = scalar @$views; - } - - if ($nbViews > 0) { - - $powerLevels = ""; - $frequencys = ""; - $modulations = ""; - - $modType = $resultData->{data}->{channelDs}->{docsis31}->[0]->{type}?"type":"modulation"; - - eval { - for(my $i = 0; $i <= $nbViews - 1; $i++) { - $powerLevels .= $resultData->{data}->{channelDs}->{docsis31}->[$i]->{powerLevel} . " "; - $frequencys .= $resultData->{data}->{channelDs}->{docsis31}->[$i]->{frequency} . " "; - $modulations .= $1 if($resultData->{data}->{channelDs}->{docsis31}->[$i]->{$modType} =~ /(\d+)/); - $modulations .= " "; - } - FRITZBOX_Readout_Add_Reading $hash, \@roReadings, "box_docsis31_Ds_powerLevels", substr($powerLevels,0,-1); - FRITZBOX_Readout_Add_Reading $hash, \@roReadings, "box_docsis31_Ds_frequencys", substr($frequencys,0,-1); - FRITZBOX_Readout_Add_Reading $hash, \@roReadings, "box_docsis31_Ds_modulations", substr($modulations,0,-1); - delete $oldDocDevice{box_docsis31_Ds_powerLevels} if exists $oldDocDevice{box_docsis31_Ds_powerLevels}; - delete $oldDocDevice{box_docsis31_Ds_frequencys} if exists $oldDocDevice{box_docsis31_Ds_frequencys}; - delete $oldDocDevice{box_docsis31_Ds_modulations} if exists $oldDocDevice{box_docsis31_Ds_modulations}; - }; - } - - # Remove inactive or non existing wan-readings in two steps - foreach ( keys %oldDocDevice ) { - # set the wan readings to 'inactive' and delete at next readout - if ( $oldDocDevice{$_} ne "inactive" ) { - FRITZBOX_Readout_Add_Reading $hash, \@roReadings, $_, "inactive"; - } else { - FRITZBOX_Readout_Add_Reading $hash, \@roReadings, $_, ""; - } - } - - } else { - FRITZBOX_Log $hash, 4, "wrong Fritz!OS: $FW1.$FW2 or AVM-Model: $avmModel for docsis informations."; + #collect current mac-readings (to delete the ones that are inactive or disappeared) + foreach (keys %{ $hash->{READINGS} }) { + $oldDocDevice{$_} = $hash->{READINGS}{$_}{VAL} if $_ =~ /^box_docsis/ && defined $hash->{READINGS}{$_}{VAL}; } - } # end for Model == "Box" + $nbViews = 0; + if (defined $resultData->{data}->{channelUs}->{docsis30}) { + $views = $resultData->{data}->{channelUs}->{docsis30}; + $nbViews = scalar @$views; + } - } else { - FRITZBOX_Log $hash, 4, "wrong Fritz!OS: $FW1.$FW2 or data.lua not available"; - } + if ($nbViews > 0) { - #------------------------------------------------------------------------------------- - if ( $hash->{TR064} == 1 && $hash->{SECPORT} ) { + $powerLevels = ""; + $frequencys = ""; + $modulations = ""; + + $modType = $resultData->{data}->{channelUs}->{docsis30}->[0]->{type}?"type":"modulation"; + + eval { + for(my $i = 0; $i <= $nbViews - 1; $i++) { + $powerLevels .= $resultData->{data}->{channelUs}->{docsis30}->[$i]->{powerLevel} . " "; + $frequencys .= $resultData->{data}->{channelUs}->{docsis30}->[$i]->{frequency} . " "; + $modulations .= $1 if($resultData->{data}->{channelUs}->{docsis30}->[$i]->{$modType} =~ /(\d+)/); + $modulations .= " "; + } + + FRITZBOX_Readout_Add_Reading $hash, $roReadings, "box_docsis30_Us_powerLevels", substr($powerLevels,0,-1); + FRITZBOX_Readout_Add_Reading $hash, $roReadings, "box_docsis30_Us_frequencys", substr($frequencys,0,-1); + FRITZBOX_Readout_Add_Reading $hash, $roReadings, "box_docsis30_Us_modulations", substr($modulations,0,-1); + delete $oldDocDevice{box_docsis30_Us_powerLevels} if exists $oldDocDevice{box_docsis30_Us_powerLevels}; + delete $oldDocDevice{box_docsis30_Us_frequencys} if exists $oldDocDevice{box_docsis30_Us_frequencys}; + delete $oldDocDevice{box_docsis30_Us_modulations} if exists $oldDocDevice{box_docsis30_Us_modulations}; + }; + } + + $nbViews = 0; + if (defined $resultData->{data}->{channelUs}->{docsis31}) { + $views = $resultData->{data}->{channelUs}->{docsis31}; + $nbViews = scalar @$views; + } + + if ($nbViews > 0) { + + $powerLevels = ""; + $frequencys = ""; + $modulations = ""; + + $modType = $resultData->{data}->{channelUs}->{docsis31}->[0]->{type}?"type":"modulation"; + + eval { + for(my $i = 0; $i <= $nbViews - 1; $i++) { + $powerLevels .= $resultData->{data}->{channelUs}->{docsis31}->[$i]->{powerLevel} . " "; + $frequencys .= $resultData->{data}->{channelUs}->{docsis31}->[$i]->{frequency} . " "; + $modulations .= $1 if($resultData->{data}->{channelUs}->{docsis31}->[$i]->{$modType} =~ /(\d+)/); + $modulations .= " "; + } + FRITZBOX_Readout_Add_Reading $hash, $roReadings, "box_docsis31_Us_powerLevels", substr($powerLevels,0,-1); + FRITZBOX_Readout_Add_Reading $hash, $roReadings, "box_docsis31_Us_frequencys", substr($frequencys,0,-1); + FRITZBOX_Readout_Add_Reading $hash, $roReadings, "box_docsis31_Us_modulations", substr($modulations,0,-1); + delete $oldDocDevice{box_docsis31_Us_powerLevels} if exists $oldDocDevice{box_docsis31_Us_powerLevels}; + delete $oldDocDevice{box_docsis31_Us_frequencys} if exists $oldDocDevice{box_docsis31_Us_frequencys}; + delete $oldDocDevice{box_docsis31_Us_modulations} if exists $oldDocDevice{box_docsis31_Us_modulations}; + }; + + } + + $nbViews = 0; + if (defined $resultData->{data}->{channelDs}->{docsis30}) { + $views = $resultData->{data}->{channelDs}->{docsis30}; + $nbViews = scalar @$views; + } + + if ($nbViews > 0) { + + $powerLevels = ""; + $latencys = ""; + $frequencys = ""; + $corrErrors = ""; + $nonCorrErrors = ""; + $mses = ""; + $modulations = ""; + + $modType = $resultData->{data}->{channelDs}->{docsis30}->[0]->{type}?"type":"modulation"; + + eval { + for(my $i = 0; $i <= $nbViews - 1; $i++) { + $powerLevels .= $resultData->{data}->{channelDs}->{docsis30}->[$i]->{powerLevel} . " "; + $latencys .= $resultData->{data}->{channelDs}->{docsis30}->[$i]->{latency} . " "; + $frequencys .= $resultData->{data}->{channelDs}->{docsis30}->[$i]->{frequency} . " "; + $corrErrors .= $resultData->{data}->{channelDs}->{docsis30}->[$i]->{corrErrors} . " "; + $nonCorrErrors .= $resultData->{data}->{channelDs}->{docsis30}->[$i]->{nonCorrErrors} . " "; + $mses .= $resultData->{data}->{channelDs}->{docsis30}->[$i]->{mse} . " "; + $modulations .= $1 if($resultData->{data}->{channelDs}->{docsis30}->[$i]->{$modType} =~ /(\d+)/); + $modulations .= " "; + } + FRITZBOX_Readout_Add_Reading $hash, $roReadings, "box_docsis30_Ds_powerLevels", substr($powerLevels,0,-1); + FRITZBOX_Readout_Add_Reading $hash, $roReadings, "box_docsis30_Ds_latencys", substr($latencys,0,-1); + FRITZBOX_Readout_Add_Reading $hash, $roReadings, "box_docsis30_Ds_frequencys", substr($frequencys,0,-1); + FRITZBOX_Readout_Add_Reading $hash, $roReadings, "box_docsis30_Ds_corrErrors", substr($corrErrors,0,-1); + FRITZBOX_Readout_Add_Reading $hash, $roReadings, "box_docsis30_Ds_nonCorrErrors", substr($latencys,0,-1); + FRITZBOX_Readout_Add_Reading $hash, $roReadings, "box_docsis30_Ds_mses", substr($mses,0,-1); + FRITZBOX_Readout_Add_Reading $hash, $roReadings, "box_docsis30_Ds_modulations", substr($modulations,0,-1); + delete $oldDocDevice{box_docsis30_Ds_powerLevels} if exists $oldDocDevice{box_docsis30_Ds_powerLevels}; + delete $oldDocDevice{box_docsis30_Ds_latencys} if exists $oldDocDevice{box_docsis30_Ds_latencys}; + delete $oldDocDevice{box_docsis30_Ds_frequencys} if exists $oldDocDevice{box_docsis30_Ds_frequencys}; + delete $oldDocDevice{box_docsis30_Ds_corrErrors} if exists $oldDocDevice{box_docsis30_Ds_corrErrors}; + delete $oldDocDevice{box_docsis30_Ds_nonCorrErrors} if exists $oldDocDevice{box_docsis30_Ds_nonCorrErrors}; + delete $oldDocDevice{box_docsis30_Ds_mses} if exists $oldDocDevice{box_docsis30_Ds_mses}; + delete $oldDocDevice{box_docsis30_Ds_modulations} if exists $oldDocDevice{box_docsis30_Ds_modulations}; + }; + + } + + $nbViews = 0; + if (defined $resultData->{data}->{channelDs}->{docsis31}) { + $views = $resultData->{data}->{channelDs}->{docsis31}; + $nbViews = scalar @$views; + } + + if ($nbViews > 0) { + + $powerLevels = ""; + $frequencys = ""; + $modulations = ""; + + $modType = $resultData->{data}->{channelDs}->{docsis31}->[0]->{type}?"type":"modulation"; + + eval { + for(my $i = 0; $i <= $nbViews - 1; $i++) { + $powerLevels .= $resultData->{data}->{channelDs}->{docsis31}->[$i]->{powerLevel} . " "; + $frequencys .= $resultData->{data}->{channelDs}->{docsis31}->[$i]->{frequency} . " "; + $modulations .= $1 if($resultData->{data}->{channelDs}->{docsis31}->[$i]->{$modType} =~ /(\d+)/); + $modulations .= " "; + } + FRITZBOX_Readout_Add_Reading $hash, $roReadings, "box_docsis31_Ds_powerLevels", substr($powerLevels,0,-1); + FRITZBOX_Readout_Add_Reading $hash, $roReadings, "box_docsis31_Ds_frequencys", substr($frequencys,0,-1); + FRITZBOX_Readout_Add_Reading $hash, $roReadings, "box_docsis31_Ds_modulations", substr($modulations,0,-1); + delete $oldDocDevice{box_docsis31_Ds_powerLevels} if exists $oldDocDevice{box_docsis31_Ds_powerLevels}; + delete $oldDocDevice{box_docsis31_Ds_frequencys} if exists $oldDocDevice{box_docsis31_Ds_frequencys}; + delete $oldDocDevice{box_docsis31_Ds_modulations} if exists $oldDocDevice{box_docsis31_Ds_modulations}; + }; + } + + # Remove inactive or non existing wan-readings in two steps + foreach ( keys %oldDocDevice ) { + # set the wan readings to 'inactive' and delete at next readout + if ( $oldDocDevice{$_} ne "inactive" ) { + FRITZBOX_Readout_Add_Reading $hash, $roReadings, $_, "inactive"; + } else { + FRITZBOX_Readout_Add_Reading $hash, $roReadings, $_, ""; + } + } + + } else { + FRITZBOX_Log $hash, 4, "wrong Fritz!OS: $hash->{fhem}{fwVersionStr} or AVM-Model: $avmModel for docsis informations."; + } + + } # end for Model == "Box" + + return ""; + +} # End FRITZBOX_Readout_Run_Web_LuaData + + +# informations depending on TR064 +#------------------------------------------------------------------------------------- + +####################################################################### +sub FRITZBOX_Readout_Run_Web_TR064($$$$) +{ + my ($name, $roReadings, $sidNew, $sid) = @_; + my $hash = $defs{$name}; + + my $result; + my $rName; + my $startTime = time(); + my $runNo; + my $host = $hash->{HOST}; + my $Tag; + my $Std; + my $Min; + my $Sek; + + my $views; + my $nbViews; + + my $avmModel = InternalVal($name, "MODEL", "FRITZ!Box"); + + my $mesh = ReadingsVal($name, "box_meshRole", "master"); + + my @webCmdArray; + my $resultData; + my $tmpData; my $strCurl; my @tr064CmdArray; @@ -4733,7 +5296,9 @@ sub FRITZBOX_Readout_Run_Web($) #------------------------------------------------------------------------------------- # USB Mobilfunk-Modem Informationen - if (AttrVal($name, "enableMobileModem", 0) && ($FW1 >= 7) && ($FW2 >= 50)) { # FB mit Mobile Modem-Stick + if (AttrVal($name, "enableMobileInfo", 0) && ($hash->{fhem}{fwVersion} >= 750) ) { # FB mit Mobile Modem-Stick + + FRITZBOX_Log $hash, 4, "MobileInfo - start getting TR064 data"; @tr064CmdArray = (["X_AVM-DE_WANMobileConnection:1", "x_wanmobileconn", "GetInfoEx"]); @@ -4753,12 +5318,12 @@ sub FRITZBOX_Readout_Run_Web($) $data =~ s/<//isg; - FRITZBOX_Log $hash, 5, "Data Mobile GetInfoEx (NewCellList): \n" . $data; + FRITZBOX_Log $hash, 4, "Data Mobile GetInfoEx (NewCellList): \n" . $data; while( $data =~ /(.*?)<\/Cell>/isg ) { my $cellList = $1; - FRITZBOX_Log $hash, 5, "Data Mobile GetInfoEx (Cell): \n" . $1; + FRITZBOX_Log $hash, 4, "Data Mobile GetInfoEx (Cell): \n" . $1; my $Index = $1 if $cellList =~ m/(.*?)<\/Index>/is; my $Connected = $1 if $cellList =~ m/(.*?)<\/Connected>/is; @@ -4773,36 +5338,36 @@ sub FRITZBOX_Readout_Run_Web($) my $RSRP = $1 if $cellList =~ m/(.*?)<\/RSRP>/is; my $Cellid = $1 if $cellList =~ m/(.*?)<\/Cellid>/is; - FRITZBOX_Readout_Add_Reading $hash, \@roReadings, "usbMobile" . $Index ."_Connected", $Connected; - FRITZBOX_Readout_Add_Reading $hash, \@roReadings, "usbMobile" . $Index ."_CellType", $CellType; - FRITZBOX_Readout_Add_Reading $hash, \@roReadings, "usbMobile" . $Index ."_PLMN", $PLMN; - FRITZBOX_Readout_Add_Reading $hash, \@roReadings, "usbMobile" . $Index ."_Provider", $Provider; - FRITZBOX_Readout_Add_Reading $hash, \@roReadings, "usbMobile" . $Index ."_TAC", $TAC; - FRITZBOX_Readout_Add_Reading $hash, \@roReadings, "usbMobile" . $Index ."_PhysicalId", $PhysicalId; - FRITZBOX_Readout_Add_Reading $hash, \@roReadings, "usbMobile" . $Index ."_Distance", $Distance; - FRITZBOX_Readout_Add_Reading $hash, \@roReadings, "usbMobile" . $Index ."_Rssi", $Rssi; - FRITZBOX_Readout_Add_Reading $hash, \@roReadings, "usbMobile" . $Index ."_Rsrq", $Rsrq; - FRITZBOX_Readout_Add_Reading $hash, \@roReadings, "usbMobile" . $Index ."_RSRP", $RSRP; - FRITZBOX_Readout_Add_Reading $hash, \@roReadings, "usbMobile" . $Index ."_Cellid", $Cellid; + FRITZBOX_Readout_Add_Reading $hash, $roReadings, "mobileInfo" . $Index ."_Connected", $Connected; + FRITZBOX_Readout_Add_Reading $hash, $roReadings, "mobileInfo" . $Index ."_CellType", $CellType; + FRITZBOX_Readout_Add_Reading $hash, $roReadings, "mobileInfo" . $Index ."_PLMN", $PLMN; + FRITZBOX_Readout_Add_Reading $hash, $roReadings, "mobileInfo" . $Index ."_Provider", $Provider; + FRITZBOX_Readout_Add_Reading $hash, $roReadings, "mobileInfo" . $Index ."_TAC", $TAC; + FRITZBOX_Readout_Add_Reading $hash, $roReadings, "mobileInfo" . $Index ."_PhysicalId", $PhysicalId; + FRITZBOX_Readout_Add_Reading $hash, $roReadings, "mobileInfo" . $Index ."_Distance", $Distance; + FRITZBOX_Readout_Add_Reading $hash, $roReadings, "mobileInfo" . $Index ."_Rssi", $Rssi; + FRITZBOX_Readout_Add_Reading $hash, $roReadings, "mobileInfo" . $Index ."_Rsrq", $Rsrq; + FRITZBOX_Readout_Add_Reading $hash, $roReadings, "mobileInfo" . $Index ."_RSRP", $RSRP; + FRITZBOX_Readout_Add_Reading $hash, $roReadings, "mobileInfo" . $Index ."_Cellid", $Cellid; } } - FRITZBOX_Readout_Add_Reading $hash, \@roReadings, "usbMobile_PPPUsername", $tr064Result[0]->{GetInfoExResponse}->{NewPPPUsername}; - FRITZBOX_Readout_Add_Reading $hash, \@roReadings, "usbMobile_PDN2_MTU", $tr064Result[0]->{GetInfoExResponse}->{NewPDN2_MTU}; - FRITZBOX_Readout_Add_Reading $hash, \@roReadings, "usbMobile_APN", $tr064Result[0]->{GetInfoExResponse}->{NewAPN}; - FRITZBOX_Readout_Add_Reading $hash, \@roReadings, "usbMobile_SoftwareVersion", $tr064Result[0]->{GetInfoExResponse}->{NewSoftwareVersion}; - FRITZBOX_Readout_Add_Reading $hash, \@roReadings, "usbMobile_Roaming", $tr064Result[0]->{GetInfoExResponse}->{NewRoaming}; - FRITZBOX_Readout_Add_Reading $hash, \@roReadings, "usbMobile_PDN1_MTU", $tr064Result[0]->{GetInfoExResponse}->{NewPDN1_MTU}; - FRITZBOX_Readout_Add_Reading $hash, \@roReadings, "usbMobile_IMSI", $tr064Result[0]->{GetInfoExResponse}->{NewIMSI}; - FRITZBOX_Readout_Add_Reading $hash, \@roReadings, "usbMobile_SignalRSRP1", $tr064Result[0]->{GetInfoExResponse}->{NewSignalRSRP1}; - FRITZBOX_Readout_Add_Reading $hash, \@roReadings, "usbMobile_CurrentAccessTechnology", $tr064Result[0]->{GetInfoExResponse}->{NewCurrentAccessTechnology}; - FRITZBOX_Readout_Add_Reading $hash, \@roReadings, "usbMobile_PPPUsernameVoIP", $tr064Result[0]->{GetInfoExResponse}->{NewPPPUsernameVoIP}; - FRITZBOX_Readout_Add_Reading $hash, \@roReadings, "usbMobile_EnableVoIPPDN", $tr064Result[0]->{GetInfoExResponse}->{NewEnableVoIPPDN}; - FRITZBOX_Readout_Add_Reading $hash, \@roReadings, "usbMobile_APN_VoIP", $tr064Result[0]->{GetInfoExResponse}->{NewAPN_VoIP}; - FRITZBOX_Readout_Add_Reading $hash, \@roReadings, "usbMobile_Uptime", $tr064Result[0]->{GetInfoExResponse}->{NewUptime}; - FRITZBOX_Readout_Add_Reading $hash, \@roReadings, "usbMobile_SignalRSRP0", $tr064Result[0]->{GetInfoExResponse}->{NewSignalRSRP0}; - FRITZBOX_Readout_Add_Reading $hash, \@roReadings, "usbMobile_SerialNumber", $tr064Result[0]->{GetInfoExResponse}->{NewSerialNumber}; + FRITZBOX_Readout_Add_Reading $hash, $roReadings, "mobileInfo_PPPUsername", $tr064Result[0]->{GetInfoExResponse}->{NewPPPUsername}; + FRITZBOX_Readout_Add_Reading $hash, $roReadings, "mobileInfo_PDN2_MTU", $tr064Result[0]->{GetInfoExResponse}->{NewPDN2_MTU}; + FRITZBOX_Readout_Add_Reading $hash, $roReadings, "mobileInfo_APN", $tr064Result[0]->{GetInfoExResponse}->{NewAPN}; + FRITZBOX_Readout_Add_Reading $hash, $roReadings, "mobileInfo_SoftwareVersion", $tr064Result[0]->{GetInfoExResponse}->{NewSoftwareVersion}; + FRITZBOX_Readout_Add_Reading $hash, $roReadings, "mobileInfo_Roaming", $tr064Result[0]->{GetInfoExResponse}->{NewRoaming}; + FRITZBOX_Readout_Add_Reading $hash, $roReadings, "mobileInfo_PDN1_MTU", $tr064Result[0]->{GetInfoExResponse}->{NewPDN1_MTU}; + FRITZBOX_Readout_Add_Reading $hash, $roReadings, "mobileInfo_IMSI", $tr064Result[0]->{GetInfoExResponse}->{NewIMSI}; + FRITZBOX_Readout_Add_Reading $hash, $roReadings, "mobileInfo_SignalRSRP1", $tr064Result[0]->{GetInfoExResponse}->{NewSignalRSRP1}; + FRITZBOX_Readout_Add_Reading $hash, $roReadings, "mobileInfo_CurrentAccessTechnology", $tr064Result[0]->{GetInfoExResponse}->{NewCurrentAccessTechnology}; + FRITZBOX_Readout_Add_Reading $hash, $roReadings, "mobileInfo_PPPUsernameVoIP", $tr064Result[0]->{GetInfoExResponse}->{NewPPPUsernameVoIP}; + FRITZBOX_Readout_Add_Reading $hash, $roReadings, "mobileInfo_EnableVoIPPDN", $tr064Result[0]->{GetInfoExResponse}->{NewEnableVoIPPDN}; + FRITZBOX_Readout_Add_Reading $hash, $roReadings, "mobileInfo_APN_VoIP", $tr064Result[0]->{GetInfoExResponse}->{NewAPN_VoIP}; + FRITZBOX_Readout_Add_Reading $hash, $roReadings, "mobileInfo_Uptime", $tr064Result[0]->{GetInfoExResponse}->{NewUptime}; + FRITZBOX_Readout_Add_Reading $hash, $roReadings, "mobileInfo_SignalRSRP0", $tr064Result[0]->{GetInfoExResponse}->{NewSignalRSRP0}; + FRITZBOX_Readout_Add_Reading $hash, $roReadings, "mobileInfo_SerialNumber", $tr064Result[0]->{GetInfoExResponse}->{NewSerialNumber}; } } @@ -4820,37 +5385,70 @@ sub FRITZBOX_Readout_Run_Web($) if ($tr064Result[0]->{GetInfoResponse}) { - FRITZBOX_Readout_Add_Reading $hash, \@roReadings, "usbMobile_PINFailureCount", $tr064Result[0]->{GetInfoResponse}->{NewPINFailureCount}; - FRITZBOX_Readout_Add_Reading $hash, \@roReadings, "usbMobile_PUKFailureCount", $tr064Result[0]->{GetInfoResponse}->{NewPUKFailureCount}; - FRITZBOX_Readout_Add_Reading $hash, \@roReadings, "usbMobile_Enabled", $tr064Result[0]->{GetInfoResponse}->{NewEnabled}; - FRITZBOX_Readout_Add_Reading $hash, \@roReadings, "usbMobile_Status", $tr064Result[0]->{GetInfoResponse}->{NewStatus}; + FRITZBOX_Readout_Add_Reading $hash, $roReadings, "mobileInfo_PINFailureCount", $tr064Result[0]->{GetInfoResponse}->{NewPINFailureCount}; + FRITZBOX_Readout_Add_Reading $hash, $roReadings, "mobileInfo_PUKFailureCount", $tr064Result[0]->{GetInfoResponse}->{NewPUKFailureCount}; + FRITZBOX_Readout_Add_Reading $hash, $roReadings, "mobileInfo_Enabled", $tr064Result[0]->{GetInfoResponse}->{NewEnabled}; + FRITZBOX_Readout_Add_Reading $hash, $roReadings, "mobileInfo_Status", $tr064Result[0]->{GetInfoResponse}->{NewStatus}; } } - # X_AVM-DE_WANMobileConnection:1 x_wanmobileconn GetBandCapabilities - # 'GetBandCapabilitiesResponse' => { - # 'NewBandCapabilitiesLTE' => '', - # 'NewBandCapabilities5GSA' => 'unknown', - # 'NewBandCapabilities5GNSA' => 'unknown' - # } + @tr064CmdArray = (["X_AVM-DE_WANMobileConnection:1", "x_wanmobileconn", "GetBandCapabilities"]); - # X_AVM-DE_WANMobileConnection:1 x_wanmobileconn GetAccessTechnology - # 'GetAccessTechnologyResponse' => { - # 'NewCurrentAccessTechnology' => 'unknown', - # 'NewPossibleAccessTechnology' => '', - # 'NewAccessTechnology' => 'AUTO' - # } + @tr064Result = FRITZBOX_call_TR064_Cmd( $hash, 0, \@tr064CmdArray ); + + if ($tr064Result[0]->{UPnPError}) { + $strCurl = Dumper (@tr064Result); + FRITZBOX_Log $hash, 2, "Mobile GetInfo -> \n" . $strCurl; + } else { + + FRITZBOX_Log $hash, 5, "Mobile GetInfo -> \n" . Dumper (@tr064Result); + + if ($tr064Result[0]->{GetInfoResponse}) { + + FRITZBOX_Readout_Add_Reading $hash, $roReadings, "mobileInfo_CapabilitiesLTE", $tr064Result[0]->{GetInfoResponse}->{NewBandCapabilitiesLTE}; + FRITZBOX_Readout_Add_Reading $hash, $roReadings, "mobileInfo_Capabilities5GSA", $tr064Result[0]->{GetInfoResponse}->{NewBandCapabilities5GSA}; + FRITZBOX_Readout_Add_Reading $hash, $roReadings, "mobileInfo_Capabilities5GNSA", $tr064Result[0]->{GetInfoResponse}->{NewBandCapabilities5GNSA}; + + } + + } + + @tr064CmdArray = (["X_AVM-DE_WANMobileConnection:1", "x_wanmobileconn", "GetAccessTechnology"]); + + @tr064Result = FRITZBOX_call_TR064_Cmd( $hash, 0, \@tr064CmdArray ); + + if ($tr064Result[0]->{UPnPError}) { + $strCurl = Dumper (@tr064Result); + FRITZBOX_Log $hash, 2, "Mobile GetInfo -> \n" . $strCurl; + } else { + + FRITZBOX_Log $hash, 5, "Mobile GetInfo -> \n" . Dumper (@tr064Result); + + if ($tr064Result[0]->{GetInfoResponse}) { + + FRITZBOX_Readout_Add_Reading $hash, $roReadings, "mobileInfo_CurrentAccessTechnology", $tr064Result[0]->{GetInfoResponse}->{NewCurrentAccessTechnology}; + FRITZBOX_Readout_Add_Reading $hash, $roReadings, "mobileInfo_PossibleAccessTechnology", $tr064Result[0]->{GetInfoResponse}->{NewPossibleAccessTechnology}; + FRITZBOX_Readout_Add_Reading $hash, $roReadings, "mobileInfo_AccessTechnology", $tr064Result[0]->{GetInfoResponse}->{NewAccessTechnology}; + + } + + } + + FRITZBOX_Log $hash, 4, "MobileInfo - end getting TR064 data"; } else { - FRITZBOX_Log $hash, 4, "wrong Fritz!OS: $FW1.$FW2 for usb mobile via TR064 or not a Fritz!Box" if AttrVal($name, "enableMobileModem", 0); + FRITZBOX_Log $hash, 4, "wrong Fritz!OS: $hash->{fhem}{fwVersionStr} for usb mobile via TR064 or not a Fritz!Box" if AttrVal($name, "enableMobileInfo", 0); } #------------------------------------------------------------------------------------- # getting PhoneBook ID's if (AttrVal($name, "enablePhoneBookInfo", 0)) { + + FRITZBOX_Log $hash, 4, "PhoneBookInfo - start getting TR064 data"; + @tr064CmdArray = (["X_AVM-DE_OnTel:1", "x_contact", "GetPhonebookList"] ); @tr064Result = FRITZBOX_call_TR064_Cmd ($hash, 0, \@tr064CmdArray); @@ -4864,7 +5462,7 @@ sub FRITZBOX_Readout_Run_Web($) if ($tr064Result[0]->{GetPhonebookListResponse}) { if (defined $tr064Result[0]->{GetPhonebookListResponse}->{NewPhonebookList}) { - FRITZBOX_Readout_Add_Reading $hash, \@roReadings, "fon_phoneBook_IDs", $tr064Result[0]->{GetPhonebookListResponse}->{NewPhonebookList}; + FRITZBOX_Readout_Add_Reading $hash, $roReadings, "fon_phoneBook_IDs", $tr064Result[0]->{GetPhonebookListResponse}->{NewPhonebookList}; my @phonebooks = split(",", $tr064Result[0]->{GetPhonebookListResponse}->{NewPhonebookList}); @@ -4884,10 +5482,10 @@ sub FRITZBOX_Readout_Run_Web($) if ($tr064Result[0]->{GetPhonebookResponse}) { if (defined $tr064Result[0]->{GetPhonebookResponse}->{NewPhonebookName}) { - FRITZBOX_Readout_Add_Reading $hash, \@roReadings, "fon_phoneBook_$item_id", $tr064Result[0]->{GetPhonebookResponse}->{NewPhonebookName}; + FRITZBOX_Readout_Add_Reading $hash, $roReadings, "fon_phoneBook_$item_id", $tr064Result[0]->{GetPhonebookResponse}->{NewPhonebookName}; } if (defined $tr064Result[0]->{GetPhonebookResponse}->{NewPhonebookURL}) { - FRITZBOX_Readout_Add_Reading $hash, \@roReadings, "fon_phoneBook_URL_$item_id", $tr064Result[0]->{GetPhonebookResponse}->{NewPhonebookURL}; + FRITZBOX_Readout_Add_Reading $hash, $roReadings, "fon_phoneBook_URL_$item_id", $tr064Result[0]->{GetPhonebookResponse}->{NewPhonebookURL}; } } else { FRITZBOX_Log $hash, 4, "no phonebook infos result via TR-064:\n" . Dumper (@tr064Result); @@ -4901,16 +5499,21 @@ sub FRITZBOX_Readout_Run_Web($) FRITZBOX_Log $hash, 4, "no phonebook ID's via TR-064:\n" . Dumper (@tr064Result); } } + + FRITZBOX_Log $hash, 4, "PhoneBookInfo - end getting TR064 data"; + } #------------------------------------------------------------------------------------- - # getting DSL donw/up stream rate + # getting DSL down/up stream rate my $globalvdsl = AttrVal($name, "enableBoxReadings", ""); if ($globalvdsl =~ /box_vdsl/) { - if (($mesh ne "slave") && (($FW1 > 6 && $FW2 >= 80) || $FW1 >= 7) && (lc($avmModel) !~ "5[4,5][9,3]0|40[2,4,6]0|68[2,5]0|6[4,5,6][3,6,9][0,1]|fiber|cable") ) { # FB ohne VDSL + FRITZBOX_Log $hash, 4, "down/up stream - start getting TR064 data: $globalvdsl"; + + if (($mesh ne "slave") && ($hash->{fhem}{fwVersion} >= 680) && (lc($avmModel) !~ "5[4,5][9,3]0|40[2,4,6]0|68[2,5]0|6[4,5,6][3,6,9][0,1]|fiber|cable") ) { # FB ohne VDSL @tr064CmdArray = (["WANDSLInterfaceConfig:1", "wandslifconfig1", "GetInfo"]); @tr064Result = FRITZBOX_call_TR064_Cmd( $hash, 0, \@tr064CmdArray ); @@ -4923,20 +5526,22 @@ sub FRITZBOX_Readout_Run_Web($) FRITZBOX_Log $hash, 5, "VDSL up/down rate GetInfo -> \n" . Dumper (@tr064Result); if ($tr064Result[0]->{GetInfoResponse}) { - FRITZBOX_Readout_Add_Reading $hash, \@roReadings, "box_vdsl_downStreamRate", $tr064Result[0]->{GetInfoResponse}->{NewDownstreamCurrRate} / 1000; - FRITZBOX_Readout_Add_Reading $hash, \@roReadings, "box_vdsl_downStreamMaxRate", $tr064Result[0]->{GetInfoResponse}->{NewDownstreamMaxRate} / 1000; - FRITZBOX_Readout_Add_Reading $hash, \@roReadings, "box_vdsl_upStreamRate", $tr064Result[0]->{GetInfoResponse}->{NewUpstreamCurrRate} / 1000; - FRITZBOX_Readout_Add_Reading $hash, \@roReadings, "box_vdsl_upStreamMaxRate", $tr064Result[0]->{GetInfoResponse}->{NewUpstreamMaxRate} / 1000; + FRITZBOX_Readout_Add_Reading $hash, $roReadings, "box_vdsl_downStreamRate", $tr064Result[0]->{GetInfoResponse}->{NewDownstreamCurrRate} / 1000; + FRITZBOX_Readout_Add_Reading $hash, $roReadings, "box_vdsl_downStreamMaxRate", $tr064Result[0]->{GetInfoResponse}->{NewDownstreamMaxRate} / 1000; + FRITZBOX_Readout_Add_Reading $hash, $roReadings, "box_vdsl_upStreamRate", $tr064Result[0]->{GetInfoResponse}->{NewUpstreamCurrRate} / 1000; + FRITZBOX_Readout_Add_Reading $hash, $roReadings, "box_vdsl_upStreamMaxRate", $tr064Result[0]->{GetInfoResponse}->{NewUpstreamMaxRate} / 1000; } } } else { - FRITZBOX_Readout_Add_Reading $hash, \@roReadings, "box_vdsl_downStreamRate", ""; - FRITZBOX_Readout_Add_Reading $hash, \@roReadings, "box_vdsl_downStreamMaxRate", ""; - FRITZBOX_Readout_Add_Reading $hash, \@roReadings, "box_vdsl_upStreamRate", ""; - FRITZBOX_Readout_Add_Reading $hash, \@roReadings, "box_vdsl_upStreamMaxRate", ""; + FRITZBOX_Readout_Add_Reading $hash, $roReadings, "box_vdsl_downStreamRate", ""; + FRITZBOX_Readout_Add_Reading $hash, $roReadings, "box_vdsl_downStreamMaxRate", ""; + FRITZBOX_Readout_Add_Reading $hash, $roReadings, "box_vdsl_upStreamRate", ""; + FRITZBOX_Readout_Add_Reading $hash, $roReadings, "box_vdsl_upStreamMaxRate", ""; } + FRITZBOX_Log $hash, 4, "down/up stream - end getting TR064 data: $globalvdsl"; + } # end getting DSL donw/up stream rate #------------------------------------------------------------------------------------- @@ -4946,6 +5551,8 @@ sub FRITZBOX_Readout_Run_Web($) if ( lc($avmModel) !~ "6[4,5,6][3,6,9][0,1]" ) { + FRITZBOX_Log $hash, 4, "wanpppconn - start getting TR064 data"; + #------------------------------------------------------------------------------------- # box_ipIntern WANPPPConnection:1 wanpppconn1 GetInfo @@ -4966,16 +5573,16 @@ sub FRITZBOX_Readout_Run_Web($) my @dns_list = split(/\,/, $dns_servers); my $cnt = 0; foreach ( @dns_list ) { - FRITZBOX_Readout_Add_Reading $hash, \@roReadings, "box_dns_Server$cnt", $_; + FRITZBOX_Readout_Add_Reading $hash, $roReadings, "box_dns_Server$cnt", $_; $cnt++; } - FRITZBOX_Readout_Add_Reading $hash, \@roReadings, "box_ipv4_Extern", $tr064Result[0]->{GetInfoResponse}->{NewExternalIPAddress}; - FRITZBOX_Readout_Add_Reading $hash, \@roReadings, "box_connection_Type", $tr064Result[0]->{GetInfoResponse}->{NewConnectionType}; - FRITZBOX_Readout_Add_Reading $hash, \@roReadings, "box_connect", $tr064Result[0]->{GetInfoResponse}->{NewConnectionStatus}; - FRITZBOX_Readout_Add_Reading $hash, \@roReadings, "box_last_connect_err", $tr064Result[0]->{GetInfoResponse}->{NewLastConnectionError}; - FRITZBOX_Readout_Add_Reading $hash, \@roReadings, "box_last_auth_err", $tr064Result[0]->{GetInfoResponse}->{NewLastAuthErrorInfo}; - FRITZBOX_Readout_Add_Reading $hash, \@roReadings, "box_mac_Address", $tr064Result[0]->{GetInfoResponse}->{NewMACAddress}; + FRITZBOX_Readout_Add_Reading $hash, $roReadings, "box_ipv4_Extern", $tr064Result[0]->{GetInfoResponse}->{NewExternalIPAddress}; + FRITZBOX_Readout_Add_Reading $hash, $roReadings, "box_connection_Type", $tr064Result[0]->{GetInfoResponse}->{NewConnectionType}; + FRITZBOX_Readout_Add_Reading $hash, $roReadings, "box_connect", $tr064Result[0]->{GetInfoResponse}->{NewConnectionStatus}; + FRITZBOX_Readout_Add_Reading $hash, $roReadings, "box_last_connect_err", $tr064Result[0]->{GetInfoResponse}->{NewLastConnectionError}; + FRITZBOX_Readout_Add_Reading $hash, $roReadings, "box_last_auth_err", $tr064Result[0]->{GetInfoResponse}->{NewLastAuthErrorInfo}; + FRITZBOX_Readout_Add_Reading $hash, $roReadings, "box_mac_Address", $tr064Result[0]->{GetInfoResponse}->{NewMACAddress}; $strCurl = $tr064Result[0]->{GetInfoResponse}->{NewUptime}; $Sek = $strCurl; @@ -4988,9 +5595,12 @@ sub FRITZBOX_Readout_Run_Web($) $Min = substr("0".$Min,-2); $Sek = substr("0".$Sek,-2); - FRITZBOX_Readout_Add_Reading $hash, \@roReadings, "box_uptimeConnect", ($mesh ne "slave") ? $strCurl . " sec = " . $Tag . "T $Std:$Min:$Sek" : ""; + FRITZBOX_Readout_Add_Reading $hash, $roReadings, "box_uptimeConnect", ($mesh ne "slave") ? $strCurl . " sec = " . $Tag . "T $Std:$Min:$Sek" : ""; } } + + FRITZBOX_Log $hash, 4, "wanpppconn - end getting TR064 data"; + } # end getting WANPPPConnection Info #------------------------------------------------------------------------------------- @@ -5006,10 +5616,12 @@ sub FRITZBOX_Readout_Run_Web($) #------------------------------------------------------------------------------------- # box_uptimeConnect + FRITZBOX_Log $hash, 4, "uptimeConnect- start getting TR064 data"; + $soap_resp = FRITZBOX_SOAP_Request($hash,$control_url . "WANIPConn1", $service_type, $service_command); if(defined $soap_resp->{Error}) { - FRITZBOX_Log $hash, 5, "SOAP-ERROR -> " . $soap_resp->{Error}; + FRITZBOX_Log $hash, 4, "SOAP-ERROR -> " . $soap_resp->{Error}; } elsif ( $soap_resp->{Response} ) { @@ -5017,10 +5629,10 @@ sub FRITZBOX_Readout_Run_Web($) FRITZBOX_Log $hash, 5, "Curl-> " . $strCurl; if($strCurl =~ m/(.*?)<\/NewConnectionStatus>/i) { - FRITZBOX_Readout_Add_Reading $hash, \@roReadings, "box_connect", $1; + FRITZBOX_Readout_Add_Reading $hash, $roReadings, "box_connect", $1; } if($strCurl =~ m/(.*?)<\/NewLastConnectionError>/i) { - FRITZBOX_Readout_Add_Reading $hash, \@roReadings, "box_last_connect_err", $1; + FRITZBOX_Readout_Add_Reading $hash, $roReadings, "box_last_connect_err", $1; } if($strCurl =~ m/(.*?)<\/NewUptime>/i) { @@ -5034,20 +5646,24 @@ sub FRITZBOX_Readout_Run_Web($) $Min = substr("0".$Min,-2); $Sek = substr("0".$Sek,-2); - FRITZBOX_Readout_Add_Reading $hash, \@roReadings, "box_uptimeConnect", $1 . " sec = " . $Tag . "T $Std:$Min:$Sek"; + FRITZBOX_Readout_Add_Reading $hash, $roReadings, "box_uptimeConnect", $1 . " sec = " . $Tag . "T $Std:$Min:$Sek"; } + } + FRITZBOX_Log $hash, 4, "uptimeConnect- end getting TR064 data"; #------------------------------------------------------------------------------------- # box_ipExtern + FRITZBOX_Log $hash, 4, "ipExtern- start getting TR064 data"; + $service_command = "GetExternalIPAddress"; $soap_resp = FRITZBOX_SOAP_Request($hash,$control_url . "WANIPConn1", $service_type, $service_command); if(exists $soap_resp->{Error}) { - FRITZBOX_Log $hash, 5, "SOAP-ERROR -> " . $soap_resp->{Error}; + FRITZBOX_Log $hash, 4, "SOAP-ERROR -> " . $soap_resp->{Error}; } elsif ( $soap_resp->{Response} ) { @@ -5055,21 +5671,27 @@ sub FRITZBOX_Readout_Run_Web($) FRITZBOX_Log $hash, 5, "Curl-> " . $strCurl; if($strCurl =~ m/(.*?)<\/NewExternalIPAddress>/i) { - FRITZBOX_Readout_Add_Reading $hash, \@roReadings, "box_ipv4_Extern", $1; + FRITZBOX_Readout_Add_Reading $hash, $roReadings, "box_ipv4_Extern", $1; } } + + FRITZBOX_Log $hash, 4, "ipExtern- end getting TR064 data"; + } #------------------------------------------------------------------------------------- # box_ipv6 -> NewPreferedLifetime, NewExternalIPv6Address, NewValidLifetime, NewPrefixLength + + FRITZBOX_Log $hash, 4, "ipv6 - start getting TR064 data"; + $service_command = "X_AVM_DE_GetExternalIPv6Address"; $soap_resp = FRITZBOX_SOAP_Request($hash,$control_url . "WANIPConn1", $service_type, $service_command); if(exists $soap_resp->{Error}) { - FRITZBOX_Log $hash, 5, "SOAP/TR064-ERROR -> " . $soap_resp->{Error}; - FRITZBOX_Readout_Add_Reading $hash, \@roReadings, "box_ipv6_Extern", $soap_resp->{ErrLevel} == 2?"unknown error":""; + FRITZBOX_Log $hash, 4, "SOAP/TR064-ERROR -> " . $soap_resp->{Error}; + FRITZBOX_Readout_Add_Reading $hash, $roReadings, "box_ipv6_Extern", $soap_resp->{ErrLevel} == 2?"unknown error":""; } elsif ( $soap_resp->{Response} ) { @@ -5077,20 +5699,24 @@ sub FRITZBOX_Readout_Run_Web($) FRITZBOX_Log $hash, 5, "Curl-> " . $strCurl; if($strCurl =~ m/(.*?)<\/NewExternalIPv6Address>/i) { - FRITZBOX_Readout_Add_Reading $hash, \@roReadings, "box_ipv6_Extern", $1; + FRITZBOX_Readout_Add_Reading $hash, $roReadings, "box_ipv6_Extern", $1; } } + FRITZBOX_Log $hash, 4, "ipv6 - end getting TR064 data"; + #------------------------------------------------------------------------------------- # box_ipv6_Prefix -> NewPreferedLifetime, NewIPv6Prefix, NewValidLifetime, NewPrefixLength + FRITZBOX_Log $hash, 4, "ipv6_Prefix - start getting TR064 data"; + $service_command = "X_AVM_DE_GetIPv6Prefix"; $soap_resp = FRITZBOX_SOAP_Request($hash,$control_url . "WANIPConn1", $service_type, $service_command); if(exists $soap_resp->{Error}) { - FRITZBOX_Log $hash, 5, "SOAP/TR064-ERROR -> " . $soap_resp->{Error}; - FRITZBOX_Readout_Add_Reading $hash, \@roReadings, "box_ipv6_Extern", $soap_resp->{ErrLevel} == 2?"unknown error":""; + FRITZBOX_Log $hash, 4, "SOAP/TR064-ERROR -> " . $soap_resp->{Error}; + FRITZBOX_Readout_Add_Reading $hash, $roReadings, "box_ipv6_Extern", $soap_resp->{ErrLevel} == 2?"unknown error":""; } elsif ( $soap_resp->{Response} ) { @@ -5098,18 +5724,23 @@ sub FRITZBOX_Readout_Run_Web($) FRITZBOX_Log $hash, 5, "Curl-> " . $strCurl; if($strCurl =~ m/(.*?)<\/NewIPv6Prefix>/i) { - FRITZBOX_Readout_Add_Reading $hash, \@roReadings, "box_ipv6_Prefix", $1; + FRITZBOX_Readout_Add_Reading $hash, $roReadings, "box_ipv6_Prefix", $1; } } + FRITZBOX_Log $hash, 4, "ipv6_Prefix - start getting TR064 data"; + # box_wan_AccessType + + FRITZBOX_Log $hash, 4, "AccessType - start getting TR064 data"; + $service_command = "GetCommonLinkProperties"; $soap_resp = FRITZBOX_SOAP_Request($hash,$control_url . "WANCommonIFC1", "urn:schemas-upnp-org:service:WANCommonInterfaceConfig:1", $service_command); if(exists $soap_resp->{Error}) { - FRITZBOX_Log $hash, 5, "SOAP/TR064-ERROR -> " . $soap_resp->{Error}; - FRITZBOX_Readout_Add_Reading $hash, \@roReadings, "box_wan_AccessType", $soap_resp->{ErrLevel} == 2?"unknown error":""; + FRITZBOX_Log $hash, 4, "SOAP/TR064-ERROR -> " . $soap_resp->{Error}; + FRITZBOX_Readout_Add_Reading $hash, $roReadings, "box_wan_AccessType", $soap_resp->{ErrLevel} == 2?"unknown error":""; } elsif ( $soap_resp->{Response} ) { @@ -5117,7 +5748,7 @@ sub FRITZBOX_Readout_Run_Web($) FRITZBOX_Log $hash, 5, "Curl-> " . $strCurl; if($strCurl =~ m/(.*?)<\/NewWANAccessType>/i) { - FRITZBOX_Readout_Add_Reading $hash, \@roReadings, "box_wan_AccessType", $1; + FRITZBOX_Readout_Add_Reading $hash, $roReadings, "box_wan_AccessType", $1; } } @@ -5127,31 +5758,11 @@ sub FRITZBOX_Readout_Run_Web($) FRITZBOX_Log $hash, 4, "unknown AVM Model $avmModel"; } - } else { - FRITZBOX_Log $hash, 4, "TR064: $hash->{TR064} or secure Port:" . ($hash->{SECPORT} ? $hash->{SECPORT} : "none") . " not available or wrong Fritz!OS: $FW1.$FW2."; - } + FRITZBOX_Log $hash, 4, "AccessType - end getting TR064 data"; - FRITZBOX_Readout_Add_Reading ($hash, \@roReadings, "->HINWEIS_BOXUSER", ""); - FRITZBOX_Readout_Add_Reading ($hash, \@roReadings, "->HINWEIS_PASSWORD", ""); + return ""; - # Ende und Rückkehr zum Hauptprozess - - push @roReadings, "readoutTime", sprintf( "%.2f", time()-$startTime); - - FRITZBOX_Readout_Add_Reading $hash, \@roReadings, "fhem->sid", $result->{sid} if $result->{sid}; - FRITZBOX_Readout_Add_Reading $hash, \@roReadings, "fhem->sidTime", time(); - FRITZBOX_Readout_Add_Reading $hash, \@roReadings, "fhem->sidErrCount", 0; - FRITZBOX_Readout_Add_Reading $hash, \@roReadings, "fhem->sidNewCount", $sidNew; - FRITZBOX_Readout_Add_Reading $hash, \@roReadings, "->WEBCONNECT", 1; - - push @roReadings, "readoutTime", sprintf( "%.2f", time()-$startTime); - my $returnStr = join('|', @roReadings ); - - FRITZBOX_Log $hash, 4, "Captured " . @roReadings . " values"; - FRITZBOX_Log $hash, 5, "Handover to main process (" . length ($returnStr) . "): " . $returnStr; - return $name."|".encode_base64($returnStr,""); - -} # End FRITZBOX_Readout_Run_Web +} # End FRITZBOX_Readout_Run_Web_TR064 ####################################################################### sub FRITZBOX_Readout_Response($$$@) @@ -5178,16 +5789,26 @@ sub FRITZBOX_Readout_Response($$$@) elsif ( defined $result->{Error} ) { # Abbruch wenn Fehler beim Lesen der Fritzbox-Antwort + push @{$roReadings}, "->APICHECKED", -1; + push @{$roReadings}, "->APICHECK_RET_CODES", $result->{Error}; + push @{$roReadings}, "Error", "cannot connect due to network error 500"; push @{$roReadings}, "->WEBCONNECT", 0; + push @{$roReadings}, "fhem->sidErrCount", $hash->{fhem}{sidErrCount} + 1; + FRITZBOX_Log $hash, 2, "" . $result->{Error}; $returnStr = "Error|" . $result->{Error}; $returnStr .= "|"; } elsif ( defined $result->{AuthorizationRequired} ) { + # Abbruch wenn Fehler bei der Anmeldung an die FritzBox + push @{$roReadings}, "->APICHECKED", -1; + push @{$roReadings}, "->APICHECK_RET_CODES", $result->{AuthorizationRequired}; + push @{$roReadings}, "Error", "cannot connect due to authorisation error"; + push @{$roReadings}, "->WEBCONNECT", 0; + push @{$roReadings}, "fhem->sidErrCount", $hash->{fhem}{sidErrCount} + 1; FRITZBOX_Log $hash, 2, "AuthorizationRequired=" . $result->{AuthorizationRequired}; - $returnStr = "Error|Authorization required"; $returnStr .= "|"; } @@ -5217,7 +5838,7 @@ sub FRITZBOX_Readout_Response($$$@) } FRITZBOX_Log $hash, 4, "Captured " . @{$roReadings} . " values"; - FRITZBOX_Log $hash, 5, "Handover to main process (" . length ($returnStr) . "): \n" . $returnStr; + FRITZBOX_Log $hash, 3, "Handover to main process (" . length ($returnStr) . "): \n" . $returnStr; return $returnStr; @@ -5233,10 +5854,10 @@ sub FRITZBOX_Readout_Done($) return; } - my ($name,$string2) = split("\\|", $string, 2); + my ($name, $string2) = split("\\|", $string, 2); my $hash = $defs{$name}; - FRITZBOX_Log $hash, 5, "Back at main process"; + FRITZBOX_Log $hash, 4, "Back at main process"; # delete the marker for RUNNING_PID process delete($hash->{helper}{READOUT_RUNNING_PID}); @@ -5266,11 +5887,11 @@ sub FRITZBOX_Readout_Process($$) my $filter_list = AttrVal($name, "enableReadingsFilter", "none"); $reading_list =~ s/,/\|/g; - FRITZBOX_Log $hash, 5, "box_ disable list: $reading_list"; + FRITZBOX_Log $hash, 4, "box_ disable list: $reading_list"; $filter_list =~ s/,/\|/g; $filter_list =~ s/ID_/_/g; - FRITZBOX_Log $hash, 5, "filter list: $filter_list"; + FRITZBOX_Log $hash, 4, "filter list: $filter_list"; my $mesh = ReadingsVal($name, "box_meshRole", "master"); @@ -5282,39 +5903,42 @@ sub FRITZBOX_Readout_Process($$) } # Statistics - if ($mesh ne "slave") { - if ( defined $values{".box_TodayBytesReceivedLow"} && defined $hash->{READINGS}{".box_TodayBytesReceivedLow"}) { - my $valueHigh = $values{".box_TodayBytesReceivedHigh"} - $hash->{READINGS}{".box_TodayBytesReceivedHigh"}{VAL}; - my $valueLow = $values{".box_TodayBytesReceivedLow"} - $hash->{READINGS}{".box_TodayBytesReceivedLow"}{VAL}; + if (defined $values{".calledFrom"} && $values{".calledFrom"} eq "runWeb") { - # Consider reset of day counter - if ($valueHigh < 0 || $valueHigh == 0 && $valueLow < 0) { - $valueLow = $values{".box_TodayBytesReceivedLow"}; - $valueHigh = $values{".box_TodayBytesReceivedHigh"}; + if ($mesh ne "slave") { + if ( defined $values{".box_TodayBytesReceivedLow"} && defined $hash->{READINGS}{".box_TodayBytesReceivedLow"}) { + my $valueHigh = $values{".box_TodayBytesReceivedHigh"} - $hash->{READINGS}{".box_TodayBytesReceivedHigh"}{VAL}; + my $valueLow = $values{".box_TodayBytesReceivedLow"} - $hash->{READINGS}{".box_TodayBytesReceivedLow"}{VAL}; + + # Consider reset of day counter + if ($valueHigh < 0 || $valueHigh == 0 && $valueLow < 0) { + $valueLow = $values{".box_TodayBytesReceivedLow"}; + $valueHigh = $values{".box_TodayBytesReceivedHigh"}; + } + $valueHigh *= 2**22; + $valueLow /= 2**10; + my $time = time()-time_str2num($hash->{READINGS}{".box_TodayBytesReceivedLow"}{TIME}); + $values{ "box_rateDown" } = sprintf ("%.3f", ($valueHigh+$valueLow) / $time ) ; } - $valueHigh *= 2**22; - $valueLow /= 2**10; - my $time = time()-time_str2num($hash->{READINGS}{".box_TodayBytesReceivedLow"}{TIME}); - $values{ "box_rateDown" } = sprintf ("%.3f", ($valueHigh+$valueLow) / $time ) ; - } - if ( defined $values{".box_TodayBytesSentLow"} && defined $hash->{READINGS}{".box_TodayBytesSentLow"} ) { - my $valueHigh = $values{".box_TodayBytesSentHigh"} - $hash->{READINGS}{".box_TodayBytesSentHigh"}{VAL}; - my $valueLow = $values{".box_TodayBytesSentLow"} - $hash->{READINGS}{".box_TodayBytesSentLow"}{VAL}; + if ( defined $values{".box_TodayBytesSentLow"} && defined $hash->{READINGS}{".box_TodayBytesSentLow"} ) { + my $valueHigh = $values{".box_TodayBytesSentHigh"} - $hash->{READINGS}{".box_TodayBytesSentHigh"}{VAL}; + my $valueLow = $values{".box_TodayBytesSentLow"} - $hash->{READINGS}{".box_TodayBytesSentLow"}{VAL}; - # Consider reset of day counter - if ($valueHigh < 0 || $valueHigh == 0 && $valueLow < 0) { - $valueLow = $values{".box_TodayBytesSentLow"}; - $valueHigh = $values{".box_TodayBytesSentHigh"}; + # Consider reset of day counter + if ($valueHigh < 0 || $valueHigh == 0 && $valueLow < 0) { + $valueLow = $values{".box_TodayBytesSentLow"}; + $valueHigh = $values{".box_TodayBytesSentHigh"}; + } + $valueHigh *= 2**22; + $valueLow /= 2**10; + my $time = time()-time_str2num($hash->{READINGS}{".box_TodayBytesSentLow"}{TIME}); + $values{ "box_rateUp" } = sprintf ("%.3f", ($valueHigh+$valueLow) / $time ) ; } - $valueHigh *= 2**22; - $valueLow /= 2**10; - my $time = time()-time_str2num($hash->{READINGS}{".box_TodayBytesSentLow"}{TIME}); - $values{ "box_rateUp" } = sprintf ("%.3f", ($valueHigh+$valueLow) / $time ) ; + } else { + $values{ "box_rateDown" } = ""; + $values{ "box_rateUp" } = ""; } - } else { - $values{ "box_rateDown" } = ""; - $values{ "box_rateUp" } = ""; } # Fill all handed over readings @@ -5351,10 +5975,12 @@ sub FRITZBOX_Readout_Process($$) delete ($hash->{HINWEIS_BOXUSER}) if $rName2 eq "HINWEIS_BOXUSER" && $rValue eq ""; delete ($hash->{HINWEIS_PASSWORD}) if $rName2 eq "HINWEIS_PASSWORD" && $rValue eq ""; + readingsBulkUpdate( $hash, "state", "check API done" ) if $rName2 eq "APICHECKED"; + } elsif ($rName eq "-{READINGS}{$rName} if ( exists $hash->{READINGS}{$rName} ); readingsBulkUpdate( $hash, "." . $rName, $rValue ); - FRITZBOX_Log $hash, 5, "SET ." . $rName . " = '$rValue'"; + FRITZBOX_Log $hash, 4, "SET ." . $rName . " = '$rValue'"; } else { $rFilter = "." . $rName; delete $hash->{READINGS}{$rFilter} if ( exists $hash->{READINGS}{$rFilter} ); readingsBulkUpdate( $hash, $rName, $rValue ); - FRITZBOX_Log $hash, 5, "SET $rName = '$rValue'"; + FRITZBOX_Log $hash, 4, "SET $rName = '$rValue'"; } } elsif ( exists $hash->{READINGS}{$rName} ) { delete $hash->{READINGS}{$rName}; - FRITZBOX_Log $hash, 5, "Delete reading $rName."; + FRITZBOX_Log $hash, 4, "Delete reading $rName."; } else { - FRITZBOX_Log $hash, 5, "Ignore reading $rName."; + FRITZBOX_Log $hash, 4, "Ignore reading $rName."; } } } @@ -5467,7 +6096,7 @@ sub FRITZBOX_Readout_Process($$) $newState .=" gWLAN: ".$values{box_guestWlan} ; $newState .=" (Remain: ".$values{box_guestWlanRemain}." min)" if $values{box_guestWlan} eq "on" && $values{box_guestWlanRemain} > 0; readingsBulkUpdate( $hash, "state", $newState); - FRITZBOX_Log $hash, 5, "SET state = '$newState'"; + FRITZBOX_Log $hash, 4, "SET state = '$newState'"; } # adapt TR064-Mode @@ -5493,7 +6122,7 @@ sub FRITZBOX_Readout_Process($$) } readingsBulkUpdate( $hash, "retStat_lastReadout", $msg ); - FRITZBOX_Log $hash, 5, "BulkUpdate lastReadout: " . $msg; + FRITZBOX_Log $hash, 4, "BulkUpdate lastReadout: " . $msg; readingsEndUpdate( $hash, 1 ); @@ -5640,7 +6269,7 @@ sub FRITZBOX_Readout_Add_Reading ($$$$@) push @{$roReadings}, $rName . "|" . $rValue ; - FRITZBOX_Log $hash, 5, "$rName: $rValue"; + FRITZBOX_Log $hash, 4, "$rName: $rValue"; } # end FRITZBOX_Readout_Add_Reading @@ -5690,7 +6319,7 @@ sub FRITZBOX_Readout_SetGet_Start($) $sub =~ s/FRITZBOX_// if ( defined $sub ); $sub ||= 'no-subroutine-specified'; - FRITZBOX_Log $hash, 5, "Set_CMD_Start -> $sub.$xline -> $val[0]"; + FRITZBOX_Log $hash, 4, "Set_CMD_Start -> $sub.$xline -> $val[0]"; return "Process " . $hash->{helper}{CMD_RUNNING_PID} . " is still running" if exists $hash->{helper}{CMD_RUNNING_PID}; @@ -5745,6 +6374,13 @@ sub FRITZBOX_Readout_SetGet_Start($) $handover = $name . "|" . join( "|", @val ); $cmdFunction = "FRITZBOX_Set_Wlan_Log_Ext_OnOff"; } +# Preparing SET wlanguestparams + elsif ($val[0] eq "wlanguestparams") { + $timeout = 20; + $cmdBufferTimeout = time() + $timeout; + $handover = $name . "|" . join( "|", @val ); + $cmdFunction = "FRITZBOX_Set_Wlan_Guest_Params"; + } # Preparing SET rescanWLANneighbors elsif ( $val[0] eq "rescanwlanneighbors" ) { $timeout = 10; @@ -5813,7 +6449,7 @@ sub FRITZBOX_Readout_SetGet_Start($) $hash->{helper}{CMD_RUNNING_PID} = BlockingCall($cmdFunction, $handover, "FRITZBOX_Readout_SetGet_Done", $timeout, "FRITZBOX_Readout_SetGet_Aborted", $hash); -# $hash->{helper}{READOUT_RUNNING_PID}->{loglevel} = GetVerbose($name); + $hash->{helper}{CMD_RUNNING_PID}->{loglevel} = GetVerbose($name); return undef; } # end FRITZBOX_Readout_SetGet_Start @@ -5902,6 +6538,7 @@ sub FRITZBOX_Set_check_APIs($) my $fwVersion = "0.0.0.error"; my $startTime = time(); my $apiError = ""; + my $luaQueryOk = 0; my $crdOK = 0; my @roReadings; my $response; @@ -5950,10 +6587,12 @@ sub FRITZBOX_Set_check_APIs($) if ($response->is_success) { FRITZBOX_Readout_Add_Reading $hash, \@roReadings, "->LUAQUERY", 1; FRITZBOX_Log $hash, 5-$myVerbose, "API luaQuery found (" . $response->code . ")."; + $luaQueryOk = 1; } elsif ($response->code eq "403") { FRITZBOX_Readout_Add_Reading $hash, \@roReadings, "->LUAQUERY", 1; FRITZBOX_Log $hash, 4-$myVerbose, "API luaQuery call responded with: " . $response->status_line; + $luaQueryOk = 1; } elsif ($response->code eq "500") { FRITZBOX_Readout_Add_Reading $hash, \@roReadings, "->LUAQUERY", 0; @@ -6032,7 +6671,7 @@ sub FRITZBOX_Set_check_APIs($) if ( $fwVersion =~ /error/ && $response->code != 500 && $crdOK) { # Ansonsten ermitteln Box Model, FritzOS Version, OEM aus jason_boxinfo - FRITZBOX_Log $hash, 5, "Read 'jason_boxinfo' from " . $host; + FRITZBOX_Log $hash, 4, "Read 'jason_boxinfo' from " . $host; $FRITZBOX_TR064pwd = FRITZBOX_Helper_read_Password($hash); @@ -6044,7 +6683,7 @@ sub FRITZBOX_Set_check_APIs($) unless ($response->is_success) { - FRITZBOX_Log $hash, 5, "retry with password 'jason_boxinfo' from " . $host; + FRITZBOX_Log $hash, 4, "retry with password 'jason_boxinfo' from " . $host; my $agentPW = LWP::UserAgent->new( env_proxy => 1, keep_alive => 1, protocols_allowed => ['http'], timeout => 10); my $req = HTTP::Request->new( GET => "http://" . $host . "/jason_boxinfo.xml"); @@ -6070,14 +6709,14 @@ sub FRITZBOX_Set_check_APIs($) FRITZBOX_Log $hash, 4-$myVerbose, "jason_boxinfo returned: $response->is_success with $content"; # Ansonsten ermitteln Box Model, FritzOS Version, OEM aus cgi-bin/system_status - FRITZBOX_Log $hash, 5, "retry with password 'cgi-bin/system_status' from " . $host; + FRITZBOX_Log $hash, 4, "retry with password 'cgi-bin/system_status' from " . $host; $agent = LWP::UserAgent->new( env_proxy => 1, keep_alive => 1, protocols_allowed => ['http'], timeout => 10); $url = "http://".$host."/cgi-bin/system_status"; $response = $agent->get( $url ); unless ($response->is_success) { - FRITZBOX_Log $hash, 5, "read 'cgi-bin/system_status' from " . $host; + FRITZBOX_Log $hash, 4, "read 'cgi-bin/system_status' from " . $host; my $agentPW = LWP::UserAgent->new( env_proxy => 1, keep_alive => 1, protocols_allowed => ['http'], timeout => 10); my $req = HTTP::Request->new( GET => "http://" . $host . "/cgi-bin/system_status"); @@ -6127,14 +6766,27 @@ sub FRITZBOX_Set_check_APIs($) } } + my @fwV = split(/\./, $fwVersion); + FRITZBOX_Readout_Add_Reading $hash, \@roReadings, "fhem->fwVersion", substr($fwV[1],0,2) * 100 + substr($fwV[2],0,2); + FRITZBOX_Readout_Add_Reading $hash, \@roReadings, "fhem->fwVersionStr", substr($fwV[1],0,2) . "." . substr($fwV[2],0,2); + if ($apiError =~ /500/) { + FRITZBOX_Readout_Add_Reading $hash, \@roReadings, "->APICHECKED", -1; FRITZBOX_Readout_Add_Reading $hash, \@roReadings, "->APICHECK_RET_CODES", $apiError; FRITZBOX_Readout_Add_Reading $hash, \@roReadings, "Error", "cannot connect due to network error 500"; + + FRITZBOX_Readout_Add_Reading $hash, \@roReadings, "fhem->sidTime", 0; + FRITZBOX_Readout_Add_Reading $hash, \@roReadings, "fhem->sidErrCount", $hash->{fhem}{sidErrCount} + 1; + } else { + FRITZBOX_Readout_Add_Reading $hash, \@roReadings, "->APICHECKED", 1; FRITZBOX_Readout_Add_Reading $hash, \@roReadings, "->APICHECK_RET_CODES", "Ok"; + FRITZBOX_Readout_Add_Reading $hash, \@roReadings, "fhem->sidTime", 0; + FRITZBOX_Readout_Add_Reading $hash, \@roReadings, "fhem->sidErrCount", 0; + # initialize first SID if password available if ( $crdOK ) { my $result = FRITZBOX_open_Web_Connection( $hash ); @@ -6142,9 +6794,9 @@ sub FRITZBOX_Set_check_APIs($) if (defined $result->{Error}) { FRITZBOX_Readout_Add_Reading $hash, \@roReadings, "Error", $result->{Error}; FRITZBOX_Readout_Add_Reading $hash, \@roReadings, "->WEBCONNECT", 0; - my $sidCnt = $hash->{fhem}{sidErrCount} + 1; + FRITZBOX_Readout_Add_Reading $hash, \@roReadings, "fhem->sidTime", 0; - FRITZBOX_Readout_Add_Reading $hash, \@roReadings, "fhem->sidErrCount", $sidCnt; + FRITZBOX_Readout_Add_Reading $hash, \@roReadings, "fhem->sidErrCount", $hash->{fhem}{sidErrCount} + 1; } else { my $sidNew = defined $result->{sidNew} ? $result->{sidNew} : 0; @@ -6154,6 +6806,57 @@ sub FRITZBOX_Set_check_APIs($) FRITZBOX_Readout_Add_Reading $hash, \@roReadings, "fhem->sidTime", time(); FRITZBOX_Readout_Add_Reading $hash, \@roReadings, "fhem->sidErrCount", 0; FRITZBOX_Readout_Add_Reading $hash, \@roReadings, "->WEBCONNECT", 1; + + + if($luaQueryOk) { + + my $queryStr = ""; + + foreach my $key (keys %{ $hash->{LuaQueryCmd} }) { + FRITZBOX_Log $hash, 4, $key . ": " . $hash->{LuaQueryCmd}{$key}{active} . ": " . $hash->{LuaQueryCmd}{$key}{AttrVal}; + $queryStr .= "&" . $key . "=" . $hash->{LuaQueryCmd}{$key}{cmd}; + } + + FRITZBOX_Log $hash, 4, "ReadOut gestartet: $queryStr"; + $response = FRITZBOX_call_Lua_Query( $hash, $queryStr, "", "luaQuery") ; + + if ( !defined $response->{sid} || defined $response->{Error} || defined $response->{AuthorizationRequired} ) { + $apiError = "luaQuery: error query string"; + FRITZBOX_Log $hash, 4, "$queryStr: not Ok"; + } else { + + foreach my $key (keys %{ $hash->{LuaQueryCmd} }) { + + if((ref $response->{$key} ne 'ARRAY') && ref \$response->{$key} ne "SCALAR") { + FRITZBOX_Log $hash, 4, "$key = $hash->{LuaQueryCmd}{$key}{cmd}: 2 not Ok"; + + FRITZBOX_Readout_Add_Reading $hash, \@roReadings, "LuaQuery->" . $key . "->active", 0; + + } elsif(ref $response->{$key} eq 'ARRAY') { + my $views = $response->{$key}; + if(scalar(@$views) == 0) { + FRITZBOX_Log $hash, 4, "$key = $hash->{LuaQueryCmd}{$key}{cmd}: 3 not Ok"; + + FRITZBOX_Readout_Add_Reading $hash, \@roReadings, "LuaQueryCmd->" . $key . "->active", 0; + } else { + FRITZBOX_Log $hash, 4, "$key = $hash->{LuaQueryCmd}{$key}{cmd}: Ok"; + FRITZBOX_Readout_Add_Reading $hash, \@roReadings, "LuaQueryCmd->" . $key . "->active", 1; + } + + } elsif ($response->{$key} eq "") { + FRITZBOX_Log $hash, 4, "$key = $hash->{LuaQueryCmd}{$key}{cmd}: 4 not Ok"; + + FRITZBOX_Readout_Add_Reading $hash, \@roReadings, "LuaQueryCmd->" . $key . "->active", 0; + + } else { + FRITZBOX_Log $hash, 4, "$key = $hash->{LuaQueryCmd}{$key}{cmd}: Ok"; + FRITZBOX_Readout_Add_Reading $hash, \@roReadings, "LuaQueryCmd->" . $key . "->active", 1; + } + } + } + + } # End if($luaQueryOk) + } } @@ -6161,6 +6864,8 @@ sub FRITZBOX_Set_check_APIs($) push @roReadings, "readoutTime", sprintf( "%.2f", time()-$startTime); + FRITZBOX_Readout_Add_Reading $hash, \@roReadings, ".calledFrom", "checkApis"; + my $returnStr = join('|', @roReadings ); FRITZBOX_Log $hash, 3, "Response -> " . $apiError; @@ -6183,11 +6888,6 @@ sub FRITZBOX_Set_block_Incoming_Phone_Call($) my @roReadings; my $startTime = time(); - my @fwV = split(/\./, ReadingsVal($name, "box_fwVersion", "0.0.0.error")); - - my $FW1 = substr($fwV[1],0,2); - my $FW2 = substr($fwV[2],0,2); - # create new one # numbertype0..n: home, work, mobile, fax_work @@ -6249,7 +6949,7 @@ sub FRITZBOX_Set_block_Incoming_Phone_Call($) push @webCmdArray, "xhr" => "1"; push @webCmdArray, "page" => "callLock"; - FRITZBOX_Log $hash, 5, "data.lua: \n" . join(" ", @webCmdArray); + FRITZBOX_Log $hash, 4, "data.lua: \n" . join(" ", @webCmdArray); $result = FRITZBOX_read_LuaData($hash, "data", \@webCmdArray) ; @@ -6303,7 +7003,7 @@ sub FRITZBOX_Set_block_Incoming_Phone_Call($) push @webCmdArray, "page" => "callLock"; } - FRITZBOX_Log $hash, 5, "data.lua: \n" . join(" ", @webCmdArray); + FRITZBOX_Log $hash, 4, "data.lua: \n" . join(" ", @webCmdArray); $result = FRITZBOX_read_LuaData($hash, "data", \@webCmdArray) ; @@ -6321,7 +7021,7 @@ sub FRITZBOX_Set_block_Incoming_Phone_Call($) push @webCmdArray, "xhr" => "1"; push @webCmdArray, "page" => "callLock"; - FRITZBOX_Log $hash, 5, "data.lua: \n" . join(" ", @webCmdArray); + FRITZBOX_Log $hash, 4, "data.lua: \n" . join(" ", @webCmdArray); $result = FRITZBOX_read_LuaData($hash, "data", \@webCmdArray) ; my $search = Dumper $result; @@ -6391,11 +7091,6 @@ sub FRITZBOX_Set_wake_Up_Call($) my @roReadings; my $startTime = time(); - my @fwV = split(/\./, ReadingsVal($name, "box_fwVersion", "0.0.0.error")); - - my $FW1 = substr($fwV[1],0,2); - my $FW2 = substr($fwV[2],0,2); - # xhr 1 lang de page alarm xhrId all # xhr: 1 @@ -6419,7 +7114,8 @@ sub FRITZBOX_Set_wake_Up_Call($) push @webCmdArray, "xhr" => "1"; - if ($FW1 == 7 && $FW2 < 50) { +# if ($FW1 == 7 && $FW2 < 50) { + if ($hash->{fhem}{fwVersion} >= 700 && $hash->{fhem}{fwVersion} < 750) { push @webCmdArray, "apply" => ""; } else { push @webCmdArray, "apply" => "true"; @@ -6452,7 +7148,7 @@ sub FRITZBOX_Set_wake_Up_Call($) } } - FRITZBOX_Log $hash, 5, "data.lua: \n" . join(" ", @webCmdArray); + FRITZBOX_Log $hash, 4, "data.lua: \n" . join(" ", @webCmdArray); $result = FRITZBOX_read_LuaData($hash, "data", \@webCmdArray) ; @@ -6507,45 +7203,200 @@ sub FRITZBOX_Set_Wlan_Log_Ext_OnOff($) # xhr 1 lang de page log xhrId log filter 2 useajax 1 no_sidrenew nop -> Log-Einträge Internetverbindung # xhr 1 lang de page log xhrId log filter 3 useajax 1 no_sidrenew nop -> Log-Einträge Fon - my @fwV = split(/\./, ReadingsVal($name, "box_fwVersion", "0.0.0.error")); - - my $FW1 = substr($fwV[1],0,2); - my $FW2 = substr($fwV[2],0,2); - FRITZBOX_Log $hash, 4, "fritzlog -> $cmd, $val[0]"; push @webCmdArray, "xhr" => "1"; push @webCmdArray, "lang" => "de"; push @webCmdArray, "page" => "log"; - if (($FW1 == 6 && $FW2 >= 80) || ($FW1 == 7 && $FW2 < 50)) { + if ($hash->{fhem}{fwVersion} >= 680 && $hash->{fhem}{fwVersion} < 750) { push @webCmdArray, "wlan" => $val[0] eq "on" ? "7" : "6"; - } elsif ($FW1 >= 7 && $FW2 >= 50) { + } elsif ($hash->{fhem}{fwVersion} >= 750) { push @webCmdArray, "filter" => "wlan"; push @webCmdArray, "apply" => ""; push @webCmdArray, "wlan" => $val[0]; } else { - FRITZBOX_Readout_Add_Reading $hash, \@roReadings, "retStat_wlanLogExtended", "Not supported Fritz!OS $FW1.$FW2"; + FRITZBOX_Readout_Add_Reading $hash, \@roReadings, "retStat_wlanLogExtended", "Not supported Fritz!OS $hash->{fhem}{fwVersionStr}"; } - FRITZBOX_Log $hash, 5, "data.lua: \n" . join(" ", @webCmdArray); + FRITZBOX_Log $hash, 4, "data.lua: \n" . join(" ", @webCmdArray); $result = FRITZBOX_read_LuaData($hash, "data", \@webCmdArray) ; # Abbruch wenn Fehler beim Lesen der Fritzbox-Antwort - return FRITZBOX_Readout_Response($hash, $result, \@roReadings) if ( defined $result->{Error} || defined $result->{AuthorizationRequired}); + if ( defined $result->{Error} || defined $result->{AuthorizationRequired}) { + FRITZBOX_Log $hash, 2, "setting wakeUpCall: " . $result->{Error}; + FRITZBOX_Readout_Add_Reading $hash, \@roReadings, "retStat_wlanGuestParams", "->ERROR: " . $result->{Error}; + return FRITZBOX_Readout_Response($hash, $result, \@roReadings, 2); + } $sidNew += $result->{sidNew} if defined $result->{sidNew}; - FRITZBOX_Log $hash, 5, "wlanLogExtended: " . $result->{data}->{wlan}; + FRITZBOX_Log $hash, 4, "wlanLogExtended: " . $result->{data}->{wlan}; FRITZBOX_Readout_Add_Reading $hash, \@roReadings, "retStat_wlanLogExtended", $result->{data}->{apply}; FRITZBOX_Readout_Add_Reading $hash, \@roReadings, "box_wlan_LogExtended", $result->{data}->{wlan} ? "on" : "off"; # Ende und Rückkehr zum Hauptprozess push @roReadings, "readoutTime", sprintf( "%.2f", time()-$startTime); - return FRITZBOX_Readout_Response($hash, $result, \@roReadings, $returnCase, $sidNew, $returnLog); + return FRITZBOX_Readout_Response($hash, $result, \@roReadings, 2, $sidNew); } # end FRITZBOX_Set_Wlan_Log_Ext_OnOff +####################################################################### +sub FRITZBOX_Set_Wlan_Guest_Params($) +{ + my ($string) = @_; + my ($name, $cmd, @val) = split "\\|", $string; + my $hash = $defs{$name}; + my $result; + my $sidNew = 0; + my @webCmdArray; + my @roReadings; + my $startTime = time(); + my $returnCase = 2; + my $returnLog = ""; + + FRITZBOX_Log $hash, 4, "wlan_guest_name -> $cmd, " . join( " ", @val ); + + # xhr 1 lang de page wGuest xhrId all + + push @webCmdArray, "xhr" => "1"; + push @webCmdArray, "lang" => "de"; + push @webCmdArray, "page" => "wGuest"; + push @webCmdArray, "xhrId" => "all"; + + FRITZBOX_Log $hash, 4, "data.lua status: \n" . join(" ", @webCmdArray); + + $result = FRITZBOX_read_LuaData($hash, "data", \@webCmdArray) ; + + # Abbruch wenn Fehler beim Lesen der Fritzbox-Antwort + if ( defined $result->{Error} || defined $result->{AuthorizationRequired}) { + FRITZBOX_Log $hash, 2, "setting wakeUpCall: " . $result->{Error}; + FRITZBOX_Readout_Add_Reading $hash, \@roReadings, "retStat_wlanGuestParams", "->ERROR: " . $result->{Error}; + return FRITZBOX_Readout_Response($hash, $result, \@roReadings, 2); + } + + $sidNew += $result->{sidNew} if defined $result->{sidNew}; + + # getting Parameters + my %paraPos; + my $lastPos = (int @val) - 1; + + for (my $i = (int @val) - 1; $i >= 0; $i--) { + if ($val[$i] =~ /ssid:|pwd:|wlan:|mode:|tmo:|tmoActive:|tmoNoForcedOff:/) { + my $para = $val[$i]; + $para =~ s/\:.*//; + + my $text = join(' ', @val[$i..$lastPos]); + $text =~ s/.*?\://; + + $paraPos{$para} = $text; + + $lastPos = $i - 1; + } + } + + for my $cmds (keys %paraPos) { + if ($cmds eq "ssid") { + $result->{data}->{guestAccess}->{ssid} = $paraPos{$cmds}; + } elsif ( $cmds eq "pwd") { + $result->{data}->{guestAccess}->{psk} = $paraPos{$cmds}; + } elsif ( $cmds eq "wlan") { + $result->{data}->{guestAccess}->{isEnabled} = $paraPos{$cmds} eq "on" ? 1 : 0; + } elsif ( $cmds eq "mode") { + $result->{data}->{guestAccess}->{mode} = $paraPos{$cmds} eq "public" ? 2 : 1; + } elsif ( $cmds eq "tmo") { + $result->{data}->{guestAccess}->{timeout} = "$paraPos{$cmds}"; + $result->{data}->{guestAccess}->{isTimeoutActive} = 1; + } elsif ( $cmds eq "tmoActive") { + $result->{data}->{guestAccess}->{isTimeoutActive} = $paraPos{$cmds} eq "on" ? 1 : 0; + } elsif ( $cmds eq "tmoNoForcedOff") { + $result->{data}->{guestAccess}->{timeoutNoForcedOff} = $paraPos{$cmds} eq "on" ? 1 : 0; + } + } + + @webCmdArray = (); + + push @webCmdArray, "xhr" => "1"; + push @webCmdArray, "lang" => "de"; + push @webCmdArray, "page" => "wGuest"; + push @webCmdArray, "apply" => ""; + push @webCmdArray, "isEnabled" => $result->{data}->{guestAccess}->{isEnabled}; + push @webCmdArray, "mode" => $result->{data}->{guestAccess}->{mode}; + push @webCmdArray, "ssid" => $result->{data}->{guestAccess}->{ssid}; + push @webCmdArray, "encryption" => $result->{data}->{guestAccess}->{encryption}; + push @webCmdArray, "psk" => $result->{data}->{guestAccess}->{psk}; + push @webCmdArray, "notification" => $result->{data}->{guestAccess}->{notification}; + push @webCmdArray, "isTimeoutActive" => $result->{data}->{guestAccess}->{isTimeoutActive}; + push @webCmdArray, "timeout" => $result->{data}->{guestAccess}->{timeout}; + push @webCmdArray, "timeoutNoForcedOff" => $result->{data}->{guestAccess}->{timeoutNoForcedOff}; + push @webCmdArray, "isolated" => $result->{data}->{guestAccess}->{isolated}; + push @webCmdArray, "guestGroupAccess" => $result->{data}->{guestAccess}->{guestGroupAccess}; + push @webCmdArray, "guestAccessType" => $result->{data}->{guestAccess}->{guestAccessType} if $result->{data}->{guestAccess}->{guestAccessType}; + push @webCmdArray, "guestAccessActive" => $result->{data}->{guestAccess}->{guestAccessActive} if $result->{data}->{guestAccess}->{guestAccessActive}; + push @webCmdArray, "lPEnabled" => $result->{data}->{guestAccess}->{lPEnabled}; + push @webCmdArray, "lPReguire" => $result->{data}->{guestAccess}->{lPReguire}; + push @webCmdArray, "lPTxt" => $result->{data}->{guestAccess}->{lPTxt}; + push @webCmdArray, "lPRedirect" => $result->{data}->{guestAccess}->{lPRedirect}; + push @webCmdArray, "lPRedirectUrl" => $result->{data}->{guestAccess}->{lPRedirectUrl}; + push @webCmdArray, "isOWEEnabled" => $result->{data}->{guestAccess}->{isOWEEnabled}; + push @webCmdArray, "isOWESupported" => $result->{data}->{guestAccess}->{isOWESupported}; + +# FRITZBOX_Log $hash, 3, "data.lua isEnabled: " . $result->{data}->{guestAccess}->{isEnabled}; +# FRITZBOX_Log $hash, 3, "data.lua mode: " . $result->{data}->{guestAccess}->{mode}; +# FRITZBOX_Log $hash, 3, "data.lua ssid: " . $result->{data}->{guestAccess}->{ssid}; +# FRITZBOX_Log $hash, 3, "data.lua encryption: " . $result->{data}->{guestAccess}->{encryption}; +# FRITZBOX_Log $hash, 3, "data.lua psk: " . $result->{data}->{guestAccess}->{psk}; +# FRITZBOX_Log $hash, 3, "data.lua notification: " . $result->{data}->{guestAccess}->{notification}; +# FRITZBOX_Log $hash, 3, "data.lua isTimeoutActive: " . $result->{data}->{guestAccess}->{isTimeoutActive}; +# FRITZBOX_Log $hash, 3, "data.lua timeout: " . $result->{data}->{guestAccess}->{timeout}; +# FRITZBOX_Log $hash, 3, "data.lua timeoutNoForcedOff: " . $result->{data}->{guestAccess}->{timeoutNoForcedOff}; +# FRITZBOX_Log $hash, 3, "data.lua isolated: " . $result->{data}->{guestAccess}->{isolated}; +# FRITZBOX_Log $hash, 3, "data.lua guestGroupAccess: " . $result->{data}->{guestAccess}->{guestGroupAccess}; +# FRITZBOX_Log $hash, 3, "data.lua guestAccessType: " . $result->{data}->{guestAccess}->{guestAccessType} if $result->{data}->{guestAccess}->{guestAccessType}; +# FRITZBOX_Log $hash, 3, "data.lua guestAccessActive: " . $result->{data}->{guestAccess}->{guestAccessActive} if $result->{data}->{guestAccess}->{guestAccessActive}; +# FRITZBOX_Log $hash, 3, "data.lua lPEnabled: " . $result->{data}->{guestAccess}->{lPEnabled}; +# FRITZBOX_Log $hash, 3, "data.lua lPReguire: " . $result->{data}->{guestAccess}->{lPReguire}; +# FRITZBOX_Log $hash, 3, "data.lua lPTxt: " . $result->{data}->{guestAccess}->{lPTxt}; +# FRITZBOX_Log $hash, 3, "data.lua lPRedirect: " . $result->{data}->{guestAccess}->{lPRedirect}; +# FRITZBOX_Log $hash, 3, "data.lua lPRedirectUrl: " . $result->{data}->{guestAccess}->{lPRedirectUrl}; +# FRITZBOX_Log $hash, 3, "data.lua isOWEEnabled: " . $result->{data}->{guestAccess}->{isOWEEnabled}; +# FRITZBOX_Log $hash, 3, "data.lua isOWESupported: " . $result->{data}->{guestAccess}->{isOWESupported}; + +# xhr 1 lang de page wGuest apply nop isEnabled 0 mode 1 ssid Unser oeffentliches WLAN encryption 6 psk Unser01GastZugang notification 1 isTimeoutActive 0 timeout 30 timeoutNoForcedOff 0 isolated 1 guestGroupAccess 0 lPEnabled 0 lPReguire 0 lPTxt nop lPRedirect 0 lPRedirectUrl nop isOWEEnabled 0 isOWESupported 1 + + FRITZBOX_Log $hash, 4, "data.lua change: \n" . join(" ", @webCmdArray); + + $result = FRITZBOX_read_LuaData($hash, "data", \@webCmdArray); + + # Abbruch wenn Fehler beim Lesen der Fritzbox-Antwort + if ( defined $result->{Error} || defined $result->{AuthorizationRequired}) { + FRITZBOX_Log $hash, 2, "setting wakeUpCall: " . $result->{Error}; + FRITZBOX_Readout_Add_Reading $hash, \@roReadings, "retStat_wlanGuestParams", "->ERROR: " . $result->{Error}; + return FRITZBOX_Readout_Response($hash, $result, \@roReadings, 2); + } + + $sidNew += $result->{sidNew} if defined $result->{sidNew}; + + if (defined $result->{data}->{apply}) { + if ($result->{data}->{apply} eq "ok") { + FRITZBOX_Readout_Add_Reading $hash, \@roReadings, "retStat_wlanGuestParams", "done"; + } else { + my $applyError = $result->{data}->{apply}; + $applyError .= " - " . $result->{data}->{$result->{data}->{apply}}->{result} if $result->{data}->{$result->{data}->{apply}}->{result}; + $applyError .= " - " . $result->{data}->{$result->{data}->{apply}}->{tomark}[0] if $result->{data}->{$result->{data}->{apply}}->{tomark}[0]; + $applyError .= " - " . $result->{data}->{$result->{data}->{apply}}->{alert} if $result->{data}->{$result->{data}->{apply}}->{alert}; + FRITZBOX_Readout_Add_Reading $hash, \@roReadings, "retStat_wlanGuestParams", $applyError; + } + } else { + FRITZBOX_Readout_Add_Reading $hash, \@roReadings, "retStat_wlanGuestParams", "no apply result"; + } + + # Ende und Rückkehr zum Hauptprozess + push @roReadings, "readoutTime", sprintf( "%.2f", time()-$startTime); + return FRITZBOX_Readout_Response($hash, $result, \@roReadings, 2, $sidNew); + +} # end FRITZBOX_Set_Wlan_Guest_Name + ####################################################################### sub FRITZBOX_Set_macFilter_OnOff($) { @@ -6608,14 +7459,9 @@ sub FRITZBOX_Set_macFilter_OnOff($) push @webCmdArray, "lang" => "de"; push @webCmdArray, "page" => "wKey"; - my @fwV = split(/\./, ReadingsVal($name, "box_fwVersion", "0.0.0.error")); + FRITZBOX_Log $hash, 4, "set $name $cmd (Fritz!OS: $hash->{fhem}{fwVersionStr})"; - my $FW1 = substr($fwV[1],0,2); - my $FW2 = substr($fwV[2],0,2); - - FRITZBOX_Log $hash, 4, "set $name $cmd (Fritz!OS: $FW1.$FW2)"; - - FRITZBOX_Log $hash, 5, "set $name $cmd " . join(" ", @webCmdArray); + FRITZBOX_Log $hash, 4, "set $name $cmd " . join(" ", @webCmdArray); $result = FRITZBOX_read_LuaData($hash, "data", \@webCmdArray) ; @@ -6686,7 +7532,7 @@ sub FRITZBOX_Set_rescan_Neighborhood($) push @webCmdArray, "lang" => "de"; push @webCmdArray, "page" => "chan"; - FRITZBOX_Log $hash, 5, "data.lua: \n" . join(" ", @webCmdArray); + FRITZBOX_Log $hash, 4, "data.lua: \n" . join(" ", @webCmdArray); $result = FRITZBOX_read_LuaData($hash, "data", \@webCmdArray) ; @@ -6769,7 +7615,7 @@ sub FRITZBOX_Set_change_Profile($) push @webCmdArrayP, "lang" => "de"; push @webCmdArrayP, "page" => "kidPro"; - FRITZBOX_Log $hash, 5, "get $name $cmd " . join(" ", @webCmdArrayP); + FRITZBOX_Log $hash, 4, "get $name $cmd " . join(" ", @webCmdArrayP); $result = FRITZBOX_read_LuaData($hash, "data", \@webCmdArrayP) ; @@ -6787,7 +7633,7 @@ sub FRITZBOX_Set_change_Profile($) eval { foreach my $key (keys %$views) { - FRITZBOX_Log $hash, 5, "Kid Profiles: ".$key; + FRITZBOX_Log $hash, 4, "Kid Profiles: ".$key; if ($result->{data}->{kidProfiles}->{$key}{Id} eq $val[1]) { $ProfileOK = "true"; last; @@ -6817,12 +7663,7 @@ sub FRITZBOX_Set_change_Profile($) if($lanDevice_Info->{data}->{vars}->{dev}->{UID} eq $val[0]) { - my @fwV = split(/\./, ReadingsVal($name, "box_fwVersion", "0.0.0.error")); - - my $FW1 = substr($fwV[1],0,2); - my $FW2 = substr($fwV[2],0,2); - - FRITZBOX_Log $hash, 4, "set $name $cmd (Fritz!OS: $FW1.$FW2)"; + FRITZBOX_Log $hash, 4, "set $name $cmd (Fritz!OS: $hash->{fhem}{fwVersionStr})"; push @webCmdArray, "xhr" => "1"; push @webCmdArray, "dev_name" => $lanDevice_Info->{data}->{vars}->{dev}->{name}->{displayName}; @@ -6838,15 +7679,15 @@ sub FRITZBOX_Set_change_Profile($) push @webCmdArray, "static_dhcp" => "off"; } - if ($FW1 <= 7 && $FW2 < 21) { + if ($hash->{fhem}{fwVersion} < 721) { push @webCmdArray, "page" => "edit_device"; - } elsif ($FW1 >= 7 && $FW2 < 50) { + } elsif ($hash->{fhem}{fwVersion} >= 700 && $hash->{fhem}{fwVersion} < 750) { push @webCmdArray, "page" => "edit_device2"; } else { push @webCmdArray, "page" => "edit_device"; } - if ($FW1 <= 7 && $FW2 < 50) { + if ($hash->{fhem}{fwVersion} < 750) { push @webCmdArray, "dev_ip3" => (split(/\./, $lanDevice_Info->{data}->{vars}->{dev}->{ipv4}->{current}->{ip}))[3]; if ($lanDevice_Info->{data}->{vars}->{dev}->{portForwarding}->{allowForwarding} eq "true") { @@ -6888,7 +7729,7 @@ sub FRITZBOX_Set_change_Profile($) push @webCmdArray, "apply" => "true"; } - FRITZBOX_Log $hash, 5, "get $name $cmd " . join(" ", @webCmdArray); + FRITZBOX_Log $hash, 4, "get $name $cmd " . join(" ", @webCmdArray); $result = FRITZBOX_read_LuaData($hash, "data", \@webCmdArray) ; @@ -6896,7 +7737,7 @@ sub FRITZBOX_Set_change_Profile($) if ( defined $result->{Error} || defined $result->{AuthorizationRequired}) { FRITZBOX_Log $hash, 2, "changing Kid Profile: " . $result->{Error}; FRITZBOX_Readout_Add_Reading $hash, \@roReadings, "retStat_chgProfile", $val[1] . "->ERROR: " . $result->{Error}; - FRITZBOX_Readout_Response($hash, $result, \@roReadings, 2); + return FRITZBOX_Readout_Response($hash, $result, \@roReadings, 2); } $sidNew += $result->{sidNew} if defined $result->{sidNew}; @@ -6918,7 +7759,7 @@ sub FRITZBOX_Set_change_Profile($) } # Ende und Rückkehr zum Hauptprozess - push @roReadings, "readoutTime", sprintf( "%.2f", time()-$startTime); + push @roReadings, "readoutTime", sprintf( "%.2f", time() - $startTime); return FRITZBOX_Readout_Response($hash, $result, \@roReadings, 2, $sidNew); } # end FRITZBOX_Set_change_Profile @@ -6947,79 +7788,75 @@ sub FRITZBOX_Set_enable_VPNshare_OnOff($) $result = FRITZBOX_call_Lua_Query( $hash, $queryStr) ; # Abbruch wenn Fehler beim Lesen der Fritzbox-Antwort - if ( defined $result->{Error} ) { - FRITZBOX_Log $hash, 2, "evaluating $val[0] -> general error: " . $result->{Error}; + if ( defined $result->{Error} || defined $result->{AuthorizationRequired}) { + FRITZBOX_Log $hash, 2, "enable_VPNshare: " . $result->{Error}; FRITZBOX_Readout_Add_Reading $hash, \@roReadings, "retStat_enableVPNshare", $val[0] . "->ERROR: " . $result->{Error}; - } elsif ( defined $result->{AuthorizationRequired} ) { - FRITZBOX_Log $hash, 2, "evaluating vpn$val[0] -> AuthorizationRequired"; - FRITZBOX_Readout_Add_Reading $hash, \@roReadings, "retStat_enableVPNshare", $val[0] . "->ERROR: AuthorizationRequired"; - } else { + return FRITZBOX_Readout_Response($hash, $result, \@roReadings, 2); + } - my $vpnok = 0; - my $vpnShare = substr($val[0],3); + my $vpnok = 0; + my $vpnShare = substr($val[0],3); - foreach ( @{ $result->{vpn_info} } ) { - $_->{_node} =~ m/(\d+)/; - if ( $1 == $vpnShare) { - $vpnok = 1; - last; - } - } - - if ($vpnok == 0){ - FRITZBOX_Log $hash, 2, "vo valid " . $val[0] . " found"; - FRITZBOX_Readout_Add_Reading $hash, \@roReadings, "retStat_enableVPNshare", $val[0] . "->ERROR: not found"; - } else { - FRITZBOX_Log $hash, 4, "set $name $cmd " . join(" ", @val); - - my $state = $val[1] eq "on"?"1":"0"; - - #xhr 1 connection0 on active_connection0 1 apply nop lang de page shareVpn - - push @webCmdArray, "xhr" => "1"; - push @webCmdArray, "lang" => "de"; - push @webCmdArray, "page" => "shareVpn"; - push @webCmdArray, "apply" => ""; - push @webCmdArray, "connection".$vpnShare => $val[1]; - push @webCmdArray, "active_connection".$vpnShare => $state; - - FRITZBOX_Log $hash, 5, "data.lua: \n" . join(" ", @webCmdArray); - - $result = FRITZBOX_read_LuaData($hash, "data", \@webCmdArray) ; - - if(defined $result->{Error}) { - FRITZBOX_Log $hash, 2, "enable $val[0] share: " . $result->{Error}; - FRITZBOX_Readout_Add_Reading $hash, \@roReadings, "retStat_enableVPNshare", $val[0] . "->ERROR: " . $result->{Error}; - } else { - - $queryStr = "&vpn_info=vpn:settings/connection$vpnShare/activated"; - my $vpnState = FRITZBOX_call_Lua_Query( $hash, $queryStr) ; - - FRITZBOX_Log $hash, 5, "$vpnState->{vpn_info} \n" . Dumper $vpnState; - - if(defined $vpnState->{Error}) { - FRITZBOX_Log $hash, 2, "enable $val[0] share: " . $vpnState->{Error}; - FRITZBOX_Readout_Add_Reading $hash, \@roReadings, "retStat_enableVPNshare", $val[0] . "->ERROR: " . $vpnState->{Error}; - } elsif ($vpnState->{vpn_info} != $state) { - FRITZBOX_Log $hash, 2, "VPNshare " . $val[0] . " not set to " . $val[1] . " <> " . $vpnState->{vpn_info}; - FRITZBOX_Readout_Add_Reading $hash, \@roReadings, "retStat_enableVPNshare", $val[0] . "->ERROR: " . $vpnState->{vpn_info}; - } else { - FRITZBOX_Log $hash, 4, "VPNshare " . $val[0] . " set to " . $val[1]; - FRITZBOX_Readout_Add_Reading $hash, \@roReadings, "retStat_enableVPNshare", $val[0] . "->" . $val[1]; - FRITZBOX_Readout_Add_Reading $hash, \@roReadings, $val[0] . "_activated", $vpnState->{vpn_info}; - } - } + foreach ( @{ $result->{vpn_info} } ) { + $_->{_node} =~ m/(\d+)/; + if ( $1 == $vpnShare) { + $vpnok = 1; + last; } } - FRITZBOX_Readout_Add_Reading $hash, \@roReadings, "fhem->sid", $result->{sid} if $result->{sid}; - FRITZBOX_Readout_Add_Reading $hash, \@roReadings, "fhem->sidTime", time(); - FRITZBOX_Readout_Add_Reading $hash, \@roReadings, "fhem->sidErrCount", 0; - FRITZBOX_Readout_Add_Reading $hash, \@roReadings, "readoutTime", sprintf( "%.2f", time()-$startTime); + if ($vpnok == 0){ + FRITZBOX_Log $hash, 2, "vo valid " . $val[0] . " found"; + FRITZBOX_Readout_Add_Reading $hash, \@roReadings, "retStat_enableVPNshare", $val[0] . "->ERROR: not found"; + } else { + FRITZBOX_Log $hash, 4, "set $name $cmd " . join(" ", @val); - my $returnStr = join('|', @roReadings ); - FRITZBOX_Log $hash, 5, "Handover to main process: " . $returnStr; - return $name . "|2|" . encode_base64($returnStr,""); + my $state = $val[1] eq "on"?"1":"0"; + + #xhr 1 connection0 on active_connection0 1 apply nop lang de page shareVpn + + push @webCmdArray, "xhr" => "1"; + push @webCmdArray, "lang" => "de"; + push @webCmdArray, "page" => "shareVpn"; + push @webCmdArray, "apply" => ""; + push @webCmdArray, "connection".$vpnShare => $val[1]; + push @webCmdArray, "active_connection".$vpnShare => $state; + + FRITZBOX_Log $hash, 4, "data.lua: \n" . join(" ", @webCmdArray); + + $result = FRITZBOX_read_LuaData($hash, "data", \@webCmdArray) ; + + # Abbruch wenn Fehler beim Lesen der Fritzbox-Antwort + if ( defined $result->{Error} || defined $result->{AuthorizationRequired}) { + FRITZBOX_Log $hash, 2, "enable_VPNshare: " . $result->{Error}; + FRITZBOX_Readout_Add_Reading $hash, \@roReadings, "retStat_enableVPNshare", $val[0] . "->ERROR: " . $result->{Error}; + return FRITZBOX_Readout_Response($hash, $result, \@roReadings, 2); + } + + $queryStr = "&vpn_info=vpn:settings/connection$vpnShare/activated"; + my $vpnState = FRITZBOX_call_Lua_Query( $hash, $queryStr) ; + + FRITZBOX_Log $hash, 5, "$vpnState->{vpn_info} \n" . Dumper $vpnState; + + # Abbruch wenn Fehler beim Lesen der Fritzbox-Antwort + if ( defined $result->{Error} || defined $result->{AuthorizationRequired}) { + FRITZBOX_Log $hash, 2, "enable_VPNshare: " . $result->{Error}; + FRITZBOX_Readout_Add_Reading $hash, \@roReadings, "retStat_enableVPNshare", $val[0] . "->ERROR: " . $result->{Error}; + return FRITZBOX_Readout_Response($hash, $result, \@roReadings, 2); + } + + if ($vpnState->{vpn_info} != $state) { + FRITZBOX_Log $hash, 2, "VPNshare " . $val[0] . " not set to " . $val[1] . " <> " . $vpnState->{vpn_info}; + FRITZBOX_Readout_Add_Reading $hash, \@roReadings, "retStat_enableVPNshare", $val[0] . "->ERROR: " . $vpnState->{vpn_info}; + } else { + FRITZBOX_Log $hash, 4, "VPNshare " . $val[0] . " set to " . $val[1]; + FRITZBOX_Readout_Add_Reading $hash, \@roReadings, "retStat_enableVPNshare", $val[0] . "->" . $val[1]; + FRITZBOX_Readout_Add_Reading $hash, \@roReadings, $val[0] . "_activated", $vpnState->{vpn_info}; + } + } + + FRITZBOX_Readout_Add_Reading $hash, \@roReadings, "readoutTime", sprintf( "%.2f", time()-$startTime); + return FRITZBOX_Readout_Response($hash, $result, \@roReadings, 2); } # end FRITZBOX_Set_enable_VPNshare_OnOff @@ -7030,8 +7867,10 @@ sub FRITZBOX_Set_lock_Landevice_OnOffRt($) my ($name, $cmd, @val) = split "\\|", $string; my $hash = $defs{$name}; my $result; + my $sidNew = 0; my @webCmdArray; my @roReadings; + my $jsonMsgId; my $startTime = time(); # xhr 1 @@ -7048,18 +7887,14 @@ sub FRITZBOX_Set_lock_Landevice_OnOffRt($) push @webCmdArray, "dev" => $val[0]; push @webCmdArray, "lang" => "de"; - my @fwV = split(/\./, ReadingsVal($name, "box_fwVersion", "0.0.0.error")); - - my $FW1 = substr($fwV[1],0,2); - my $FW2 = substr($fwV[2],0,2); my $dev_name = $hash->{fhem}->{landevice}->{$val[0]}; - FRITZBOX_Log $hash, 4, "set $name $cmd (Fritz!OS$FW1.$FW2)"; + FRITZBOX_Log $hash, 4, "set $name $cmd (Fritz!OS: $hash->{fhem}{fwVersionStr})"; - if ($FW1 <= 7 && $FW2 < 21) { + if ($hash->{fhem}{fwVersion} < 721) { push @webCmdArray, "page" => "edit_device2"; push @webCmdArray, "block_dev" => ""; - } elsif ($FW1 >= 7 && $FW2 < 50) { + } elsif ($hash->{fhem}{fwVersion} >= 700 && $hash->{fhem}{fwVersion} < 750) { push @webCmdArray, "page" => "edit_device"; push @webCmdArray, "block_dev" => ""; } else { @@ -7075,54 +7910,98 @@ sub FRITZBOX_Set_lock_Landevice_OnOffRt($) push @webCmdArray, "dev_name" => "$dev_name"; } + # Abfrage, ob Anforderung ungleich Istzustand my $lock_res = FRITZBOX_Get_Lan_Device_Info( $hash, $val[0], "lockLandevice"); - # FRITZBOX_Log $hash, 3, "Lan_Device_Info $name $cmd " . $lock_res; - - unless (($lock_res =~ /blocked/ && $val[1] eq "on") || ($lock_res =~ /unlimited|limited/ && $val[1] eq "off") || ($lock_res =~ /realtime/ && $val[1] eq "rt")) { - - FRITZBOX_Log $hash, 5, "get $name $cmd " . join(" ", @webCmdArray); - - my $result = FRITZBOX_read_LuaData($hash, "data", \@webCmdArray); - - my $analyse = FRITZBOX_Helper_analyse_Lua_Result($hash, $result); - - if ( $analyse =~ /ERROR/) { - FRITZBOX_Log $hash, 2, "lockLandevice status: " . $analyse; - FRITZBOX_Readout_Add_Reading $hash, \@roReadings, "retStat_lockLandevice", $val[0] . "->ERROR: " . $analyse; - - } else { - - $lock_res = FRITZBOX_Get_Lan_Device_Info( $hash, $val[0], "lockLandevice"); - # FRITZBOX_Log $hash, 3, "Lan_Device_Info $name $cmd " . $lock_res; - - if ($lock_res =~ /ERROR/) { - FRITZBOX_Log $hash, 2, "setting locklandevice: " . substr($lock_res, 7); - FRITZBOX_Readout_Add_Reading $hash, \@roReadings, "retStat_lockLandevice", $val[0] . "->ERROR:" . substr($lock_res, 7); - } else { - - unless (($lock_res =~ /blocked/ && $val[1] eq "on") || ($lock_res =~ /unlimited|limited/ && $val[1] eq "off") || ($lock_res =~ /realtime/ && $val[1] eq "rt")) { - FRITZBOX_Log $hash, 2, "setting locklandevice: " . $val[0]; - FRITZBOX_Readout_Add_Reading $hash, \@roReadings, "retStat_lockLandevice", $val[0] . "->ERROR: setting locklandevice " . $val[1]; - } else { - FRITZBOX_Log $hash, 4, "" . $lock_res . " -> $name $cmd $val[1]"; - FRITZBOX_Readout_Add_Reading $hash, \@roReadings, "retStat_lockLandevice", $val[0] . "->" . $val[1]; - } - } - } - } else { - FRITZBOX_Log $hash, 4, "" . $lock_res . " -> $name $cmd $val[1]"; - FRITZBOX_Readout_Add_Reading $hash, \@roReadings, "retStat_lockLandevice", $val[0] . " locked is " . $val[1]; + # Abbruch wenn Fehler beim Lesen der Fritzbox-Antwort + if ( defined $lock_res->{Error} || defined $lock_res->{AuthorizationRequired}) { + FRITZBOX_Log $hash, 2, "locklandevice: " . $lock_res->{Error}; + FRITZBOX_Readout_Add_Reading $hash, \@roReadings, "retStat_lockLandevice", $val[1] . "->ERROR: " . $lock_res->{Error}; + return FRITZBOX_Readout_Response($hash, $lock_res, \@roReadings, 2); } - FRITZBOX_Readout_Add_Reading $hash, \@roReadings, "fhem->sid", $result->{sid} if $result->{sid}; - FRITZBOX_Readout_Add_Reading $hash, \@roReadings, "fhem->sidTime", time(); - FRITZBOX_Readout_Add_Reading $hash, \@roReadings, "fhem->sidErrCount", 0; - FRITZBOX_Readout_Add_Reading $hash, \@roReadings, "readoutTime", sprintf( "%.2f", time()-$startTime); + $sidNew += $lock_res->{sidNew} if defined $lock_res->{sidNew}; - $returnStr = join('|', @roReadings ); - FRITZBOX_Log $hash, 5, "Handover to main process: " . $returnStr; - return $name . "|2|" . encode_base64($returnStr,""); + FRITZBOX_Log $hash, 5, "\n" . Dumper $lock_res; + + unless ($lock_res->{data}->{vars}->{dev}->{netAccess}->{kisi}->{selectedRights}->{msgid}) { + + FRITZBOX_Log $hash, 2, "setting locklandevice: " . substr($lock_res, 7); + FRITZBOX_Readout_Add_Reading $hash, \@roReadings, "retStat_lockLandevice", $val[0] . "->ERROR:" . substr($lock_res, 7); + + } else { + + $jsonMsgId = $lock_res->{data}->{vars}->{dev}->{netAccess}->{kisi}->{selectedRights}->{msgid}; + + # wenn Anforderung ungleich Istzustand + unless (($jsonMsgId =~ /blocked/ && $val[1] eq "on") || ($jsonMsgId =~ /unlimited|limited/ && $val[1] eq "off") || ($jsonMsgId =~ /realtime/ && $val[1] eq "rt")) { + + FRITZBOX_Log $hash, 4, "get $name $cmd " . join(" ", @webCmdArray); + + # Anforderung umsetzen + my $result = FRITZBOX_read_LuaData($hash, "data", \@webCmdArray); + + # Abbruch wenn Fehler beim Lesen der Fritzbox-Antwort + if ( defined $result->{Error} || defined $result->{AuthorizationRequired}) { + FRITZBOX_Log $hash, 2, "locklandevice: " . $result->{Error}; + FRITZBOX_Readout_Add_Reading $hash, \@roReadings, "retStat_lockLandevice", $val[1] . "->ERROR: " . $result->{Error}; + FRITZBOX_Readout_Response($hash, $result, \@roReadings, 2); + } + + $sidNew += $result->{sidNew} if defined $result->{sidNew}; + + my $analyse = FRITZBOX_Helper_analyse_Lua_Result($hash, $result); + + if ( $analyse =~ /ERROR/) { + FRITZBOX_Log $hash, 2, "lockLandevice status: " . $analyse; + FRITZBOX_Readout_Add_Reading $hash, \@roReadings, "retStat_lockLandevice", $val[0] . "->ERROR: " . $analyse; + + } else { + + FRITZBOX_Readout_Add_Reading $hash, \@roReadings, "fhem->sid", $result->{sid} if $result->{sid}; + FRITZBOX_Readout_Add_Reading $hash, \@roReadings, "fhem->sidTime", time(); + FRITZBOX_Readout_Add_Reading $hash, \@roReadings, "fhem->sidErrCount", 0; + + # Prüfen, ob Anforderung umgesetzt worden ist + $lock_res = FRITZBOX_Get_Lan_Device_Info( $hash, $val[0], "lockLandevice"); + + # Abbruch wenn Fehler beim Lesen der Fritzbox-Antwort + if ( defined $lock_res->{Error} || defined $lock_res->{AuthorizationRequired}) { + FRITZBOX_Log $hash, 2, "lockLandevice: " . $lock_res->{Error}; + FRITZBOX_Readout_Add_Reading $hash, \@roReadings, "retStat_lockLandevice", $val[1] . "->ERROR: " . $lock_res->{Error}; + return FRITZBOX_Readout_Response($hash, $lock_res, \@roReadings, 2); + } + + $sidNew += $lock_res->{sidNew} if defined $lock_res->{sidNew}; + + FRITZBOX_Log $hash, 5, "\n" . Dumper $lock_res; + + unless ($lock_res->{data}->{vars}->{dev}->{netAccess}->{kisi}->{selectedRights}->{msgid}) { + + FRITZBOX_Log $hash, 2, "setting locklandevice: " . substr($lock_res, 7); + FRITZBOX_Readout_Add_Reading $hash, \@roReadings, "retStat_lockLandevice", $val[0] . "->ERROR:" . substr($lock_res, 7); + + } else { + + $jsonMsgId = $lock_res->{data}->{vars}->{dev}->{netAccess}->{kisi}->{selectedRights}->{msgid}; + + unless (($jsonMsgId =~ /blocked/ && $val[1] eq "on") || ($jsonMsgId =~ /unlimited|limited/ && $val[1] eq "off") || ($jsonMsgId =~ /realtime/ && $val[1] eq "rt")) { + FRITZBOX_Log $hash, 2, "setting locklandevice: " . $val[0]; + FRITZBOX_Readout_Add_Reading $hash, \@roReadings, "retStat_lockLandevice", $val[0] . "->ERROR: setting locklandevice " . $val[1]; + } else { + FRITZBOX_Log $hash, 4, "" . $lock_res . " -> $name $cmd $val[1]"; + FRITZBOX_Readout_Add_Reading $hash, \@roReadings, "retStat_lockLandevice", $val[0] . "->" . $val[1]; + } + } + } + } else { + FRITZBOX_Log $hash, 4, "" . $jsonMsgId . " -> $name $cmd $val[1]"; + FRITZBOX_Readout_Add_Reading $hash, \@roReadings, "retStat_lockLandevice", $val[0] . " locked is " . $val[1]; + } + } + + FRITZBOX_Readout_Add_Reading $hash, \@roReadings, "readoutTime", sprintf( "%.2f", time()-$startTime); + return FRITZBOX_Readout_Response($hash, $result, \@roReadings, 2); } # end FRITZBOX_Set_lock_Landevice_OnOffRt @@ -7135,23 +8014,11 @@ sub FRITZBOX_Set_call_Phone($) FRITZBOX_Log $hash, 4, "set $name " . join(" ", @val); - unless (int @val) { - FRITZBOX_Log $hash, 4, "At least one parameter must be defined."; - return "$name|0|Error: At least one parameter must be defined." - } - my $result; my @tr064CallArray; my $duration = 60; + my $extNo = $val[0]; - - # Check if 1st parameter is a valid number - - unless ($extNo =~ /^[\d\*\#+,]+$/) { - FRITZBOX_Log $hash, 4, "Parameter '$extNo' not a valid phone number."; - return $name."|0|Error: Parameter '$extNo' not a valid phone number" - } - $extNo =~ s/#$//; # Check if 2nd parameter is the duration @@ -7173,7 +8040,9 @@ sub FRITZBOX_Set_call_Phone($) FRITZBOX_Log $hash, 4, "result of calling number $extNo -> " . $result; } else { - FRITZBOX_Log $hash, 3, "Your Fritz!OS version has limited interfaces. You cannot use call."; + my $msg = "ERROR (set call): TR064 SECPORT not available for calling "; + FRITZBOX_Log $hash, 2, $msg; + return $name . "|0|" . $msg } FRITZBOX_Log $hash, 4, "waiting"; @@ -7187,7 +8056,7 @@ sub FRITZBOX_Set_call_Phone($) FRITZBOX_Log $hash, 4, "result of stop ringing number $extNo -> ". $result; } - return $name."|1|Calling done"; + return $name . "|1|Calling done"; } # end FRITZBOX_Set_call_Phone @@ -7207,46 +8076,64 @@ sub FRITZBOX_Set_GuestWlan_OnOff($) $state =~ s/on/1/; $state =~ s/off/0/; -# Set guestWLAN, if necessary set also WLAN + # Set guestWLAN, if necessary set also WLAN if ( $hash->{SECPORT} ) { #TR-064 - if ($state == 1) { # WLAN on when Guest WLAN on - push @tr064CmdArray, ["WLANConfiguration:2", "wlanconfig2", "SetEnable", "NewEnable", "1"] - if $hash->{fhem}{is_double_wlan} == 1; - push @tr064CmdArray, ["WLANConfiguration:1", "wlanconfig1", "SetEnable", "NewEnable", "1"]; - } - my $gWlanNo = 2; - $gWlanNo = 3 if $hash->{fhem}{is_double_wlan} == 1; - push @tr064CmdArray, ["WLANConfiguration:".$gWlanNo, "wlanconfig".$gWlanNo, "SetEnable", "NewEnable", $state]; - $result = FRITZBOX_call_TR064_Cmd( $hash, 0, \@tr064CmdArray ); - FRITZBOX_Log $hash, 5, "switch GuestWLAN: " . $result; - } - else { #no API - FRITZBOX_Log $hash, 2, "No API available to switch WLAN."; - } + if ($state == 1) { # WLAN on when Guest WLAN on + push @tr064CmdArray, ["WLANConfiguration:2", "wlanconfig2", "SetEnable", "NewEnable", "1"] + if $hash->{fhem}{is_double_wlan} == 1; -# Read WLAN-Status - my $queryStr = "&box_wlan_24GHz=wlan:settings/ap_enabled"; # WLAN - $queryStr .= "&box_wlan_5GHz=wlan:settings/ap_enabled_scnd"; # 2nd WLAN - $queryStr .= "&box_guestWlan=wlan:settings/guest_ap_enabled"; # Gäste WLAN - $queryStr .= "&box_guestWlanRemain=wlan:settings/guest_time_remain"; - $queryStr .= "&box_macFilter_active=wlan:settings/is_macfilter_active"; + push @tr064CmdArray, ["WLANConfiguration:1", "wlanconfig1", "SetEnable", "NewEnable", "1"]; + } - $result = FRITZBOX_call_Lua_Query( $hash, $queryStr) ; + my $gWlanNo = 2; + $gWlanNo = 3 if $hash->{fhem}{is_double_wlan} == 1; + push @tr064CmdArray, ["WLANConfiguration:".$gWlanNo, "wlanconfig".$gWlanNo, "SetEnable", "NewEnable", $state]; - if ( defined $result->{Error} ) { - FRITZBOX_Log $hash, 2, "".$result->{Error}; - } else { + my @tr064Result = FRITZBOX_call_TR064_Cmd( $hash, 0, \@tr064CmdArray ); - FRITZBOX_Readout_Add_Reading $hash, \@roReadings, "box_wlan_2.4GHz", $result->{box_wlan_24GHz}, "onoff"; - FRITZBOX_Readout_Add_Reading $hash, \@roReadings, "box_wlan_5GHz", $result->{box_wlan_5GHz}, "onoff"; - FRITZBOX_Readout_Add_Reading $hash, \@roReadings, "box_guestWlan", $result->{box_guestWlan}, "onoff"; - FRITZBOX_Readout_Add_Reading $hash, \@roReadings, "box_guestWlanRemain", $result->{box_guestWlanRemain}; - FRITZBOX_Readout_Add_Reading $hash, \@roReadings, "box_macFilter_active", $result->{box_macFilter_active}, "onoff"; + if( $tr064Result[0]->{Error}) { + my $msg = "set guestWlan: TR064 error switching guestWlan: $val[0]"; + FRITZBOX_Readout_Add_Reading $hash, \@roReadings, "retStat_SetGet_nonBlocking", $msg; + FRITZBOX_Log $hash, 2, $msg . " - " . $tr064Result[0]->{Error}; + } else { - FRITZBOX_Readout_Add_Reading $hash, \@roReadings, "fhem->sid", $result->{sid} if $result->{sid}; - FRITZBOX_Readout_Add_Reading $hash, \@roReadings, "fhem->sidTime", time(); - FRITZBOX_Readout_Add_Reading $hash, \@roReadings, "fhem->sidErrCount", 0; - FRITZBOX_Readout_Add_Reading $hash, \@roReadings, "readoutTime", sprintf( "%.2f", time()-$startTime); + FRITZBOX_Log $hash, 4, "switch GuestWLAN: " . $tr064Result[0]; + + # Read WLAN-Status + my $queryStr = "&box_wlan_24GHz=wlan:settings/ap_enabled"; # WLAN + $queryStr .= "&box_wlan_5GHz=wlan:settings/ap_enabled_scnd"; # 2nd WLAN + $queryStr .= "&box_guestWlan=wlan:settings/guest_ap_enabled"; # Gäste WLAN + $queryStr .= "&box_guestWlanRemain=wlan:settings/guest_time_remain"; + $queryStr .= "&box_macFilter_active=wlan:settings/is_macfilter_active"; + + $result = FRITZBOX_call_Lua_Query( $hash, $queryStr) ; + + # Abbruch wenn Fehler beim Lesen der Fritzbox-Antwort + if ( defined $result->{Error} || defined $result->{AuthorizationRequired}) { + my $msg = "set guestWlan: Lua_Query error verifying guestWlan: $val[0]"; + FRITZBOX_Readout_Add_Reading $hash, \@roReadings, "retStat_SetGet_nonBlocking", $msg; + FRITZBOX_Log $hash, 2, $msg . " - " . $result->{Error}; + + } else { + + FRITZBOX_Readout_Add_Reading $hash, \@roReadings, "box_wlan_2.4GHz", $result->{box_wlan_24GHz}, "onoff"; + FRITZBOX_Readout_Add_Reading $hash, \@roReadings, "box_wlan_5GHz", $result->{box_wlan_5GHz}, "onoff"; + FRITZBOX_Readout_Add_Reading $hash, \@roReadings, "box_guestWlan", $result->{box_guestWlan}, "onoff"; + FRITZBOX_Readout_Add_Reading $hash, \@roReadings, "box_guestWlanRemain", $result->{box_guestWlanRemain}; + FRITZBOX_Readout_Add_Reading $hash, \@roReadings, "box_macFilter_active", $result->{box_macFilter_active}, "onoff"; + + FRITZBOX_Readout_Add_Reading $hash, \@roReadings, "retStat_SetGet_nonBlocking", "set guestWlan: $val[0]"; + + FRITZBOX_Readout_Add_Reading $hash, \@roReadings, "fhem->sid", $result->{sid} if $result->{sid}; + FRITZBOX_Readout_Add_Reading $hash, \@roReadings, "fhem->sidTime", time(); + FRITZBOX_Readout_Add_Reading $hash, \@roReadings, "fhem->sidErrCount", 0; + FRITZBOX_Readout_Add_Reading $hash, \@roReadings, "readoutTime", sprintf( "%.2f", time()-$startTime); + } + } + } else { #no API + my $msg = "set guestWlan: TR064 SECPORT not available to switch WLAN."; + FRITZBOX_Log $hash, 2, $msg; + FRITZBOX_Readout_Add_Reading $hash, \@roReadings, "retStat_SetGet_nonBlocking", $msg; } my $returnStr = join('|', @roReadings ); @@ -7273,44 +8160,63 @@ sub FRITZBOX_Set_Wlan_OnOff($) # Set WLAN if ($hash->{SECPORT}) { #TR-064 - push @tr064CmdArray, ["WLANConfiguration:2", "wlanconfig2", "SetEnable", "NewEnable", $state] + + push @tr064CmdArray, ["WLANConfiguration:2", "wlanconfig2", "SetEnable", "NewEnable", $state] if $hash->{fhem}{is_double_wlan} == 1 && $cmd ne "wlan2.4"; - push @tr064CmdArray, ["WLANConfiguration:1", "wlanconfig1", "SetEnable", "NewEnable", $state] + + push @tr064CmdArray, ["WLANConfiguration:1", "wlanconfig1", "SetEnable", "NewEnable", $state] if $cmd =~ /^(wlan|wlan2\.4)$/; - FRITZBOX_Log $hash, 3, "TR-064 Command"; - $result = FRITZBOX_call_TR064_Cmd( $hash, 0, \@tr064CmdArray ); - } - else { #no API - FRITZBOX_Log $hash, 2, "No API available to switch WLAN."; - } -# Read WLAN-Status - my $queryStr = "&box_wlan_24GHz=wlan:settings/ap_enabled"; # WLAN - $queryStr .= "&box_wlan_5GHz=wlan:settings/ap_enabled_scnd"; # 2nd WLAN - $queryStr .= "&box_guestWlan=wlan:settings/guest_ap_enabled"; # Gäste WLAN - $queryStr .= "&box_guestWlanRemain=wlan:settings/guest_time_remain"; - $queryStr .= "&box_macFilter_active=wlan:settings/is_macfilter_active"; + FRITZBOX_Log $hash, 4, "TR-064 Command"; + my @tr064Result = FRITZBOX_call_TR064_Cmd( $hash, 0, \@tr064CmdArray ); - $result = FRITZBOX_call_Lua_Query( $hash, $queryStr) ; + if( $tr064Result[0]->{Error}) { + my $msg = "set $cmd: TR064 error switching $cmd: $val[0]"; + FRITZBOX_Readout_Add_Reading $hash, \@roReadings, "retStat_SetGet_nonBlocking", $msg; + FRITZBOX_Log $hash, 2, $msg . " - " . $tr064Result[0]->{Error}; + } else { - if ( defined $result->{Error} ) { - FRITZBOX_Log $hash, 2, "".$result->{Error}; - } else { - FRITZBOX_Readout_Add_Reading $hash, \@roReadings, "box_wlan_2.4GHz", $result->{box_wlan_24GHz}, "onoff"; - FRITZBOX_Readout_Add_Reading $hash, \@roReadings, "box_wlan_5GHz", $result->{box_wlan_5GHz}, "onoff"; - FRITZBOX_Readout_Add_Reading $hash, \@roReadings, "box_guestWlan", $result->{box_guestWlan}, "onoff"; - FRITZBOX_Readout_Add_Reading $hash, \@roReadings, "box_guestWlanRemain", $result->{box_guestWlanRemain}; - FRITZBOX_Readout_Add_Reading $hash, \@roReadings, "box_macFilter_active", $result->{box_macFilter_active}, "onoff"; + FRITZBOX_Log $hash, 4, "switch WLAN: " . $tr064Result[0]; - FRITZBOX_Readout_Add_Reading $hash, \@roReadings, "fhem->sid", $result->{sid} if $result->{sid}; - FRITZBOX_Readout_Add_Reading $hash, \@roReadings, "fhem->sidTime", time(); - FRITZBOX_Readout_Add_Reading $hash, \@roReadings, "fhem->sidErrCount", 0; - FRITZBOX_Readout_Add_Reading $hash, \@roReadings, "readoutTime", sprintf( "%.2f", time()-$startTime); + # Read WLAN-Status + my $queryStr = "&box_wlan_24GHz=wlan:settings/ap_enabled"; # WLAN + $queryStr .= "&box_wlan_5GHz=wlan:settings/ap_enabled_scnd"; # 2nd WLAN + $queryStr .= "&box_guestWlan=wlan:settings/guest_ap_enabled"; # Gäste WLAN + $queryStr .= "&box_guestWlanRemain=wlan:settings/guest_time_remain"; + $queryStr .= "&box_macFilter_active=wlan:settings/is_macfilter_active"; + + $result = FRITZBOX_call_Lua_Query( $hash, $queryStr) ; + + if ( defined $result->{Error} ) { + my $msg = "set $cmd: Lua_Query error verifiying $cmd: $val[0]"; + FRITZBOX_Readout_Add_Reading $hash, \@roReadings, "retStat_SetGet_nonBlocking", $msg; + FRITZBOX_Log $hash, 2, $msg . " - " . $result->{Error}; + + } else { + + FRITZBOX_Readout_Add_Reading $hash, \@roReadings, "box_wlan_2.4GHz", $result->{box_wlan_24GHz}, "onoff"; + FRITZBOX_Readout_Add_Reading $hash, \@roReadings, "box_wlan_5GHz", $result->{box_wlan_5GHz}, "onoff"; + FRITZBOX_Readout_Add_Reading $hash, \@roReadings, "box_guestWlan", $result->{box_guestWlan}, "onoff"; + FRITZBOX_Readout_Add_Reading $hash, \@roReadings, "box_guestWlanRemain", $result->{box_guestWlanRemain}; + FRITZBOX_Readout_Add_Reading $hash, \@roReadings, "box_macFilter_active", $result->{box_macFilter_active}, "onoff"; + + FRITZBOX_Readout_Add_Reading $hash, \@roReadings, "retStat_SetGet_nonBlocking", "set $cmd: $val[0]"; + + FRITZBOX_Readout_Add_Reading $hash, \@roReadings, "fhem->sid", $result->{sid} if $result->{sid}; + FRITZBOX_Readout_Add_Reading $hash, \@roReadings, "fhem->sidTime", time(); + FRITZBOX_Readout_Add_Reading $hash, \@roReadings, "fhem->sidErrCount", 0; + FRITZBOX_Readout_Add_Reading $hash, \@roReadings, "readoutTime", sprintf( "%.2f", time()-$startTime); + } + } + } else { #no API + my $msg = "set $cmd: TR064 SECPORT not available to switch WLAN."; + FRITZBOX_Log $hash, 2, $msg; + FRITZBOX_Readout_Add_Reading $hash, \@roReadings, "retStat_SetGet_nonBlocking", $msg; } my $returnStr = join('|', @roReadings ); - FRITZBOX_Log $hash, 5, "Handover to main process: ".$returnStr; - return $name."|2|".encode_base64($returnStr,""); + FRITZBOX_Log $hash, 5, "Handover to main process: " . $returnStr; + return $name . "|2|" . encode_base64($returnStr, ""); } # end FRITZBOX_Set_Wlan_OnOff @@ -7321,15 +8227,12 @@ sub FRITZBOX_Set_ring_Phone($) my ($name, @val) = split "\\|", $string; my $hash = $defs{$name}; - return "$name|0|Error: At least one parameter must be defined." unless int @val; - my $result; my @tr064Result; my $curCallerName; my @tr064CmdArray; my @roReadings; my $duration = -1; - my $intNo = $val[0]; my @FritzFons; my $ringTone; my %field; @@ -7338,16 +8241,14 @@ sub FRITZBOX_Set_ring_Phone($) my $startValue; my $startTime = time(); - # Check if 1st parameter are comma separated numbers - return $name."|0|Error (set ring): Parameter '$intNo' not a number (only commas (,) are allowed to separate phone numbers)" - unless $intNo =~ /^[\d,]+$/; + my $intNo = $val[0]; $intNo =~ s/#$//; # Create a hash for the DECT devices whose ring tone (or radio station) can be changed foreach ( split( /,/, $intNo ) ) { if (defined $hash->{fhem}{$_}{brand} && "AVM" eq $hash->{fhem}{$_}{brand}) { my $userId = $hash->{fhem}{$_}{userId}; - FRITZBOX_Log $hash, 5, "Internal number $_ (dect$userId) seems to be a Fritz!Fon."; + FRITZBOX_Log $hash, 4, "Internal number $_ (dect$userId) seems to be a Fritz!Fon."; push @FritzFons, $hash->{fhem}{$_}{userId}; } } @@ -7357,7 +8258,7 @@ sub FRITZBOX_Set_ring_Phone($) if (int @val) { if ($val[0] =~ /^\d+$/ && int $val[0] >= 0) { $duration = $val[0]; - FRITZBOX_Log $hash, 5, "Extracted ring duration of $duration s."; + FRITZBOX_Log $hash, 4, "Extracted ring duration of $duration s."; shift @val; } } @@ -7381,7 +8282,7 @@ sub FRITZBOX_Set_ring_Phone($) else { #oder Pech gehabt my $msg = "ERROR (set ring): Cannot ring because ClickToDial (Waehlhilfe) is off."; FRITZBOX_Log $hash, 2, $msg; - return $name."|0|".$msg + return $name . "|0|" . $msg } } @@ -7399,7 +8300,9 @@ sub FRITZBOX_Set_ring_Phone($) return $name."|0|Error (set ring): ".$tr064Result[0]->{Error} if $tr064Result[0]->{Error}; } else { - FRITZBOX_Log $hash, 3, "Your Fritz!OS version has limited interfaces. You cannot ring."; + my $msg = "ERROR (set ring): TR064 SECPORT not available. You cannot ring."; + FRITZBOX_Log $hash, 2, $msg; + return $name . "|0|" . $msg } sleep 5 if $duration <= 0; # always wait before reseting everything @@ -7420,13 +8323,325 @@ sub FRITZBOX_Set_ring_Phone($) FRITZBOX_Readout_Add_Reading $hash, \@roReadings, "readoutTime", sprintf( "%.2f", time()-$startTime); my $returnStr = join('|', @roReadings ); - FRITZBOX_Log $hash, 5, "Handover to main process: ".$returnStr; - return $name."|2|".encode_base64($returnStr,""); + FRITZBOX_Log $hash, 5, "Handover to main process: " . $returnStr; + return $name . "|2|" . encode_base64($returnStr,""); # return $name."|1|Ringing done"; } # end FRITZBOX_Set_ring_Phone + +# get list of mobile informations + +############################################ +sub FRITZBOX_Get_MobileInfo($) { + + my ($hash) = @_; + my $name = $hash->{NAME}; + + my $returnStr; + + my @webCmdArray = (); + push @webCmdArray, "xhr" => "1"; + push @webCmdArray, "lang" => "de"; + push @webCmdArray, "page" => "mobile"; + push @webCmdArray, "xhrId" => "all"; + + my $result = FRITZBOX_read_LuaData($hash, "data", \@webCmdArray) ; + + return $result if($hash->{helper}{gFilters}); + + my $analyse = FRITZBOX_Helper_analyse_Lua_Result($hash, $result); + + if ( defined $result->{Error} ) { + FRITZBOX_Log $hash, 2, "evaluating user info -> " . $analyse; + $returnStr .= "Mobile informations\n"; + $returnStr .= "---------------------------------\n"; + return $returnStr . $analyse; + } elsif ( defined $result->{AuthorizationRequired} ) { + FRITZBOX_Log $hash, 2, "evaluating user info -> AuthorizationRequired"; + $returnStr .= "Mobile informations\n"; + $returnStr .= "---------------------------------\n"; + return $returnStr . "AuthorizationRequired"; + } + + FRITZBOX_Log $hash, 5, "\n" . Dumper ($result->{data}); + + my $tableFormat = AttrVal($name, "disableTableFormat", "undef"); + + $returnStr .= '{data}->{simOk}, "onoff"); + $returnStr .= FRITZBOX_Helper_make_TableRow($hash, "Activation status", $result->{data}->{activation}); + + if ($result->{data}->{fallback}) { + $returnStr .= FRITZBOX_Helper_make_TableRow($hash, "Fallback possible", $result->{data}->{fallback}->{possible}, "onoff"); + $returnStr .= FRITZBOX_Helper_make_TableRow($hash, "Fallback enableable", $result->{data}->{fallback}->{enableable}); + } + + if ($result->{data}->{config}) { + $returnStr .= FRITZBOX_Helper_make_TableRow($hash, "Config DSL" , ($result->{data}->{config}->{dsl} ? "on" : "off")); + $returnStr .= FRITZBOX_Helper_make_TableRow($hash, "Config FIBER", ($result->{data}->{config}->{fiber} ? "on" : "off")); + $returnStr .= FRITZBOX_Helper_make_TableRow($hash, "Config CABLE", ($result->{data}->{config}->{cable} ? "on" : "off")); + } + + if ($result->{data}->{connection}) { + $returnStr .= FRITZBOX_Helper_make_TableRow($hash, "Connection operator" , $result->{data}->{connection}->{operator}); + $returnStr .= FRITZBOX_Helper_make_TableRow($hash, "Connection state" , $result->{data}->{connection}->{state}); + $returnStr .= FRITZBOX_Helper_make_TableRow($hash, "Connection quality" , $result->{data}->{connection}->{quality}); + $returnStr .= FRITZBOX_Helper_make_TableRow($hash, "Connection accessTechnology", $result->{data}->{connection}->{accessTechnology}); + } + + if ($result->{data}->{progress}) { + $returnStr .= FRITZBOX_Helper_make_TableRow($hash, "Progress refreshNeeded", $result->{data}->{progress}->{refreshNeeded}); + $returnStr .= FRITZBOX_Helper_make_TableRow($hash, "Progress error" , $result->{data}->{progress}->{error}); + } + + if ($result->{data}->{compatibilityMode}) { + $returnStr .= FRITZBOX_Helper_make_TableRow($hash, "compatibilityMode enabled" , ($result->{data}->{compatibilityMode}->{enabled} ? "on" : "off")); + $returnStr .= FRITZBOX_Helper_make_TableRow($hash, "compatibilityMode enableable", ($result->{data}->{compatibilityMode}->{enableable} ? "on" : "off")); + } + + if ($result->{data}->{voipOverMobile}) { + $returnStr .= FRITZBOX_Helper_make_TableRow($hash, "voipOverMobile", ($result->{data}->{voipOverMobile} ? "on" : "off")); + } + + if ($result->{data}->{wds}) { + $returnStr .= FRITZBOX_Helper_make_TableRow($hash, "wds", ($result->{data}->{wds} ? "on" : "off")); + } + + if ($result->{data}->{ipclient}) { + $returnStr .= FRITZBOX_Helper_make_TableRow($hash, "ipclient", ($result->{data}->{ipclient} ? "on" : "off")); + } + + if ($result->{data}->{capabilities}) { + $returnStr .= FRITZBOX_Helper_make_TableRow($hash, "Capabilities voice", ($result->{data}->{capabilities}->{voice} ? "on" : "off")); + } + + if ($result->{data}->{activation}) { + $returnStr .= FRITZBOX_Helper_make_TableRow($hash, "activation", $result->{data}->{activation}); + } + + if ($result->{data}->{sipNumberCount}) { + $returnStr .= FRITZBOX_Helper_make_TableRow($hash, "sipNumberCount", $result->{data}->{sipNumberCount}); + } + + $returnStr .= "\n"; + + if ( $hash->{TR064} == 1 && $hash->{SECPORT} ) { + + $returnStr .= '
{UPnPError}) { + $strCurl = Dumper (@tr064Result); + FRITZBOX_Log $hash, 2, "Mobile GetInfoEX -> \n" . $strCurl; + + } else { + + FRITZBOX_Log $hash, 5, "Mobile GetInfoEx -> \n" . Dumper (@tr064Result); + + if ($tr064Result[0]->{GetInfoExResponse}) { + + if (defined $tr064Result[0]->{GetInfoExResponse}->{NewCellList}) { + my $data = $tr064Result[0]->{GetInfoExResponse}->{NewCellList}; + $data =~ s/<//isg; + + FRITZBOX_Log $hash, 5, "Data Mobile GetInfoEx (NewCellList): \n" . $data; + + while( $data =~ /(.*?)<\/Cell>/isg ) { + my $cellList = $1; + + FRITZBOX_Log $hash, 5, "Data Mobile GetInfoEx (Cell): \n" . $1; + + my $Index = $1 if $cellList =~ m/(.*?)<\/Index>/is; + my $Connected = $1 if $cellList =~ m/(.*?)<\/Connected>/is; + my $CellType = $1 if $cellList =~ m/(.*?)<\/CellType>/is; + my $PLMN = $1 if $cellList =~ m/(.*?)<\/PLMN>/is; + my $Provider = $1 if $cellList =~ m/(.*?)<\/Provider>/is; + my $TAC = $1 if $cellList =~ m/(.*?)<\/TAC>/is; + my $PhysicalId = $1 if $cellList =~ m/(.*?)<\/PhysicalId>/is; + my $Distance = $1 if $cellList =~ m/(.*?)<\/Distance>/is; + my $Rssi = $1 if $cellList =~ m/(.*?)<\/Rssi>/is; + my $Rsrq = $1 if $cellList =~ m/(.*?)<\/Rsrq>/is; + my $RSRP = $1 if $cellList =~ m/(.*?)<\/RSRP>/is; + my $Cellid = $1 if $cellList =~ m/(.*?)<\/Cellid>/is; + + $returnStr .= FRITZBOX_Helper_make_TableRow($hash, "Connected_$Index", $Connected); + $returnStr .= FRITZBOX_Helper_make_TableRow($hash, "CellType_$Index", $CellType); + $returnStr .= FRITZBOX_Helper_make_TableRow($hash, "PLMN_$Index", $PLMN); + $returnStr .= FRITZBOX_Helper_make_TableRow($hash, "Provider_$Index", $Provider); + $returnStr .= FRITZBOX_Helper_make_TableRow($hash, "TAC_$Index", $TAC); + $returnStr .= FRITZBOX_Helper_make_TableRow($hash, "PhysicalId_$Index", $PhysicalId); + $returnStr .= FRITZBOX_Helper_make_TableRow($hash, "Distance_$Index", $Distance); + $returnStr .= FRITZBOX_Helper_make_TableRow($hash, "Rssi_$Index", $Rssi); + $returnStr .= FRITZBOX_Helper_make_TableRow($hash, "Rsrq_$Index", $Rsrq); + $returnStr .= FRITZBOX_Helper_make_TableRow($hash, "RSRP_$Index", $RSRP); + $returnStr .= FRITZBOX_Helper_make_TableRow($hash, "Cellid_$Index", $Cellid); + + $returnStr .= FRITZBOX_Helper_make_TableRow($hash, "emptyRow"); + + } + + } + + $returnStr .= FRITZBOX_Helper_make_TableRow($hash, "PPPUsername", $tr064Result[0]->{GetInfoExResponse}->{NewPPPUsername}); + $returnStr .= FRITZBOX_Helper_make_TableRow($hash, "PDN2_MTU", $tr064Result[0]->{GetInfoExResponse}->{NewPDN2_MTU}); + $returnStr .= FRITZBOX_Helper_make_TableRow($hash, "APN", $tr064Result[0]->{GetInfoExResponse}->{NewAPN}); + $returnStr .= FRITZBOX_Helper_make_TableRow($hash, "SoftwareVersion", $tr064Result[0]->{GetInfoExResponse}->{NewSoftwareVersion}); + $returnStr .= FRITZBOX_Helper_make_TableRow($hash, "Roaming", $tr064Result[0]->{GetInfoExResponse}->{NewRoaming}); + $returnStr .= FRITZBOX_Helper_make_TableRow($hash, "PDN1_MTU", $tr064Result[0]->{GetInfoExResponse}->{NewPDN1_MTU}); + $returnStr .= FRITZBOX_Helper_make_TableRow($hash, "IMSI", $tr064Result[0]->{GetInfoExResponse}->{NewIMSI}); + $returnStr .= FRITZBOX_Helper_make_TableRow($hash, "SignalRSRP1", $tr064Result[0]->{GetInfoExResponse}->{NewSignalRSRP1}); + $returnStr .= FRITZBOX_Helper_make_TableRow($hash, "CurrentAccessTechnology", $tr064Result[0]->{GetInfoExResponse}->{NewCurrentAccessTechnology}); + $returnStr .= FRITZBOX_Helper_make_TableRow($hash, "PPPUsernameVoIP", $tr064Result[0]->{GetInfoExResponse}->{NewPPPUsernameVoIP}); + $returnStr .= FRITZBOX_Helper_make_TableRow($hash, "EnableVoIPPDN", $tr064Result[0]->{GetInfoExResponse}->{NewEnableVoIPPDN}); + $returnStr .= FRITZBOX_Helper_make_TableRow($hash, "APN_VoIP", $tr064Result[0]->{GetInfoExResponse}->{NewAPN_VoIP}); + $returnStr .= FRITZBOX_Helper_make_TableRow($hash, "Uptime", $tr064Result[0]->{GetInfoExResponse}->{NewUptime}); + $returnStr .= FRITZBOX_Helper_make_TableRow($hash, "SignalRSRP0", $tr064Result[0]->{GetInfoExResponse}->{NewSignalRSRP0}); + $returnStr .= FRITZBOX_Helper_make_TableRow($hash, "SerialNumber", $tr064Result[0]->{GetInfoExResponse}->{NewSerialNumber}); + + } + + } + + @tr064CmdArray = (["X_AVM-DE_WANMobileConnection:1", "x_wanmobileconn", "GetInfo"]); + + @tr064Result = FRITZBOX_call_TR064_Cmd( $hash, 0, \@tr064CmdArray ); + + if ($tr064Result[0]->{UPnPError}) { + $strCurl = Dumper (@tr064Result); + FRITZBOX_Log $hash, 2, "Mobile GetInfo -> \n" . $strCurl; + } else { + + FRITZBOX_Log $hash, 5, "Mobile GetInfo -> \n" . Dumper (@tr064Result); + + if ($tr064Result[0]->{GetInfoResponse}) { + + $returnStr .= FRITZBOX_Helper_make_TableRow($hash, "emptyRow"); + + $returnStr .= FRITZBOX_Helper_make_TableRow($hash, "PINFailureCount", $tr064Result[0]->{GetInfoResponse}->{NewPINFailureCount}); + $returnStr .= FRITZBOX_Helper_make_TableRow($hash, "PUKFailureCount", $tr064Result[0]->{GetInfoResponse}->{NewPUKFailureCount}); + $returnStr .= FRITZBOX_Helper_make_TableRow($hash, "Enabled", $tr064Result[0]->{GetInfoResponse}->{NewEnabled}); + $returnStr .= FRITZBOX_Helper_make_TableRow($hash, "Status", $tr064Result[0]->{GetInfoResponse}->{NewStatus}); + + } + + } + + @tr064CmdArray = (["X_AVM-DE_WANMobileConnection:1", "x_wanmobileconn", "GetBandCapabilities"]); + + @tr064Result = FRITZBOX_call_TR064_Cmd( $hash, 0, \@tr064CmdArray ); + + if ($tr064Result[0]->{UPnPError}) { + $strCurl = Dumper (@tr064Result); + FRITZBOX_Log $hash, 2, "Mobile GetInfo -> \n" . $strCurl; + } else { + + FRITZBOX_Log $hash, 5, "Mobile GetInfo -> \n" . Dumper (@tr064Result); + + if ($tr064Result[0]->{GetInfoResponse}) { + + $returnStr .= FRITZBOX_Helper_make_TableRow($hash, "emptyRow"); + + $returnStr .= FRITZBOX_Helper_make_TableRow($hash, "CapabilitiesLTE", $tr064Result[0]->{GetInfoResponse}->{NewBandCapabilitiesLTE}); + $returnStr .= FRITZBOX_Helper_make_TableRow($hash, "Capabilities5GSA", $tr064Result[0]->{GetInfoResponse}->{NewBandCapabilities5GSA}); + $returnStr .= FRITZBOX_Helper_make_TableRow($hash, "Capabilities5GNSA", $tr064Result[0]->{GetInfoResponse}->{NewBandCapabilities5GNSA}); + + } + + } + + @tr064CmdArray = (["X_AVM-DE_WANMobileConnection:1", "x_wanmobileconn", "GetAccessTechnology"]); + + @tr064Result = FRITZBOX_call_TR064_Cmd( $hash, 0, \@tr064CmdArray ); + + if ($tr064Result[0]->{UPnPError}) { + $strCurl = Dumper (@tr064Result); + FRITZBOX_Log $hash, 2, "Mobile GetInfo -> \n" . $strCurl; + } else { + + FRITZBOX_Log $hash, 5, "Mobile GetInfo -> \n" . Dumper (@tr064Result); + + if ($tr064Result[0]->{GetInfoResponse}) { + + $returnStr .= FRITZBOX_Helper_make_TableRow($hash, "emptyRow"); + + $returnStr .= FRITZBOX_Helper_make_TableRow($hash, "CurrentAccessTechnology", $tr064Result[0]->{GetInfoResponse}->{NewCurrentAccessTechnology}); + $returnStr .= FRITZBOX_Helper_make_TableRow($hash, "PossibleAccessTechnology", $tr064Result[0]->{GetInfoResponse}->{NewPossibleAccessTechnology}); + $returnStr .= FRITZBOX_Helper_make_TableRow($hash, "AccessTechnology", $tr064Result[0]->{GetInfoResponse}->{NewAccessTechnology}); + + } + + } + } + + $returnStr .= "\n"; + + return $returnStr; + +} # end FRITZBOX_Get_MobileInfo + +# make a table row +############################################ +sub FRITZBOX_Helper_make_TableRow($@) { + + my ($hash, $column1, $column2, $format2) = @_; + my $name = $hash->{NAME}; + + my $trtd = "\n" . ""; + my $tdtd = " "; + my $tdtr = "" . "\n"; + + return $trtd . " " . $tdtd . " " . $tdtr if $column1 eq "emptyRow"; + + if (defined $format2) { + if ($format2 eq "onoff") { + $column2 = $column2 == 0 ? "off" : "on" if defined $column2; + } elsif ($format2 ne "") { + $column2 = $format2; + } + } + + return "" unless defined $column2; + + my $returnStr; + + $returnStr .= $trtd . $column1 . $tdtd . $column2 . $tdtr; + + return $returnStr; + +} # end FRITZBOX_Helper_make_TableRow + # get list of global filters ############################################ sub FRITZBOX_Get_WLAN_globalFilters($) { @@ -7718,13 +8933,8 @@ sub FRITZBOX_Get_VPN_Shares_List($) { } }; - my @fwV = split(/\./, ReadingsVal($name, "box_fwVersion", "0.0.0.error")); - - my $FW1 = substr($fwV[1],0,2); - my $FW2 = substr($fwV[2],0,2); - # Wirguard VPN only available with Fritz!OS 7.50 and greater - return $returnStr . "\n" if $FW1 <= 7 && $FW2 < 50; + return $returnStr . "\n" if $hash->{fhem}{fwVersion} < 750; @webCmdArray = (); push @webCmdArray, "xhr" => "1"; @@ -8048,12 +9258,7 @@ sub FRITZBOX_Get_SmartHome_Devices_List($@) { my $views; my $nbViews = 0; - my @fwV = split(/\./, ReadingsVal($name, "box_fwVersion", "0.0.0.error")); - - my $FW1 = substr($fwV[1],0,2); - my $FW2 = substr($fwV[2],0,2); - - FRITZBOX_Log $hash, 4, "FRITZBOX_SmartHome_Device_List (Fritz!OS: $FW1.$FW2) "; + FRITZBOX_Log $hash, 4, "FRITZBOX_SmartHome_Device_List (Fritz!OS: $hash->{fhem}{fwVersionStr}) "; my @webCmdArray; # "xhr 1 lang de page sh_dev xhrId all; @@ -8388,10 +9593,12 @@ sub FRITZBOX_Get_SmartHome_Devices_List($@) { $skillInfo[2] = "" . $units->[$unit]->{skills}->[0]->{chargeLevelInPercent} . "%"; } elsif ( $units->[$unit]->{'type'} eq 'SOCKET' ) { - $skillInfo[3] = "" . $units->[$unit]->{skills}->[0]->{voltageInVolt} . " V"; - $skillInfo[4] = "" . $units->[$unit]->{skills}->[0]->{powerPerHour} . " w/h"; - $skillInfo[5] = "" . $units->[$unit]->{skills}->[0]->{electricCurrentInAmpere} . " A"; - $skillInfo[6] = "" . $units->[$unit]->{skills}->[0]->{powerConsumptionInWatt} . " W"; + if($units->[$unit]->{skills}->[0]->{voltageInVolt}) { + $skillInfo[3] = "" . $units->[$unit]->{skills}->[0]->{voltageInVolt} . " V"; + $skillInfo[4] = "" . $units->[$unit]->{skills}->[0]->{powerPerHour} . " w/h"; + $skillInfo[5] = "" . $units->[$unit]->{skills}->[0]->{electricCurrentInAmpere} . " A"; + $skillInfo[6] = "" . $units->[$unit]->{skills}->[0]->{powerConsumptionInWatt} . " W"; + } $skillInfo[7] = "" . $units->[$unit]->{skills}->[1]->{ledState}; $skillInfo[8] = "" . $units->[$unit]->{skills}->[2]->{state}; } @@ -8417,12 +9624,7 @@ sub FRITZBOX_Get_Lan_Devices_List($) { my ($hash) = @_; my $name = $hash->{NAME}; - my @fwV = split(/\./, ReadingsVal($name, "box_fwVersion", "0.0.0.error")); - - my $FW1 = substr($fwV[1],0,2); - my $FW2 = substr($fwV[2],0,2); - - FRITZBOX_Log $hash, 4, "FRITZBOX_Lan_Device_List (Fritz!OS: $FW1.$FW2) "; + FRITZBOX_Log $hash, 4, "FRITZBOX_Lan_Device_List (Fritz!OS: $hash->{fhem}{fwVersionStr}) "; my @webCmdArray; # "xhr 1 lang de page netDev xhrId cleanup useajax 1 no_sidrenew nop; @@ -8713,10 +9915,6 @@ sub FRITZBOX_Get_Fritz_Log_Info_nonBlk($) # xhr 1 lang de page log xhrId log filter 2 useajax 1 no_sidrenew nop -> Log-Einträge Internetverbindung # xhr 1 lang de page log xhrId log filter 3 useajax 1 no_sidrenew nop -> Log-Einträge Fon - my @fwV = split(/\./, ReadingsVal($name, "box_fwVersion", "0.0.0.error")); - - my $FW1 = substr($fwV[1],0,2); - my $FW2 = substr($fwV[2],0,2); my $returnStr; FRITZBOX_Log $hash, 3, "fritzlog -> $cmd, $val[0], $val[1]"; @@ -8728,41 +9926,43 @@ sub FRITZBOX_Get_Fritz_Log_Info_nonBlk($) push @webCmdArray, "useajax" => "1"; push @webCmdArray, "no_sidrenew" => ""; - if (($FW1 == 6 && $FW2 >= 83) || ($FW1 == 7 && $FW2 < 50)) { + if ($hash->{fhem}{fwVersion} >= 683 && $hash->{fhem}{fwVersion} < 750) { push @webCmdArray, "filter" => "0" if $val[1] =~ /all/; push @webCmdArray, "filter" => "1" if $val[1] =~ /sys/; push @webCmdArray, "filter" => "2" if $val[1] =~ /net/; push @webCmdArray, "filter" => "3" if $val[1] =~ /fon/; push @webCmdArray, "filter" => "4" if $val[1] =~ /wlan/; push @webCmdArray, "filter" => "5" if $val[1] =~ /usb/; - } elsif ($FW1 >= 7 && $FW2 >= 50) { + } elsif ($hash->{fhem}{fwVersion} >= 750) { push @webCmdArray, "filter" => $val[1]; } else { } - FRITZBOX_Log $hash, 5, "data.lua: \n" . join(" ", @webCmdArray); + if ($hash->{fhem}{fwVersion} >= 683) { + FRITZBOX_Log $hash, 4, "data.lua: \n" . join(" ", @webCmdArray); - $result = FRITZBOX_read_LuaData($hash, "data", \@webCmdArray) ; + $result = FRITZBOX_read_LuaData($hash, "data", \@webCmdArray) ; - # Abbruch wenn Fehler beim Lesen der Fritzbox-Antwort - return FRITZBOX_Readout_Response($hash, $result, \@roReadings) if ( defined $result->{Error} || defined $result->{AuthorizationRequired}); + # Abbruch wenn Fehler beim Lesen der Fritzbox-Antwort + return FRITZBOX_Readout_Response($hash, $result, \@roReadings) if ( defined $result->{Error} || defined $result->{AuthorizationRequired}); - $sidNew += $result->{sidNew} if defined $result->{sidNew}; + $sidNew += $result->{sidNew} if defined $result->{sidNew}; - FRITZBOX_Readout_Add_Reading $hash, \@roReadings, "retStat_fritzLogInfo", "done"; + FRITZBOX_Readout_Add_Reading $hash, \@roReadings, "retStat_fritzLogInfo", "done"; - if (int @val == 3 && $val[2] eq "off") { - $returnLog = "|" . $val[1] . "|" . toJSON ($result); - $returnCase = 3; - } else { - - my $returnExPost = eval { myUtilsFritzLogExPostnb ($hash, $val[1], $result); }; - - if ($@) { - FRITZBOX_Log $hash, 2, "fritzLogExPost: " . $@; - FRITZBOX_Readout_Add_Reading $hash, \@roReadings, "retStat_fritzLogExPost", "->ERROR: " . $@; + if (int @val == 3 && $val[2] eq "off") { + $returnLog = "|" . $val[1] . "|" . toJSON ($result); + $returnCase = 3; } else { - FRITZBOX_Readout_Add_Reading $hash, \@roReadings, "retStat_fritzLogExPost", $returnExPost; + + my $returnExPost = eval { myUtilsFritzLogExPostnb ($hash, $val[1], $result); }; + + if ($@) { + FRITZBOX_Log $hash, 2, "fritzLogExPost: " . $@; + FRITZBOX_Readout_Add_Reading $hash, \@roReadings, "retStat_fritzLogExPost", "->ERROR: " . $@; + } else { + FRITZBOX_Readout_Add_Reading $hash, \@roReadings, "retStat_fritzLogExPost", $returnExPost; + } } } @@ -8801,11 +10001,6 @@ sub FRITZBOX_Get_Fritz_Log_Info_Std($$$) { # xhr 1 lang de page log xhrId log filter 2 useajax 1 no_sidrenew nop -> Log-Einträge Internetverbindung # xhr 1 lang de page log xhrId log filter 3 useajax 1 no_sidrenew nop -> Log-Einträge Fon - my @fwV = split(/\./, ReadingsVal($name, "box_fwVersion", "0.0.0.error")); - - my $FW1 = substr($fwV[1],0,2); - my $FW2 = substr($fwV[2],0,2); - my @webCmdArray; push @webCmdArray, "xhr" => "1"; @@ -8817,19 +10012,19 @@ sub FRITZBOX_Get_Fritz_Log_Info_Std($$$) { my $returnStr; - if (($FW1 == 6 && $FW2 >= 80) || ($FW1 == 7 && $FW2 < 50)) { + if ($hash->{fhem}{fwVersion} >= 680 && $hash->{fhem}{fwVersion} < 750) { push @webCmdArray, "filter" => "0" if $logInfo =~ /all/; push @webCmdArray, "filter" => "1" if $logInfo =~ /sys/; push @webCmdArray, "filter" => "2" if $logInfo =~ /net/; push @webCmdArray, "filter" => "3" if $logInfo =~ /fon/; push @webCmdArray, "filter" => "4" if $logInfo =~ /wlan/; push @webCmdArray, "filter" => "5" if $logInfo =~ /usb/; - } elsif ($FW1 >= 7 && $FW2 >= 50) { + } elsif ($hash->{fhem}{fwVersion} >= 750) { push @webCmdArray, "filter" => $logInfo; } else { $returnStr .= "FritzLog Filter:$logInfo\n"; $returnStr .= "---------------------------------\n"; - return $returnStr . "Not supported Fritz!OS $FW1.$FW2"; + return $returnStr . "Not supported Fritz!OS $hash->{fhem}{fwVersionStr}"; } FRITZBOX_Log $hash, 3, "set $name $logInfo " . join(" ", @webCmdArray); @@ -8867,7 +10062,7 @@ sub FRITZBOX_Get_Fritz_Log_Info_Std($$$) { $returnStr .= "\n"; if ($nbViews > 0) { - if (($FW1 == 6 && $FW2 >= 80) || ($FW1 == 7 && $FW2 < 50)) { + if ($hash->{fhem}{fwVersion} >= 680 && $hash->{fhem}{fwVersion} < 750) { eval { for(my $i = 0; $i <= $nbViews - 1; $i++) { $returnStr .= "\n"; @@ -8878,7 +10073,7 @@ sub FRITZBOX_Get_Fritz_Log_Info_Std($$$) { $returnStr .= "\n"; } }; - } elsif ($FW1 >= 7 && $FW2 >= 50) { + } elsif ($hash->{fhem}{fwVersion} >= 750) { eval { for(my $i = 0; $i <= $nbViews - 1; $i++) { $returnStr .= "\n"; @@ -8924,14 +10119,9 @@ sub FRITZBOX_Get_Lan_Device_Info($$$) { push @webCmdArray, "initalRefreshParamsSaved" => "true"; push @webCmdArray, "lang" => "de"; - my @fwV = split(/\./, ReadingsVal($name, "box_fwVersion", "0.0.0.error")); + FRITZBOX_Log $hash, 4, "FRITZBOX_Get_Lan_Device_Info (Fritz!OS: $hash->{fhem}{fwVersionStr}) "; - my $FW1 = substr($fwV[1],0,2); - my $FW2 = substr($fwV[2],0,2); - - FRITZBOX_Log $hash, 4, "FRITZBOX_Get_Lan_Device_Info (Fritz!OS: $FW1.$FW2) "; - - if ($FW1 >= 7 && $FW2 >= 25) { + if ($hash->{fhem}{fwVersion} >= 725) { push @webCmdArray, "page" => "edit_device"; } else { push @webCmdArray, "page" => "edit_device2"; @@ -8941,65 +10131,53 @@ sub FRITZBOX_Get_Lan_Device_Info($$$) { my $result = FRITZBOX_read_LuaData($hash, "data", \@webCmdArray) ; - if ($action eq "chgProf") { + if ($action =~ /chgProf|lockLandevice/) { return $result; } - my $analyse = FRITZBOX_Helper_analyse_Lua_Result($hash, $result); - - if ( $analyse =~ /ERROR/ ) { - FRITZBOX_Log $hash, 2, "get $name $action \n" . $analyse; - return "ERROR: getting Lan_Device_Info: " . $action . " for: " . $lDevID; + if (defined $result->{Error} ) { + return "ERROR: " . $result->{Error}; + } elsif (defined $result->{AuthorizationRequired}){ + return "ERROR: " . $result->{AuthorizationRequired}; } if (exists $result->{data}->{vars}) { - FRITZBOX_Log $hash, 5, "landevice: " . $lDevID . "landevice: \n" . $analyse; - if ($action eq "info") { - if($result->{data}->{vars}->{dev}->{UID} eq $lDevID) { - my $returnStr = ""; - $returnStr .= "MAC:" . $result->{data}->{vars}->{dev}->{mac}; - $returnStr .= " IPv4:" . $result->{data}->{vars}->{dev}->{ipv4}->{current}->{ip}; - $returnStr .= " UID:" . $result->{data}->{vars}->{dev}->{UID}; - $returnStr .= " NAME:" . $result->{data}->{vars}->{dev}->{name}->{displayName}; - if ( ref ($result->{data}->{vars}->{dev}->{netAccess}->{kisi}->{selectedRights}) eq 'HASH' ) { - my $kisi = $result->{data}->{vars}->{dev}->{netAccess}->{kisi}; + if($result->{data}->{vars}->{dev}->{UID} eq $lDevID) { + + my $returnStr = ""; + + $returnStr .= "MAC:" . $result->{data}->{vars}->{dev}->{mac}; + $returnStr .= " IPv4:" . $result->{data}->{vars}->{dev}->{ipv4}->{current}->{ip}; + $returnStr .= " UID:" . $result->{data}->{vars}->{dev}->{UID}; + $returnStr .= " NAME:" . $result->{data}->{vars}->{dev}->{name}->{displayName}; + if ( ref ($result->{data}->{vars}->{dev}->{netAccess}->{kisi}->{selectedRights}) eq 'HASH' ) { + my $kisi = $result->{data}->{vars}->{dev}->{netAccess}->{kisi}; # $returnStr .= " ACCESS:" . $result->{data}->{vars}->{dev}->{netAccess}->{kisi}->{selectedRights}->{msgid} if defined($result->{data}->{vars}->{dev}->{netAccess}->{kisi}->{selectedRights}->{msgid}); # $returnStr .= " USEABLE:" . $result->{data}->{vars}->{dev}->{netAccess}->{kisi}->{onlineTime}->{useable}; # $returnStr .= " UNSPENT:" . $result->{data}->{vars}->{dev}->{netAccess}->{kisi}->{onlineTime}->{unspent}; # $returnStr .= " PERCENT:" . $result->{data}->{vars}->{dev}->{netAccess}->{kisi}->{onlineTime}->{percent}; # $returnStr .= " USED:" . $result->{data}->{vars}->{dev}->{netAccess}->{kisi}->{onlineTime}->{used}; # $returnStr .= " USEDSTR:" . $result->{data}->{vars}->{dev}->{netAccess}->{kisi}->{onlineTime}->{usedstr}; - $returnStr .= " ACCESS:" . $kisi->{selectedRights}->{msgid} if defined($kisi->{selectedRights}->{msgid}); - $returnStr .= " USEABLE:" . $kisi->{onlineTime}->{useable} if defined($kisi->{onlineTime}->{useable}); - $returnStr .= " UNSPENT:" . $kisi->{onlineTime}->{unspent} if defined($kisi->{onlineTime}->{unspent}); - $returnStr .= " PERCENT:" . $kisi->{onlineTime}->{percent} if defined($kisi->{onlineTime}->{percent}); - $returnStr .= " USED:" . $kisi->{onlineTime}->{used} if defined($kisi->{onlineTime}->{used}); - $returnStr .= " USEDSTR:" . $kisi->{onlineTime}->{usedstr} if defined($kisi->{onlineTime}->{usedstr}); - } - $returnStr .= " DEVTYPE:" . $result->{data}->{vars}->{dev}->{devType}; - $returnStr .= " STATE:" . $result->{data}->{vars}->{dev}->{wlan}->{state} if defined($result->{data}->{vars}->{dev}->{wlan}->{state}) and $result->{data}->{vars}->{dev}->{devType} eq 'wlan'; - $returnStr .= " ONLINE:" . $result->{data}->{vars}->{dev}->{state}; - $returnStr .= " REALTIME:" . $result->{data}->{vars}->{dev}->{realtime}->{state} if defined($result->{data}->{vars}->{dev}->{realtime}->{state}); - return $returnStr; - } else { - return "ERROR: no lanDeviceInfo: " . $lDevID; - } - } elsif ($action eq "chgProf") { - if($result->{data}->{vars}->{dev}->{UID} eq $lDevID) { - return $result; - } - } elsif ($action eq "lockLandevice") { - unless (defined $result->{data}->{vars}->{dev}->{netAccess}->{kisi}->{selectedRights}->{msgid}) { - FRITZBOX_Log $hash, 2, "no msgId returned"; - return "ERROR: no msgId returned"; + $returnStr .= " ACCESS:" . $kisi->{selectedRights}->{msgid} if defined($kisi->{selectedRights}->{msgid}); + $returnStr .= " USEABLE:" . $kisi->{onlineTime}->{useable} if defined($kisi->{onlineTime}->{useable}); + $returnStr .= " UNSPENT:" . $kisi->{onlineTime}->{unspent} if defined($kisi->{onlineTime}->{unspent}); + $returnStr .= " PERCENT:" . $kisi->{onlineTime}->{percent} if defined($kisi->{onlineTime}->{percent}); + $returnStr .= " USED:" . $kisi->{onlineTime}->{used} if defined($kisi->{onlineTime}->{used}); + $returnStr .= " USEDSTR:" . $kisi->{onlineTime}->{usedstr} if defined($kisi->{onlineTime}->{usedstr}); } - my $jsonMsgId = $result->{data}->{vars}->{dev}->{netAccess}->{kisi}->{selectedRights}->{msgid}; + $returnStr .= " DEVTYPE:" . $result->{data}->{vars}->{dev}->{devType}; + $returnStr .= " STATE:" . $result->{data}->{vars}->{dev}->{wlan}->{state} if defined($result->{data}->{vars}->{dev}->{wlan}->{state}) and $result->{data}->{vars}->{dev}->{devType} eq 'wlan'; + $returnStr .= " ONLINE:" . $result->{data}->{vars}->{dev}->{state}; + $returnStr .= " REALTIME:" . $result->{data}->{vars}->{dev}->{realtime}->{state} if defined($result->{data}->{vars}->{dev}->{realtime}->{state}); - FRITZBOX_Log $hash, 5, "MsgId: " . $jsonMsgId; - return "INFO: " . $jsonMsgId; + return $returnStr; + + } else { + return "ERROR: no lanDeviceInfo: " . $lDevID; } + } else { FRITZBOX_Log $hash, 2, "landevice: " . $lDevID . "landevice: Fehler holen Lan_Device_Info"; @@ -9023,13 +10201,13 @@ sub FRITZBOX_Get_Lua_Kids($$@) $sidNew = $result->{sidNew} if defined $result->{sidNew}; - FRITZBOX_Log $hash, 5, "Request data via API dataQuery."; + FRITZBOX_Log $hash, 4, "Request data via API dataQuery."; my $host = $hash->{HOST}; my $url = 'http://' . $host . '/internet/kids_userlist.lua?sid=' . $result->{sid}; # . '&' . $queryStr; - FRITZBOX_Log $hash, 5, "URL: $url"; + FRITZBOX_Log $hash, 4, "URL: $url"; - my $agent = LWP::UserAgent->new( env_proxy => 1, keep_alive => 1, protocols_allowed => ['http'], timeout => 180); + my $agent = LWP::UserAgent->new( env_proxy => 1, keep_alive => 1, protocols_allowed => ['http'], timeout => $hash->{AGENTTMOUT}); my $response = $agent->post ( $url, $queryStr ); FRITZBOX_Log $hash, 5, "Response: ".$response->status_line."\n".$response->content; @@ -9052,7 +10230,7 @@ sub FRITZBOX_Get_Lua_Kids($$@) $jsonText =~ s/\\'/'/g; #Hochkomma $jsonText =~ s/\\x\{[0-9a-f]\}//g; #delete control codes (as hex numbers) - FRITZBOX_Log $hash, 5, "Decode JSON string."; + FRITZBOX_Log $hash, 4, "Decode JSON string."; my $jsonResult ; if ($charSet eq "UTF-8") { $jsonResult = JSON->new->utf8->decode( $jsonText ); @@ -9063,7 +10241,7 @@ sub FRITZBOX_Get_Lua_Kids($$@) if ( ref ($jsonResult) ne "HASH" ) { chop $jsonText; - FRITZBOX_Log $hash, 5, "no json string returned (" . $jsonText . ")"; + FRITZBOX_Log $hash, 4, "no json string returned (" . $jsonText . ")"; my %retHash = ("Error" => "no json string returned (" . $jsonText . ")", "ResetSID" => "1"); return \%retHash; } @@ -9238,7 +10416,7 @@ sub FRITZBOX_call_TR064_Cmd($$$) push @soapParams, SOAP::Data->name( $_ => $params{$_} ); } - FRITZBOX_Log $hash, 5, "Perform TR-064 call - $action => " . $logMsg; + FRITZBOX_Log $hash, 4, "Perform TR-064 call - $action => " . $logMsg; my $soap = SOAP::Lite -> on_fault ( sub {} ) @@ -9312,7 +10490,7 @@ sub FRITZBOX_get_TR064_ServiceList($) return "TR-064 switched off." if $hash->{READINGS}{box_tr064}{VAL} eq "off"; - FRITZBOX_Log $hash, 5, "Getting service page $url"; + FRITZBOX_Log $hash, 4, "Getting service page $url"; my $agent = LWP::UserAgent->new( env_proxy => 1, keep_alive => 1, protocols_allowed => ['http'], timeout => 10); my $response = $agent->get( $url ); @@ -9337,7 +10515,7 @@ sub FRITZBOX_get_TR064_ServiceList($) $url = 'http://'.$host.":49000".$_->[2]; - FRITZBOX_Log $hash, 5, "Getting action page $url"; + FRITZBOX_Log $hash, 5, "Getting action page $url"; my $agent = LWP::UserAgent->new( env_proxy => 1, keep_alive => 1, protocols_allowed => ['http'], timeout => 10); my $response = $agent->get( $url ); @@ -9425,7 +10603,7 @@ sub FRITZBOX_init_TR064 ($$) FRITZBOX_Log $hash, 5, "SecPort-String " . Dumper($s); my $port = $s->result; - FRITZBOX_Log $hash, 4, "SecPort-Result " . Dumper($s->result); + FRITZBOX_Log $hash, 5, "SecPort-Result " . Dumper($s->result); unless( $port ) { FRITZBOX_Log $hash, 2, "Could not get secure port: $!"; @@ -9466,7 +10644,7 @@ sub FRITZBOX_open_Web_Connection ($) return \%retHash; } - FRITZBOX_Log $hash, 5, "checking HOST -> " . $hash->{DEF} if defined $hash->{DEF}; + FRITZBOX_Log $hash, 4, "checking HOST -> " . $hash->{DEF} if defined $hash->{DEF}; # my $hash = $defs{$name}; my $host = $hash->{HOST}; @@ -9520,14 +10698,9 @@ sub FRITZBOX_open_Web_Connection ($) my $avmModel = InternalVal($name, "MODEL", $hash->{boxModel}); my $user = AttrVal( $name, "boxUser", "" ); - my @fwV = split(/\./, ReadingsVal($name, "box_fwVersion", "0.0.0.error")); + FRITZBOX_Log $hash, 4, "FRITZBOX_Get_Lan_Device_Info (Fritz!OS: $hash->{fhem}{fwVersionStr}) "; - my $FW1 = substr($fwV[1],0,2); - my $FW2 = substr($fwV[2],0,2); - - FRITZBOX_Log $hash, 4, "FRITZBOX_Get_Lan_Device_Info (Fritz!OS: $FW1.$FW2) "; - - if ($user eq "" && $avmModel && $avmModel =~ "Box" && ($FW1 >= 7 && $FW2 >= 25)) { + if ($user eq "" && $avmModel && $avmModel =~ "Box" && ($hash->{fhem}{fwVersion} >= 725) ) { FRITZBOX_Log $hash, 2, "No boxUser set. Please define it (once) with 'attr $name boxUser YourBoxUser'"; %retHash = ( "Error" => "No attr boxUser set", "ResetSID" => "1" ) ; return \%retHash; @@ -9592,10 +10765,10 @@ sub FRITZBOX_call_Lua_Query($$@) return \%retHash; } - my $agent = LWP::UserAgent->new( env_proxy => 1, keep_alive => 1, protocols_allowed => ['http'], timeout => 180); + my $agent = LWP::UserAgent->new( env_proxy => 1, keep_alive => 1, protocols_allowed => ['http'], timeout => $hash->{AGENTTMOUT}); my $response; - FRITZBOX_Log $hash, 5, "get -> URL: $url"; + FRITZBOX_Log $hash, 4, "get -> URL: $url"; $response = $agent->get ( $url ); @@ -9656,10 +10829,10 @@ sub FRITZBOX_read_LuaData($$$@) FRITZBOX_Log $hash, 4, "URL: $url"; - my $agent = LWP::UserAgent->new( env_proxy => 1, keep_alive => 1, protocols_allowed => ['http'], timeout => 180); + my $agent = LWP::UserAgent->new( env_proxy => 1, keep_alive => 1, protocols_allowed => ['http'], timeout => $hash->{AGENTTMOUT}); my $response = $agent->post ( $url, $queryStr ); - FRITZBOX_Log $hash, 4, "Response: " . $response->status_line . "\n" . $response->content; + FRITZBOX_Log $hash, 5, "Response: " . $response->status_line . "\n" . $response->content; unless ($response->is_success) { my %retHash = ("Error" => $response->status_line, "ResetSID" => "1"); @@ -9881,7 +11054,7 @@ sub FRITZBOX_Helper_process_JSON($$$@) { $jsonText =~ s/\\'/'/g; #Hochkomma $jsonText =~ s/\\x\{[0-9a-f]\}//g; #delete control codes (as hex numbers) - FRITZBOX_Log $hash, 5, "Decode JSON string."; + FRITZBOX_Log $hash, 4, "Decode JSON string."; my $jsonResult ; if ($charSet eq "UTF-8") { @@ -9927,6 +11100,12 @@ sub FRITZBOX_Helper_analyse_Lua_Result($$;@) my $tmp; + if (defined $result->{Error} ) { + return "ERROR: " . $result->{Error}; + } elsif (defined $result->{AuthorizationRequired}){ + return "ERROR: " . $result->{AuthorizationRequired}; + } + if (defined $result->{ResetSID}) { if ($result->{ResetSID}) { $hash->{fhem}{sidErrCount} += 1; @@ -9937,12 +11116,6 @@ sub FRITZBOX_Helper_analyse_Lua_Result($$;@) } } - if (defined $result->{Error} ) { - $tmp = "ERROR: " . $result->{Error}; - } elsif (defined $result->{AuthorizationRequired}){ - $tmp = "ERROR: " . $result->{AuthorizationRequired}; - } - if (defined $result->{sid}) { $hash->{fhem}{sid} = $result->{sid}; @@ -10271,7 +11444,7 @@ sub FRITZBOX_Helper_read_Password($) $dec_pwd.=chr(ord($char)^ord($decode)); $key=$decode.$key; } - + return $dec_pwd; } else { @@ -10351,6 +11524,52 @@ sub FRITZBOX_Helper_Url_Regex { ##################################### +############################################################################### +# This example Perl script demonstrates converting arbitrary JSON # +# to HTML using JSON::Parse and HTML::Make # +# Regular expression for URL validation in Perl # +# # +# https://www.lemoda.net/perl/json-to-html/index.html # +############################################################################### +# html xhr 1 lang de page mobile xhrId all +# +# sub FRITZBOX_Helper_Json2HTML($) { +# binmode STDOUT, ":encoding(utf8)"; +# +# my ($input) = @_; +# +# my $element; +# if (ref $input eq 'ARRAY') { +# +# $element = HTML::Make->new ('ol'); +# +# for my $k (@$input) { +# my $li = $element->push ('li'); +# $li->push (FRITZBOX_Helper_Json2HTML ($k)); +# } +# +# } elsif (ref $input eq 'HASH') { +# +# $element = HTML::Make->new ('table'); +# +# for my $k (sort keys %$input) { +# my $tr = $element->push ('tr'); +# $tr->push ('th', text => $k); +# my $td = $tr->push ('td'); +# $td->push (FRITZBOX_Helper_Json2HTML ($input->{$k})); +# } +# +# } else { +# $element = HTML::Make->new ('span', text => $input); +# } +# +# return $element->text(); +# +# } # end FRITZBOX_Helper_Json2HTML + +##################################### + + 1; =pod @@ -10679,6 +11898,21 @@ sub FRITZBOX_Helper_Url_Regex { Status in reading: retStat_wlanLogExtended.
+
  • +
    set <name> wlanGuestParams <param:value> [<param:value> ...]
    +
    + Possible combinations of <param:value> +
      +
    • <wlan:on|off>
    • +
    • <ssid:name>
    • +
    • <psk:password>
    • +
    • <mode:private|public>
    • +
    • <tmo:minutes> , tmo == timeout in minutes (15 - 4320). If tmo is set, isTimeoutActive is automatically set to on.
    • +
    • <isTimeoutActive:on|off>
    • +
    • <timeoutNoForcedOff:on|off>
    • +
    + Status in Reading: retStat_wlanGuestParams +

  • @@ -10750,7 +11984,7 @@ sub FRITZBOX_Helper_Url_Regex {
  • -
    get <name> luaInfo <landevices|ledSettings|smartHome|vpnShares|globalFilters|kidProfiles|userInfos|wlanNeighborhood|docsisInformation>
    +
    get <name> luaInfo <landevices|ledSettings|smartHome|vpnShares|globalFilters|kidProfiles|userInfos|wlanNeighborhood|mobileInfo|docsisInformation>

    Needs FRITZ!OS 7.21 or higher.
    lanDevices -> Shows a list of active and inactive lan devices.
    @@ -10762,6 +11996,7 @@ sub FRITZBOX_Helper_Url_Regex { userInfos -> Shows a list of FRITZ!BOX users.
    wlanNeighborhood -> Shows a list of WLAN neighborhood devices.
    docsisInformation -> Shows DOCSIS informations (only Cable).
    + mobileInfo -> Shows cell phone informations.

  • @@ -10835,7 +12070,7 @@ sub FRITZBOX_Helper_Url_Regex {

  • -
    nonblockingTimeOut <50|75|100|125>
    +
    nonblockingTimeOut <30|35|40|50|75|100|125>

    Timeout for fetching data from the Fritz!Box. Default is 55 (seconds).

  • @@ -10870,6 +12105,8 @@ sub FRITZBOX_Helper_Url_Regex {
  • disableBoxReadings <list>

    + If the following readings are deactivated, an entire group of readings is always deactivated.
    + box_dns_Server -> deactivates all readings box_dns_Servern
    disable single box_ Readings.

  • @@ -10877,10 +12114,20 @@ sub FRITZBOX_Helper_Url_Regex {
    enableBoxReadings <list>

    If the following readings are activated, an entire group of readings is always activated.
    - box_energyMode -> activates all readings box_energyMode.*
    - box_globalFilter -> activates all readings box_globalFilter.*
    - box_led -> activates all readings box_led.*
    - box_vdsl -> activates all readings box_vdsl.*
    + box_energyMode -> activates all readings box_energyMode.* FritzOS >= 7.21
    + box_globalFilter -> activates all readings box_globalFilter.* FritzOS >= 7.21
    + box_led -> activates all readings box_led.* FritzOS >= 6.00
    + box_vdsl -> activates all readings box_vdsl.* FritzOS >= 7.80
    + box_dns_Srv -> activates all readings box_dns_Srvn FritzOS > 7.31
    +
    + +
  • +
    enableLogReadings<list>
    +
    + If the following readings are activated, the corresponding system log of the Fritz device is retrieved.
    + box_sys_Log -> gets the system log. Last log date in reading: box_sys_LogNewest
    + box_wlan_Log -> gets the WLAN log. Last log date in reading: box_wlan_LogNewest
    + box_fon_Log -> gets the phone log. Last log date in reading: box_fon_LogNewest

  • @@ -10925,8 +12172,8 @@ sub FRITZBOX_Helper_Url_Regex { Switches the takeover of kid profiles as reading off / on.

  • -
  • -
    enableMobileModem <0 | 1>
    +
  • +
    enableMobileInfo <0 | 1>


    ! Experimentel !

    @@ -11004,7 +12251,9 @@ sub FRITZBOX_Helper_Url_Regex {
  • alarm1_time - Alarm time of the alarm clock 1
  • alarm1_wdays - Weekdays of the alarm clock 1

  • -
  • box_box_dns_Servern - DNS Server
  • +
  • box_box_dns_Servern - Provider DNS Server
  • +
  • box_box_dns_Srvn_used_IPv4_n - used IPv4 DNS Server
  • +
  • box_box_dns_Srvn_used_IPv6_n - used IPv6 DNS Server
  • box_connection_Type - connection type
  • box_cpuTemp - Tempreture of the Fritx!Box CPU
  • box_dect - Current state of the DECT base: activ, inactiv
  • @@ -11019,6 +12268,14 @@ sub FRITZBOX_Helper_Url_Regex {
  • box_guestWlan - Current state of the guest WLAN
  • box_guestWlanCount - Number of devices connected to guest WLAN
  • box_guestWlanRemain - Remaining time until the guest WLAN is switched off
  • +
  • box_guestWlan - Aktueller Status des Gäste-WLAN
  • +
  • box_guestWlanCount - Anzahl der Geräte die über das Gäste-WLAN verbunden sind
  • +
  • box_guestWlanRemain - Verbleibende Zeit bis zum Ausschalten des Gäste-WLAN
  • +
  • box_guestWlan_SSID - guest WLAN Name (SSID)
  • +
  • box_guestWlan_defPubSSID - default public name (SSID)
  • +
  • box_guestWlan_defPrivSSID - default private name (SSID)
  • +
  • box_guestWlan_groupAccess - group access active
  • +
  • box_guestWlan_tmoActive - time restriction active
  • box_globalFilterNetbios - Current status: NetBIOS filter active
  • box_globalFilterSmtp - Current status: Email filter active via port 25
  • box_globalFilterStealth - Current status: Firewall in stealth mode
  • @@ -11045,6 +12302,7 @@ sub FRITZBOX_Helper_Url_Regex {
  • box_uptime - uptime since last reboot
  • box_uptimeConnect - connect uptime since last reconnect
  • box_powerRate - current power in percent of maximal power
  • +
  • box_powerLine - powerline active
  • box_rateDown - average download rate in the last update interval
  • box_rateUp - average upload rate in the last update interval
  • box_stdDialPort - standard caller port when using the dial function of the box
  • @@ -11118,22 +12376,20 @@ sub FRITZBOX_Helper_Url_Regex {
  • gsm_state - state of the connection to the GSM network
  • gsm_technology - GSM technology used for data transfer (GPRS, EDGE, UMTS, HSPA)

  • -
  • mac_nn_nn_nn_nn_nn_nn - MAC address and name of an active network device. +
  • mobileInfo_... - Mobile radio readings (USB mobile radio stick or FritzBox LTE).

  • - If no MAC address is provided, e.g. Switch or VPN, then the FritzBox DeviceID is used instead of the MAC address. -
    - For a WLAN connection, "WLAN" and (as seen from the box) the sending and receiving speed and the reception strength are appended. For a LAN connection, the LAN port and the LAN speed are appended. Guest connections are marked with “gWLAN” or “gLAN”.
    +
  • mac_nn_nn_nn_nn_nn_nn - MAC address and name of an active network device.
    + If no MAC address is provided, e.g. Switch or VPN, then the FritzBox DeviceID is used instead of the MAC address.
    + For a WLAN connection, "WLAN" and (as seen from the box) the sending and receiving speed and the reception strength are appended. For a LAN connection, the LAN port and the LAN speed are appended. Guest connections are marked with “gWLAN” or “gLAN”.
    Inactive or removed devices first receive the value "inactive: IP address" or "inactive: DeviceID" if no IP address is available
    and will be deleted with the next update.

  • -
  • ip_nnn.nnn.nnn.nnn - IP address and name of an active network device. -
    - For a WLAN connection, "WLAN" and (as seen from the box) the sending and receiving speed and the reception strength are appended. For a LAN connection, the LAN port and the LAN speed are appended. Guest connections are marked with “gWLAN” or “gLAN”. -
    +
  • ip_nnn.nnn.nnn.nnn - IP address and name of an active network device.
    + For a WLAN connection, "WLAN" and (as seen from the box) the sending and receiving speed and the reception strength are appended. For a LAN connection, the LAN port and the LAN speed are appended. Guest connections are marked with “gWLAN” or “gLAN”.
    Inactive or removed devices will first receive the value "inactive: DeviceID" and will be deleted with the next update.
  • -
  • nbh_nn_nn_nn_nn_nn_nn - MAC address and name of an active WLAN neighborhood device.
    +
  • nbh_nn_nn_nn_nn_nn_nn - MAC address and name of an active WLAN neighborhood device.
    shown is the SSID, the channel and the bandwidth. Inactive or removed devices get first the value "inactive" and will be deleted during the next update.

  • radionn - Name of the internet radio station 01
  • @@ -11188,6 +12444,7 @@ sub FRITZBOX_Helper_Url_Regex {
  • retStat_smartHome - Return Status: set <name> smartHome
  • retStat_wakeUpCall - Return Status: set <name> wakeUpCall
  • retStat_wlanLogExtended - Return Status: set <name> wlanLogExtended <on|off>
  • +
  • retStat_wlanGuestParams - Return Status

  • @@ -11584,6 +12841,22 @@ sub FRITZBOX_Helper_Url_Regex {
    Status in Reading: retStat_wlanLogExtended
    + +
  • +
    set <name> wlanGuestParams <param:value> [<param:value> ...]
    +
    + Mögliche Kombinationen aus <param:value> +
      +
    • <wlan:on|off>
    • +
    • <ssid:name>
    • +
    • <psk:password>
    • +
    • <mode:private|public>
    • +
    • <tmo:minutes> , tmo == timeout in Minuten (15 - 4320). Wird tmo gesetzt, so wird automatisch isTimeoutActive auf on gesetzt.
    • +
    • <isTimeoutActive:on|off>
    • +
    • <timeoutNoForcedOff:on|off>
    • +
    + Status in Reading: retStat_wlanGuestParams +

  • @@ -11637,7 +12910,7 @@ sub FRITZBOX_Helper_Url_Regex {
    get <name> luaData [json] <Command>

    Führt Komandos über data.lua aus. Sofern in den Parametern ein Semikolon vorkommt ist dieses durch #x003B zu ersetzen.
    - Optional kann als erster Parameter json angegeben werden. Es wir dann für wietere Verarbeitungen das Ergebnis als JSON zurück gegeben. + Optional kann als erster Parameter json angegeben werden. Es wir dann für weitere Verarbeitungen das Ergebnis als JSON zurück gegeben.
  • @@ -11655,7 +12928,7 @@ sub FRITZBOX_Helper_Url_Regex {

  • -
    get <name> luaInfo <landevices|ledSettings|smartHome|vpnShares|globalFilters|kidProfiles|userInfos|wlanNeighborhood|docsisInformation>
    +
    get <name> luaInfo <landevices|ledSettings|smartHome|vpnShares|globalFilters|kidProfiles|userInfos|wlanNeighborhood|mobileInfo|docsisInformation>

    Benötigt FRITZ!OS 7.21 oder höher.
    lanDevices -> Generiert eine Liste der aktiven und inaktiven Netzwerkgeräte.
    @@ -11666,6 +12939,7 @@ sub FRITZBOX_Helper_Url_Regex { kidProfiles -> Generiert eine Liste der Zugangsprofile.
    userInfos -> Generiert eine Liste der FRITZ!BOX Benutzer.
    wlanNeighborhood -> Generiert eine Liste der WLAN Nachbarschaftsgeräte.
    + mobileInfo -> Informationen über Mobilfunk.
    docsisInformation -> Zeigt Informationen zu DOCSIS an (nur Cable).

  • @@ -11739,7 +13013,7 @@ sub FRITZBOX_Helper_Url_Regex {
  • -
    nonblockingTimeOut <50|75|100|125>
    +
    nonblockingTimeOut <30|35|40|50|75|100|125>

    Timeout für das regelmäßige Holen der Daten von der Fritz!Box. Standard ist 55 (Sekunden).

  • @@ -11776,21 +13050,27 @@ sub FRITZBOX_Helper_Url_Regex {
    Abwählen einzelner box_ Readings.
    Werden folgende Readings deaktiviert, so wird immer eine ganze Gruppe von Readings deaktiviert.
    - box_dns_Server -> deaktiviert alle Readings box_box_dns_Servern
    - box_led -> deaktiviert alle Readings box_led.*
    - box_energyMode -> deaktiviert alle Readings box_energyMode.*
    - box_globalFilter -> deaktiviert alle Readings box_globalFilter.*
    - box_vdsl deaktiviert -> alle Readings box_vdsl.*
    + box_dns_Server -> deaktiviert alle Readings box_dns_Servern

  • enableBoxReadings <liste>

    Werden folgende Readings aktiviert, so wird immer eine ganze Gruppe von Readings aktiviert.
    - box_energyMode -> aktiviert alle Readings box_energyMode.*
    - box_globalFilter -> aktiviert alle Readings box_globalFilter.*
    - box_led -> aktiviert alle Readings box_led.*
    - box_vdsl -> aktiviert alle Readings box_vdsl.*
    + box_energyMode -> aktiviert alle Readings box_energyMode.* FritzOS >= 7.21
    + box_globalFilter -> aktiviert alle Readings box_globalFilter.* FritzOS >= 7.21
    + box_led -> aktiviert alle Readings box_led.* FritzOS >= 6.00
    + box_vdsl -> aktiviert alle Readings box_vdsl.* FritzOS >= 7.80
    + box_dns_Srv -> aktiviert alle Readings box_dns_Srvn FritzOS > 7.31
    +

  • + +
  • +
    enableLogReadings<liste>
    +
    + Werden folgende Readings aktiviert, wird das entsprechende SystemLog des Fritz Gerätes abgeholt.
    + box_sys_Log -> holt das System-Log. Letztes Log-Datum im Reading: box_sys_LogNewest
    + box_wlan_Log -> holt das WLAN-Log. Letztes Log-Datum im Reading: box_wlan_LogNewest
    + box_fon_Log -> holt das Telefon-Log. Letztes Log-Datum im Reading: box_fon_LogNewest

  • @@ -11835,8 +13115,8 @@ sub FRITZBOX_Helper_Url_Regex { Schaltet die Übernahme von Kid-Profilen als Reading aus/ein.

  • -
  • -
    enableMobileModem <0 | 1>
    +
  • +
    enableMobileInfo <0 | 1>


    ! Experimentel !

    @@ -11917,7 +13197,9 @@ sub FRITZBOX_Helper_Url_Regex {
  • box_connection_Type - Verbindungsart
  • box_cpuTemp - Temperatur der FritxBox CPU
  • box_dect - Aktueller Status des DECT-Basis: aktiv, inaktiv
  • -
  • box_box_dns_Servern - genutzte DNS Server
  • +
  • box_box_dns_Servern - Provider DNS Server
  • +
  • box_box_dns_Srvn_used_IPv4_n - benutzte IPv4 DNS Server
  • +
  • box_box_dns_Srvn_used_IPv6_n - benutzte IPv6 DNS Server
  • box_dsl_downStream - Min Effektive Datenrate (MBit/s)
  • box_dsl_upStream - Min Effektive Datenrate (MBit/s)
  • box_energyMode - Energiemodus der FritzBox
  • @@ -11926,14 +13208,19 @@ sub FRITZBOX_Helper_Url_Regex {
  • box_energyModeWLAN_Repetition - Wiederholung des WLAN Tminers
  • box_fon_LogNewest - aktuellstes Telefonie-Ereignis: ID Datum Zeit
  • box_fwVersion - Firmware-Version der Box, wenn veraltet dann wird '(old)' angehangen
  • -
  • box_guestWlan - Aktueller Status des Gäste-WLAN
  • box_globalFilterNetbios - Aktueller Status: NetBIOS-Filter aktiv
  • box_globalFilterSmtp - Aktueller Status: E-Mail-Filter über Port 25 aktiv
  • box_globalFilterStealth - Aktueller Status: Firewall im Stealth Mode
  • box_globalFilterTeredo - Aktueller Status: Teredo-Filter aktiv
  • box_globalFilterWpad - Aktueller Status: WPAD-Filter aktiv
  • +
  • box_guestWlan - Aktueller Status des Gäste-WLAN
  • box_guestWlanCount - Anzahl der Geräte die über das Gäste-WLAN verbunden sind
  • box_guestWlanRemain - Verbleibende Zeit bis zum Ausschalten des Gäste-WLAN
  • +
  • box_guestWlan_SSID - Name (SSID) des Gäste-WLAN
  • +
  • box_guestWlan_defPubSSID - Standard öffentlicher Name (SSID) des Gäste-WLAN
  • +
  • box_guestWlan_defPrivSSID - Standard privater Name (SSID) des Gäste-WLAN
  • +
  • box_guestWlan_groupAccess - Gruppenzugriff möglich
  • +
  • box_guestWlan_tmoActive - Zeitbrenzung aktiv
  • box_ipv4_Extern - Internet IPv4 der FRITZ!BOX
  • box_ipv6_Extern - Internet IPv6 der FRITZ!BOX
  • box_ipv6_Prefix - Internet IPv6 Prefix der FRITZ!BOX für das LAN/WLAN
  • @@ -11955,6 +13242,7 @@ sub FRITZBOX_Helper_Url_Regex {
  • box_uptime - Laufzeit seit letztem Neustart
  • box_uptimeConnect - Verbindungsdauer seit letztem Neuverbinden
  • box_powerRate - aktueller Stromverbrauch in Prozent der maximalen Leistung
  • +
  • box_powerLine - verbindung über Powerline aktiv
  • box_rateDown - Download-Geschwindigkeit des letzten Intervals in kByte/s
  • box_rateUp - Upload-Geschwindigkeit des letzten Intervals in kByte/s
  • box_sys_LogNewest - aktuellstes Systemereignis: ID Datum Zeit
  • @@ -12024,25 +13312,20 @@ sub FRITZBOX_Helper_Url_Regex {
  • gsm_state - Status der Mobilfunk-Verbindung
  • gsm_technology - GSM-Technologie, die für die Datenübertragung genutzt wird (GPRS, EDGE, UMTS, HSPA)

  • -
  • mac_nn_nn_nn_nn_nn_nn - MAC Adresse und Name eines aktiven Netzwerk-Gerätes. -
    - Wird keine MAC-Adresse bereit gestellt,z.B. Switch oder VPN, dann wird anstatt der MAC-Adresse die FritzBox DeviceID genommen. -
    - Bei einer WLAN-Verbindung wird "WLAN" und (von der Box gesehen) die Sende- und Empfangsgeschwindigkeit und die Empfangsstärke angehangen. Bei einer LAN-Verbindung wird der LAN-Port und die LAN-Geschwindigkeit angehangen. Gast-Verbindungen werden mit "gWLAN" oder "gLAN" gekennzeichnet. +
  • mobileInfo_... - Mobilfunk Readings (USB-Mobilfunk-Stick oder FritzBox LTE).

  • +
  • mac_nn_nn_nn_nn_nn_nn - MAC Adresse und Name eines aktiven Netzwerk-Gerätes.
    + Wird keine MAC-Adresse bereit gestellt,z.B. Switch oder VPN, dann wird anstatt der MAC-Adresse die FritzBox DeviceID genommen.
    + Bei einer WLAN-Verbindung wird "WLAN" und (von der Box gesehen) die Sende- und Empfangsgeschwindigkeit und die Empfangsstärke angehangen. Bei einer LAN-Verbindung wird der LAN-Port und die LAN-Geschwindigkeit angehangen. Gast-Verbindungen werden mit "gWLAN" oder "gLAN" gekennzeichnet.
    Inaktive oder entfernte Geräte erhalten zuerst den Werte "inactive: IP-Adresse" bzw "inactiv: DeviceID" wenn keine IP-Adresse zur Verfügung steht
    und werden beim nächsten Update gelöscht.

  • -
  • ip_nnn.nnn.nnn.nnn - IP-Adresse und Name eines aktiven Netzwerk-Gerätes. -
    - Bei einer WLAN-Verbindung wird "WLAN" und (von der Box gesehen) die Sende- und Empfangsgeschwindigkeit und die Empfangsstärke angehangen. Bei einer LAN-Verbindung wird der LAN-Port und die LAN-Geschwindigkeit angehangen. Gast-Verbindungen werden mit "gWLAN" oder "gLAN" gekennzeichnet. -
    +
  • ip_nnn.nnn.nnn.nnn - IP-Adresse und Name eines aktiven Netzwerk-Gerätes.
    + Bei einer WLAN-Verbindung wird "WLAN" und (von der Box gesehen) die Sende- und Empfangsgeschwindigkeit und die Empfangsstärke angehangen. Bei einer LAN-Verbindung wird der LAN-Port und die LAN-Geschwindigkeit angehangen. Gast-Verbindungen werden mit "gWLAN" oder "gLAN" gekennzeichnet.
    Inaktive oder entfernte Geräte erhalten zuerst den Wert "inactive: DeviceID" und werden beim nächsten Update gelöscht.

  • -
  • nbh_nn_nn_nn_nn_nn_nn - MAC-Adresse und Name eines aktiven WAN-Gerätes. -
    - Es wird die SSID, der Kanal und das Frequenzband angezeigt. -
    +
  • nbh_nn_nn_nn_nn_nn_nn - MAC-Adresse und Name eines aktiven WAN-Gerätes.
    + Es wird die SSID, der Kanal und das Frequenzband angezeigt.
    Inaktive oder entfernte Geräte erhalten zuerst den Werte "inactive" und werden beim nächsten Update gelöscht.

  • radionn - Name der Internetradiostation 01
  • @@ -12097,6 +13380,7 @@ sub FRITZBOX_Helper_Url_Regex {
  • retStat_smartHome - Return Status: set <name> smartHome
  • retStat_wakeUpCall - Return Status: set <name> wakeUpCall
  • retStat_wlanLogExtended - Return Status: set <name> wlanLogExtended <on|off>
  • +
  • retStat_wlanGuestParams - Return Status