mirror of
https://github.com/fhem/fhem-mirror.git
synced 2025-01-31 06:39:11 +00:00
22_HOMEMODE: v1.5.1 - fixed batteryLow readings creation while adding sensors to HomeSensorsBattery, added attributes HomeCMDbattery and HomeCMDbatteryNormal, added new reading lastBatteryNormal, added new placeholder %BATTERYNORMAL%
git-svn-id: https://svn.fhem.de/fhem/trunk@20333 2b470e98-0d58-463d-a4d8-8e2adae1ed80
This commit is contained in:
parent
b9dd959d44
commit
f13f6bd0dd
@ -1,5 +1,10 @@
|
|||||||
# 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: 22_HOMEMODE: added attribs HomeCMDbattery & HomeCMDbatteryNormal
|
||||||
|
added new reading lastBatteryNormal
|
||||||
|
added new placeholder %BATTERYNORMAL%
|
||||||
|
- bugfix: 22_HOMEMODE: fixed batteryLow readings creation while adding
|
||||||
|
sensors to HomeSensorsBattery
|
||||||
- change: 93_DbLog: enhanced configCheck, minor fix warning
|
- change: 93_DbLog: enhanced configCheck, minor fix warning
|
||||||
- feature: 93_DbRep: seqDoubletsVariance - separate specification of positive
|
- feature: 93_DbRep: seqDoubletsVariance - separate specification of positive
|
||||||
and negative variance possible,
|
and negative variance possible,
|
||||||
|
@ -16,7 +16,7 @@ use Time::HiRes qw(gettimeofday);
|
|||||||
use HttpUtils;
|
use HttpUtils;
|
||||||
use vars qw{%attr %defs %modules $FW_CSRF};
|
use vars qw{%attr %defs %modules $FW_CSRF};
|
||||||
|
|
||||||
my $HOMEMODE_version = "1.5.0";
|
my $HOMEMODE_version = "1.5.1";
|
||||||
my $HOMEMODE_Daytimes = "05:00|morning 10:00|day 14:00|afternoon 18:00|evening 23:00|night";
|
my $HOMEMODE_Daytimes = "05:00|morning 10:00|day 14:00|afternoon 18:00|evening 23:00|night";
|
||||||
my $HOMEMODE_Seasons = "03.01|spring 06.01|summer 09.01|autumn 12.01|winter";
|
my $HOMEMODE_Seasons = "03.01|spring 06.01|summer 09.01|autumn 12.01|winter";
|
||||||
my $HOMEMODE_UserModes = "gotosleep,awoken,asleep";
|
my $HOMEMODE_UserModes = "gotosleep,awoken,asleep";
|
||||||
@ -464,7 +464,6 @@ sub HOMEMODE_Notify($$)
|
|||||||
readingsBulkUpdateIfChanged($hash,"batteryLow_ct",scalar @low);
|
readingsBulkUpdateIfChanged($hash,"batteryLow_ct",scalar @low);
|
||||||
readingsBulkUpdateIfChanged($hash,"batteryLow_hr",HOMEMODE_makeHR($hash,1,@low));
|
readingsBulkUpdateIfChanged($hash,"batteryLow_hr",HOMEMODE_makeHR($hash,1,@low));
|
||||||
readingsBulkUpdateIfChanged($hash,"lastBatteryLow",$devname) if (grep(/^$devname$/,@low) && !grep(/^$devname$/,@lowOld));
|
readingsBulkUpdateIfChanged($hash,"lastBatteryLow",$devname) if (grep(/^$devname$/,@low) && !grep(/^$devname$/,@lowOld));
|
||||||
push @commands,AttrVal($name,"HomeCMDbatteryLow","") if (AttrVal($name,"HomeCMDbatteryLow",undef) && grep(/^$devname$/,@low) && !grep(/^$devname$/,@lowOld));
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
@ -472,7 +471,11 @@ sub HOMEMODE_Notify($$)
|
|||||||
readingsBulkUpdateIfChanged($hash,"batteryLow_ct",scalar @low);
|
readingsBulkUpdateIfChanged($hash,"batteryLow_ct",scalar @low);
|
||||||
readingsBulkUpdateIfChanged($hash,"batteryLow_hr","");
|
readingsBulkUpdateIfChanged($hash,"batteryLow_hr","");
|
||||||
}
|
}
|
||||||
|
readingsBulkUpdateIfChanged($hash,"lastBatteryNormal",$devname) if (!grep(/^$devname$/,@low) && grep(/^$devname$/,@lowOld));
|
||||||
readingsEndUpdate($hash,1);
|
readingsEndUpdate($hash,1);
|
||||||
|
push @commands,AttrVal($name,"HomeCMDbattery","") if (AttrVal($name,"HomeCMDbattery",undef) && (grep(/^$devname$/,@low) || grep(/^$devname$/,@lowOld)));
|
||||||
|
push @commands,AttrVal($name,"HomeCMDbatteryLow","") if (AttrVal($name,"HomeCMDbatteryLow",undef) && grep(/^$devname$/,@low) && !grep(/^$devname$/,@lowOld));
|
||||||
|
push @commands,AttrVal($name,"HomeCMDbatteryNormal","") if (AttrVal($name,"HomeCMDbatteryNormal",undef) && !grep(/^$devname$/,@low) && grep(/^$devname$/,@lowOld));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -656,8 +659,13 @@ sub HOMEMODE_updateInternals($;$$)
|
|||||||
next unless (defined $val && $val =~ /^(ok|low|nok|\d{1,3})(%|\s%)?$/);
|
next unless (defined $val && $val =~ /^(ok|low|nok|\d{1,3})(%|\s%)?$/);
|
||||||
push @sensors,$s;
|
push @sensors,$s;
|
||||||
push @allMonitoredDevices,$s if (!grep /^$s$/,@allMonitoredDevices);
|
push @allMonitoredDevices,$s if (!grep /^$s$/,@allMonitoredDevices);
|
||||||
|
$hash->{SENSORSBATTERY} = join(",",sort @sensors) if (@sensors);
|
||||||
|
if (!grep(/^$s$/,split(/,/,ReadingsVal($name,"batteryLow",""))))
|
||||||
|
{
|
||||||
|
CommandTrigger(undef,"$s $read: ok");
|
||||||
|
CommandTrigger(undef,"$s $read: $val");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
$hash->{SENSORSBATTERY} = join(",",sort @sensors) if (@sensors);
|
|
||||||
}
|
}
|
||||||
my $weather = HOMEMODE_AttrCheck($hash,"HomeWeatherDevice");
|
my $weather = HOMEMODE_AttrCheck($hash,"HomeWeatherDevice");
|
||||||
push @allMonitoredDevices,$weather if ($weather && !grep /^$weather$/,@allMonitoredDevices);
|
push @allMonitoredDevices,$weather if ($weather && !grep /^$weather$/,@allMonitoredDevices);
|
||||||
@ -1324,7 +1332,9 @@ sub HOMEMODE_Attributes($)
|
|||||||
push @attribs,"HomeCMDanyoneElseAtHome:textField-long";
|
push @attribs,"HomeCMDanyoneElseAtHome:textField-long";
|
||||||
push @attribs,"HomeCMDanyoneElseAtHome-on:textField-long";
|
push @attribs,"HomeCMDanyoneElseAtHome-on:textField-long";
|
||||||
push @attribs,"HomeCMDanyoneElseAtHome-off:textField-long";
|
push @attribs,"HomeCMDanyoneElseAtHome-off:textField-long";
|
||||||
|
push @attribs,"HomeCMDbattery:textField-long";
|
||||||
push @attribs,"HomeCMDbatteryLow:textField-long";
|
push @attribs,"HomeCMDbatteryLow:textField-long";
|
||||||
|
push @attribs,"HomeCMDbatteryNormal:textField-long";
|
||||||
push @attribs,"HomeCMDcontact:textField-long";
|
push @attribs,"HomeCMDcontact:textField-long";
|
||||||
push @attribs,"HomeCMDcontactClosed:textField-long";
|
push @attribs,"HomeCMDcontactClosed:textField-long";
|
||||||
push @attribs,"HomeCMDcontactOpen:textField-long";
|
push @attribs,"HomeCMDcontactOpen:textField-long";
|
||||||
@ -2056,7 +2066,7 @@ sub HOMEMODE_Attr(@)
|
|||||||
elsif ($attr_name =~ /^(HomeAdvancedUserAttr|HomeAutoPresence|HomePresenceDeviceType|HomeEvents(Holiday|Calendar)Devices|HomeSensorAirpressure|HomeSensorWindspeed|HomeSensorsBattery|HomeSensorsBatteryReading)$/)
|
elsif ($attr_name =~ /^(HomeAdvancedUserAttr|HomeAutoPresence|HomePresenceDeviceType|HomeEvents(Holiday|Calendar)Devices|HomeSensorAirpressure|HomeSensorWindspeed|HomeSensorsBattery|HomeSensorsBatteryReading)$/)
|
||||||
{
|
{
|
||||||
CommandDeleteReading(undef,"$name event-.+") if ($attr_name =~ /^HomeEvents(Holiday|Calendar)Devices$/);
|
CommandDeleteReading(undef,"$name event-.+") if ($attr_name =~ /^HomeEvents(Holiday|Calendar)Devices$/);
|
||||||
CommandDeleteReading(undef,"$name battery.*") if ($attr_name eq "HomeSensorsBattery");
|
CommandDeleteReading(undef,"$name battery.*|lastBatteryLow") if ($attr_name eq "HomeSensorsBattery");
|
||||||
HOMEMODE_updateInternals($hash,1);
|
HOMEMODE_updateInternals($hash,1);
|
||||||
}
|
}
|
||||||
elsif ($attr_name =~ /^(HomeSensorsContact|HomeSensorsMotion)$/)
|
elsif ($attr_name =~ /^(HomeSensorsContact|HomeSensorsMotion)$/)
|
||||||
@ -2190,6 +2200,7 @@ sub HOMEMODE_replacePlaceholders($$;$)
|
|||||||
my $uwzs = HOMEMODE_uwzTXT($hash,$uwzc,undef);
|
my $uwzs = HOMEMODE_uwzTXT($hash,$uwzc,undef);
|
||||||
my $uwzl = HOMEMODE_uwzTXT($hash,$uwzc,1);
|
my $uwzl = HOMEMODE_uwzTXT($hash,$uwzc,1);
|
||||||
my $lowBat = HOMEMODE_name2alias(ReadingsVal($name,"lastBatteryLow",""));
|
my $lowBat = HOMEMODE_name2alias(ReadingsVal($name,"lastBatteryLow",""));
|
||||||
|
my $normBat = HOMEMODE_name2alias(ReadingsVal($name,"lastBatteryNormal",""));
|
||||||
my $lowBatAll = ReadingsVal($name,"batteryLow_hr","");
|
my $lowBatAll = ReadingsVal($name,"batteryLow_hr","");
|
||||||
my $lowBatCount = ReadingsVal($name,"batteryLow_ct",0);
|
my $lowBatCount = ReadingsVal($name,"batteryLow_ct",0);
|
||||||
my $disabled = ReadingsVal($name,"devicesDisabled","");
|
my $disabled = ReadingsVal($name,"devicesDisabled","");
|
||||||
@ -2210,6 +2221,7 @@ sub HOMEMODE_replacePlaceholders($$;$)
|
|||||||
$cmd =~ s/%AEAH%/$aeah/g;
|
$cmd =~ s/%AEAH%/$aeah/g;
|
||||||
$cmd =~ s/%ARRIVERS%/$arrivers/g;
|
$cmd =~ s/%ARRIVERS%/$arrivers/g;
|
||||||
$cmd =~ s/%AUDIO%/$audio/g;
|
$cmd =~ s/%AUDIO%/$audio/g;
|
||||||
|
$cmd =~ s/%BATTERYNORMAL%/$normBat/g;
|
||||||
$cmd =~ s/%BATTERYLOW%/$lowBat/g;
|
$cmd =~ s/%BATTERYLOW%/$lowBat/g;
|
||||||
$cmd =~ s/%BATTERYLOWALL%/$lowBatAll/g;
|
$cmd =~ s/%BATTERYLOWALL%/$lowBatAll/g;
|
||||||
$cmd =~ s/%BATTERYLOWCT%/$lowBatCount/g;
|
$cmd =~ s/%BATTERYLOWCT%/$lowBatCount/g;
|
||||||
@ -3867,10 +3879,18 @@ sub HOMEMODE_Details($$$)
|
|||||||
<b><i>HomeCMDcontact</i></b><br>
|
<b><i>HomeCMDcontact</i></b><br>
|
||||||
cmds to execute if any contact has been triggered (open/tilted/closed)
|
cmds to execute if any contact has been triggered (open/tilted/closed)
|
||||||
</li>
|
</li>
|
||||||
|
<li>
|
||||||
|
<b><i>HomeCMDbattery</i></b><br>
|
||||||
|
cmds to execute on any battery change of a battery sensor
|
||||||
|
</li>
|
||||||
<li>
|
<li>
|
||||||
<b><i>HomeCMDbatteryLow</i></b><br>
|
<b><i>HomeCMDbatteryLow</i></b><br>
|
||||||
cmds to execute if any battery sensor has low battery
|
cmds to execute if any battery sensor has low battery
|
||||||
</li>
|
</li>
|
||||||
|
<li>
|
||||||
|
<b><i>HomeCMDbatteryNormal</i></b><br>
|
||||||
|
cmds to execute if any battery sensor returns to normal battery
|
||||||
|
</li>
|
||||||
<li>
|
<li>
|
||||||
<b><i>HomeCMDcontactClosed</i></b><br>
|
<b><i>HomeCMDcontactClosed</i></b><br>
|
||||||
cmds to execute if any contact has been closed
|
cmds to execute if any contact has been closed
|
||||||
@ -4634,6 +4654,10 @@ sub HOMEMODE_Details($$$)
|
|||||||
<b><i>lastAwokenByResident</i></b><br>
|
<b><i>lastAwokenByResident</i></b><br>
|
||||||
last resident who went awoken
|
last resident who went awoken
|
||||||
</li>
|
</li>
|
||||||
|
<li>
|
||||||
|
<b><i>lastBatteryNormal</i></b><br>
|
||||||
|
last sensor with normal battery
|
||||||
|
</li>
|
||||||
<li>
|
<li>
|
||||||
<b><i>lastBatteryLow</i></b><br>
|
<b><i>lastBatteryLow</i></b><br>
|
||||||
last sensor with low battery
|
last sensor with low battery
|
||||||
@ -4901,6 +4925,10 @@ sub HOMEMODE_Details($$$)
|
|||||||
<b><i>%BATTERYLOWCT%</i></b><br>
|
<b><i>%BATTERYLOWCT%</i></b><br>
|
||||||
number of battery sensors which reported low battery currently
|
number of battery sensors which reported low battery currently
|
||||||
</li>
|
</li>
|
||||||
|
<li>
|
||||||
|
<b><i>%BATTERYNORMAL%</i></b><br>
|
||||||
|
alias (or name if alias is not set) of the last battery sensor which reported normal battery
|
||||||
|
</li>
|
||||||
<li>
|
<li>
|
||||||
<b><i>%CONDITION%</i></b><br>
|
<b><i>%CONDITION%</i></b><br>
|
||||||
value of the condition reading of monitored Weather device<br>
|
value of the condition reading of monitored Weather device<br>
|
||||||
|
Loading…
Reference in New Issue
Block a user