Geolocation Status added to Readings

thx to Andreas Krause <Andreas@die4krauses.net>
This commit is contained in:
Philipp Wo 2019-12-09 21:15:44 +01:00
parent 61c33fc956
commit 2bd257970f

View File

@ -158,6 +158,9 @@ sub TadoAPI_Set(@) {
return "Unknown argument $a[1], choose one of " . join(" ", @cmds); return "Unknown argument $a[1], choose one of " . join(" ", @cmds);
} }
if (($cmd ne "password")) if (($cmd ne "password"))
{ {
my $pwd = TadoAPI_readPassword($name); my $pwd = TadoAPI_readPassword($name);
@ -666,12 +669,9 @@ sub TadoAPI_SetZoneOverlayById(@){
#Log3 $name, 5, 'NonBlocking Request: ' . Dumper($request); #Log3 $name, 5, 'NonBlocking Request: ' . Dumper($request);
HttpUtils_NonblockingGet($request); HttpUtils_NonblockingGet($request);
} }
} }
sub TadoAPI_SetAllOverlays(@){ sub TadoAPI_SetAllOverlays(@){
my ($hash, $setting) = @_; my ($hash, $setting) = @_;
my $name = $hash->{NAME}; my $name = $hash->{NAME};
@ -928,7 +928,17 @@ sub TadoAPI_UpdateMobileReadingsCallback($){
}else{ }else{
foreach my $item ( @$decoded_data ){ foreach my $item ( @$decoded_data ){
readingsBeginUpdate($hash); readingsBeginUpdate($hash);
readingsBulkUpdate($hash, "Geolocation_" . $item->{'id'}, $item->{'settings'}->{'geoTrackingEnabled'}); readingsBulkUpdate($hash, "GeoTracking_" . $item->{'id'}, $item->{'settings'}->{'geoTrackingEnabled'});
if(defined($item->{'location'}->{'atHome'}) && defined($item->{'location'}->{'atHome'}) eq "true"){
# present
readingsBulkUpdate($hash, "GeoLocation_" . $item->{'id'}, "present");
}elsif(defined($item->{'location'}->{'atHome'})){
# away
readingsBulkUpdate($hash, "GeoLocation_" . $item->{'id'}, "away");
}else{
# no state
readingsDelete($hash, "GeoLocation_" . $item->{'id'})
}
readingsEndUpdate( $hash, 1 ); readingsEndUpdate( $hash, 1 );
$hash->{LastRequest}="OK"; $hash->{LastRequest}="OK";
} }
@ -1139,7 +1149,7 @@ sub TadoAPI_GetGeoById(@){
}else{ }else{
my $setting = $decoded_data->{'geoTrackingEnabled'}; my $setting = $decoded_data->{'geoTrackingEnabled'};
readingsBeginUpdate($hash); readingsBeginUpdate($hash);
readingsBulkUpdate($hash, "Geolocation_" . $mobileID, $setting); readingsBulkUpdate($hash, "GeoLocation_" . $mobileID, $setting);
readingsEndUpdate( $hash, 1 ); readingsEndUpdate( $hash, 1 );
return $setting; return $setting;
} }