mirror of
https://github.com/fhem/fhem-mirror.git
synced 2025-05-01 20:20:10 +00:00
20_X10: migrated to use readings functions
git-svn-id: https://svn.fhem.de/fhem/trunk/fhem@25094 2b470e98-0d58-463d-a4d8-8e2adae1ed80
This commit is contained in:
parent
9b37c0c80a
commit
3293037e30
@ -27,20 +27,20 @@
|
|||||||
|
|
||||||
#
|
#
|
||||||
# Internals introduced in this module:
|
# Internals introduced in this module:
|
||||||
# MODEL distinguish between different X10 device types
|
# MODEL distinguish between different X10 device types
|
||||||
# BRIGHT brightness level of dimmer devices in units of microdims (0..210)
|
# BRIGHT brightness level of dimmer devices in units of microdims (0..210)
|
||||||
#
|
#
|
||||||
# Readings introduced in this module:
|
# Readings introduced in this module:
|
||||||
# state function and argument of last command
|
# state function and argument of last command
|
||||||
# onoff inherited from switch interface (0= on, 1= off)
|
# onoff inherited from switch interface (0= on, 1= off)
|
||||||
# dimmer inherited from dimmer interface (0= dark, 100= bright)
|
# dimmer inherited from dimmer interface (0= dark, 100= bright)
|
||||||
#
|
#
|
||||||
# Setters introduced in this module:
|
# Setters introduced in this module:
|
||||||
# on inherited from switch interface
|
# on inherited from switch interface
|
||||||
# off inherited from switch interface
|
# off inherited from switch interface
|
||||||
# dimmer inherited from dimmer interface (0= dark, 100= bright)
|
# dimmer inherited from dimmer interface (0= dark, 100= bright)
|
||||||
# dimdown inherited from dimmer interface
|
# dimdown inherited from dimmer interface
|
||||||
# dimup inherited from dimmer interface
|
# dimup inherited from dimmer interface
|
||||||
#
|
#
|
||||||
|
|
||||||
package main;
|
package main;
|
||||||
@ -93,9 +93,9 @@ my %functions_set = ( "on" => 0,
|
|||||||
"off" => 0,
|
"off" => 0,
|
||||||
"dimup" => 1,
|
"dimup" => 1,
|
||||||
"dimdown" => 1,
|
"dimdown" => 1,
|
||||||
"dimto" => 1,
|
"dimto" => 1,
|
||||||
"on-till" => 1,
|
"on-till" => 1,
|
||||||
"on-for-timer" => 1,
|
"on-for-timer" => 1,
|
||||||
"all_units_off" => 0,
|
"all_units_off" => 0,
|
||||||
"all_units_on" => 0,
|
"all_units_on" => 0,
|
||||||
"all_lights_off" => 0,
|
"all_lights_off" => 0,
|
||||||
@ -103,7 +103,7 @@ my %functions_set = ( "on" => 0,
|
|||||||
);
|
);
|
||||||
|
|
||||||
my %models = (
|
my %models = (
|
||||||
lm12 => 'dimmer',
|
lm12 => 'dimmer',
|
||||||
lm15 => 'switch',
|
lm15 => 'switch',
|
||||||
am12 => 'switch',
|
am12 => 'switch',
|
||||||
tm13 => 'switch',
|
tm13 => 'switch',
|
||||||
@ -135,7 +135,8 @@ X10_Initialize($)
|
|||||||
$hash->{UndefFn} = "X10_Undef";
|
$hash->{UndefFn} = "X10_Undef";
|
||||||
$hash->{ParseFn} = "X10_Parse";
|
$hash->{ParseFn} = "X10_Parse";
|
||||||
$hash->{AttrList} = "IODev do_not_notify:1,0 " .
|
$hash->{AttrList} = "IODev do_not_notify:1,0 " .
|
||||||
"dummy:1,0 showtime:1,0 model:lm12,lm15,am12,tm13";
|
"dummy:1,0 showtime:1,0 model:lm12,lm15,am12,tm13 " .
|
||||||
|
$readingFnAttributes;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -208,10 +209,15 @@ X10_StateMachine($$$$)
|
|||||||
|
|
||||||
$hash->{ONOFF}= $onoff;
|
$hash->{ONOFF}= $onoff;
|
||||||
$hash->{BRIGHT}= $bright;
|
$hash->{BRIGHT}= $bright;
|
||||||
$hash->{READINGS}{onoff}{TIME}= $time;
|
#$hash->{READINGS}{onoff}{TIME}= $time;
|
||||||
$hash->{READINGS}{onoff}{VAL}= $onoff;
|
#$hash->{READINGS}{onoff}{VAL}= $onoff;
|
||||||
$hash->{READINGS}{dimmer}{TIME}= $time;
|
readingsBeginUpdate($hash);
|
||||||
$hash->{READINGS}{dimmer}{VAL}= int(1000.0*$bright/210.0+0.5)/10.0;
|
readingsBulkUpdate($hash,'onoff',$onoff,1,$time);
|
||||||
|
#$hash->{READINGS}{dimmer}{TIME}= $time;
|
||||||
|
#$hash->{READINGS}{dimmer}{VAL}= int(1000.0*$bright/210.0+0.5)/10.0;
|
||||||
|
readingsBulkUpdate($hash,'dimmer',int(1000.0*$bright/210.0+0.5)/10.0,1,$time);
|
||||||
|
readingsEndUpdate($hash,1);
|
||||||
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
#############################
|
#############################
|
||||||
@ -353,11 +359,11 @@ X10_Set($@)
|
|||||||
if(defined($hash->{BRIGHT})) { $bright= $hash->{BRIGHT} };
|
if(defined($hash->{BRIGHT})) { $bright= $hash->{BRIGHT} };
|
||||||
$arg= $arg-100.0*$bright/210.0;
|
$arg= $arg-100.0*$bright/210.0;
|
||||||
if($arg> 0) {
|
if($arg> 0) {
|
||||||
$function= "dimup";
|
$function= "dimup";
|
||||||
$dim= X10_LevelToDims($arg);
|
$dim= X10_LevelToDims($arg);
|
||||||
} else {
|
} else {
|
||||||
$function= "dimdown";
|
$function= "dimdown";
|
||||||
$dim= X10_LevelToDims(-$arg);
|
$dim= X10_LevelToDims(-$arg);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
$dim= X10_LevelToDims($arg);
|
$dim= X10_LevelToDims($arg);
|
||||||
@ -379,9 +385,10 @@ X10_Set($@)
|
|||||||
my $tn = TimeNow();
|
my $tn = TimeNow();
|
||||||
|
|
||||||
$hash->{CHANGED}[0] = $v;
|
$hash->{CHANGED}[0] = $v;
|
||||||
$hash->{STATE} = $v;
|
#$hash->{STATE} = $v;
|
||||||
$hash->{READINGS}{state}{TIME} = $tn;
|
#$hash->{READINGS}{state}{TIME} = $tn;
|
||||||
$hash->{READINGS}{state}{VAL} = $v;
|
#$hash->{READINGS}{state}{VAL} = $v;
|
||||||
|
readingsSingleUpdate($hash,'state',$v,1,$tn);
|
||||||
X10_StateMachine($hash, $tn, $function, int(210.0*$dim/22.0+0.5));
|
X10_StateMachine($hash, $tn, $function, int(210.0*$dim/22.0+0.5));
|
||||||
|
|
||||||
return undef;
|
return undef;
|
||||||
@ -405,12 +412,12 @@ X10_Define($$)
|
|||||||
my $housecode = $a[3];
|
my $housecode = $a[3];
|
||||||
return "Define $a[0]: wrong housecode format: specify a value ".
|
return "Define $a[0]: wrong housecode format: specify a value ".
|
||||||
"from A to P"
|
"from A to P"
|
||||||
if($housecode !~ m/^[A-P]$/i);
|
if($housecode !~ m/^[A-P]$/i);
|
||||||
|
|
||||||
my $unitcode = $a[4];
|
my $unitcode = $a[4];
|
||||||
return "Define $a[0]: wrong unitcode format: specify a value " .
|
return "Define $a[0]: wrong unitcode format: specify a value " .
|
||||||
"from 1 to 16"
|
"from 1 to 16"
|
||||||
if( ($unitcode<1) || ($unitcode>16) );
|
if( ($unitcode<1) || ($unitcode>16) );
|
||||||
|
|
||||||
|
|
||||||
$hash->{MODEL} = $model;
|
$hash->{MODEL} = $model;
|
||||||
@ -515,10 +522,11 @@ X10_Parse($$)
|
|||||||
if($h) {
|
if($h) {
|
||||||
my $name= $h->{NAME};
|
my $name= $h->{NAME};
|
||||||
$h->{CHANGED}[0] = $value;
|
$h->{CHANGED}[0] = $value;
|
||||||
$h->{STATE} = $value;
|
#$h->{STATE} = $value;
|
||||||
$h->{READINGS}{state}{TIME} = $tn;
|
#$h->{READINGS}{state}{TIME} = $tn;
|
||||||
$h->{READINGS}{state}{VAL} = $value;
|
#$h->{READINGS}{state}{VAL} = $value;
|
||||||
X10_StateMachine($h, $tn, $function, $arg);
|
readingsSingleUpdate($h,'state',$value,1,$tn);
|
||||||
|
X10_StateMachine($h, $tn, $function, $arg);
|
||||||
Log3 $hash, 2, "X10 $name $value";
|
Log3 $hash, 2, "X10 $name $value";
|
||||||
push(@list, $name);
|
push(@list, $name);
|
||||||
} else {
|
} else {
|
||||||
@ -535,15 +543,17 @@ X10_Parse($$)
|
|||||||
|
|
||||||
1;
|
1;
|
||||||
|
|
||||||
|
__END__
|
||||||
|
|
||||||
=pod
|
=pod
|
||||||
=item summary devices communicating via the X10 protocol
|
=item summary devices communicating via the X10 protocol
|
||||||
=item summary_DE Anbindung von X10-Geräten
|
=item summary_DE Anbindung von X10-Geräten
|
||||||
=begin html
|
=begin html
|
||||||
|
|
||||||
<a name="X10"></a>
|
<a id="X10"></a>
|
||||||
<h3>X10</h3>
|
<h3>X10</h3>
|
||||||
<ul>
|
<ul>
|
||||||
<a name="X10define"></a>
|
<a id="X10-define"></a>
|
||||||
<b>Define</b>
|
<b>Define</b>
|
||||||
<ul>
|
<ul>
|
||||||
<code>define <name> X10 <model> <housecode>
|
<code>define <name> X10 <model> <housecode>
|
||||||
@ -578,7 +588,7 @@ X10_Parse($$)
|
|||||||
</ul>
|
</ul>
|
||||||
<br>
|
<br>
|
||||||
|
|
||||||
<a name="X10set"></a>
|
<a id="X10-set"></a>
|
||||||
<b>Set </b>
|
<b>Set </b>
|
||||||
<ul>
|
<ul>
|
||||||
<code>set <name> <value> [<argument>]</code>
|
<code>set <name> <value> [<argument>]</code>
|
||||||
@ -610,6 +620,7 @@ X10_Parse($$)
|
|||||||
<li>An X10 device has 210 discrete brightness levels. If you use a
|
<li>An X10 device has 210 discrete brightness levels. If you use a
|
||||||
X10 sender, e.g. a remote control or a wall switch to dim, a
|
X10 sender, e.g. a remote control or a wall switch to dim, a
|
||||||
brightness step is 100%/210.</li>
|
brightness step is 100%/210.</li>
|
||||||
|
<a id="X10-set-dimup" data-pattern="dim(up|down)"></a>
|
||||||
<li><code>dimdown</code> and <code>dimup</code> take a number in the
|
<li><code>dimdown</code> and <code>dimup</code> take a number in the
|
||||||
range from 0 to 22 as argument. It is assumed that argument 1 is
|
range from 0 to 22 as argument. It is assumed that argument 1 is
|
||||||
a 1% brightness change (microdim) and arguments 2 to 22 are
|
a 1% brightness change (microdim) and arguments 2 to 22 are
|
||||||
@ -637,10 +648,10 @@ X10_Parse($$)
|
|||||||
</ul>
|
</ul>
|
||||||
<br>
|
<br>
|
||||||
|
|
||||||
<a name="X10get"></a>
|
<a id="X10-get"></a>
|
||||||
<b>Get</b> <ul>N/A</ul><br>
|
<b>Get</b> <ul>N/A</ul><br>
|
||||||
|
|
||||||
<a name="X10attr"></a>
|
<a id="X10-attr"></a>
|
||||||
<b>Attributes</b>
|
<b>Attributes</b>
|
||||||
<ul>
|
<ul>
|
||||||
<li><a href="#do_not_notify">do_not_notify</a></li>
|
<li><a href="#do_not_notify">do_not_notify</a></li>
|
||||||
|
Loading…
x
Reference in New Issue
Block a user