add Attributs
This commit is contained in:
parent
b35d0fda60
commit
30922717e1
@ -388,7 +388,6 @@ sub SmarterCoffee_Connect($) {
|
|||||||
|
|
||||||
my $isNewConnection = $hash->{STATE} eq "initializing";
|
my $isNewConnection = $hash->{STATE} eq "initializing";
|
||||||
|
|
||||||
RemoveInternalTimer($hash);
|
|
||||||
$hash->{STATE} = "disconnected";
|
$hash->{STATE} = "disconnected";
|
||||||
delete $hash->{INVALID_DEVICE} if defined($hash->{INVALID_DEVICE});
|
delete $hash->{INVALID_DEVICE} if defined($hash->{INVALID_DEVICE});
|
||||||
|
|
||||||
@ -400,11 +399,15 @@ sub SmarterCoffee_Connect($) {
|
|||||||
if (not ($hash->{DeviceName} =~ m/^(.+):([0-9]+)$/)) {
|
if (not ($hash->{DeviceName} =~ m/^(.+):([0-9]+)$/)) {
|
||||||
$hash->{DeviceName} .= ":$SmarterCoffee_Port";
|
$hash->{DeviceName} .= ":$SmarterCoffee_Port";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
RemoveInternalTimer($hash);
|
||||||
|
|
||||||
DevIo_CloseDev($hash) if DevIo_IsOpen($hash);
|
DevIo_CloseDev($hash) if DevIo_IsOpen($hash);
|
||||||
delete $hash->{DevIoJustClosed} if ($hash->{DevIoJustClosed});
|
delete $hash->{DevIoJustClosed} if ($hash->{DevIoJustClosed});
|
||||||
|
|
||||||
SmarterCoffee_ReConnectTimer($hash);
|
SmarterCoffee_ReConnectTimer($hash)
|
||||||
|
unless( AttrVal($hash->{NAME},'reconnectTimer',0) == 0 );
|
||||||
|
|
||||||
return SmarterCoffee_OpenIfRequiredAndWritePending($hash, $isNewConnection);
|
return SmarterCoffee_OpenIfRequiredAndWritePending($hash, $isNewConnection);
|
||||||
}
|
}
|
||||||
return 0;
|
return 0;
|
||||||
@ -510,7 +513,8 @@ sub SmarterCoffee_Initialize($) {
|
|||||||
$hash->{ReadFn} = 'SmarterCoffee_Read';
|
$hash->{ReadFn} = 'SmarterCoffee_Read';
|
||||||
$hash->{ReadyFn} = 'SmarterCoffee_OpenIfRequiredAndWritePending';
|
$hash->{ReadyFn} = 'SmarterCoffee_OpenIfRequiredAndWritePending';
|
||||||
$hash->{NotifyFn} = 'SmarterCoffee_Notify';
|
$hash->{NotifyFn} = 'SmarterCoffee_Notify';
|
||||||
|
|
||||||
|
$hash->{AttrFn} = 'SmarterCoffee_Attr';
|
||||||
$hash->{AttrList} = ""
|
$hash->{AttrList} = ""
|
||||||
."default-hotplate-on-for-minutes "
|
."default-hotplate-on-for-minutes "
|
||||||
."ignore-max-cups "
|
."ignore-max-cups "
|
||||||
@ -520,6 +524,8 @@ sub SmarterCoffee_Initialize($) {
|
|||||||
."strength-extra-pre-brew-cups "
|
."strength-extra-pre-brew-cups "
|
||||||
."strength-extra-pre-brew-delay-seconds "
|
."strength-extra-pre-brew-delay-seconds "
|
||||||
."strength-extra-start-on-device-strength:off,weak,medium,strong "
|
."strength-extra-start-on-device-strength:off,weak,medium,strong "
|
||||||
|
."devioLoglevel:0,1,2,3,4,5 "
|
||||||
|
."reconnectTimer:1 "
|
||||||
.$readingFnAttributes;
|
.$readingFnAttributes;
|
||||||
|
|
||||||
Log 5, "Initialized module 'SmarterCoffee'";
|
Log 5, "Initialized module 'SmarterCoffee'";
|
||||||
@ -551,7 +557,6 @@ sub SmarterCoffee_Define($$) {
|
|||||||
|
|
||||||
$hash->{NOTIFYDEV} = "global,$name";
|
$hash->{NOTIFYDEV} = "global,$name";
|
||||||
$hash->{STATE} = "initializing";
|
$hash->{STATE} = "initializing";
|
||||||
$hash->{devioLoglevel} = 4;
|
|
||||||
|
|
||||||
$hash->{".last_command"} =
|
$hash->{".last_command"} =
|
||||||
$hash->{".last_response"} =
|
$hash->{".last_response"} =
|
||||||
@ -577,6 +582,26 @@ sub SmarterCoffee_Undefine($$) {
|
|||||||
return undef;
|
return undef;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
sub SmarterCoffee_Attr(@) {
|
||||||
|
|
||||||
|
my ( $cmd, $name, $attrName, $attrVal ) = @_;
|
||||||
|
my $hash = $defs{$name};
|
||||||
|
|
||||||
|
|
||||||
|
if( $attrName eq "devioLoglevel" ) {
|
||||||
|
if( $cmd eq "set" ) {
|
||||||
|
$hash->{devioLoglevel} = $attrVal;
|
||||||
|
Log3 $name, 3, "SmarterCoffee ($name) - set devioLoglevel to $attrVal";
|
||||||
|
|
||||||
|
} elsif( $cmd eq "del" ) {
|
||||||
|
delete $hash->{devioLoglevel};
|
||||||
|
Log3 $name, 3, "SmarterCoffee ($name) - delete Internal devioLoglevel";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return undef;
|
||||||
|
}
|
||||||
|
|
||||||
sub SmarterCoffee_Get {
|
sub SmarterCoffee_Get {
|
||||||
my ($hash, @param) = @_;
|
my ($hash, @param) = @_;
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user