diff --git a/fhem/CHANGED b/fhem/CHANGED index 70fe0a689..6f93c3c29 100644 --- a/fhem/CHANGED +++ b/fhem/CHANGED @@ -1,5 +1,6 @@ # Add changes at the top of the list. Keep it in ASCII, and 80-char wide. # Do not insert empty lines here, update check depends on it. + - changed: 88_xs1Bridge: changed for another module - bugfix: 88_HMCCU: Fixed bug in attribute peer - bugfix: 32_withings, 38_netatmo: maintenance update - added: 72_XiaomiDevice: added new module for Xiaomi WiFi devices diff --git a/fhem/FHEM/88_xs1Bridge.pm b/fhem/FHEM/88_xs1Bridge.pm index 735ac3352..81ffba991 100644 --- a/fhem/FHEM/88_xs1Bridge.pm +++ b/fhem/FHEM/88_xs1Bridge.pm @@ -37,13 +37,14 @@ sub xs1Bridge_Initialize($) { $hash->{AttrFn} = "xs1Bridge_Attr"; $hash->{UndefFn} = "xs1Bridge_Undef"; $hash->{AttrList} = "debug:0,1 ". - "disable:0,1 ". - "ignore:0,1 ". - "interval:30,60,180,360 ". - "update_only_difference:0,1 ". - "view_Device_name:0,1 ". - "view_Device_function:0,1 "; - ##$readingFnAttributes; ## die Standardattribute von FHEM + "disable:0,1 ". + "ignore:0,1 ". + "interval:30,60,180,360 ". + "update_only_difference:0,1 ". + "view_Device_name:0,1 ". + "view_Device_function:0,1 ". + "xs1_control:0,1 "; + ##$readingFnAttributes; ## die Standardattribute von FHEM foreach my $d(sort keys %{$modules{xs1Bridge}{defptr}}) { my $hash = $modules{xs1Bridge}{defptr}{$d}; @@ -64,14 +65,15 @@ sub xs1Bridge_Define($$) { return "Your IP is not valid. Please Check!" if not($arg[2] =~ /[0-9]{1,3}[.][0-9]{1,3}[.][0-9]{1,3}[.][0-9]{1,3}/s); return "Cannot define xs1Bridge device. Perl modul ${missingModul}is missing." if ( $missingModul ); - my $xs1check; - my $p = Net::Ping->new("tcp", 2); - if(!($p->ping("$arg[2]", 2))) { - $xs1check = 1 ; + my $xs1check = 0; + if(!defined $modules{xs1Bridge}) { + my $p = Net::Ping->new("tcp", 2); + if(!($p->ping("$arg[2]", 2))) { + $xs1check = 1; + } + $p->close(); + return "Your IP is not reachable. Please Check!" if ($xs1check == 1); } - $p->close(); - - return "Your IP is not reachable. Please Check!" if ($xs1check == 1); # Parameter Define my $xs1_ip = $arg[2]; ## Zusatzparameter 1 bei Define - ggf. nur in Sub @@ -83,9 +85,10 @@ sub xs1Bridge_Define($$) { $hash->{BRIDGE} = 1; # Attribut gesetzt - $attr{$name}{disable} = "0"; - $attr{$name}{interval} = "60"; - $attr{$name}{room} = "xs1" if( not defined( $attr{$name}{room} ) ); + $attr{$name}{disable} = "0"; + $attr{$name}{interval} = "60"; + $attr{$name}{room} = "xs1" if( not defined( $attr{$name}{room} ) ); + $attr{$name}{xs1_control} = "0"; $modules{xs1Bridge}{defptr}{BRIDGE} = $hash; @@ -110,6 +113,7 @@ sub xs1Bridge_Attr(@) { my $viewDeviceName = AttrVal($hash->{NAME},"view_Device_name",0); my $viewDeviceFunction = AttrVal($hash->{NAME},"view_Device_function",0); my $update_only_difference = AttrVal($hash->{NAME},"update_only_difference",0); + my $xs1_control = AttrVal($hash->{NAME},"xs1_control",0); # $cmd - Vorgangsart - kann die Werte "del" (löschen) oder "set" (setzen) annehmen # $name - Gerätename @@ -161,6 +165,13 @@ sub xs1Bridge_Attr(@) { delete $hash->{READINGS}{"Aktor_".sprintf("%02d", $i)."_name"} if($hash->{READINGS}); } } + }elsif ($attrName eq "xs1_control") { + if ($attrValue eq "1") { ## Handling bei attribute disable 1 + if(! $modules{xs1Dev}) { ## Check Modul vorhanden + $attr{$name}{xs1_control} = "0"; + return "Module xs1Dev is non-existent or still under development. Please wait" + } + } } } @@ -232,7 +243,8 @@ sub xs1Bridge_GetUpDate() { my $viewDeviceName = AttrVal($hash->{NAME},"view_Device_name",0); my $viewDeviceFunction = AttrVal($hash->{NAME},"view_Device_function",0); my $update_only_difference = AttrVal($hash->{NAME},"update_only_difference",0); - + my $xs1_control = AttrVal($hash->{NAME},"xs1_control",0); + if (AttrVal($hash->{NAME},"disable",0) == 0 && $xs1_ConnectionTry <= 5) { RemoveInternalTimer($hash); ## Timer löschen InternalTimer(gettimeofday()+$interval, "xs1Bridge_GetUpDate", $hash); @@ -283,9 +295,10 @@ sub xs1Bridge_GetUpDate() { # ERROR Message # http://192.168.2.5/control?callback=cname&cmd=get_list_actuators: Can't connect(1) to http://192.168.2.5:80: IO::Socket::INET: connect: No route to host # http://192.168.2.5/control?callback=cname&cmd=get_config_info: empty answer received + # http://192.168.2.5/control?callback=cname&cmd=get_config_info: Select timeout/error: - ($Http_err) = $Http_err =~ /[:]\s.*/g; - Log3 $name, 3, "$typ: GetUpDate | Try=$xs1_ConnectionTry loop=$i | Error".$Http_err; + #($Http_err) = $Http_err =~ /[:]\s.*/g; + Log3 $name, 3, "$typ: GetUpDate | Try=$xs1_ConnectionTry loop=$i | Error: ".$Http_err; $xs1_ConnectionTry++; last; ## Abbruch Schleife } elsif ($Http_data ne "") { ## HTTP Requests, OK dann ARRAY Verarbeitung @@ -294,7 +307,6 @@ sub xs1Bridge_GetUpDate() { $decoded = eval {decode_json( $json_utf8 )}; $xs1_ConnectionTry = 1; - if ($i <= 1 ) { ### xs1 Aktoren / Sensoren my $xs1_data; my @array; @@ -381,7 +393,7 @@ sub xs1Bridge_GetUpDate() { } ### Dispatch an xs1Device Modul - if ($xs1Dev_check eq "ok") { + if ($xs1Dev_check eq "ok" && $xs1_control == 1) { Debug " $typ: GetUpDate | Dispatch: $xs1_data" if($debug); Dispatch($hash,$xs1_data,undef) if($xs1_data); } @@ -460,7 +472,7 @@ sub xs1Bridge_GetUpDate() { sub xs1Bridge_Write($) ## Zustellen von Daten via IOWrite() vom logischen zum physischen Modul { - my ($hash, $Aktor_ID, $xs1_typ, $cmd) = @_; + my ($hash, $Aktor_ID, $xs1_typ, $cmd, $cmd2) = @_; my $name = $hash->{NAME}; my $typ = $hash->{TYPE}; my $xs1_ip = $hash->{xs1_ip}; @@ -469,16 +481,16 @@ sub xs1Bridge_Write($) ## Zustellen von Daten via IOWrite() vom logischen zum $Aktor_ID = substr($Aktor_ID, 1,2); - if ($xs1_typ eq "switch") { + my $xs1cmd; + if ($xs1_typ eq "switch") { ## Anpassung Sendebefehl xs1 + $xs1cmd = "http://$xs1_ip/control?callback=cname&cmd=set_state_actuator&number=$Aktor_ID&$cmd2"; + } elsif ($xs1_typ eq "dimmer") { if ($cmd eq "off") { $cmd = 0; - } elsif ($cmd eq "on") { - $cmd = 100; } + $xs1cmd = "http://$xs1_ip/control?callback=cname&cmd=set_state_actuator&number=$Aktor_ID&value=$cmd"; } - my $xs1cmd = "http://$xs1_ip/control?callback=cname&cmd=set_state_actuator&number=$Aktor_ID&value=$cmd"; - ### HTTP Requests #### Start #### my $connection; my $Http_err = ""; @@ -589,6 +601,10 @@ sub xs1Bridge_Undef($$)
  • view_Device_function (0,1)
    The actuator functions defined in xs1 are read out as Reading.
    (Default, view_Device_function 0)
    +

  • +
  • xs1_control (0,1)
    + Option to control the xs1. After activating this, the xs1Dev module creates each actuator and sensor in FHEM.
    + (Default, xs1_control 0)


  • explanation: @@ -607,7 +623,8 @@ sub xs1Bridge_Undef($$)
  • xs1_firmware
  • firmware number
  • xs1_start
  • device start

    -
  • The message "... Can't connect ..." in the system logfile says that there was no query for a short time.
  • +
  • The message "... Can't connect ..." or "ERROR: empty answer received" in the system logfile says that there was no query for a short time.
    + (This can happen more often with DLAN.)

  • If the device has not been connected after 5 connection attempts, the module will switch on < disable > !

  • Create logfile automatically after define | scheme: define FileLog_xs1Bridge FileLog ./log/xs1Bridge-%Y-%m.log <name>
    The following values ​​are recorded in logfile: Aktor_(01-64) or Sensor_(01-64) values | Timer | xs1-status information
  • @@ -619,7 +636,7 @@ sub xs1Bridge_Undef($$)

    xs1Bridge

    Erläuterung: @@ -690,7 +711,8 @@ sub xs1Bridge_Undef($$)
  • xs1_firmware
  • Firmwareversion
  • xs1_start
  • Gerätestart

    -
  • Die Meldung "... Can't connect ..." im System-Logfile besagt, das kurzzeitig keine Abfrage erfolgen konnte.
  • +
  • Die Meldung "Error: Can't connect ..." oder "ERROR: empty answer received" im System-Logfile, besagt das kurzzeitig keine Abfrage erfolgen konnte.
    + (Das kann häufiger bei DLAN vorkommen.)

  • Sollte das Gerät nach 5 Verbindungsversuchen ebenfalls keine Verbindung erhalten haben, so schaltet das Modul auf < disable > !

  • Logfile Erstellung erfolgt automatisch nach dem definieren. | Schema: define FileLog_xs1Bridge FileLog ./log/xs1Bridge-%Y-%m.log <Name>
    Folgende Werte werden im Logfile erfasst: Aktor_(01-64) bzw. Sensor_(01-64) Werte | Timer | xs1-Statusinformationen