mirror of
https://github.com/fhem/fhem-mirror.git
synced 2025-05-04 22:19:38 +00:00
30_HUEBridge.pm: enable autocreation of sensor devices
git-svn-id: https://svn.fhem.de/fhem/trunk/fhem@24296 2b470e98-0d58-463d-a4d8-8e2adae1ed80
This commit is contained in:
parent
381dc8322f
commit
75fcde59ca
1
CHANGED
1
CHANGED
@ -1,5 +1,6 @@
|
|||||||
# Add changes at the top of the list. Keep it in ASCII, and 80-char wide.
|
# 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.
|
# Do not insert empty lines here, update check depends on it.
|
||||||
|
- feature: 30_HUEBridge: enable autocreation of sensors for deconz
|
||||||
- new: lib/FHEM/Core/Password/Utils.pm: new modul for developer to save
|
- new: lib/FHEM/Core/Password/Utils.pm: new modul for developer to save
|
||||||
passwords or passphrase in fhem keystore
|
passwords or passphrase in fhem keystore
|
||||||
- bugfix: 98_WeekdayTimer: don't enable disabled WDT in group par. setting
|
- bugfix: 98_WeekdayTimer: don't enable disabled WDT in group par. setting
|
||||||
|
@ -646,9 +646,9 @@ HUEBridge_Set($@)
|
|||||||
return "starting update";
|
return "starting update";
|
||||||
|
|
||||||
} elsif($cmd eq 'autocreate') {
|
} elsif($cmd eq 'autocreate') {
|
||||||
return "usage: autocreate" if( @args != 0 );
|
return "usage: autocreate [sensors]" if( $arg && $arg ne 'sensors' );
|
||||||
|
|
||||||
return HUEBridge_Autocreate($hash,1);
|
return HUEBridge_Autocreate($hash,1,$arg);
|
||||||
|
|
||||||
} elsif($cmd eq 'autodetect') {
|
} elsif($cmd eq 'autodetect') {
|
||||||
return "usage: autodetect" if( @args != 0 );
|
return "usage: autodetect" if( @args != 0 );
|
||||||
@ -1514,9 +1514,9 @@ HUEBridge_Parse($$)
|
|||||||
}
|
}
|
||||||
|
|
||||||
sub
|
sub
|
||||||
HUEBridge_Autocreate($;$)
|
HUEBridge_Autocreate($;$$)
|
||||||
{
|
{
|
||||||
my ($hash,$force)= @_;
|
my ($hash,$force,$sensors)= @_;
|
||||||
my $name = $hash->{NAME};
|
my $name = $hash->{NAME};
|
||||||
|
|
||||||
if( !$force ) {
|
if( !$force ) {
|
||||||
@ -1578,7 +1578,7 @@ HUEBridge_Autocreate($;$)
|
|||||||
|
|
||||||
my $cmdret= CommandDefine(undef,$define);
|
my $cmdret= CommandDefine(undef,$define);
|
||||||
if($cmdret) {
|
if($cmdret) {
|
||||||
Log3 $name, 1, "$name: Autocreate: An error occurred while creating device for id '$id': $cmdret";
|
Log3 $name, 1, "$name: Autocreate: An error occurred while creating group for id '$id': $cmdret";
|
||||||
} else {
|
} else {
|
||||||
$cmdret= CommandAttr(undef,"$devname alias ".$result->{$id}{name});
|
$cmdret= CommandAttr(undef,"$devname alias ".$result->{$id}{name});
|
||||||
$cmdret= CommandAttr(undef,"$devname room HUEDevice");
|
$cmdret= CommandAttr(undef,"$devname room HUEDevice");
|
||||||
@ -1592,6 +1592,40 @@ HUEBridge_Autocreate($;$)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if( $sensors || $hash->{websocket} ) {
|
||||||
|
$result = HUEBridge_Call($hash,undef, 'sensors', undef);
|
||||||
|
foreach my $key ( keys %{$result} ) {
|
||||||
|
my $id= $key;
|
||||||
|
|
||||||
|
my $code = $name ."-S". $id;
|
||||||
|
if( defined($modules{HUEDevice}{defptr}{$code}) ) {
|
||||||
|
Log3 $name, 5, "$name: id '$id' already defined as '$modules{HUEDevice}{defptr}{$code}->{NAME}'";
|
||||||
|
next;
|
||||||
|
}
|
||||||
|
|
||||||
|
my $devname= "HUESensor" . $id;
|
||||||
|
$devname = $name ."_". $devname if( $hash->{helper}{count} );
|
||||||
|
my $define= "$devname HUEDevice sensor $id IODev=$name";
|
||||||
|
|
||||||
|
Log3 $name, 4, "$name: create new sensor '$devname' for address '$id'";
|
||||||
|
|
||||||
|
my $cmdret= CommandDefine(undef,$define);
|
||||||
|
if($cmdret) {
|
||||||
|
Log3 $name, 1, "$name: Autocreate: An error occurred while creating sensor for id '$id': $cmdret";
|
||||||
|
} else {
|
||||||
|
$cmdret= CommandAttr(undef,"$devname alias ".$result->{$id}{name});
|
||||||
|
$cmdret= CommandAttr(undef,"$devname room HUEDevice");
|
||||||
|
$cmdret= CommandAttr(undef,"$devname group HUESensor");
|
||||||
|
$cmdret= CommandAttr(undef,"$devname IODev $name");
|
||||||
|
|
||||||
|
HUEDeviceSetIcon($devname);
|
||||||
|
$defs{$devname}{helper}{fromAutocreate} = 1 ;
|
||||||
|
|
||||||
|
$autocreated++;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if( $autocreated ) {
|
if( $autocreated ) {
|
||||||
Log3 $name, 2, "$name: autocreated $autocreated devices";
|
Log3 $name, 2, "$name: autocreated $autocreated devices";
|
||||||
CommandSave(undef,undef) if( AttrVal( "autocreate", "autosave", 1 ) );
|
CommandSave(undef,undef) if( AttrVal( "autocreate", "autosave", 1 ) );
|
||||||
@ -2177,7 +2211,7 @@ HUEBridge_Attr($$$)
|
|||||||
The actual hue bulbs, living colors or living whites devices are defined as <a href="#HUEDevice">HUEDevice</a> devices.
|
The actual hue bulbs, living colors or living whites devices are defined as <a href="#HUEDevice">HUEDevice</a> devices.
|
||||||
|
|
||||||
<br><br>
|
<br><br>
|
||||||
All newly found devices and groups are autocreated at startup and added to the room HUEDevice.
|
All newly found lights and groups are autocreated at startup and added to the room HUEDevice.
|
||||||
|
|
||||||
<br><br>
|
<br><br>
|
||||||
Notes:
|
Notes:
|
||||||
@ -2234,8 +2268,8 @@ HUEBridge_Attr($$$)
|
|||||||
<a name="HUEBridge_Set"></a>
|
<a name="HUEBridge_Set"></a>
|
||||||
<b>Set</b>
|
<b>Set</b>
|
||||||
<ul>
|
<ul>
|
||||||
<li>autocreate<br>
|
<li>autocreate [sensors]<br>
|
||||||
Create fhem devices for all bridge devices.</li>
|
Create fhem devices for all light and group devices. sensors are autocreated only if sensors parameter is given.</li>
|
||||||
<li>autodetect<br>
|
<li>autodetect<br>
|
||||||
Initiate the detection of new ZigBee devices. After aproximately one minute any newly detected
|
Initiate the detection of new ZigBee devices. After aproximately one minute any newly detected
|
||||||
devices can be listed with <code>get <bridge> devices</code> and the corresponding fhem devices
|
devices can be listed with <code>get <bridge> devices</code> and the corresponding fhem devices
|
||||||
|
Loading…
x
Reference in New Issue
Block a user