mirror of
https://github.com/fhem/fhem-mirror.git
synced 2025-04-21 01:46:08 +00:00
39_siri.pm, 39_alexa.pm: skeleton modules for the configuration of the fhem/siri and fhem/alexa integration
git-svn-id: https://svn.fhem.de/fhem/trunk@12592 2b470e98-0d58-463d-a4d8-8e2adae1ed80
This commit is contained in:
parent
79b9311984
commit
8678ed686e
@ -1,5 +1,7 @@
|
|||||||
# 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.
|
||||||
|
- new: 39_siri.pm: configuration of fhem/siri integration
|
||||||
|
39_alexa.pm: configuration of fhem/alexa integration
|
||||||
- feature: 30_pilight_contact: new module to handle pilight contact sensors
|
- feature: 30_pilight_contact: new module to handle pilight contact sensors
|
||||||
- feature: 59_Weather: attribute disable
|
- feature: 59_Weather: attribute disable
|
||||||
- new: 10_EQ3BT: Support EQ3 Bluetooth thermostat
|
- new: 10_EQ3BT: Support EQ3 Bluetooth thermostat
|
||||||
|
168
fhem/FHEM/39_alexa.pm
Normal file
168
fhem/FHEM/39_alexa.pm
Normal file
@ -0,0 +1,168 @@
|
|||||||
|
|
||||||
|
# $Id$
|
||||||
|
|
||||||
|
package main;
|
||||||
|
|
||||||
|
use strict;
|
||||||
|
use warnings;
|
||||||
|
|
||||||
|
#use IO::Socket::INET;
|
||||||
|
|
||||||
|
sub
|
||||||
|
alexa_Initialize($)
|
||||||
|
{
|
||||||
|
my ($hash) = @_;
|
||||||
|
|
||||||
|
#$hash->{ReadFn} = "alexa_Read";
|
||||||
|
|
||||||
|
$hash->{DefFn} = "alexa_Define";
|
||||||
|
#$hash->{NOTIFYDEV} = "global";
|
||||||
|
#$hash->{NotifyFn} = "alexa_Notify";
|
||||||
|
$hash->{UndefFn} = "alexa_Undefine";
|
||||||
|
#$hash->{SetFn} = "alexa_Set";
|
||||||
|
#$hash->{GetFn} = "alexa_Get";
|
||||||
|
#$hash->{AttrFn} = "alexa_Attr";
|
||||||
|
$hash->{AttrList} = "$readingFnAttributes";
|
||||||
|
}
|
||||||
|
|
||||||
|
#####################################
|
||||||
|
|
||||||
|
sub
|
||||||
|
alexa_Define($$)
|
||||||
|
{
|
||||||
|
my ($hash, $def) = @_;
|
||||||
|
|
||||||
|
my @a = split("[ \t][ \t]*", $def);
|
||||||
|
|
||||||
|
return "Usage: define <name> alexa" if(@a != 2);
|
||||||
|
|
||||||
|
my $name = $a[0];
|
||||||
|
$hash->{NAME} = $name;
|
||||||
|
|
||||||
|
my $d = $modules{$hash->{TYPE}}{defptr};
|
||||||
|
return "$hash->{TYPE} device already defined as $d->{NAME}." if( defined($d) );
|
||||||
|
$modules{$hash->{TYPE}}{defptr} = $hash;
|
||||||
|
|
||||||
|
addToAttrList("$hash->{TYPE}Name");
|
||||||
|
|
||||||
|
$hash->{STATE} = 'active';
|
||||||
|
|
||||||
|
return undef;
|
||||||
|
}
|
||||||
|
|
||||||
|
sub
|
||||||
|
alexa_Notify($$)
|
||||||
|
{
|
||||||
|
my ($hash,$dev) = @_;
|
||||||
|
|
||||||
|
return if($dev->{NAME} ne "global");
|
||||||
|
return if(!grep(m/^INITIALIZED|REREADCFG$/, @{$dev->{CHANGED}}));
|
||||||
|
|
||||||
|
return undef;
|
||||||
|
}
|
||||||
|
|
||||||
|
sub
|
||||||
|
alexa_Undefine($$)
|
||||||
|
{
|
||||||
|
my ($hash, $arg) = @_;
|
||||||
|
|
||||||
|
delete $modules{$hash->{TYPE}}{defptr};
|
||||||
|
|
||||||
|
return undef;
|
||||||
|
}
|
||||||
|
|
||||||
|
sub
|
||||||
|
alexa_Set($$@)
|
||||||
|
{
|
||||||
|
my ($hash, $name, $cmd, @args) = @_;
|
||||||
|
|
||||||
|
my $list = "";
|
||||||
|
|
||||||
|
return "Unknown argument $cmd, choose one of $list";
|
||||||
|
}
|
||||||
|
|
||||||
|
sub
|
||||||
|
alexa_Get($$@)
|
||||||
|
{
|
||||||
|
my ($hash, $name, $cmd) = @_;
|
||||||
|
|
||||||
|
my $list = "";
|
||||||
|
|
||||||
|
return "Unknown argument $cmd, choose one of $list";
|
||||||
|
}
|
||||||
|
|
||||||
|
sub
|
||||||
|
alexa_Parse($$;$)
|
||||||
|
{
|
||||||
|
my ($hash,$data,$peerhost) = @_;
|
||||||
|
my $name = $hash->{NAME};
|
||||||
|
}
|
||||||
|
|
||||||
|
sub
|
||||||
|
alexa_Read($)
|
||||||
|
{
|
||||||
|
my ($hash) = @_;
|
||||||
|
my $name = $hash->{NAME};
|
||||||
|
|
||||||
|
my $len;
|
||||||
|
my $buf;
|
||||||
|
|
||||||
|
$len = $hash->{CD}->recv($buf, 1024);
|
||||||
|
if( !defined($len) || !$len ) {
|
||||||
|
Log 1, "!!!!!!!!!!";
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
alexa_Parse($hash, $buf, $hash->{CD}->peerhost);
|
||||||
|
}
|
||||||
|
|
||||||
|
sub
|
||||||
|
alexa_Attr($$$)
|
||||||
|
{
|
||||||
|
my ($cmd, $name, $attrName, $attrVal) = @_;
|
||||||
|
|
||||||
|
my $orig = $attrVal;
|
||||||
|
|
||||||
|
my $hash = $defs{$name};
|
||||||
|
if( $attrName eq "disable" ) {
|
||||||
|
}
|
||||||
|
|
||||||
|
if( $cmd eq 'set' ) {
|
||||||
|
if( $orig ne $attrVal ) {
|
||||||
|
$attr{$name}{$attrName} = $attrVal;
|
||||||
|
return $attrName ." set to ". $attrVal;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
1;
|
||||||
|
|
||||||
|
=pod
|
||||||
|
=item summary Module to control the FHEM/Alexa integration
|
||||||
|
=item summary_DE Modul zur Konfiguration der FHEM/Alexa Integration
|
||||||
|
=begin html
|
||||||
|
|
||||||
|
<a name="alexa"></a>
|
||||||
|
<h3>alexa</h3>
|
||||||
|
<ul>
|
||||||
|
Module to control the FHEM/Alexa integration.<br><br>
|
||||||
|
|
||||||
|
Notes:
|
||||||
|
<ul>
|
||||||
|
<li><br>
|
||||||
|
</li>
|
||||||
|
</ul>
|
||||||
|
|
||||||
|
<a name="alexa_Attr"></a>
|
||||||
|
<b>Attr</b>
|
||||||
|
<ul>
|
||||||
|
<li><br>
|
||||||
|
</li>
|
||||||
|
</ul>
|
||||||
|
</ul><br>
|
||||||
|
|
||||||
|
=end html
|
||||||
|
=cut
|
168
fhem/FHEM/39_siri.pm
Normal file
168
fhem/FHEM/39_siri.pm
Normal file
@ -0,0 +1,168 @@
|
|||||||
|
|
||||||
|
# $Id$
|
||||||
|
|
||||||
|
package main;
|
||||||
|
|
||||||
|
use strict;
|
||||||
|
use warnings;
|
||||||
|
|
||||||
|
#use IO::Socket::INET;
|
||||||
|
|
||||||
|
sub
|
||||||
|
siri_Initialize($)
|
||||||
|
{
|
||||||
|
my ($hash) = @_;
|
||||||
|
|
||||||
|
#$hash->{ReadFn} = "siri_Read";
|
||||||
|
|
||||||
|
$hash->{DefFn} = "siri_Define";
|
||||||
|
#$hash->{NOTIFYDEV} = "global";
|
||||||
|
#$hash->{NotifyFn} = "siri_Notify";
|
||||||
|
$hash->{UndefFn} = "siri_Undefine";
|
||||||
|
#$hash->{SetFn} = "siri_Set";
|
||||||
|
#$hash->{GetFn} = "siri_Get";
|
||||||
|
#$hash->{AttrFn} = "siri_Attr";
|
||||||
|
$hash->{AttrList} = "$readingFnAttributes";
|
||||||
|
}
|
||||||
|
|
||||||
|
#####################################
|
||||||
|
|
||||||
|
sub
|
||||||
|
siri_Define($$)
|
||||||
|
{
|
||||||
|
my ($hash, $def) = @_;
|
||||||
|
|
||||||
|
my @a = split("[ \t][ \t]*", $def);
|
||||||
|
|
||||||
|
return "Usage: define <name> siri" if(@a != 2);
|
||||||
|
|
||||||
|
my $name = $a[0];
|
||||||
|
$hash->{NAME} = $name;
|
||||||
|
|
||||||
|
my $d = $modules{$hash->{TYPE}}{defptr};
|
||||||
|
return "$hash->{TYPE} device already defined as $d->{NAME}." if( defined($d) );
|
||||||
|
$modules{$hash->{TYPE}}{defptr} = $hash;
|
||||||
|
|
||||||
|
addToAttrList("$hash->{TYPE}Name");
|
||||||
|
|
||||||
|
$hash->{STATE} = 'active';
|
||||||
|
|
||||||
|
return undef;
|
||||||
|
}
|
||||||
|
|
||||||
|
sub
|
||||||
|
siri_Notify($$)
|
||||||
|
{
|
||||||
|
my ($hash,$dev) = @_;
|
||||||
|
|
||||||
|
return if($dev->{NAME} ne "global");
|
||||||
|
return if(!grep(m/^INITIALIZED|REREADCFG$/, @{$dev->{CHANGED}}));
|
||||||
|
|
||||||
|
return undef;
|
||||||
|
}
|
||||||
|
|
||||||
|
sub
|
||||||
|
siri_Undefine($$)
|
||||||
|
{
|
||||||
|
my ($hash, $arg) = @_;
|
||||||
|
|
||||||
|
delete $modules{$hash->{TYPE}}{defptr};
|
||||||
|
|
||||||
|
return undef;
|
||||||
|
}
|
||||||
|
|
||||||
|
sub
|
||||||
|
siri_Set($$@)
|
||||||
|
{
|
||||||
|
my ($hash, $name, $cmd, @args) = @_;
|
||||||
|
|
||||||
|
my $list = "";
|
||||||
|
|
||||||
|
return "Unknown argument $cmd, choose one of $list";
|
||||||
|
}
|
||||||
|
|
||||||
|
sub
|
||||||
|
siri_Get($$@)
|
||||||
|
{
|
||||||
|
my ($hash, $name, $cmd) = @_;
|
||||||
|
|
||||||
|
my $list = "";
|
||||||
|
|
||||||
|
return "Unknown argument $cmd, choose one of $list";
|
||||||
|
}
|
||||||
|
|
||||||
|
sub
|
||||||
|
siri_Parse($$;$)
|
||||||
|
{
|
||||||
|
my ($hash,$data,$peerhost) = @_;
|
||||||
|
my $name = $hash->{NAME};
|
||||||
|
}
|
||||||
|
|
||||||
|
sub
|
||||||
|
siri_Read($)
|
||||||
|
{
|
||||||
|
my ($hash) = @_;
|
||||||
|
my $name = $hash->{NAME};
|
||||||
|
|
||||||
|
my $len;
|
||||||
|
my $buf;
|
||||||
|
|
||||||
|
$len = $hash->{CD}->recv($buf, 1024);
|
||||||
|
if( !defined($len) || !$len ) {
|
||||||
|
Log 1, "!!!!!!!!!!";
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
siri_Parse($hash, $buf, $hash->{CD}->peerhost);
|
||||||
|
}
|
||||||
|
|
||||||
|
sub
|
||||||
|
siri_Attr($$$)
|
||||||
|
{
|
||||||
|
my ($cmd, $name, $attrName, $attrVal) = @_;
|
||||||
|
|
||||||
|
my $orig = $attrVal;
|
||||||
|
|
||||||
|
my $hash = $defs{$name};
|
||||||
|
if( $attrName eq "disable" ) {
|
||||||
|
}
|
||||||
|
|
||||||
|
if( $cmd eq 'set' ) {
|
||||||
|
if( $orig ne $attrVal ) {
|
||||||
|
$attr{$name}{$attrName} = $attrVal;
|
||||||
|
return $attrName ." set to ". $attrVal;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
1;
|
||||||
|
|
||||||
|
=pod
|
||||||
|
=item summary Module to control the FHEM/Siri integration
|
||||||
|
=item summary_DE Modul zur Konfiguration der FHEM/Siri Integration
|
||||||
|
=begin html
|
||||||
|
|
||||||
|
<a name="siri"></a>
|
||||||
|
<h3>siri</h3>
|
||||||
|
<ul>
|
||||||
|
Module to control the FHEM/Siri integration.<br><br>
|
||||||
|
|
||||||
|
Notes:
|
||||||
|
<ul>
|
||||||
|
<li><br>
|
||||||
|
</li>
|
||||||
|
</ul>
|
||||||
|
|
||||||
|
<a name="siri_Attr"></a>
|
||||||
|
<b>Attr</b>
|
||||||
|
<ul>
|
||||||
|
<li><br>
|
||||||
|
</li>
|
||||||
|
</ul>
|
||||||
|
</ul><br>
|
||||||
|
|
||||||
|
=end html
|
||||||
|
=cut
|
Loading…
x
Reference in New Issue
Block a user