mirror of
https://github.com/fhem/fhem-mirror.git
synced 2025-04-22 02:10:32 +00:00
39_alexa.pm: added alexaConfirmationLevel and alexaStatusLevel attributes, added property keyword to alexaMapping
git-svn-id: https://svn.fhem.de/fhem/trunk@12885 2b470e98-0d58-463d-a4d8-8e2adae1ed80
This commit is contained in:
parent
9a775a0710
commit
206445dd48
@ -23,7 +23,10 @@ alexa_Initialize($)
|
|||||||
$hash->{SetFn} = "alexa_Set";
|
$hash->{SetFn} = "alexa_Set";
|
||||||
$hash->{GetFn} = "alexa_Get";
|
$hash->{GetFn} = "alexa_Get";
|
||||||
$hash->{AttrFn} = "alexa_Attr";
|
$hash->{AttrFn} = "alexa_Attr";
|
||||||
$hash->{AttrList} = "alexaMapping:textField-long alexaTypes fhemIntents:textField-long articles prepositions $readingFnAttributes";
|
$hash->{AttrList} = "alexaMapping:textField-long alexaTypes:textField-long fhemIntents:textField-long ".
|
||||||
|
"articles prepositions ".
|
||||||
|
"alexaConfirmationLevel:2,1 alexaStatusLevel:2,1 ".
|
||||||
|
$readingFnAttributes;
|
||||||
}
|
}
|
||||||
|
|
||||||
#####################################
|
#####################################
|
||||||
@ -38,19 +41,30 @@ alexa_AttrDefaults($)
|
|||||||
CommandAttr(undef,"$name alexaMapping #Characteristic=<name>=<value>,...\n".
|
CommandAttr(undef,"$name alexaMapping #Characteristic=<name>=<value>,...\n".
|
||||||
"On=verb=schalte,valueOn=an;ein,valueOff=aus,valueToggle=um\n\n".
|
"On=verb=schalte,valueOn=an;ein,valueOff=aus,valueToggle=um\n\n".
|
||||||
|
|
||||||
"Brightness=verb=stelle,valuePrefix=auf,values=AMAZON.NUMBER,valueSuffix=prozent\n\n".
|
"Brightness=verb=stelle,property=helligkeit,valuePrefix=auf,values=AMAZON.NUMBER,valueSuffix=prozent\n\n".
|
||||||
|
|
||||||
"TargetPosition=verb=mach,articles=den,values=auf:100;zu:0\n".
|
|
||||||
"TargetPosition=verb=stelle,valuePrefix=auf,values=AMAZON.NUMBER,valueSuffix=prozent\n\n".
|
|
||||||
|
|
||||||
"Hue=verb=stelle,valuePrefix=auf,values=rot:0;grün:128;blau:200\n".
|
"Hue=verb=stelle,valuePrefix=auf,values=rot:0;grün:128;blau:200\n".
|
||||||
"Hue=verb=färbe,values=rot:0;grün:120;blau:220\n\n".
|
"Hue=verb=färbe,values=rot:0;grün:120;blau:220\n\n".
|
||||||
|
|
||||||
|
"Saturation=verb=stelle,property=sättigung,valuePrefix=auf,values=AMAZON.NUMBER\n".
|
||||||
|
"Saturation=verb=sättige,values=AMAZON.NUMBER\n\n".
|
||||||
|
|
||||||
|
"TargetPosition=verb=mach,articles=den,values=auf:100;zu:0\n".
|
||||||
|
"TargetPosition=verb=stelle,valuePrefix=auf,values=AMAZON.NUMBER,valueSuffix=prozent\n\n".
|
||||||
|
|
||||||
"TargetTemperature=verb=stelle,valuePrefix=auf,values=AMAZON.NUMBER,valueSuffix=grad\n\n".
|
"TargetTemperature=verb=stelle,valuePrefix=auf,values=AMAZON.NUMBER,valueSuffix=grad\n\n".
|
||||||
|
|
||||||
|
"Volume:verb=stelle,valuePrefix=auf,values=AMAZON.NUMBER,valueSuffix=prozent\n\n".
|
||||||
|
|
||||||
"#Weckzeit=verb=stelle,valuePrefix=auf;für,values=AMAZON.TIME,valueSuffix=uhr" );
|
"#Weckzeit=verb=stelle,valuePrefix=auf;für,values=AMAZON.TIME,valueSuffix=uhr" );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if( !AttrVal( $name, 'alexaTypes', undef ) ) {
|
||||||
|
CommandAttr(undef,"$name alexaTypes #Type=<alias>[,<alias2>[,...]]\n".
|
||||||
|
"light=licht,lampen\n".
|
||||||
|
"blind=rolladen,rolläden,jalousie,jalousien,rollo,rollos" );
|
||||||
|
}
|
||||||
|
|
||||||
if( !AttrVal( $name, 'fhemIntents', undef ) ) {
|
if( !AttrVal( $name, 'fhemIntents', undef ) ) {
|
||||||
CommandAttr(undef,"$name fhemIntents #IntentName=<sample utterance>\n".
|
CommandAttr(undef,"$name fhemIntents #IntentName=<sample utterance>\n".
|
||||||
"gutenMorgen=guten morgen\n".
|
"gutenMorgen=guten morgen\n".
|
||||||
@ -111,7 +125,7 @@ alexa_Set($$@)
|
|||||||
{
|
{
|
||||||
my ($hash, $name, $cmd, @args) = @_;
|
my ($hash, $name, $cmd, @args) = @_;
|
||||||
|
|
||||||
my $list = "reload";
|
my $list = "reload:noArg";
|
||||||
|
|
||||||
if( $cmd eq 'reload' ) {
|
if( $cmd eq 'reload' ) {
|
||||||
$hash->{".triggerUsed"} = 1;
|
$hash->{".triggerUsed"} = 1;
|
||||||
@ -132,7 +146,7 @@ alexa_Get($$@)
|
|||||||
{
|
{
|
||||||
my ($hash, $name, $cmd) = @_;
|
my ($hash, $name, $cmd) = @_;
|
||||||
|
|
||||||
my $list = "customSlotTypes interactionModel";
|
my $list = "customSlotTypes:noArg interactionModel:noArg";
|
||||||
|
|
||||||
if( lc($cmd) eq 'customslottypes' ) {
|
if( lc($cmd) eq 'customslottypes' ) {
|
||||||
if( $hash->{CL} ) {
|
if( $hash->{CL} ) {
|
||||||
@ -171,6 +185,7 @@ alexa_Get($$@)
|
|||||||
$characteristic{$p[0]} = $values2[0] if( scalar @values2 == 1 );
|
$characteristic{$p[0]} = $values2[0] if( scalar @values2 == 1 );
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
|
$p[1] =~ s/\+/ /g;
|
||||||
$characteristic{$p[0]} = $p[1];
|
$characteristic{$p[0]} = $p[1];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -237,9 +252,11 @@ Log 1, Dumper \%types;
|
|||||||
next;
|
next;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
$mapping->{property} = '' if( !$mapping->{property} );
|
||||||
|
$mapping->{property} = [$mapping->{property}] if( ref($mapping->{property}) ne 'ARRAY' );
|
||||||
|
foreach my $property (@{$mapping->{property}}) {
|
||||||
my $intent = $characteristic;
|
my $intent = $characteristic;
|
||||||
$intent = lcfirst($mapping->{valueSuffix}) if( $mapping->{valueSuffix} );
|
$intent = lcfirst($mapping->{valueSuffix}) if( !$property && $mapping->{valueSuffix} );
|
||||||
$intent .= 'Intent';
|
$intent .= 'Intent';
|
||||||
|
|
||||||
my $values = [];
|
my $values = [];
|
||||||
@ -255,6 +272,7 @@ Log 1, Dumper \%types;
|
|||||||
append($characteristicsOfIntent, $intent, $characteristic );
|
append($characteristicsOfIntent, $intent, $characteristic );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
Log 1, Dumper $verbsOfIntent;
|
Log 1, Dumper $verbsOfIntent;
|
||||||
Log 1, Dumper $intentsOfVerb;
|
Log 1, Dumper $intentsOfVerb;
|
||||||
Log 1, Dumper $valuesOfIntent;
|
Log 1, Dumper $valuesOfIntent;
|
||||||
@ -283,12 +301,15 @@ Log 1, Dumper $characteristicsOfIntent;
|
|||||||
$values = merge( $values, $mapping->{valueOff} );
|
$values = merge( $values, $mapping->{valueOff} );
|
||||||
$values = merge( $values, $mapping->{valueToggle} );
|
$values = merge( $values, $mapping->{valueToggle} );
|
||||||
|
|
||||||
|
$mapping->{property} = '' if( !$mapping->{property} );
|
||||||
|
$mapping->{property} = [$mapping->{property}] if( ref($mapping->{property}) ne 'ARRAY' );
|
||||||
|
foreach my $property (@{$mapping->{property}}) {
|
||||||
|
|
||||||
my $nr = $i?chr(65+$i):'';
|
my $nr = $i?chr(65+$i):'';
|
||||||
$nr = '' if( $mapping->{valueSuffix} );
|
$nr = '' if( $mapping->{valueSuffix} );
|
||||||
#my $intent = $characteristic .'Intent'. $nr;
|
#my $intent = $characteristic .'Intent'. $nr;
|
||||||
my $intent = $characteristic;
|
my $intent = $characteristic;
|
||||||
$intent = lcfirst($mapping->{valueSuffix}) if( $mapping->{valueSuffix} );
|
$intent = lcfirst($mapping->{valueSuffix}) if( !$property && $mapping->{valueSuffix} );
|
||||||
$intent .= 'Intent';
|
$intent .= 'Intent';
|
||||||
$intent .= $nr;
|
$intent .= $nr;
|
||||||
|
|
||||||
@ -306,7 +327,7 @@ Log 1, Dumper $characteristicsOfIntent;
|
|||||||
$types->{"${characteristic}_prefix$nr"} = $mapping->{valuePrefix};
|
$types->{"${characteristic}_prefix$nr"} = $mapping->{valuePrefix};
|
||||||
}
|
}
|
||||||
my $slot_name = "${characteristic}_Value$nr";
|
my $slot_name = "${characteristic}_Value$nr";
|
||||||
$slot_name = lcfirst($mapping->{valueSuffix})."_Value$nr" if( $mapping->{valueSuffix} );
|
$slot_name = lcfirst($mapping->{valueSuffix})."_Value$nr" if( !$property && $mapping->{valueSuffix} );
|
||||||
if( $mapping->{values} && $mapping->{values} =~ /^AMAZON/ ) {
|
if( $mapping->{values} && $mapping->{values} =~ /^AMAZON/ ) {
|
||||||
push @{$slots}, { name => $slot_name, type => $mapping->{values} };
|
push @{$slots}, { name => $slot_name, type => $mapping->{values} };
|
||||||
} else {
|
} else {
|
||||||
@ -337,6 +358,7 @@ Log 1, Dumper $characteristicsOfIntent;
|
|||||||
my $line;
|
my $line;
|
||||||
|
|
||||||
$line .= "$intent $verb";
|
$line .= "$intent $verb";
|
||||||
|
$line .= " $property" if( $property );
|
||||||
$line .= " $article" if( $article );
|
$line .= " $article" if( $article );
|
||||||
$line .= $mapping->{device}?" $mapping->{device}":' {Device}';
|
$line .= $mapping->{device}?" $mapping->{device}":' {Device}';
|
||||||
$line .= " {preposition} $room" if( $room );
|
$line .= " {preposition} $room" if( $room );
|
||||||
@ -361,6 +383,7 @@ Log 1, Dumper $characteristicsOfIntent;
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
push @{$schema->{intents}}, {intent => $intent, slots => $slots};
|
push @{$schema->{intents}}, {intent => $intent, slots => $slots};
|
||||||
|
}
|
||||||
|
|
||||||
++$i;
|
++$i;
|
||||||
}
|
}
|
||||||
@ -543,6 +566,10 @@ alexa_Attr($$$)
|
|||||||
maps spoken device types to ServiceClasses. eg: attr alexa alexaTypes light:licht,lampe,lampen blind:rolladen,jalousie,rollo Outlet:steckdose TemperatureSensor:thermometer LockMechanism:schloss OccupancySensor: anwesenheit</li>
|
maps spoken device types to ServiceClasses. eg: attr alexa alexaTypes light:licht,lampe,lampen blind:rolladen,jalousie,rollo Outlet:steckdose TemperatureSensor:thermometer LockMechanism:schloss OccupancySensor: anwesenheit</li>
|
||||||
<li>fhemIntents<br>
|
<li>fhemIntents<br>
|
||||||
maps spoken commands directed to fhem as a whole (i.e. not to specific devices) to events from the alexa device.</li>
|
maps spoken commands directed to fhem as a whole (i.e. not to specific devices) to events from the alexa device.</li>
|
||||||
|
<li>alexaConfirmationLevel<br>
|
||||||
|
</li>
|
||||||
|
<li>alexaStatusLevel<br>
|
||||||
|
</li>
|
||||||
Note: changes to attributes of the alexa device will automatically trigger a reconfiguration of
|
Note: changes to attributes of the alexa device will automatically trigger a reconfiguration of
|
||||||
alxea-fhem and there is no need to restart the service.
|
alxea-fhem and there is no need to restart the service.
|
||||||
</ul>
|
</ul>
|
||||||
|
Loading…
x
Reference in New Issue
Block a user