diff --git a/fhem/CHANGED b/fhem/CHANGED index 9443675ed..b1611a37a 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: 98_pilight.pm: New protocols - feature: 55_InfoPanel - added direct link to rect,circle,ellipse, img, trash - added new layout item "counter" diff --git a/fhem/FHEM/98_pilight.pm b/fhem/FHEM/98_pilight.pm index e7f8d73c6..457471222 100644 --- a/fhem/FHEM/98_pilight.pm +++ b/fhem/FHEM/98_pilight.pm @@ -13,7 +13,7 @@ pilight_Initialize($) $hash->{SetFn} = "pilight_Set"; $hash->{DefFn} = "pilight_Define"; - $hash->{AttrList} = "protocol housecode number systemcode unitcode id remote_ip remote_port"; + $hash->{AttrList} = "protocol housecode number systemcode unitcode id remote_ip remote_port useOldVersion rawCodeOn rawCodeOff"; } # housecode == id und number == unitcode @@ -76,12 +76,15 @@ sub commit my ($hash, $on) = @_; my $name = $hash->{NAME}; my $protocol = $hash->{protocol}; + my $rawCodeOn = AttrVal($name, "rawCodeOn", $hash->{rawCodeOn}); + my $rawCodeOff = AttrVal($name, "rawCodeOff", $hash->{rawCodeOff}); my $housecode = AttrVal($name, "id", AttrVal($name, "housecode", $hash->{housecode})); my $unit = AttrVal($name, "unitcode", $hash->{unitcode}); my $systemcode = AttrVal($name, "systemcode", '0'); my $param = $on ? "on" : "off"; my $remote_ip = AttrVal($name, "remote_ip", '127.0.0.1'); my $remote_port = AttrVal($name, "remote_port", '5000'); + my $useOldVersion = AttrVal($name, "useOldVersion", undef); my ($socket,$client_socket); # flush after every write @@ -92,16 +95,16 @@ sub commit PeerPort => $remote_port, Proto => 'tcp', ); - + if (!$socket) { - Log 3, "pilight: ERROR. Can't open socket to pilight-daemon: $!\n"; + Log 3, "pilight: ERROR. Can't open socket to pilight-daemon: $! See: https://github.com/andreas-fey/fhem-pilight/issues/3\n"; return undef }; my $data = '{ "message": "client sender" }'; $socket->send($data); $socket->recv($data,1024); - + $data =~ s/\n/ /g; if ( $data !~ /accept client/ ) { Log 3, "pilight: ERROR. No handshake with pilight-daemon. Received: >>>$data<<<\n"; @@ -109,9 +112,53 @@ sub commit }; my $code = "{\"protocol\":[ \"$protocol\" ],"; - switch( $protocol ) { - case 'kaku_switch' { $code = $code . "\"id\":\"$housecode\", \"unit\":\"$unit\",\"$param\":\"1\""} - case 'elro' { $code = $code . "\"systemcode\":\"$systemcode\", \"unitcode\":\"$unit\",\"$param\":\"1\""} + if($useOldVersion) { + switch( $protocol ) { + case 'kaku_switch' { $code = $code . "\"id\":\"$housecode\", \"unit\":\"$unit\",\"$param\":\"1\""} + case 'quigg_switch' { $code = $code . "\"id\":\"$housecode\", \"unit\":\"$unit\",\"$param\":\"1\""} + case 'elro' { $code = $code . "\"systemcode\":\"$systemcode\", \"unitcode\":\"$unit\",\"$param\":\"1\""} + case 'elro_he' { $code = $code . "\"systemcode\":\"$systemcode\", \"unitcode\":\"$unit\",\"$param\":\"1\""} + case 'elro_hc' { $code = $code . "\"systemcode\":\"$systemcode\", \"unitcode\":\"$unit\",\"$param\":\"1\""} + case 'silvercrest' { $code = $code . "\"systemcode\":\"$systemcode\", \"unitcode\":\"$unit\",\"$param\":\"1\""} + case 'pollin' { $code = $code . "\"systemcode\":\"$systemcode\", \"unitcode\":\"$unit\",\"$param\":\"1\""} + case 'mumbi' { $code = $code . "\"systemcode\":\"$systemcode\", \"unitcode\":\"$unit\",\"$param\":\"1\""} + case 'intertechno_old' { $code = $code . "\"id\":\"$systemcode\", \"unit\":\"$unit\",\"$param\":\"1\""} + } + } + else { + if( $protocol eq 'raw') + { + Log 3, "pilight protocol: $protocol"; + Log 4, "pilight raw param: $param"; + Log 4, "pilight rawCodeOn: $rawCodeOn"; + Log 4, "piligth rawCodeCff: $rawCodeOff"; + + switch( $param ) { + case 'on' { $code = $code . "\"code\":\"$rawCodeOn\""} # on + case 'off' { $code = $code . "\"code\":\"$rawCodeOff\""} #off + } + } + else + { + switch( $protocol ) { + case 'kaku_switch' { $code = $code . "\"id\":$housecode, \"unit\":$unit,\"$param\":1"} + case 'quigg_switch' { $code = $code . "\"id\":$housecode, \"unit\":$unit,\"$param\":1"} + case 'elro' { $code = $code . "\"systemcode\":$systemcode, \"unitcode\":$unit,\"$param\":1"} + case 'elro_he' { $code = $code . "\"systemcode\":$systemcode, \"unitcode\":$unit,\"$param\":1"} + case 'elro_hc' { $code = $code . "\"systemcode\":$systemcode, \"unitcode\":$unit,\"$param\":1"} + case 'silvercrest' { $code = $code . "\"systemcode\":$systemcode, \"unitcode\":$unit,\"$param\":1"} + case 'pollin' { $code = $code . "\"systemcode\":$systemcode, \"unitcode\":$unit,\"$param\":1"} + case 'brennenstuhl' { $code = $code . "\"systemcode\":$systemcode, \"unitcode\":$unit,\"$param\":1"} + case 'mumbi' { $code = $code . "\"systemcode\":$systemcode, \"unitcode\":$unit,\"$param\":1"} + case 'impuls' { $code = $code . "\"systemcode\":$systemcode, \"programcode\":$unit,\"$param\":1"} + case 'rsl366' { $code = $code . "\"systemcode\":$systemcode, \"programcode\":$unit,\"$param\":1"} + case 'intertechno_old' { $code = $code . "\"id\":$systemcode, \"unit\":$unit,\"$param\":1"} + case 'clarus_switch' { $code = $code . "\"id\":$systemcode, \"unit\":$unit,\"$param\":1"} + case 'rev1_switch' { $code = $code . "\"id\":\"$systemcode\", \"unit\":$unit,\"$param\":1"} + case 'rev2_switch' { $code = $code . "\"id\":\"$systemcode\", \"unit\":$unit,\"$param\":1"} + case 'rev3_switch' { $code = $code . "\"id\":\"$systemcode\", \"unit\":$unit,\"$param\":1"} + } + } } $code = $code . '}'; @@ -139,7 +186,7 @@ sub commit

Defines a module for setting pilight compartible switches on or off. See Sweetpi.

- Supported protocols: kaku_switch, elso. If you need more, just contact me!

+ Supported protocols: kaku_switch, quigg_switch, elro_he, elro_hc, silvercrest, pollin, brennenstuhl, mumbi, impuls, rsl366, rev1_switch, rev2_switch, clarus_switch, raw, and intertechno_old. If you need more, just write an issue!

Example:
- If your pilight server does not run on localhost, please set both the attributes remote_ip and remote_port. + If your pilight server does not run on localhost, please set both the attributes remote_ip and remote_port. If you are running pilight >3.0, then please define the port used by pilight settings: http://www.pilight.org/getting-started/settings/; fhem-plight uses 5000 by default.
+ This version is written for pilight 5.0. If you run a version < 3.0, please set the following attribute: + attr Weihnachtsbaum useOldVersion 1 @@ -156,18 +205,25 @@ sub commit =end html =cut +