mirror of
https://github.com/fhem/fhem-mirror.git
synced 2025-03-04 11:26:55 +00:00
36_Shelly.pm: neue Version mit Bugfix
git-svn-id: https://svn.fhem.de/fhem/trunk@17434 2b470e98-0d58-463d-a4d8-8e2adae1ed80
This commit is contained in:
parent
7652a024d3
commit
1a0982e0f2
@ -38,7 +38,7 @@ use vars qw{%attr %defs};
|
||||
sub Log($$);
|
||||
|
||||
#-- globals on start
|
||||
my $version = "1.31";
|
||||
my $version = "1.33";
|
||||
|
||||
#-- these we may get on request
|
||||
my %gets = (
|
||||
@ -357,7 +357,7 @@ sub Shelly_Set ($@) {
|
||||
|
||||
my $model = AttrVal($name,"model","shelly2");
|
||||
my $mode = AttrVal($name,"mode","relay");
|
||||
my $time;
|
||||
my ($channel,$time);
|
||||
|
||||
#-- we have a Shelly 1,4 or ShellyPlug switch type device
|
||||
#-- or we have a Shelly 2 switch type device
|
||||
@ -372,8 +372,14 @@ sub Shelly_Set ($@) {
|
||||
}
|
||||
|
||||
if( $cmd =~ /^((on)|(off)).*/ ){
|
||||
my $channel = $value;
|
||||
|
||||
$channel = $value;
|
||||
if( $cmd =~ /(.*)-for-timer/ ){
|
||||
$time = shift @a;
|
||||
if( !defined($time) ){
|
||||
$time = $value;
|
||||
$channel = undef;
|
||||
}
|
||||
}
|
||||
if( $shelly_models{$model}[0] == 1){
|
||||
$channel = 0
|
||||
}else{
|
||||
@ -392,14 +398,8 @@ sub Shelly_Set ($@) {
|
||||
}
|
||||
if( $cmd =~ /(.*)-for-timer/ ){
|
||||
$cmd = $1;
|
||||
my $time = shift @a;
|
||||
if( $cmd !~ /^(on)|(off)$/ ){
|
||||
$msg = "Error: wrong command $cmd";
|
||||
Log3 $name, 1,"[Shelly_Set] ".$msg;
|
||||
return $msg
|
||||
}
|
||||
if( $time !~ /\d+/ ){
|
||||
$msg = "Error: wrong time spec $time, must be <integer> only";
|
||||
$msg = "Error: wrong time spec $time, must be <integer>";
|
||||
Log3 $name, 1,"[Shelly_Set] ".$msg;
|
||||
return $msg;
|
||||
}
|
||||
@ -596,6 +596,10 @@ sub Shelly_Set ($@) {
|
||||
Log3 $name, 1,"[Shelly_status] has error $err";
|
||||
readingsSingleUpdate($hash,"state","Error",1);
|
||||
readingsSingleUpdate($hash,"network","not connected",1);
|
||||
#-- cyclic update nevertheless
|
||||
RemoveInternalTimer($hash);
|
||||
InternalTimer(gettimeofday()+$hash->{INTERVAL}, "Shelly_status", $hash, 1)
|
||||
if( $hash->{INTERVAL} ne "0" );
|
||||
return $err;
|
||||
}
|
||||
|
||||
@ -711,7 +715,6 @@ sub Shelly_Set ($@) {
|
||||
return undef;
|
||||
}
|
||||
|
||||
|
||||
########################################################################################
|
||||
#
|
||||
# Shelly_updown - Move rollere blind
|
||||
@ -866,7 +869,7 @@ sub Shelly_Set ($@) {
|
||||
|
||||
if ( $hash && !$err && !$data ){
|
||||
$url = "http://".$hash->{TCPIP}."/relay/".$channel.$cmd;
|
||||
Log3 $name, 5,"[Shelly_onoff] called with only hash => Issue a non-blocking call to $url";
|
||||
Log3 $name, 1,"[Shelly_onoff] called with only hash => Issue a non-blocking call to $url";
|
||||
HttpUtils_NonblockingGet({
|
||||
url => $url,
|
||||
callback=>sub($$$){ Shelly_onoff($hash,$channel,$cmd,$_[1],$_[2]) }
|
||||
@ -911,7 +914,7 @@ sub Shelly_Set ($@) {
|
||||
if( $ison ne $cmd ) {
|
||||
Log3 $name,1,"[Shelly_onoff] returns without success, cmd=$cmd but ison=$ison";
|
||||
}
|
||||
if( $overpower eq "1") {
|
||||
if( defined($overpower) && $overpower eq "1") {
|
||||
Log3 $name,1,"[Shelly_onoff] switched off automatically because of overpower signal";
|
||||
}
|
||||
#--
|
||||
|
Loading…
x
Reference in New Issue
Block a user