mirror of
https://github.com/fhem/fhem-mirror.git
synced 2025-03-10 03:06:37 +00:00
98_pilight: more protocols and rewrite
git-svn-id: https://svn.fhem.de/fhem/trunk@9060 2b470e98-0d58-463d-a4d8-8e2adae1ed80
This commit is contained in:
parent
bff49d7ad7
commit
d1ad0c0369
@ -1,5 +1,6 @@
|
|||||||
# Add changes at the top of the list. Keep it in ASCII, and 80-char wide.
|
# 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.
|
# Do not insert empty lines here, update check depends on it.
|
||||||
|
- change: 98_pilight: all protocols, rewrite
|
||||||
- feature: 70_PHTV: added support for WoWifi/WoLAN to wake device up
|
- feature: 70_PHTV: added support for WoWifi/WoLAN to wake device up
|
||||||
- change: 98_GEOFANCY: improved/tightened input validation. 3rd party mobile
|
- change: 98_GEOFANCY: improved/tightened input validation. 3rd party mobile
|
||||||
apps need to ensure using correct API data format.
|
apps need to ensure using correct API data format.
|
||||||
|
@ -13,7 +13,7 @@ pilight_Initialize($)
|
|||||||
|
|
||||||
$hash->{SetFn} = "pilight_Set";
|
$hash->{SetFn} = "pilight_Set";
|
||||||
$hash->{DefFn} = "pilight_Define";
|
$hash->{DefFn} = "pilight_Define";
|
||||||
$hash->{AttrList} = "protocol housecode number systemcode unitcode id remote_ip remote_port useOldVersion rawCodeOn rawCodeOff";
|
$hash->{AttrList} = "protocol housecode number systemcode unitcode id remote_ip remote_port useOldVersion rawCodeOn rawCodeOff follow-on-for-timer";
|
||||||
}
|
}
|
||||||
|
|
||||||
# housecode == id und number == unitcode
|
# housecode == id und number == unitcode
|
||||||
@ -27,8 +27,9 @@ pilight_Set($@)
|
|||||||
return "no set value specified" if(int(@a) < 2);
|
return "no set value specified" if(int(@a) < 2);
|
||||||
return "on off" if($a[1] eq "?");
|
return "on off" if($a[1] eq "?");
|
||||||
|
|
||||||
shift @a;
|
my $command = $a[1];
|
||||||
my $command = shift @a;
|
my $c_timer= "";
|
||||||
|
if(defined($a[2])) { $c_timer=$a[2]; }
|
||||||
|
|
||||||
Log 3, "pilight command: $command";
|
Log 3, "pilight command: $command";
|
||||||
|
|
||||||
@ -36,6 +37,13 @@ pilight_Set($@)
|
|||||||
{
|
{
|
||||||
$rc = commit($hash, 1);
|
$rc = commit($hash, 1);
|
||||||
}
|
}
|
||||||
|
elsif($command eq "on-for-timer")
|
||||||
|
{
|
||||||
|
InternalTimer(gettimeofday()+$c_timer, "pilight_on_timeout",$hash, 0);
|
||||||
|
# on-for-timer is now a on.
|
||||||
|
$rc = commit($hash, 1);
|
||||||
|
}
|
||||||
|
# elsif
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
$rc = commit($hash, 0);
|
$rc = commit($hash, 0);
|
||||||
@ -51,6 +59,22 @@ pilight_Set($@)
|
|||||||
return undef;
|
return undef;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
###################################
|
||||||
|
sub
|
||||||
|
pilight_on_timeout($)
|
||||||
|
{
|
||||||
|
my ($hash) = @_;
|
||||||
|
my @a;
|
||||||
|
|
||||||
|
$a[0]=$hash->{NAME};
|
||||||
|
$a[1]="off";
|
||||||
|
|
||||||
|
pilight_Set($hash,@a);
|
||||||
|
|
||||||
|
return undef;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
sub
|
sub
|
||||||
pilight_Define($$)
|
pilight_Define($$)
|
||||||
{
|
{
|
||||||
@ -101,48 +125,33 @@ sub commit
|
|||||||
return undef
|
return undef
|
||||||
};
|
};
|
||||||
|
|
||||||
my $data = '{ "message": "client sender" }';
|
|
||||||
|
my $data = $useOldVersion ? '{ "message": "client sender" }' : '{ "action": "identify" }';
|
||||||
$socket->send($data);
|
$socket->send($data);
|
||||||
$socket->recv($data,1024);
|
$socket->recv($data,1024);
|
||||||
|
|
||||||
$data =~ s/\n/ /g;
|
$data =~ s/\n/ /g;
|
||||||
if ( $data !~ /accept client/ ) {
|
if ( $data !~ /accept client/ && $data !~ /success/) # "accept client" < v6,
|
||||||
Log 3, "pilight: ERROR. No handshake with pilight-daemon. Received: >>>$data<<<\n";
|
{
|
||||||
return undef
|
Log 3, "pilight: ERROR. No handshake with pilight-daemon. Received: >>>$data<<<\n";
|
||||||
|
return undef
|
||||||
};
|
};
|
||||||
|
|
||||||
my $code = "{\"protocol\":[ \"$protocol\" ],";
|
my $code = "{\"protocol\":[ \"$protocol\" ],";
|
||||||
if($useOldVersion) {
|
if( $protocol eq 'raw')
|
||||||
switch( $protocol ) {
|
{
|
||||||
case 'kaku_switch' { $code = $code . "\"id\":\"$housecode\", \"unit\":\"$unit\",\"$param\":\"1\""}
|
switch( $param ) {
|
||||||
case 'quigg_switch' { $code = $code . "\"id\":\"$housecode\", \"unit\":\"$unit\",\"$param\":\"1\""}
|
case 'on' { $code = $code . "\"code\":\"$rawCodeOn\""} # on
|
||||||
case 'elro' { $code = $code . "\"systemcode\":\"$systemcode\", \"unitcode\":\"$unit\",\"$param\":\"1\""}
|
case 'off' { $code = $code . "\"code\":\"$rawCodeOff\""} #off
|
||||||
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 {
|
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 ) {
|
switch( $protocol ) {
|
||||||
case 'kaku_switch' { $code = $code . "\"id\":$housecode, \"unit\":$unit,\"$param\":1"}
|
case 'kaku_switch' { $code = $code . "\"id\":$housecode, \"unit\":$unit,\"$param\":1"}
|
||||||
case 'quigg_switch' { $code = $code . "\"id\":$housecode, \"unit\":$unit,\"$param\":1"}
|
case 'quigg_switch' { $code = $code . "\"id\":$housecode, \"unit\":$unit,\"$param\":1"}
|
||||||
|
case 'quigg_gt7000' { $code = $code . "\"id\":$housecode, \"unit\":$unit,\"$param\":1"}
|
||||||
|
case 'quigg_gt1000' { $code = $code . "\"id\":$housecode, \"unit\":$unit,\"$param\":1"}
|
||||||
case 'elro' { $code = $code . "\"systemcode\":$systemcode, \"unitcode\":$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_he' { $code = $code . "\"systemcode\":$systemcode, \"unitcode\":$unit,\"$param\":1"}
|
||||||
case 'elro_hc' { $code = $code . "\"systemcode\":$systemcode, \"unitcode\":$unit,\"$param\":1"}
|
case 'elro_hc' { $code = $code . "\"systemcode\":$systemcode, \"unitcode\":$unit,\"$param\":1"}
|
||||||
@ -153,16 +162,15 @@ sub commit
|
|||||||
case 'impuls' { $code = $code . "\"systemcode\":$systemcode, \"programcode\":$unit,\"$param\":1"}
|
case 'impuls' { $code = $code . "\"systemcode\":$systemcode, \"programcode\":$unit,\"$param\":1"}
|
||||||
case 'rsl366' { $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 'intertechno_old' { $code = $code . "\"id\":$systemcode, \"unit\":$unit,\"$param\":1"}
|
||||||
case 'clarus_switch' { $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 'rev1_switch' { $code = $code . "\"id\":\"$systemcode\", \"unit\":$unit,\"$param\":1"}
|
||||||
case 'rev2_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"}
|
case 'rev3_switch' { $code = $code . "\"id\":\"$systemcode\", \"unit\":$unit,\"$param\":1"}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
}
|
}
|
||||||
$code = $code . '}';
|
$code = $code . '}';
|
||||||
|
|
||||||
$data = "{ \"message\": \"send\", \"code\": $code}";
|
$data = $useOldVersion ? "{ \"message\": \"send\", \"code\": $code}" : "{ \"action\": \"send\", \"code\": $code}";
|
||||||
Log 3, "pilight data: $data";
|
Log 3, "pilight data: $data";
|
||||||
|
|
||||||
$socket->send($data);
|
$socket->send($data);
|
||||||
@ -186,7 +194,7 @@ sub commit
|
|||||||
<br/>
|
<br/>
|
||||||
<br/>
|
<br/>
|
||||||
Defines a module for setting pilight compartible switches on or off. See <a href="http://www.sweetpi.de/blog/258/funksteckdosen-mit-dem-raspberry-pi-und-pilight-schalten">Sweetpi</a>.<br><br>
|
Defines a module for setting pilight compartible switches on or off. See <a href="http://www.sweetpi.de/blog/258/funksteckdosen-mit-dem-raspberry-pi-und-pilight-schalten">Sweetpi</a>.<br><br>
|
||||||
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!<br/><br/>
|
Supported protocols: kaku_switch, quigg_*, 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!<br/><br/>
|
||||||
Example:
|
Example:
|
||||||
<ul>
|
<ul>
|
||||||
<code>define Weihnachtsbaum pilight kaku_switch</code><br>
|
<code>define Weihnachtsbaum pilight kaku_switch</code><br>
|
||||||
@ -196,7 +204,7 @@ sub commit
|
|||||||
<br/>
|
<br/>
|
||||||
If your pilight server does not run on localhost, please set both the attributes <b>remote_ip</b> and <b>remote_port</b>. If you are running pilight >3.0, then please <b>define the port used by pilight</b> settings: http://www.pilight.org/getting-started/settings/; fhem-plight uses 5000 by default.
|
If your pilight server does not run on localhost, please set both the attributes <b>remote_ip</b> and <b>remote_port</b>. If you are running pilight >3.0, then please <b>define the port used by pilight</b> settings: http://www.pilight.org/getting-started/settings/; fhem-plight uses 5000 by default.
|
||||||
<br/>
|
<br/>
|
||||||
<b>This version is written for pilight 5.0. If you run a version < 3.0, please set the following attribute:</b>
|
<b>This version is written for pilight 6.0. If you run a prior version, please set the following attribute:</b>
|
||||||
<code> attr Weihnachtsbaum useOldVersion 1</code>
|
<code> attr Weihnachtsbaum useOldVersion 1</code>
|
||||||
</ul>
|
</ul>
|
||||||
|
|
||||||
@ -206,7 +214,7 @@ sub commit
|
|||||||
<li><a name="protocol"><code>attr <name> protocol <string></code></a>
|
<li><a name="protocol"><code>attr <name> protocol <string></code></a>
|
||||||
<br />Protocol used in pilight, e.g. "kaku_switch"</li>
|
<br />Protocol used in pilight, e.g. "kaku_switch"</li>
|
||||||
<li><a name="housecode"><code>attr <name> housecode <string></code></a>
|
<li><a name="housecode"><code>attr <name> housecode <string></code></a>
|
||||||
<br />Housecode used in pilight (for protocol kaku*, clarus_switch, rev1_switch, rev2_switch, rev3_switch, quigg_switch)</li>
|
<br />Housecode used in pilight (for protocol kaku*, clarus_switch, rev1_switch, rev2_switch, rev3_switch, quigg_switch, quigg_gt1000, quigg_gt7000)</li>
|
||||||
<li><a name="systemcode"><code>attr <name> systemcode <string></code></a>
|
<li><a name="systemcode"><code>attr <name> systemcode <string></code></a>
|
||||||
<br />Systemcode of your switch (for protocol elso, elro_he, elro_hc, silvercrest, impuls, rsl366, pollin, mumbi, brennenstuhl, intertechno_old)</li>
|
<br />Systemcode of your switch (for protocol elso, elro_he, elro_hc, silvercrest, impuls, rsl366, pollin, mumbi, brennenstuhl, intertechno_old)</li>
|
||||||
<li><a name="unitcode"><code>attr <name> unitcode <string></code></a>
|
<li><a name="unitcode"><code>attr <name> unitcode <string></code></a>
|
||||||
|
Loading…
x
Reference in New Issue
Block a user