22_HOMEMODE: v1.4.7 - minor bugfixes

git-svn-id: https://svn.fhem.de/fhem/trunk/fhem@18798 2b470e98-0d58-463d-a4d8-8e2adae1ed80
This commit is contained in:
deespe 2019-03-05 19:13:28 +00:00
parent 014d44d9aa
commit b2d8fb6d16
2 changed files with 28 additions and 21 deletions

View File

@ -1,5 +1,9 @@
# 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.
- bugfix: 22_HOMEMODE: - fix illegal division by zero in HOMEMODE_Luminance
- renamed attribute name HomeYahooWeatherDevice to
HomeWeatherDevic
- changed characteristic AirPressure UUID to name
- bugfix: 49_SSCam: no snapinfos when snap was done by SVS itself - bugfix: 49_SSCam: no snapinfos when snap was done by SVS itself
(Forum: #45671.msg914685.html#msg914685), minor fixes (Forum: #45671.msg914685.html#msg914685), minor fixes
- feature: 59_Weather: use demo data up to start then apikey equevalent demo - feature: 59_Weather: use demo data up to start then apikey equevalent demo

View File

@ -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.4.6"; my $HOMEMODE_version = "1.4.7";
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";
@ -39,6 +39,7 @@ sub HOMEMODE_Initialize($)
$hash->{NotifyOrderPrefix} = "51-"; $hash->{NotifyOrderPrefix} = "51-";
$hash->{FW_deviceOverview} = 1; $hash->{FW_deviceOverview} = 1;
$hash->{FW_addDetailToSummary} = 1; $hash->{FW_addDetailToSummary} = 1;
$hash->{AttrRenameMap} = { "HomeYahooWeatherDevice" => "HomeWeatherDevice" };
} }
sub HOMEMODE_Define($$) sub HOMEMODE_Define($$)
@ -185,7 +186,7 @@ sub HOMEMODE_Notify($$)
{ {
HOMEMODE_RESIDENTS($hash,$devname); HOMEMODE_RESIDENTS($hash,$devname);
} }
elsif (AttrVal($name,"HomeYahooWeatherDevice",undef) && $devname eq AttrVal($name,"HomeYahooWeatherDevice","")) elsif (AttrVal($name,"HomeWeatherDevice",undef) && $devname eq AttrVal($name,"HomeWeatherDevice",""))
{ {
HOMEMODE_Weather($hash,$devname); HOMEMODE_Weather($hash,$devname);
} }
@ -657,7 +658,7 @@ sub HOMEMODE_updateInternals($;$$)
} }
$hash->{SENSORSBATTERY} = join(",",sort @sensors) if (@sensors); $hash->{SENSORSBATTERY} = join(",",sort @sensors) if (@sensors);
} }
my $weather = HOMEMODE_AttrCheck($hash,"HomeYahooWeatherDevice"); my $weather = HOMEMODE_AttrCheck($hash,"HomeWeatherDevice");
push @allMonitoredDevices,$weather if ($weather && !grep /^$weather$/,@allMonitoredDevices); push @allMonitoredDevices,$weather if ($weather && !grep /^$weather$/,@allMonitoredDevices);
my $twilight = HOMEMODE_AttrCheck($hash,"HomeTwilightDevice"); my $twilight = HOMEMODE_AttrCheck($hash,"HomeTwilightDevice");
push @allMonitoredDevices,$twilight if ($twilight && !grep /^$twilight$/,@allMonitoredDevices); push @allMonitoredDevices,$twilight if ($twilight && !grep /^$twilight$/,@allMonitoredDevices);
@ -762,7 +763,7 @@ sub HOMEMODE_Get($@)
my $params = "mode:noArg modeAlarm:noArg publicIP:noArg devicesDisabled:noArg"; my $params = "mode:noArg modeAlarm:noArg publicIP:noArg devicesDisabled:noArg";
$params .= " contactsOpen:all,doorsinside,doorsoutside,doorsmain,outside,windows" if ($hash->{SENSORSCONTACT}); $params .= " contactsOpen:all,doorsinside,doorsoutside,doorsmain,outside,windows" if ($hash->{SENSORSCONTACT});
$params .= " sensorsTampered:noArg" if ($hash->{SENSORSCONTACT} || $hash->{SENSORSMOTION}); $params .= " sensorsTampered:noArg" if ($hash->{SENSORSCONTACT} || $hash->{SENSORSMOTION});
if (AttrVal($name,"HomeYahooWeatherDevice",undef)) if (AttrVal($name,"HomeWeatherDevice",undef))
{ {
if (AttrVal($name,"HomeTextWeatherLong",undef) || AttrVal($name,"HomeTextWeatherShort",undef)) if (AttrVal($name,"HomeTextWeatherLong",undef) || AttrVal($name,"HomeTextWeatherShort",undef))
{ {
@ -1426,7 +1427,7 @@ sub HOMEMODE_Attributes($)
push @attribs,"HomeTriggerPanic"; push @attribs,"HomeTriggerPanic";
push @attribs,"HomeTwilightDevice"; push @attribs,"HomeTwilightDevice";
push @attribs,"HomeUWZ"; push @attribs,"HomeUWZ";
push @attribs,"HomeYahooWeatherDevice"; push @attribs,"HomeWeatherDevice";
return join(" ",@attribs); return join(" ",@attribs);
} }
@ -1809,7 +1810,7 @@ sub HOMEMODE_Attr(@)
HOMEMODE_updateInternals($hash); HOMEMODE_updateInternals($hash);
} }
} }
elsif ($attr_name eq "HomeYahooWeatherDevice" && $init_done) elsif ($attr_name eq "HomeWeatherDevice" && $init_done)
{ {
$trans = $HOMEMODE_de? $trans = $HOMEMODE_de?
"$attr_value muss ein gültiges Gerät vom TYPE Weather sein!": "$attr_value muss ein gültiges Gerät vom TYPE Weather sein!":
@ -1834,7 +1835,7 @@ sub HOMEMODE_Attr(@)
CommandDeleteAttr(undef,"$name HomeSensorHumidityOutside") if (AttrVal($name,"HomeSensorHumidityOutside",undef) && $attr_value eq AttrVal($name,"HomeSensorHumidityOutside",undef)); CommandDeleteAttr(undef,"$name HomeSensorHumidityOutside") if (AttrVal($name,"HomeSensorHumidityOutside",undef) && $attr_value eq AttrVal($name,"HomeSensorHumidityOutside",undef));
if ($attr_value_old ne $attr_value) if ($attr_value_old ne $attr_value)
{ {
CommandDeleteReading(undef,"$name temperature") if (!AttrVal($name,"HomeYahooWeatherDevice",undef)); CommandDeleteReading(undef,"$name temperature") if (!AttrVal($name,"HomeWeatherDevice",undef));
HOMEMODE_updateInternals($hash); HOMEMODE_updateInternals($hash);
} }
} }
@ -1850,7 +1851,7 @@ sub HOMEMODE_Attr(@)
return $trans if (!HOMEMODE_CheckIfIsValidDevspec($attr_value,"humidity")); return $trans if (!HOMEMODE_CheckIfIsValidDevspec($attr_value,"humidity"));
if ($attr_value_old ne $attr_value) if ($attr_value_old ne $attr_value)
{ {
CommandDeleteReading(undef,"$name humidity") if (!AttrVal($name,"HomeYahooWeatherDevice",undef)); CommandDeleteReading(undef,"$name humidity") if (!AttrVal($name,"HomeWeatherDevice",undef));
HOMEMODE_updateInternals($hash); HOMEMODE_updateInternals($hash);
} }
} }
@ -2050,9 +2051,9 @@ sub HOMEMODE_Attr(@)
{ {
delete $hash->{".IP_TRIGGERTIME_NEXT"}; delete $hash->{".IP_TRIGGERTIME_NEXT"};
} }
elsif ($attr_name =~ /^(HomeYahooWeatherDevice|HomeTwilightDevice)$/) elsif ($attr_name =~ /^(HomeWeatherDevice|HomeTwilightDevice)$/)
{ {
if ($attr_name eq "HomeYahooWeatherDevice") if ($attr_name eq "HomeWeatherDevice")
{ {
CommandDeleteReading(undef,"$name pressure|condition|wind"); CommandDeleteReading(undef,"$name pressure|condition|wind");
CommandDeleteReading(undef,"$name temperature") if (!AttrVal($name,"HomeSensorTemperatureOutside",undef)); CommandDeleteReading(undef,"$name temperature") if (!AttrVal($name,"HomeSensorTemperatureOutside",undef));
@ -2066,8 +2067,8 @@ sub HOMEMODE_Attr(@)
} }
elsif ($attr_name =~ /^(HomeSensorTemperatureOutside|HomeSensorHumidityOutside)$/) elsif ($attr_name =~ /^(HomeSensorTemperatureOutside|HomeSensorHumidityOutside)$/)
{ {
CommandDeleteReading(undef,"$name .*temperature.*") if (!AttrVal($name,"HomeYahooWeatherDevice",undef) && $attr_name eq "HomeSensorTemperatureOutside"); CommandDeleteReading(undef,"$name .*temperature.*") if (!AttrVal($name,"HomeWeatherDevice",undef) && $attr_name eq "HomeSensorTemperatureOutside");
CommandDeleteReading(undef,"$name .*humidity.*") if (!AttrVal($name,"HomeYahooWeatherDevice",undef) && $attr_name eq "HomeSensorHumidityOutside"); CommandDeleteReading(undef,"$name .*humidity.*") if (!AttrVal($name,"HomeWeatherDevice",undef) && $attr_name eq "HomeSensorHumidityOutside");
HOMEMODE_updateInternals($hash); HOMEMODE_updateInternals($hash);
} }
elsif ($attr_name =~ /^(HomeDaytimes|HomeSeasons|HomeSpecialLocations|HomeSpecialModes)$/ && $init_done) elsif ($attr_name =~ /^(HomeDaytimes|HomeSeasons|HomeSpecialLocations|HomeSpecialModes)$/ && $init_done)
@ -2088,7 +2089,7 @@ sub HOMEMODE_replacePlaceholders($$;$)
{ {
my ($hash,$cmd,$resident) = @_; my ($hash,$cmd,$resident) = @_;
my $name = $hash->{NAME}; my $name = $hash->{NAME};
my $sensor = AttrVal($name,"HomeYahooWeatherDevice",""); my $sensor = AttrVal($name,"HomeWeatherDevice","");
$resident = $resident ? $resident : ReadingsVal($name,"lastActivityByResident",""); $resident = $resident ? $resident : ReadingsVal($name,"lastActivityByResident","");
my $alias = AttrVal($resident,"alias",""); my $alias = AttrVal($resident,"alias","");
my $audio = AttrVal($resident,"msgContactAudio",""); my $audio = AttrVal($resident,"msgContactAudio","");
@ -2347,7 +2348,7 @@ sub HOMEMODE_WeatherTXT($$)
{ {
my ($hash,$text) = @_; my ($hash,$text) = @_;
my $name = $hash->{NAME}; my $name = $hash->{NAME};
my $weather = AttrVal($name,"HomeYahooWeatherDevice",""); my $weather = AttrVal($name,"HomeWeatherDevice","");
my $condition = ReadingsVal($weather,"condition",""); my $condition = ReadingsVal($weather,"condition","");
my $conditionart = ReadingsVal($name,".be",""); my $conditionart = ReadingsVal($name,".be","");
my $pressure = ReadingsVal($name,"pressure",""); my $pressure = ReadingsVal($name,"pressure","");
@ -2372,7 +2373,7 @@ sub HOMEMODE_ForecastTXT($;$)
my ($hash,$day) = @_; my ($hash,$day) = @_;
$day = 2 if (!$day); $day = 2 if (!$day);
my $name = $hash->{NAME}; my $name = $hash->{NAME};
my $weather = AttrVal($name,"HomeYahooWeatherDevice",""); my $weather = AttrVal($name,"HomeWeatherDevice","");
my $cond = ReadingsVal($weather,"fc".$day."_condition",""); my $cond = ReadingsVal($weather,"fc".$day."_condition","");
my $low = ReadingsVal($weather,"fc".$day."_low_c",""); my $low = ReadingsVal($weather,"fc".$day."_low_c","");
my $high = ReadingsVal($weather,"fc".$day."_high_c",""); my $high = ReadingsVal($weather,"fc".$day."_high_c","");
@ -2658,6 +2659,7 @@ sub HOMEMODE_Luminance($;$$)
next unless ($val > 0); next unless ($val > 0);
$lum += $val if (!$dev || $dev ne $_); $lum += $val if (!$dev || $dev ne $_);
} }
return if (!scalar @sensorsa);
my $lumval = defined $lum ? int ($lum / scalar @sensorsa) : undef; my $lumval = defined $lum ? int ($lum / scalar @sensorsa) : undef;
if (defined $lumval && $lumval >= 0) if (defined $lumval && $lumval >= 0)
{ {
@ -3182,7 +3184,7 @@ sub HOMEMODE_HomebridgeMapping($)
$mapping .= "\nMotionDetected=motionsInside_ct,values=0:0;/.*/:1" if (HOMEMODE_ID($name,undef,"motionsInside_ct")); $mapping .= "\nMotionDetected=motionsInside_ct,values=0:0;/.*/:1" if (HOMEMODE_ID($name,undef,"motionsInside_ct"));
$mapping .= "\nStatusLowBattery=batteryLow_ct,values=0:0;/.*/:1" if (HOMEMODE_ID($name,undef,"batteryLow_ct")); $mapping .= "\nStatusLowBattery=batteryLow_ct,values=0:0;/.*/:1" if (HOMEMODE_ID($name,undef,"batteryLow_ct"));
$mapping .= "\nSmokeDetected=alarmSmoke_ct,values=0:0;/.*/:1" if (HOMEMODE_ID($name,undef,"alarmSmoke_ct")); $mapping .= "\nSmokeDetected=alarmSmoke_ct,values=0:0;/.*/:1" if (HOMEMODE_ID($name,undef,"alarmSmoke_ct"));
$mapping .= "\nE863F10F-079E-48FF-8F27-9C2605A29F52=pressure,name=AirPressure,format=UINT16" if (HOMEMODE_ID($name,undef,"wind")); $mapping .= "\nAirPressure=pressure" if (HOMEMODE_ID($name,undef,"pressure"));
addToDevAttrList($name,"genericDeviceType") if (!grep /^genericDeviceType/,split(" ",AttrVal("global","userattr",""))); addToDevAttrList($name,"genericDeviceType") if (!grep /^genericDeviceType/,split(" ",AttrVal("global","userattr","")));
addToDevAttrList($name,"homebridgeMapping:textField-long") if (!grep /^homebridgeMapping/,split(" ",AttrVal("global","userattr",""))); addToDevAttrList($name,"homebridgeMapping:textField-long") if (!grep /^homebridgeMapping/,split(" ",AttrVal("global","userattr","")));
CommandAttr(undef,"$name genericDeviceType security"); CommandAttr(undef,"$name genericDeviceType security");
@ -3486,7 +3488,9 @@ sub HOMEMODE_Details($$$)
$html .= "<style>.homehover{cursor:pointer}.homeinfo{display:none}.tar{text-align:right}.homeinfopanel{min-height:30px;max-width:480px;padding:3px 10px}</style>"; $html .= "<style>.homehover{cursor:pointer}.homeinfo{display:none}.tar{text-align:right}.homeinfopanel{min-height:30px;max-width:480px;padding:3px 10px}</style>";
$html .= "<div class=\"homeinfopanel\" informid=\"$name-$iid\">$info</div>"; $html .= "<div class=\"homeinfopanel\" informid=\"$name-$iid\">$info</div>";
$html .= "<table class=\"wide\">"; $html .= "<table class=\"wide\">";
if (AttrVal($name,"HomeYahooWeatherDevice","")) if (AttrVal($name,"HomeWeatherDevice","") ||
(AttrVal($name,"HomeSensorAirpressure","") && AttrVal($name,"HomeSensorHumidityOutside","") && AttrVal($name,"HomeSensorTemperatureOutside","")) ||
(AttrVal($name,"HomeSensorAirpressure","") && AttrVal($name,"HomeSensorTemperatureOutside","") && HOMEMODE_ID(AttrVal($name,"HomeSensorTemperatureOutside",""),undef,"humidity")))
{ {
$html .= "<tr class=\"homehover\">"; $html .= "<tr class=\"homehover\">";
my $temp = $HOMEMODE_de ? "Temperatur" : "Temperature"; my $temp = $HOMEMODE_de ? "Temperatur" : "Temperature";
@ -3523,8 +3527,7 @@ sub HOMEMODE_Details($$$)
my $tamp = $HOMEMODE_de ? "Sabotiert" : "Tampered"; my $tamp = $HOMEMODE_de ? "Sabotiert" : "Tampered";
$html .= "<td class=\"tar\">$tamp:</td>"; $html .= "<td class=\"tar\">$tamp:</td>";
$html .= "<td class=\"dval homehover\"><span informid=\"$name-sensorsTampered_ct\">".ReadingsVal($name,"sensorsTampered_ct","")."</span><span class=\"homeinfo\" informid=\"$name-sensorsTampered_hr\">".ReadingsVal($name,"sensorsTampered_hr","")."</span></td>"; $html .= "<td class=\"dval homehover\"><span informid=\"$name-sensorsTampered_ct\">".ReadingsVal($name,"sensorsTampered_ct","")."</span><span class=\"homeinfo\" informid=\"$name-sensorsTampered_hr\">".ReadingsVal($name,"sensorsTampered_hr","")."</span></td>";
my $alarms = $HOMEMODE_de ? "Alarme" : "Alarms"; $html .= "<td class=\"tar\">Alarm:</td>";
$html .= "<td class=\"tar\">$alarms:</td>";
$html .= "<td class=\"dval homehover\"><span informid=\"$name-alarmTriggered_ct\">".ReadingsVal($name,"alarmTriggered_ct","")."</span><span class=\"homeinfo\" informid=\"$name-alarmTriggered_hr\">".ReadingsVal($name,"alarmTriggered_hr","")."</span></td>"; $html .= "<td class=\"dval homehover\"><span informid=\"$name-alarmTriggered_ct\">".ReadingsVal($name,"alarmTriggered_ct","")."</span><span class=\"homeinfo\" informid=\"$name-alarmTriggered_hr\">".ReadingsVal($name,"alarmTriggered_hr","")."</span></td>";
$html .= "</tr>"; $html .= "</tr>";
} }
@ -4377,8 +4380,8 @@ sub HOMEMODE_Details($$$)
default: default:
</li> </li>
<li> <li>
<b><i>HomeYahooWeatherDevice</i></b><br> <b><i>HomeWeatherDevice</i></b><br>
your local yahoo weather device<br> your local weather device<br>
default: default:
</li> </li>
<li> <li>