mirror of
https://github.com/fhem/fhem-mirror.git
synced 2025-04-22 20:24:36 +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:
parent
e281942419
commit
f6a7213fdf
@ -87,7 +87,7 @@ sub xs1Bridge_Define($$) {
|
||||
|
||||
$hash->{STATE} = "Initialized"; ## Der Status des Modules nach Initialisierung.
|
||||
$hash->{TIME} = time(); ## Zeitstempel, derzeit vom anlegen des Moduls
|
||||
$hash->{VERSION} = "1.19"; ## Version
|
||||
$hash->{VERSION} = "1.20"; ## Version
|
||||
$hash->{BRIDGE} = 1;
|
||||
|
||||
# Attribut gesetzt
|
||||
@ -102,11 +102,11 @@ sub xs1Bridge_Define($$) {
|
||||
#Log3 $name, 3, "$typ: IODev defined with xs1_ip: $xs1_ip";
|
||||
|
||||
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("attr FileLog_xs1Bridge room xs1"); ## Logfile in xs1 room
|
||||
} else {
|
||||
Log3 $name, 3, "$typ: FileLog_xs1Bridge ist definiert";
|
||||
Log3 $name, 4, "$typ: FileLog_xs1Bridge ist definiert";
|
||||
}
|
||||
|
||||
return undef;
|
||||
@ -135,6 +135,7 @@ sub xs1Bridge_Attr(@) {
|
||||
my $xs1_interval = $attrValue;
|
||||
InternalTimer(gettimeofday()+$xs1_interval, "xs1Bridge_GetUpDate", $hash);
|
||||
readingsSingleUpdate($hash, "state", "active", 1);
|
||||
### Ansicht xs1_Device_function ###
|
||||
}elsif ($attrName eq "view_Device_function") {
|
||||
if ($attrValue eq "1") { ## Handling view_Device_function 1
|
||||
Log3 $name, 3, "$typ: Attribut view_Device_function $cmd to $attrValue";
|
||||
@ -142,6 +143,7 @@ sub xs1Bridge_Attr(@) {
|
||||
elsif ($attrValue eq "0") { ## Handling view_Device_function 0
|
||||
Log3 $name, 3, "$typ: Attribut view_Device_function $cmd to $attrValue";
|
||||
}
|
||||
### Ansicht xs1_Device_name ###
|
||||
}elsif ($attrName eq "view_Device_name") {
|
||||
if ($attrValue eq "1") { ## Handling view_Device_name 1
|
||||
Log3 $name, 3, "$typ: Attribut view_Device_name $cmd to $attrValue";
|
||||
@ -153,6 +155,7 @@ sub xs1Bridge_Attr(@) {
|
||||
delete $hash->{READINGS}{"Sensor_".sprintf("%02d", $i)."_name"} if($hash->{READINGS});
|
||||
}
|
||||
}
|
||||
### Wertaenderung nur bei Difference ###
|
||||
}elsif ($attrName eq "update_only_difference") {
|
||||
if ($attrValue eq "1") { ## Handling update_only_difference 1
|
||||
Log3 $name, 3, "$typ: Attribut update_only_difference $cmd to $attrValue";
|
||||
@ -163,6 +166,7 @@ sub xs1Bridge_Attr(@) {
|
||||
delete $hash->{READINGS}{"Aktor_".sprintf("%02d", $i)."_name"} if($hash->{READINGS});
|
||||
}
|
||||
}
|
||||
### xs1 - steuern ###
|
||||
}elsif ($attrName eq "xs1_control") {
|
||||
if ($attrValue eq "1") { ## Handling xs1_control 1
|
||||
if(! $modules{xs1Dev}) { ## Check Modul vorhanden
|
||||
@ -170,15 +174,12 @@ sub xs1Bridge_Attr(@) {
|
||||
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
|
||||
#if ($attrValue eq "1") {
|
||||
Log3 $name, 3, "$typ: Attribut xs1_blackl_aktor $attrValue";
|
||||
#}
|
||||
Log3 $name, 4, "$typ: Attribut xs1_blackl_aktor $attrValue";
|
||||
}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
|
||||
@ -208,7 +209,7 @@ sub xs1Bridge_Attr(@) {
|
||||
}
|
||||
}
|
||||
|
||||
# #### Handling bei state active
|
||||
#### Handling bei state active
|
||||
if ($hash->{STATE} eq "active") {
|
||||
RemoveInternalTimer($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)."_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) {
|
||||
for my $count (1..4) {
|
||||
delete $hash->{READINGS}{$readingsname[$i]."_".sprintf("%02d", $i3)."_function_".$count} if($hash->{READINGS});
|
||||
@ -645,7 +666,13 @@ sub is_in_array($$$)
|
||||
<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>
|
||||
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>
|
||||
<b>Define</b><br>
|
||||
@ -737,7 +764,13 @@ sub is_in_array($$$)
|
||||
<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>
|
||||
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>
|
||||
<b>Define</b><br>
|
||||
|
@ -40,12 +40,14 @@ sub xs1Dev_Initialize($) {
|
||||
}
|
||||
|
||||
sub xs1Dev_Define($$) {
|
||||
# $def --> Definition des Module
|
||||
# $hash --> ARRAY des Module
|
||||
|
||||
my ($hash, $def) = @_;
|
||||
my @arg = split("[ \t][ \t]*", $def);
|
||||
|
||||
# 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> IODev= | wrong IODev argument" if not ( $arg[4] =~ m/IODev=([^\s]*)[a-zA-Z0-9]/);
|
||||
#-----0------1------2----3----4
|
||||
return "Usage: define <NAME> xs1Dev <Typ> <ID> | wrong number of arguments" if( @arg != 4);
|
||||
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");
|
||||
|
||||
@ -53,6 +55,7 @@ sub xs1Dev_Define($$) {
|
||||
my $iodev;
|
||||
my $i = 0;
|
||||
|
||||
############## !! ################ nicht genutzt derzeit ############# !! #################
|
||||
#### Schleife (Durchlauf der Argumente @arg) wo IODev= gefiltert wird aus define | Dispatch
|
||||
foreach my $param ( @arg ) {
|
||||
if( $param =~ m/IODev=([^\s]*)/ ) {
|
||||
@ -96,7 +99,7 @@ sub xs1Dev_Define($$) {
|
||||
|
||||
$hash->{STATE} = "Defined"; ## Der Status des Modules nach Initialisierung.
|
||||
$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_typ} = "undefined"; ## xs1_Typ switch | hygrometer | temperature ...
|
||||
@ -111,21 +114,23 @@ sub xs1Dev_Define($$) {
|
||||
# Attribut gesetzt
|
||||
$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)
|
||||
|
||||
# alles mit IODev erst NACH AssignIoPort nutzbar !!!
|
||||
$hash->{VERSION} = $hash->{IODev}->{VERSION}; ## Version
|
||||
|
||||
if(defined($hash->{IODev}->{NAME})) {
|
||||
Log3 $name, 4, "xs1Dev: $name - I/O device is " . $hash->{IODev}->{NAME};
|
||||
Log3 $name, 4, "xs1Dev: $name - I/O Device is " . $hash->{IODev}->{NAME};
|
||||
} else {
|
||||
Log3 $name, 3, "xs1Dev: $name - no I/O Device, Please delete and restart FHEM.";
|
||||
}
|
||||
|
||||
# GENERELL in FHEM auf LOG1 genommen von Rudi
|
||||
# else {
|
||||
# Log3 $name, 3, "xs1Dev: $name - no I/O device";
|
||||
# }
|
||||
#$iodev = $hash->{IODev}->{NAME};
|
||||
|
||||
# if(defined($hash->{IODev}->{xs1_ip})) { ## IP von xs1Bridge - Device aus HASH
|
||||
# $hash->{xs1_ip} = $hash->{IODev}->{xs1_ip};
|
||||
# }
|
||||
|
||||
return undef;
|
||||
}
|
||||
|
||||
@ -153,7 +158,7 @@ sub xs1Dev_Set ($$@)
|
||||
|
||||
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
|
||||
push (@xs1_function, $hash->{xs1_function1});
|
||||
push (@xs1_function, $hash->{xs1_function2});
|
||||
@ -265,6 +270,8 @@ sub xs1Dev_Set ($$@)
|
||||
if(defined($hash->{IODev}->{NAME})) {
|
||||
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");
|
||||
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);
|
||||
readingsSingleUpdate($hash, "state", $cmd , 1);
|
||||
}
|
||||
@ -302,12 +309,13 @@ sub xs1Dev_Parse($$) ## Input Data from 88_xs1Bridge
|
||||
$typ = "xs1Dev" if (!$def); ## Erstanlegung
|
||||
|
||||
###### 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) {
|
||||
# "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";
|
||||
return "UNDEFINED xs1Dev"."_".$xs1_readingsname."_"."$xs1_ID xs1Dev $xs1_typ1 $xs1_ID IODev=$IODev";
|
||||
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";
|
||||
} else {
|
||||
#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"; }
|
||||
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;
|
||||
@ -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>
|
||||
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.
|
||||
<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>
|
||||
<b>Define</b><br>
|
||||
@ -470,8 +515,6 @@ sub xs1Dev_Undef($$)
|
||||
xs1_name: defined name in the device<br>
|
||||
xs1_typ: defined type in the device<br>
|
||||
</ul><br>
|
||||
|
||||
<li>The following xs1 device types are already integrated: dimmer | shutter | switch | timerswitch</li>
|
||||
</ul>
|
||||
</ul>
|
||||
=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>
|
||||
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>
|
||||
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>
|
||||
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><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>
|
||||
<b>Define</b><br>
|
||||
@ -539,8 +587,6 @@ sub xs1Dev_Undef($$)
|
||||
xs1_name: definierter Name im Gerät<br>
|
||||
xs1_typ: definierter Typ im Gerät<br>
|
||||
</ul><br>
|
||||
|
||||
<li>Folgende xs1-Gerätetypen sind bereits integriert: dimmer | shutter | switch | timerswitch</li>
|
||||
</ul>
|
||||
|
||||
</ul>
|
||||
|
Loading…
x
Reference in New Issue
Block a user