mirror of
https://github.com/fhem/fhem-mirror.git
synced 2025-03-09 20:57:11 +00:00
88_xs1Dev: new type shutter integrated (Forum #85137)
88_xs1Bridge: actuator functions incorrect (Forum #85137) git-svn-id: https://svn.fhem.de/fhem/trunk@16334 2b470e98-0d58-463d-a4d8-8e2adae1ed80
This commit is contained in:
parent
ff9ef988db
commit
67161fdc0d
@ -1,5 +1,7 @@
|
||||
# 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.
|
||||
- bugfix: 88_xs1Dev: new type shutter integrated (Forum #85137)
|
||||
- bugfix: 88_xs1Bridge: actuator functions incorrect (Forum #85137)
|
||||
- bugfix: 93_DbRep: fix perl warning
|
||||
- bugfix: 38_netatmo: fixed public stations update, added fixed interval
|
||||
- bugfix: 93_DbRep: V7.14.1, bugfix for PostgreSQL
|
||||
|
@ -318,10 +318,13 @@ sub xs1Bridge_GetUpDate() {
|
||||
last;
|
||||
}
|
||||
|
||||
my $i3 = 0; ## Counter für real Werte in xs1, da sonst Verschiebungen wenn User ID´s verschiebt, NOTWENDIG!
|
||||
|
||||
foreach my $f ( @array ) {
|
||||
$i3++;
|
||||
if ($f->{"type"} ne "disabled") {
|
||||
my $xs1Dev = "xs1Dev";
|
||||
|
||||
|
||||
### Aktoren spezifisch
|
||||
my $xs1_function1 = "-";
|
||||
my $xs1_function2 = "-";
|
||||
@ -331,65 +334,71 @@ sub xs1Bridge_GetUpDate() {
|
||||
if ($i == 0) {
|
||||
### xs1 Aktoren nur update bei differenten Wert
|
||||
if ($update_only_difference == 1) {
|
||||
my $oldState = ReadingsVal($name, $readingsname[$i]."_".sprintf("%02d", $f->{"id"}), "unknown"); ## Readings Wert
|
||||
my $oldState = ReadingsVal($name, $readingsname[$i]."_".sprintf("%02d", $i3), "unknown"); ## Readings Wert
|
||||
my $newState = sprintf("%.1f" , $f->{"value"}); ## ARRAY Wert xs1 aktuell
|
||||
|
||||
Debug " $typ: ".$readingsname[$i]."_".sprintf("%02d", $f->{"id"})." oldState=$oldState newState=$newState" if($debug);
|
||||
Debug " $typ: ".$readingsname[$i]."_".sprintf("%02d", $i3)." oldState=$oldState newState=$newState" if($debug);
|
||||
|
||||
if ($oldState ne $newState) {
|
||||
readingsSingleUpdate($hash, $readingsname[$i]."_".sprintf("%02d", $f->{"id"}) , $newState, 1);
|
||||
readingsSingleUpdate($hash, $readingsname[$i]."_".sprintf("%02d", $i3) , $newState, 0);
|
||||
}
|
||||
}
|
||||
|
||||
### xs1 Aktoren / Funktion != disable
|
||||
my @array2 = @{ $decoded->{'actuator'}->[($f->{"id"})-1]->{$arrayname[4]} };
|
||||
my @array2 = @{ $decoded->{'actuator'}->[$i3-1]->{$arrayname[4]} };
|
||||
my $i2 = 0; ## Funktionscounter
|
||||
|
||||
foreach my $f2 ( @array2 ) {
|
||||
$i2 = $i2+1;
|
||||
$i2++;
|
||||
|
||||
### xs1 Option - Ansicht Funktionsname
|
||||
if ($viewDeviceFunction == 1) {
|
||||
my $oldState = ReadingsVal($name, $readingsname[$i]."_".sprintf("%02d", $f->{"id"})."_".$arrayname[4]."_".$i2, "unknown"); ## Readings Wert
|
||||
my $oldState = ReadingsVal($name, $readingsname[$i]."_".sprintf("%02d", $i3)."_".$arrayname[4]."_".$i2, "unknown"); ## Readings Wert
|
||||
my $newState = $f2->{'type'}; ## ARRAY Wert xs1 aktuell
|
||||
|
||||
if ($oldState ne "unknown" && $newState eq "disabled") { ## FunktionReading del bei disable
|
||||
Debug " $typ: "."Aktor_".sprintf("%02d", $i3)."_function_".$i2." are disabled" if($debug);
|
||||
delete $hash->{READINGS}{"Aktor_".sprintf("%02d", $i3)."_function_".$i2} if($hash->{READINGS});
|
||||
}
|
||||
|
||||
if ($f2->{"type"} ne "disabled") { ## Funktion != function -> type disable
|
||||
if ($oldState ne $newState) {
|
||||
readingsSingleUpdate($hash, $readingsname[$i]."_".sprintf("%02d", $f->{"id"})."_".$arrayname[4]."_".$i2 , $f2->{"type"} , 0);
|
||||
}
|
||||
}
|
||||
} else {
|
||||
if ($f2->{"type"} ne "disabled") { ## Funktion != function -> type disable
|
||||
|
||||
if ($i2 == 1) {
|
||||
$xs1_function1 = $f2->{"type"};
|
||||
}elsif ($i2 == 2) {
|
||||
$xs1_function2 = $f2->{"type"};
|
||||
}elsif ($i2 == 3) {
|
||||
$xs1_function3 = $f2->{"type"};
|
||||
}elsif ($i2 == 4) {
|
||||
$xs1_function4 = $f2->{"type"};
|
||||
readingsSingleUpdate($hash, $readingsname[$i]."_".sprintf("%02d", $i3)."_".$arrayname[4]."_".$i2 , $f2->{"type"} , 1);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if ($f2->{"type"} ne "disabled") { ## Funktion != function -> type disable
|
||||
|
||||
if ($i2 == 1) {
|
||||
$xs1_function1 = $f2->{"type"};
|
||||
}elsif ($i2 == 2) {
|
||||
$xs1_function2 = $f2->{"type"};
|
||||
}elsif ($i2 == 3) {
|
||||
$xs1_function3 = $f2->{"type"};
|
||||
}elsif ($i2 == 4) {
|
||||
$xs1_function4 = $f2->{"type"};
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
### Value der Aktoren | Sensoren
|
||||
if ($i == 1 || $i == 0 && $update_only_difference == 0) { # Aktoren | Sensoren im intervall - Format 0.0 bzw. 37.0 wie aus xs1
|
||||
readingsSingleUpdate($hash, $readingsname[$i]."_".sprintf("%02d", $f->{"id"}) , sprintf("%.1f" , $f->{"value"}), 1);
|
||||
$xs1_data = $xs1Dev."#".$readingsname[$i]."#".sprintf("%02d", $f->{"id"})."#".$f->{"type"}."#".sprintf("%.1f" , $f->{"value"})."#"."$xs1_function1"."#"."$xs1_function2"."#"."$xs1_function3"."#"."$xs1_function4"."#".$f->{"name"};
|
||||
readingsSingleUpdate($hash, $readingsname[$i]."_".sprintf("%02d", $i3) , sprintf("%.1f" , $f->{"value"}), 0);
|
||||
$xs1_data = $xs1Dev."#".$readingsname[$i]."#".sprintf("%02d", $i3)."#".$f->{"type"}."#".sprintf("%.1f" , $f->{"value"})."#"."$xs1_function1"."#"."$xs1_function2"."#"."$xs1_function3"."#"."$xs1_function4"."#".$f->{"name"};
|
||||
} elsif ($i == 0 && $update_only_difference == 1){ # Aktoren | nur bei DIFF - Format 0.0 bzw. 37.0 wie aus xs1
|
||||
$xs1_data = $xs1Dev."#".$readingsname[$i]."#".sprintf("%02d", $f->{"id"})."#".$f->{"type"}."#".sprintf("%.1f" , $f->{"value"})."#"."$xs1_function1"."#"."$xs1_function2"."#"."$xs1_function3"."#"."$xs1_function4"."#".$f->{"name"};
|
||||
$xs1_data = $xs1Dev."#".$readingsname[$i]."#".sprintf("%02d", $i3)."#".$f->{"type"}."#".sprintf("%.1f" , $f->{"value"})."#"."$xs1_function1"."#"."$xs1_function2"."#"."$xs1_function3"."#"."$xs1_function4"."#".$f->{"name"};
|
||||
}
|
||||
|
||||
### Ausgaben je Typ unterschiedlich !!!
|
||||
Debug " $typ: ".$readingsname[$i]."_".sprintf("%02d", $f->{"id"})." | ".$f->{"type"}." | ".$f->{"name"}." | ". $f->{"value"}." | "."F1 $xs1_function1 | F2 $xs1_function2 | F3 $xs1_function3 | F4 $xs1_function4" if($debug == 1 && $i == 0);
|
||||
Debug " $typ: ".$readingsname[$i]."_".sprintf("%02d", $f->{"id"})." | ".$f->{"type"}." | ".$f->{"name"}." | ". $f->{"value"} if($debug == 1 && $i != 0);
|
||||
Debug " $typ: ".$readingsname[$i]."_".sprintf("%02d", $i3)." | ".$f->{"type"}." | ".$f->{"name"}." | ". $f->{"value"}." | "."F1 $xs1_function1 | F2 $xs1_function2 | F3 $xs1_function3 | F4 $xs1_function4" if($debug == 1 && $i == 0);
|
||||
Debug " $typ: ".$readingsname[$i]."_".sprintf("%02d", $i3)." | ".$f->{"type"}." | ".$f->{"name"}." | ". $f->{"value"} if($debug == 1 && $i != 0);
|
||||
|
||||
### Namen der Aktoren | Sensoren
|
||||
if ($viewDeviceName == 1) {
|
||||
readingsSingleUpdate($hash, $readingsname[$i]."_".sprintf("%02d", $f->{"id"})."_name" , $f->{"name"} , 0);
|
||||
readingsSingleUpdate($hash, $readingsname[$i]."_".sprintf("%02d", $i3)."_name" , $f->{"name"} , 0);
|
||||
}
|
||||
|
||||
### Dispatch an xs1Device Modul
|
||||
@ -397,6 +406,17 @@ sub xs1Bridge_GetUpDate() {
|
||||
Debug " $typ: GetUpDate | Dispatch: $xs1_data" if($debug);
|
||||
Dispatch($hash,$xs1_data,undef) if($xs1_data);
|
||||
}
|
||||
} else {
|
||||
#### ID bzw. Speicherplatz xs1 ist disabled | Reading are delete ####
|
||||
delete $hash->{READINGS}{$readingsname[$i]."_".sprintf("%02d", $i3)} if($hash->{READINGS});
|
||||
delete $hash->{READINGS}{$readingsname[$i]."_".sprintf("%02d", $i3)."_name"} if($hash->{READINGS});
|
||||
|
||||
if ($i == 0) {
|
||||
for my $count (1..4) {
|
||||
delete $hash->{READINGS}{$readingsname[$i]."_".sprintf("%02d", $i3)."_function_".$count} if($hash->{READINGS});
|
||||
}
|
||||
}
|
||||
#### #### #### ####
|
||||
}
|
||||
}
|
||||
} elsif ($i == 2) { ### xs1 Info´s nur bei uptime Änderung
|
||||
@ -482,13 +502,17 @@ sub xs1Bridge_Write($) ## Zustellen von Daten via IOWrite() vom logischen zum
|
||||
$Aktor_ID = substr($Aktor_ID, 1,2);
|
||||
|
||||
my $xs1cmd;
|
||||
if ($xs1_typ eq "switch") { ## Anpassung Sendebefehl xs1
|
||||
if ($xs1_typ eq "switch" || $xs1_typ eq "shutter") { ## Anpassung Sendebefehl xs1
|
||||
$xs1cmd = "http://$xs1_ip/control?callback=cname&cmd=set_state_actuator&number=$Aktor_ID&$cmd2";
|
||||
} elsif ($xs1_typ eq "dimmer") {
|
||||
if ($cmd eq "off") {
|
||||
$cmd = 0;
|
||||
}
|
||||
$xs1cmd = "http://$xs1_ip/control?callback=cname&cmd=set_state_actuator&number=$Aktor_ID&value=$cmd";
|
||||
} else {
|
||||
### keine Verarbeitung zum senden ####
|
||||
Log3 $name, 3, "$typ: Write | $xs1_typ not control xs1";
|
||||
last;
|
||||
}
|
||||
|
||||
### HTTP Requests #### Start ####
|
||||
@ -627,7 +651,7 @@ sub xs1Bridge_Undef($$)
|
||||
(This can happen more often with DLAN.)<br><br></li>
|
||||
<li>If the device has not been connected after 5 connection attempts, the module will switch on < disable > !</li><br>
|
||||
<li>Create logfile automatically after define | scheme: <code>define FileLog_xs1Bridge FileLog ./log/xs1Bridge-%Y-%m.log <name></code><br>
|
||||
The following values are recorded in logfile: Aktor_(01-64) or Sensor_(01-64) values | Timer | xs1-status information</li>
|
||||
The following values are recorded in logfile: Timer | xs1-status information</li>
|
||||
</ul>
|
||||
</ul>
|
||||
=end html
|
||||
@ -715,7 +739,7 @@ sub xs1Bridge_Undef($$)
|
||||
(Das kann häufiger bei DLAN vorkommen.)<br><br></li>
|
||||
<li>Sollte das Gerät nach 5 Verbindungsversuchen ebenfalls keine Verbindung erhalten haben, so schaltet das Modul auf < disable > !</li><br>
|
||||
<li>Logfile Erstellung erfolgt automatisch nach dem definieren. | Schema: <code>define FileLog_xs1Bridge FileLog ./log/xs1Bridge-%Y-%m.log <Name></code><br>
|
||||
Folgende Werte werden im Logfile erfasst: Aktor_(01-64) bzw. Sensor_(01-64) Werte | Timer | xs1-Statusinformationen</li>
|
||||
Folgende Werte werden im Logfile erfasst: Timer | xs1-Statusinformationen</li>
|
||||
</ul>
|
||||
</ul>
|
||||
=end html_DE
|
||||
|
@ -168,7 +168,7 @@ sub xs1Dev_Set ($$@)
|
||||
|
||||
Debug " -------------- ERROR CHECK - START --------------" if($debug);
|
||||
|
||||
$cmdList = $cmdListNew if($xs1_typ eq "switch" || $xs1_typ eq "dimmer");
|
||||
$cmdList = $cmdListNew if($xs1_typ eq "switch" || $xs1_typ eq "dimmer" || $xs1_typ eq "shutter");
|
||||
#$cmdList .= "dim:slider,0,6.25,100 dimup dimdown" if ($xs1_typ eq "dimmer");
|
||||
my $cmdFound = index($cmdListNew, $cmd); ## check cmd in cmdListNew
|
||||
|
||||
@ -183,7 +183,8 @@ sub xs1Dev_Set ($$@)
|
||||
}
|
||||
SetExtensionsCancel($hash);
|
||||
} else {
|
||||
if($xs1_typ eq "switch") { ############## Funktion switch ##############
|
||||
############## Funktion switch ##############
|
||||
if($xs1_typ eq "switch") {
|
||||
Debug " $name: Set | xs1_function 1=$xs1_function[0] 2=$xs1_function[1] 3=$xs1_function[2] 4=$xs1_function[3]" if($debug);
|
||||
if ($cmdFound >= 0) { ## cmdFound in welchem Funktionsplatz xs1
|
||||
for my $i (0 .. 3) {
|
||||
@ -194,7 +195,9 @@ sub xs1Dev_Set ($$@)
|
||||
}
|
||||
}
|
||||
return "Wrong set argument, choose one of $cmdList" if($cmdFound < 0);
|
||||
} elsif ($xs1_typ eq "dimmer") { ############## Funktion dimmer ##############
|
||||
}
|
||||
############## Funktion dimmer ##############
|
||||
elsif ($xs1_typ eq "dimmer") {
|
||||
|
||||
Debug " $name: Set | xs1_typ=$xs1_typ cmd=$cmd" if ( not defined ($args[0]) );
|
||||
Debug " $name: Set | xs1_typ=$xs1_typ cmd=$cmd args0=".$args[0] if ( defined ($args[0]) && $cmd ne "?");
|
||||
@ -230,26 +233,36 @@ sub xs1Dev_Set ($$@)
|
||||
$cmd = $cmd." $newState";
|
||||
}
|
||||
|
||||
#} elsif ($cmd eq "dim_down") { # Umsetzung "anderer Befehl"
|
||||
|
||||
#} elsif ($cmd eq "dim_up") { # Umsetzung "anderer Befehl"
|
||||
|
||||
}
|
||||
|
||||
} elsif ($xs1_typ ne "dimmer" && $xs1_typ ne "switch" && $xs1_typ ne "undefined") { ## alles außer Dimmer || Switch
|
||||
Log3 $name, 2, "$name: Set | xs1_typ=$xs1_typ are not supported (loop not dimmer & switch)";
|
||||
return "xs1_typ=$xs1_typ are not supported (loop not dimmer & switch)";
|
||||
}
|
||||
############## Funktion shutter ##############
|
||||
elsif ($xs1_typ eq "shutter") {
|
||||
Debug " $name: Set | xs1_function 1=$xs1_function[0] 2=$xs1_function[1] 3=$xs1_function[2] 4=$xs1_function[3]" if($debug);
|
||||
if ($cmdFound >= 0) { ## cmdFound in welchem Funktionsplatz xs1
|
||||
for my $i (0 .. 3) {
|
||||
if ($xs1_function[$i] eq $cmd) {
|
||||
$cmd2 = "function=".($i+1);
|
||||
Debug " $name: Set | cmd=$cmd cmd2=$cmd2 on xs1_function place".($i+1) if($debug);
|
||||
}
|
||||
}
|
||||
}
|
||||
return "Wrong set argument, choose one of $cmdList" if($cmdFound < 0);
|
||||
}
|
||||
############## alles Andere ##############
|
||||
elsif ($xs1_typ ne "dimmer" && $xs1_typ ne "switch" && $xs1_typ ne "undefined") {
|
||||
Log3 $name, 2, "$name: Set | xs1_typ=$xs1_typ are not supported. Please inform me!";
|
||||
return "xs1_typ=$xs1_typ are not supported. Please inform me!";
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if(defined($hash->{IODev}->{NAME})) {
|
||||
Debug " $name: Set | xs1_ID=$xs1_ID xs1_typ=$xs1_typ cmd=$cmd cmd2=$cmd2" if($debug && $xs1_typ ne "temperature" && $xs1_typ ne "hygrometer");
|
||||
if ($xs1_typ eq "switch" || $xs1_typ eq "dimmer") {
|
||||
if ($xs1_typ eq "switch" || $xs1_typ eq "dimmer" || $xs1_typ eq "shutter") {
|
||||
Debug " $name: Set IOWrite | xs1_ID=$xs1_ID xs1_typ=$xs1_typ cmd=$cmd cmd2=$cmd2" if($debug && $xs1_typ ne "temperature" && $xs1_typ ne "hygrometer");
|
||||
IOWrite($hash, $xs1_ID, $xs1_typ, $cmd, $cmd2);
|
||||
|
||||
readingsSingleUpdate($hash, "state", $cmd , 1);
|
||||
}
|
||||
} else { Log3 $name, 2, "$name: Device $xs1_typ are not supported for Dispatch"; }
|
||||
} else {
|
||||
return "no IODev define. Please define xs1Bridge.";
|
||||
}
|
||||
@ -261,7 +274,7 @@ sub xs1Dev_Set ($$@)
|
||||
return undef;
|
||||
}
|
||||
|
||||
sub xs1Dev_Parse($$) ## Input Bridge
|
||||
sub xs1Dev_Parse($$) ## Input Data from 88_xs1Bridge
|
||||
{
|
||||
my ( $io_hash, $data) = @_; ## $io_hash = ezControl -> def. Name von xs1Bridge
|
||||
|
||||
@ -298,7 +311,7 @@ sub xs1Dev_Parse($$) ## Input Bridge
|
||||
$hash->{xs1_function4} = $xs1_f4;
|
||||
}
|
||||
|
||||
if ($xs1_typ2 eq "switch") { # switch on | off mod for FHEM Default
|
||||
if ($xs1_typ2 eq "switch") { ## switch on | off mod for FHEM Default
|
||||
if ($xs1_value == 0) { $xs1_value = "off"; }
|
||||
elsif ($xs1_value == 100) { $xs1_value = "on"; }
|
||||
readingsSingleUpdate($hash, "state", $xs1_value ,1); # Aktor | Sensor Update value
|
||||
@ -309,21 +322,21 @@ sub xs1Dev_Parse($$) ## Input Bridge
|
||||
$attr{$name}{devStateIcon} = "dim_up:dimup dim_down:dimdown" if( not defined( $attr{$name}{devStateIcon} ) );
|
||||
}
|
||||
|
||||
} elsif ($xs1_typ2 eq "temperature") { # temperature typ
|
||||
my $xs1_value_new = "T: ".$xs1_value; # temperature mod for FHEM Default
|
||||
} elsif ($xs1_typ2 eq "temperature") { ## temperature typ
|
||||
my $xs1_value_new = "T: ".$xs1_value; ## temperature mod for FHEM Default
|
||||
|
||||
readingsBeginUpdate($hash);
|
||||
readingsBulkUpdate($hash, "state", $xs1_value_new);
|
||||
readingsBulkUpdate($hash, "temperature", $xs1_value);
|
||||
readingsEndUpdate($hash, 1);
|
||||
} elsif ($xs1_typ2 eq "hygrometer") { # hygrometer typ
|
||||
my $xs1_value_new = "H: ".$xs1_value; # hygrometer mod for FHEM Default
|
||||
} elsif ($xs1_typ2 eq "hygrometer") { ## hygrometer typ
|
||||
my $xs1_value_new = "H: ".$xs1_value; ## hygrometer mod for FHEM Default
|
||||
|
||||
readingsBeginUpdate($hash);
|
||||
readingsBulkUpdate($hash, "state", $xs1_value_new);
|
||||
readingsBulkUpdate($hash, "humidity", $xs1_value);
|
||||
readingsEndUpdate($hash, 1);
|
||||
} elsif ($xs1_typ2 eq "dimmer") { # dimmer
|
||||
} elsif ($xs1_typ2 eq "dimmer") { ## dimmer
|
||||
|
||||
## RegEx devStateIcon da Symbole nicht durchweg von 0 - 100 | dim_up | dim_down
|
||||
$attr{$name}{devStateIcon} = "dim0[1-6]\\D%:dim06% dim[7-9]\\D|dim[1][0-2]%:dim12% dim[1][3-8]%:dim18% \n"
|
||||
@ -340,7 +353,12 @@ sub xs1Dev_Parse($$) ## Input Bridge
|
||||
}
|
||||
|
||||
readingsSingleUpdate($hash, "state", $xs1_value ,1);
|
||||
} elsif ($xs1_typ2 eq "shutter") { ## shutter on | off mod for FHEM Default
|
||||
if ($xs1_value == 0) { $xs1_value = "off"; }
|
||||
elsif ($xs1_value == 100) { $xs1_value = "on"; }
|
||||
readingsSingleUpdate($hash, "state", $xs1_value ,1);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
return $name;
|
||||
|
Loading…
x
Reference in New Issue
Block a user