2
0
mirror of https://github.com/fhem/fhem-mirror.git synced 2025-04-23 14:46:24 +00:00

88_xs1Dev: various sensor types added

git-svn-id: https://svn.fhem.de/fhem/trunk@16529 2b470e98-0d58-463d-a4d8-8e2adae1ed80
This commit is contained in:
HomeAuto_User 2018-04-01 17:51:09 +00:00
parent e281942419
commit f6a7213fdf
2 changed files with 149 additions and 70 deletions

View File

@ -85,9 +85,9 @@ sub xs1Bridge_Define($$) {
my $xs1_ip = $arg[2]; ## Zusatzparameter 1 bei Define - ggf. nur in Sub my $xs1_ip = $arg[2]; ## Zusatzparameter 1 bei Define - ggf. nur in Sub
$hash->{xs1_ip} = $xs1_ip; $hash->{xs1_ip} = $xs1_ip;
$hash->{STATE} = "Initialized"; ## Der Status des Modules nach Initialisierung. $hash->{STATE} = "Initialized"; ## Der Status des Modules nach Initialisierung.
$hash->{TIME} = time(); ## Zeitstempel, derzeit vom anlegen des Moduls $hash->{TIME} = time(); ## Zeitstempel, derzeit vom anlegen des Moduls
$hash->{VERSION} = "1.19"; ## Version $hash->{VERSION} = "1.20"; ## Version
$hash->{BRIDGE} = 1; $hash->{BRIDGE} = 1;
# Attribut gesetzt # Attribut gesetzt
@ -102,11 +102,11 @@ sub xs1Bridge_Define($$) {
#Log3 $name, 3, "$typ: IODev defined with xs1_ip: $xs1_ip"; #Log3 $name, 3, "$typ: IODev defined with xs1_ip: $xs1_ip";
if(!defined($defs{'FileLog_xs1Bridge'})) { ## Logfile existent check if(!defined($defs{'FileLog_xs1Bridge'})) { ## Logfile existent check
Log3 $name, 3, "$typ: FileLog_xs1Bridge ist NICHT definiert"; Log3 $name, 4, "$typ: FileLog_xs1Bridge ist NICHT definiert";
fhem("define FileLog_xs1Bridge FileLog ./log/xs1Bridge-%Y-%m.log ".$arg[0]); ## Logfile define fhem("define FileLog_xs1Bridge FileLog ./log/xs1Bridge-%Y-%m.log ".$arg[0]); ## Logfile define
fhem("attr FileLog_xs1Bridge room xs1"); ## Logfile in xs1 room fhem("attr FileLog_xs1Bridge room xs1"); ## Logfile in xs1 room
} else { } else {
Log3 $name, 3, "$typ: FileLog_xs1Bridge ist definiert"; Log3 $name, 4, "$typ: FileLog_xs1Bridge ist definiert";
} }
return undef; return undef;
@ -127,7 +127,7 @@ sub xs1Bridge_Attr(@) {
if ($cmd eq "set") { if ($cmd eq "set") {
RemoveInternalTimer($hash); ## Timer löschen RemoveInternalTimer($hash); ## Timer löschen
Debug " $typ: Attr | Cmd:$cmd | RemoveInternalTimer" if($debug); Debug " $typ: Attr | Cmd:$cmd | RemoveInternalTimer" if($debug);
if ($attrName eq "xs1_interval" && $attrValue == 0) { ## Handling xs1_interval == 0 if ($attrName eq "xs1_interval" && $attrValue == 0) { ## Handling xs1_interval == 0
RemoveInternalTimer($hash); RemoveInternalTimer($hash);
readingsSingleUpdate($hash, "state", "deactive", 1); readingsSingleUpdate($hash, "state", "deactive", 1);
}elsif ($attrName eq "xs1_interval" && $attrValue >= 30) { ## Handling xs1_interval >= 30 }elsif ($attrName eq "xs1_interval" && $attrValue >= 30) { ## Handling xs1_interval >= 30
@ -135,34 +135,38 @@ sub xs1Bridge_Attr(@) {
my $xs1_interval = $attrValue; my $xs1_interval = $attrValue;
InternalTimer(gettimeofday()+$xs1_interval, "xs1Bridge_GetUpDate", $hash); InternalTimer(gettimeofday()+$xs1_interval, "xs1Bridge_GetUpDate", $hash);
readingsSingleUpdate($hash, "state", "active", 1); readingsSingleUpdate($hash, "state", "active", 1);
### Ansicht xs1_Device_function ###
}elsif ($attrName eq "view_Device_function") { }elsif ($attrName eq "view_Device_function") {
if ($attrValue eq "1") { ## Handling view_Device_function 1 if ($attrValue eq "1") { ## Handling view_Device_function 1
Log3 $name, 3, "$typ: Attribut view_Device_function $cmd to $attrValue"; Log3 $name, 3, "$typ: Attribut view_Device_function $cmd to $attrValue";
} }
elsif ($attrValue eq "0") { ## Handling view_Device_function 0 elsif ($attrValue eq "0") { ## Handling view_Device_function 0
Log3 $name, 3, "$typ: Attribut view_Device_function $cmd to $attrValue"; Log3 $name, 3, "$typ: Attribut view_Device_function $cmd to $attrValue";
} }
### Ansicht xs1_Device_name ###
}elsif ($attrName eq "view_Device_name") { }elsif ($attrName eq "view_Device_name") {
if ($attrValue eq "1") { ## Handling view_Device_name 1 if ($attrValue eq "1") { ## Handling view_Device_name 1
Log3 $name, 3, "$typ: Attribut view_Device_name $cmd to $attrValue"; Log3 $name, 3, "$typ: Attribut view_Device_name $cmd to $attrValue";
}
elsif ($attrValue eq "0") { ## Handling view_Device_name 0
Log3 $name, 3, "$typ: Attribut view_Device_name $cmd to $attrValue";
for my $i (0..64) {
delete $hash->{READINGS}{"Aktor_".sprintf("%02d", $i)."_name"} if($hash->{READINGS});
delete $hash->{READINGS}{"Sensor_".sprintf("%02d", $i)."_name"} if($hash->{READINGS});
} }
} elsif ($attrValue eq "0") { ## Handling view_Device_name 0
Log3 $name, 3, "$typ: Attribut view_Device_name $cmd to $attrValue";
for my $i (0..64) {
delete $hash->{READINGS}{"Aktor_".sprintf("%02d", $i)."_name"} if($hash->{READINGS});
delete $hash->{READINGS}{"Sensor_".sprintf("%02d", $i)."_name"} if($hash->{READINGS});
}
}
### Wertaenderung nur bei Difference ###
}elsif ($attrName eq "update_only_difference") { }elsif ($attrName eq "update_only_difference") {
if ($attrValue eq "1") { ## Handling update_only_difference 1 if ($attrValue eq "1") { ## Handling update_only_difference 1
Log3 $name, 3, "$typ: Attribut update_only_difference $cmd to $attrValue"; Log3 $name, 3, "$typ: Attribut update_only_difference $cmd to $attrValue";
} }
elsif ($attrValue eq "0") { ## Handling update_only_difference 0 elsif ($attrValue eq "0") { ## Handling update_only_difference 0
Log3 $name, 3, "$typ: Attribut update_only_difference $cmd to $attrValue"; Log3 $name, 3, "$typ: Attribut update_only_difference $cmd to $attrValue";
for my $i (0..64) { for my $i (0..64) {
delete $hash->{READINGS}{"Aktor_".sprintf("%02d", $i)."_name"} if($hash->{READINGS}); delete $hash->{READINGS}{"Aktor_".sprintf("%02d", $i)."_name"} if($hash->{READINGS});
} }
} }
### xs1 - steuern ###
}elsif ($attrName eq "xs1_control") { }elsif ($attrName eq "xs1_control") {
if ($attrValue eq "1") { ## Handling xs1_control 1 if ($attrValue eq "1") { ## Handling xs1_control 1
if(! $modules{xs1Dev}) { ## Check Modul vorhanden if(! $modules{xs1Dev}) { ## Check Modul vorhanden
@ -170,20 +174,17 @@ sub xs1Bridge_Attr(@) {
return "Module xs1Dev is non-existent or still under development. Please wait" return "Module xs1Dev is non-existent or still under development. Please wait"
} }
} }
################# WUNSCH ################# ### Blacklist - Aktor / Sensor ###
}elsif ($attrName eq "xs1_blackl_aktor") { ## Handling xs1_blackl_aktor }elsif ($attrName eq "xs1_blackl_aktor") { ## Handling xs1_blackl_aktor
#if ($attrValue eq "1") { Log3 $name, 4, "$typ: Attribut xs1_blackl_aktor $attrValue";
Log3 $name, 3, "$typ: Attribut xs1_blackl_aktor $attrValue";
#}
}elsif ($attrName eq "xs1_blackl_sensor") { ## Handling xs1_blackl_sensor }elsif ($attrName eq "xs1_blackl_sensor") { ## Handling xs1_blackl_sensor
Log3 $name, 3, "$typ: Attribut xs1_blackl_sensor $attrValue"; Log3 $name, 4, "$typ: Attribut xs1_blackl_sensor $attrValue";
} }
################# WUNSCH ENDE #################
} }
#### Handling bei del ... attribute #### Handling bei del ... attribute
if ($cmd eq "del") { if ($cmd eq "del") {
if ($attrName eq "xs1_interval") { ## Handling deleteattr xs1_interval if ($attrName eq "xs1_interval") { ## Handling deleteattr xs1_interval
RemoveInternalTimer($hash); RemoveInternalTimer($hash);
readingsSingleUpdate($hash, "state", "deactive", 1); readingsSingleUpdate($hash, "state", "deactive", 1);
Debug " $typ: Attr | Cmd:$cmd | $attrName" if($debug); Debug " $typ: Attr | Cmd:$cmd | $attrName" if($debug);
@ -196,7 +197,7 @@ sub xs1Bridge_Attr(@) {
} }
} }
} }
elsif ($attrName eq "view_Device_name") { ## Handling deleteattr view_Device_name elsif ($attrName eq "view_Device_name") { ## Handling deleteattr view_Device_name
Log3 $name, 3, "$typ: Attribut view_Device_name delete"; Log3 $name, 3, "$typ: Attribut view_Device_name delete";
for my $i (0..64) { for my $i (0..64) {
delete $hash->{READINGS}{"Aktor_".sprintf("%02d", $i)."_name"} if($hash->{READINGS}); delete $hash->{READINGS}{"Aktor_".sprintf("%02d", $i)."_name"} if($hash->{READINGS});
@ -208,7 +209,7 @@ sub xs1Bridge_Attr(@) {
} }
} }
# #### Handling bei state active #### Handling bei state active
if ($hash->{STATE} eq "active") { if ($hash->{STATE} eq "active") {
RemoveInternalTimer($hash); RemoveInternalTimer($hash);
InternalTimer(gettimeofday()+$xs1_interval, "xs1Bridge_GetUpDate", $hash); InternalTimer(gettimeofday()+$xs1_interval, "xs1Bridge_GetUpDate", $hash);
@ -429,6 +430,26 @@ sub xs1Bridge_GetUpDate() {
delete $hash->{READINGS}{$readingsname[$i]."_".sprintf("%02d", $i3)} if($hash->{READINGS}); delete $hash->{READINGS}{$readingsname[$i]."_".sprintf("%02d", $i3)} if($hash->{READINGS});
delete $hash->{READINGS}{$readingsname[$i]."_".sprintf("%02d", $i3)."_name"} if($hash->{READINGS}); delete $hash->{READINGS}{$readingsname[$i]."_".sprintf("%02d", $i3)."_name"} if($hash->{READINGS});
### Erweiterung v1.20 ### Device | Logfile | SVG löschen wenn in xs1 disable - TEST
my $delDevice = "xs1Dev_".$readingsname[$i]."_".sprintf("%02d", $i3);
if (defined($defs{"xs1Dev_".$readingsname[$i]."_".sprintf("%02d", $i3)})) {
#Log3 $name, 3, "$typ: GetUpDate | for delete $delDevice";
fhem("delete ".$delDevice); ## delete Device
}
if (defined($defs{"SVG_xs1Dev_".$readingsname[$i]."_".sprintf("%02d", $i3)})) {
#Log3 $name, 3, "$typ: GetUpDate | for delete FileLog_$delDevice";
fhem("delete SVG_".$delDevice); ## delete FileLog_Device
}
if (defined($defs{"FileLog_xs1Dev_".$readingsname[$i]."_".sprintf("%02d", $i3)})) {
#Log3 $name, 3, "$typ: GetUpDate | for delete FileLog_$delDevice";
fhem("delete FileLog_".$delDevice); ## delete FileLog_Device
}
### Erweiterung v1.20 ### Device | Logfile | SVG löschen wenn in xs1 disable - TEST ### ENDE ###
if ($i == 0) { if ($i == 0) {
for my $count (1..4) { for my $count (1..4) {
delete $hash->{READINGS}{$readingsname[$i]."_".sprintf("%02d", $i3)."_function_".$count} if($hash->{READINGS}); delete $hash->{READINGS}{$readingsname[$i]."_".sprintf("%02d", $i3)."_function_".$count} if($hash->{READINGS});
@ -519,23 +540,23 @@ sub xs1Bridge_Write($) ## Zustellen von Daten via IOWrite() vom logischen zum
my $typ = $hash->{TYPE}; my $typ = $hash->{TYPE};
my $xs1_ip = $hash->{xs1_ip}; my $xs1_ip = $hash->{xs1_ip};
## Anfrage (Client -> XS1): http://192.168.1.242/control?callback=cname&cmd=set_state_actuator&number=1&value=100 ## Anfrage (Client -> XS1): http://192.168.1.242/control?callback=cname&cmd=set_state_actuator&number=1&value=100
## Aktor Typen aus xs1: (notwendig zur Verarbeitung) ## Aktor Typen aus xs1: (notwendig zur Verarbeitung)
## ------------------------------------------------- ## -------------------------------------------------
## blind - Jalousie | dimmer - Dimmer | door - Tür | disabled - deaktivert ## blind - Jalousie | dimmer - Dimmer | door - Tür | disabled - deaktivert
## switch - Schalter | shutter - Rolladen | sound - Ton | sun-blind - Markise ## switch - Schalter | shutter - Rolladen | sound - Ton | sun-blind - Markise
## temperature - Temperatur | timerswitch - Zeitschalter | window - Fenster ## temperature - Temperatur | timerswitch - Zeitschalter | window - Fenster
## Sensor Typen (Auswahl) aus xs1: (nur Info) ## Sensor Typen (Auswahl) aus xs1: (nur Info)
## ------------------------------------------ ## ------------------------------------------
## alarmmat - Alarmmatte | disabled - deaktivert ## alarmmat - Alarmmatte | disabled - deaktivert
## gas_butan - Gasmelder Butan | gas_peak - Gas Spitzenwert ## gas_butan - Gasmelder Butan | gas_peak - Gas Spitzenwert
## mail - Briefmelder | motion - Bewegung ## mail - Briefmelder | motion - Bewegung
## other - Andere | presence - Anwesenheit ## other - Andere | presence - Anwesenheit
## pwr_consump - Energiezähler | pwr_peak - Energie Spitzenwert ## pwr_consump - Energiezähler | pwr_peak - Energie Spitzenwert
## soilmoisture - Bodenfeuchte | soiltemp - Bodentemperatur ## soilmoisture - Bodenfeuchte | soiltemp - Bodentemperatur
## leafwetness - Blattfeuchte | remotecontrol - Fernbedienung ## leafwetness - Blattfeuchte | remotecontrol - Fernbedienung
## windowopen - Fenstermelder ... ## windowopen - Fenstermelder ...
$Aktor_ID = substr($Aktor_ID, 1,2); $Aktor_ID = substr($Aktor_ID, 1,2);
@ -550,9 +571,9 @@ sub xs1Bridge_Write($) ## Zustellen von Daten via IOWrite() vom logischen zum
} }
$xs1cmd = "http://$xs1_ip/control?callback=cname&cmd=set_state_actuator&number=$Aktor_ID&value=$cmd"; $xs1cmd = "http://$xs1_ip/control?callback=cname&cmd=set_state_actuator&number=$Aktor_ID&value=$cmd";
} else { } else {
#### keine Verarbeitung zum senden #### #### keine Verarbeitung zum senden ####
Log3 $name, 3, "$typ: Write | $xs1_typ not control xs1. Please inform me!"; Log3 $name, 3, "$typ: Write | $xs1_typ not control xs1. Please inform me!";
last; last;
} }
### HTTP Requests #### Start #### ### HTTP Requests #### Start ####
@ -560,10 +581,10 @@ sub xs1Bridge_Write($) ## Zustellen von Daten via IOWrite() vom logischen zum
my $Http_err = ""; my $Http_err = "";
my $Http_data; my $Http_data;
my $param = { my $param = {
url => "$xs1cmd", url => "$xs1cmd",
timeout => 3, timeout => 3,
method => "GET", # Lesen von Inhalten method => "GET", # Lesen von Inhalten
}; };
HttpUtils_BlockingGet($param); HttpUtils_BlockingGet($param);
($Http_err, $Http_data) = HttpUtils_BlockingGet($param); ($Http_err, $Http_data) = HttpUtils_BlockingGet($param);
@ -645,7 +666,13 @@ sub is_in_array($$$)
<br><br> <br><br>
The module was developed based on the firmware version v4-Beta of the xs1. There may be errors due to different adjustments within the manufacturer's firmware.<br> The module was developed based on the firmware version v4-Beta of the xs1. There may be errors due to different adjustments within the manufacturer's firmware.<br>
Testet firmware: v4.0.0.5326 (Beta) @me | v3.0.0.4493 @ForumUser<br><br> Testet firmware: v4.0.0.5326 (Beta) @me | v3.0.0.4493 @ForumUser<br>
<br><ul>
<u>Currently implemented types of xs1 for processing: </u><br>
<li>Aktor: dimmer, switch, shutter, timerswitch</li>
<li>Sensor: barometer, counter, counterdiff, light, motion, other, rain, rain_1h, rain_24h, rainintensity, remotecontrol, uv_index, waterdetector, winddirection, windgust, windspeed, windvariance</li>
</ul><br><br>
<a name="xs1Bridge_define"></a> <a name="xs1Bridge_define"></a>
<b>Define</b><br> <b>Define</b><br>
@ -737,7 +764,13 @@ sub is_in_array($$$)
<br><br> <br><br>
Das Modul wurde entwickelt basierend auf dem Firmwarestand v4-Beta des xs1. Es kann aufgrund von unterschiedlichen Anpassungen innerhalb der Firmware des Herstellers zu Fehlern kommen.<br> Das Modul wurde entwickelt basierend auf dem Firmwarestand v4-Beta des xs1. Es kann aufgrund von unterschiedlichen Anpassungen innerhalb der Firmware des Herstellers zu Fehlern kommen.<br>
Getestete Firmware: v4.0.0.5326 (Beta) @me | v3.0.0.4493 @ForumUser<br><br> Getestete Firmware: v4.0.0.5326 (Beta) @me | v3.0.0.4493 @ForumUser<br>
<br><ul>
<u>Derzeit implementierte Typen des xs1 zur Verarbeitung: </u><br>
<li>Aktor: dimmer, switch, shutter, timerswitch</li>
<li>Sensor: barometer, counter, counterdiff, light, motion, other, rain, rain_1h, rain_24h, rainintensity, remotecontrol, uv_index, waterdetector, winddirection, windgust, windspeed, windvariance</li>
</ul><br><br>
<a name="xs1Bridge_define"></a> <a name="xs1Bridge_define"></a>
<b>Define</b><br> <b>Define</b><br>

View File

@ -40,12 +40,14 @@ sub xs1Dev_Initialize($) {
} }
sub xs1Dev_Define($$) { sub xs1Dev_Define($$) {
# $def --> Definition des Module
# $hash --> ARRAY des Module
my ($hash, $def) = @_; my ($hash, $def) = @_;
my @arg = split("[ \t][ \t]*", $def); my @arg = split("[ \t][ \t]*", $def);
# 0 1 2 3 4 #-----0------1------2----3----4
return "Usage: define <NAME> xs1Dev <Typ> <ID> IODev= | wrong number of arguments" if( @arg != 5); return "Usage: define <NAME> xs1Dev <Typ> <ID> | wrong number of arguments" if( @arg != 4);
return "Usage: define <NAME> xs1Dev <Typ> <ID> IODev= | wrong IODev argument" if not ( $arg[4] =~ m/IODev=([^\s]*)[a-zA-Z0-9]/);
return "Usage: define <NAME> xs1Dev <Typ> <ID> | wrong ID, must be 1-64" if ( $arg[3] <1 || $arg[3] >64); return "Usage: define <NAME> xs1Dev <Typ> <ID> | wrong ID, must be 1-64" if ( $arg[3] <1 || $arg[3] >64);
return "Usage: define <NAME> xs1Dev <Typ> <ID> | wrong Typ, must be A or S" if ( $arg[2] ne "A" && $arg[2] ne "S"); return "Usage: define <NAME> xs1Dev <Typ> <ID> | wrong Typ, must be A or S" if ( $arg[2] ne "A" && $arg[2] ne "S");
@ -53,6 +55,7 @@ sub xs1Dev_Define($$) {
my $iodev; my $iodev;
my $i = 0; my $i = 0;
############## !! ################ nicht genutzt derzeit ############# !! #################
#### Schleife (Durchlauf der Argumente @arg) wo IODev= gefiltert wird aus define | Dispatch #### Schleife (Durchlauf der Argumente @arg) wo IODev= gefiltert wird aus define | Dispatch
foreach my $param ( @arg ) { foreach my $param ( @arg ) {
if( $param =~ m/IODev=([^\s]*)/ ) { if( $param =~ m/IODev=([^\s]*)/ ) {
@ -96,7 +99,7 @@ sub xs1Dev_Define($$) {
$hash->{STATE} = "Defined"; ## Der Status des Modules nach Initialisierung. $hash->{STATE} = "Defined"; ## Der Status des Modules nach Initialisierung.
$hash->{TIME} = time(); ## Zeitstempel, derzeit vom anlegen des Moduls $hash->{TIME} = time(); ## Zeitstempel, derzeit vom anlegen des Moduls
$hash->{VERSION} = "1.16"; ## Version #$hash->{VERSION} = "1.17"; ## Version
$hash->{xs1_name} = "undefined"; ## Aktor | Sensor Name welcher def. im xs1 $hash->{xs1_name} = "undefined"; ## Aktor | Sensor Name welcher def. im xs1
$hash->{xs1_typ} = "undefined"; ## xs1_Typ switch | hygrometer | temperature ... $hash->{xs1_typ} = "undefined"; ## xs1_Typ switch | hygrometer | temperature ...
@ -109,23 +112,25 @@ sub xs1Dev_Define($$) {
} }
# Attribut gesetzt # Attribut gesetzt
$attr{$name}{room} = "xs1" if( not defined( $attr{$name}{room} ) ); $attr{$name}{room} = "xs1" if( not defined( $attr{$name}{room} ) );
AssignIoPort($hash,$iodev) if( !$hash->{IODev} ); ## sucht nach einem passenden IO-Gerät (physikalische Definition) AssignIoPort($hash,$iodev) if( !$hash->{IODev} ); ## sucht nach einem passenden IO-Gerät (physikalische Definition)
if(defined($hash->{IODev}->{NAME})) { # alles mit IODev erst NACH AssignIoPort nutzbar !!!
Log3 $name, 4, "xs1Dev: $name - I/O device is " . $hash->{IODev}->{NAME}; $hash->{VERSION} = $hash->{IODev}->{VERSION}; ## Version
}
# GENERELL in FHEM auf LOG1 genommen von Rudi if(defined($hash->{IODev}->{NAME})) {
# else { Log3 $name, 4, "xs1Dev: $name - I/O Device is " . $hash->{IODev}->{NAME};
# Log3 $name, 3, "xs1Dev: $name - no I/O device"; } else {
# } Log3 $name, 3, "xs1Dev: $name - no I/O Device, Please delete and restart FHEM.";
}
#$iodev = $hash->{IODev}->{NAME};
# if(defined($hash->{IODev}->{xs1_ip})) { ## IP von xs1Bridge - Device aus HASH # if(defined($hash->{IODev}->{xs1_ip})) { ## IP von xs1Bridge - Device aus HASH
# $hash->{xs1_ip} = $hash->{IODev}->{xs1_ip}; # $hash->{xs1_ip} = $hash->{IODev}->{xs1_ip};
# } # }
return undef; return undef;
} }
@ -153,7 +158,7 @@ sub xs1Dev_Set ($$@)
return "no set value specified" if(int(@args) < 1); return "no set value specified" if(int(@args) < 1);
if ($xs1_typ ne "temperature" && $xs1_typ ne "hygrometer") { if ($xs1_typ ne "temperature" && $xs1_typ ne "hygrometer" && $xs1_typ ne "undefined") {
my @xs1_function =(); ## Funktionen in ARRAY schreiben my @xs1_function =(); ## Funktionen in ARRAY schreiben
push (@xs1_function, $hash->{xs1_function1}); push (@xs1_function, $hash->{xs1_function1});
push (@xs1_function, $hash->{xs1_function2}); push (@xs1_function, $hash->{xs1_function2});
@ -265,6 +270,8 @@ sub xs1Dev_Set ($$@)
if(defined($hash->{IODev}->{NAME})) { if(defined($hash->{IODev}->{NAME})) {
if ($xs1_typ eq "switch" || $xs1_typ eq "dimmer" || $xs1_typ eq "shutter" || $xs1_typ eq "timerswitch") { if ($xs1_typ eq "switch" || $xs1_typ eq "dimmer" || $xs1_typ eq "shutter" || $xs1_typ eq "timerswitch") {
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"); 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");
Log3 $name, 3, "$name: Set IOWrite | xs1_ID=$xs1_ID xs1_typ=$xs1_typ cmd=$cmd cmd2=$cmd2 IODev=$hash->{IODev}->{NAME}";
IOWrite($hash, $xs1_ID, $xs1_typ, $cmd, $cmd2); IOWrite($hash, $xs1_ID, $xs1_typ, $cmd, $cmd2);
readingsSingleUpdate($hash, "state", $cmd , 1); readingsSingleUpdate($hash, "state", $cmd , 1);
} }
@ -302,12 +309,13 @@ sub xs1Dev_Parse($$) ## Input Data from 88_xs1Bridge
$typ = "xs1Dev" if (!$def); ## Erstanlegung $typ = "xs1Dev" if (!$def); ## Erstanlegung
###### Define and values update ###### ###### Define and values update ######
#Log3 $typ, 3, "$typ: Parse | Data: $xs1Dev | $xs1_readingsname | $xs1_ID | $xs1_typ2 | $xs1_value | $xs1_typ1 | $IODev" if (!$def); #Log3 $typ, 3, "$typ: Parse | Data: $xs1Dev | $xs1_readingsname | $xs1_ID | $xs1_typ2 | $xs1_value | $xs1_typ1" if (!$def);
#Log3 $typ, 3, "$typ: Parse | Data: $xs1Dev | $xs1_readingsname | $xs1_ID | $xs1_typ2 | $xs1_value | $xs1_typ1";
if(!$def) { if(!$def) {
# "UNDEFINED xs1Dev_Aktor_12 xs1Dev A 12" # "UNDEFINED xs1Dev_Aktor_12 xs1Dev A 12"
Log3 $name, 3, "$typ: Unknown device ".$xs1Dev."_".$xs1_readingsname."_"."$xs1_ID $xs1_ID $xs1_typ1 IODev=$IODev, please define it"; Log3 $name, 3, "$typ: Unknown device ".$xs1Dev."_".$xs1_readingsname."_"."$xs1_ID $xs1_ID $xs1_typ1 , please define it";
return "UNDEFINED xs1Dev"."_".$xs1_readingsname."_"."$xs1_ID xs1Dev $xs1_typ1 $xs1_ID IODev=$IODev"; return "UNDEFINED xs1Dev"."_".$xs1_readingsname."_"."$xs1_ID xs1Dev $xs1_typ1 $xs1_ID";
} else { } else {
#Log3 $name, 3, "$typ: device $xs1_readingsname"."_"."$xs1_ID xs1_value:$xs1_value xs1_typ2:$xs1_typ2"; #Log3 $name, 3, "$typ: device $xs1_readingsname"."_"."$xs1_ID xs1_value:$xs1_value xs1_typ2:$xs1_typ2";
@ -382,6 +390,37 @@ sub xs1Dev_Parse($$) ## Input Data from 88_xs1Bridge
elsif ($xs1_value == 100) { $xs1_value = "on"; } elsif ($xs1_value == 100) { $xs1_value = "on"; }
readingsSingleUpdate($hash, "state", $xs1_value ,1); readingsSingleUpdate($hash, "state", $xs1_value ,1);
} }
#### ### Erweiterung v1.20 ###
elsif ($xs1_typ2 eq "barometer") {
readingsBeginUpdate($hash);
readingsSingleUpdate($hash, "pressure", $xs1_value ,1);
readingsSingleUpdate($hash, "state", "P: ".$xs1_value ,1);
readingsEndUpdate($hash, 1);
}
elsif ($xs1_typ2 eq "rain") {
readingsBeginUpdate($hash);
readingsSingleUpdate($hash, "rain", $xs1_value ,1);
readingsSingleUpdate($hash, "state", "R: ".$xs1_value ,1);
readingsEndUpdate($hash, 1);
}
elsif ($xs1_typ2 eq "rain_1h") {
readingsBeginUpdate($hash);
readingsSingleUpdate($hash, "rain_calc_h", $xs1_value ,1);
readingsSingleUpdate($hash, "state", "R: ".$xs1_value ,1);
readingsEndUpdate($hash, 1);
}
elsif ($xs1_typ2 eq "rain_24h") {
readingsBeginUpdate($hash);
readingsSingleUpdate($hash, "rain_calc_d", $xs1_value ,1);
readingsSingleUpdate($hash, "state", "R: ".$xs1_value ,1);
readingsEndUpdate($hash, 1);
}
elsif ($xs1_typ2 eq "counter" || $xs1_typ2 eq "counterdiff" || $xs1_typ2 eq "light" || $xs1_typ2 eq "motion" ||
$xs1_typ2 eq "other" || $xs1_typ2 eq "rainintensity" || $xs1_typ2 eq "remotecontrol" || $xs1_typ2 eq "uv_index" ||
$xs1_typ2 eq "waterdetector" || $xs1_typ2 eq "winddirection" || $xs1_typ2 eq "windgust" || $xs1_typ2 eq "windspeed" || $xs1_typ2 eq "windvariance") {
readingsSingleUpdate($hash, "state", $xs1_value ,1);
}
#### ### Erweiterung v1.20 ### ENDE ###
} }
return $name; return $name;
@ -415,7 +454,13 @@ sub xs1Dev_Undef($$)
This module works with the xs1Bridge module. (The <code>xs1_control</code> attribute in the xs1Bridge module must be set to 1!) <br> This module works with the xs1Bridge module. (The <code>xs1_control</code> attribute in the xs1Bridge module must be set to 1!) <br>
It communicates with this and creates all actuators of the xs1 as a device in FHEM. So you can control the actuators of the xs1 from the FHEM. <br><br> It communicates with this and creates all actuators of the xs1 as a device in FHEM. So you can control the actuators of the xs1 from the FHEM. <br><br>
The module was developed based on the firmware version v4-Beta of the xs1. There may be errors due to different adjustments within the manufacturer's firmware. The module was developed based on the firmware version v4-Beta of the xs1. There may be errors due to different adjustments within the manufacturer's firmware.
<br><br> <br>
<br><ul>
<u>Currently implemented types of xs1 for processing: </u><br>
<li>Aktor: dimmer, switch, shutter, timerswitch</li>
<li>Sensor: barometer, counter, counterdiff, light, motion, other, rain, rain_1h, rain_24h, rainintensity, remotecontrol, uv_index, waterdetector, winddirection, windgust, windspeed, windvariance</li>
</ul><br><br>
<a name="xs1Dev_define"></a> <a name="xs1Dev_define"></a>
<b>Define</b><br> <b>Define</b><br>
@ -470,8 +515,6 @@ sub xs1Dev_Undef($$)
xs1_name: defined name in the device<br> xs1_name: defined name in the device<br>
xs1_typ: defined type in the device<br> xs1_typ: defined type in the device<br>
</ul><br> </ul><br>
<li>The following xs1 device types are already integrated: dimmer | shutter | switch | timerswitch</li>
</ul> </ul>
</ul> </ul>
=end html =end html
@ -483,8 +526,13 @@ sub xs1Dev_Undef($$)
Dieses Modul arbeitet mit dem Modul xs1Bridge zusammen. (Das Attribut <code>xs1_control</code> im Modul xs1Bridge muss auf 1 gestellt sein!) <br> Dieses Modul arbeitet mit dem Modul xs1Bridge zusammen. (Das Attribut <code>xs1_control</code> im Modul xs1Bridge muss auf 1 gestellt sein!) <br>
Es kommuniziert mit diesem und legt sämtliche Aktoren des xs1 als Device im FHEM an. So kann man vom FHEM aus, die Aktoren der xs1 steuern. Es kommuniziert mit diesem und legt sämtliche Aktoren des xs1 als Device im FHEM an. So kann man vom FHEM aus, die Aktoren der xs1 steuern.
<br><br> <br><br>
Das Modul wurde entwickelt basierend auf dem Firmwarestand v4-Beta des xs1. Es kann aufgrund von unterschiedlichen Anpassungen innerhalb der Firmware des Herstellers zu Fehlern kommen. Das Modul wurde entwickelt basierend auf dem Firmwarestand v4-Beta des xs1. Es kann aufgrund von unterschiedlichen Anpassungen innerhalb der Firmware des Herstellers zu Fehlern kommen.<br>
<br><br>
<br><ul>
<u>Derzeit implementierte Typen des xs1 zur Verarbeitung: </u><br>
<li>Aktor: dimmer, switch, shutter, timerswitch</li>
<li>Sensor: barometer, counter, counterdiff, light, motion, other, rain, rain_1h, rain_24h, rainintensity, remotecontrol, uv_index, waterdetector, winddirection, windgust, windspeed, windvariance</li>
</ul><br><br>
<a name="xs1Dev_define"></a> <a name="xs1Dev_define"></a>
<b>Define</b><br> <b>Define</b><br>
@ -539,8 +587,6 @@ sub xs1Dev_Undef($$)
xs1_name: definierter Name im Ger&auml;t<br> xs1_name: definierter Name im Ger&auml;t<br>
xs1_typ: definierter Typ im Ger&auml;t<br> xs1_typ: definierter Typ im Ger&auml;t<br>
</ul><br> </ul><br>
<li>Folgende xs1-Ger&aumltetypen sind bereits integriert: dimmer | shutter | switch | timerswitch</li>
</ul> </ul>
</ul> </ul>