mirror of
https://github.com/fhem/fhem-mirror.git
synced 2025-02-01 07:19:24 +00:00
32_withings: API endpoint change to Nokia servers - bugfix
git-svn-id: https://svn.fhem.de/fhem/trunk@17339 2b470e98-0d58-463d-a4d8-8e2adae1ed80
This commit is contained in:
parent
c4d4f7bcc6
commit
ccdfdea2b6
@ -50,7 +50,7 @@ my %device_models = ( 1 => { 1 => "Smart Scale", 2 => "Wireless Scale", 3 => "S
|
||||
2 => { 21 => "Smart Baby Monitor", 22 => "Home", 22 => "Home v2", },
|
||||
4 => { 41 => "iOS Blood Pressure Monitor", 42 => "Wireless Blood Pressure Monitor", 43 => "BPM", 44 => "BPM+", },
|
||||
16 => { 51 => "Pulse Ox", 52 => "Activite", 53 => "Activite v2", 54 => "Go", 55 => "Steel HR", },
|
||||
32 => { 60 => "Aura", 61 => "Sleep Sensor", 62 => "Sleep Mat", },
|
||||
32 => { 60 => "Aura", 61 => "Sleep Sensor", 62 => "Sleep Mat", 63 => "Sleep", },
|
||||
64 => { 70 => "Thermo", }, );
|
||||
|
||||
#Firmware files: cdnfw_withings_net
|
||||
@ -873,13 +873,13 @@ sub withings_initDevice($) {
|
||||
$hash->{lastweighindate} = $device->{lastweighindate} if( defined($device->{lastweighindate}) );
|
||||
|
||||
|
||||
if((defined($hash->{typeID}) && $hash->{typeID} == 16) or (defined($hash->{modelID}) && $hash->{modelID} == 61))
|
||||
if((defined($hash->{typeID}) && $hash->{typeID} == 16) or (defined($hash->{typeID}) && $hash->{typeID} == 32 && defined($hash->{modelID}) && $hash->{modelID} != 60))
|
||||
{
|
||||
my $devicelink = withings_getDeviceLink( $hash );
|
||||
if(defined($devicelink->{userid}))
|
||||
if(defined($devicelink) && defined($devicelink->{linkuserid}))
|
||||
{
|
||||
$hash->{User} = $devicelink->{userid};
|
||||
$hash->{UserDevice} = $modules{$hash->{TYPE}}{defptr}{"U".$devicelink->{userid}} if defined($modules{$hash->{TYPE}}{defptr}{"U".$devicelink->{userid}});
|
||||
$hash->{User} = $devicelink->{linkuserid};
|
||||
$hash->{UserDevice} = $modules{$hash->{TYPE}}{defptr}{"U".$devicelink->{linkuserid}} if defined($modules{$hash->{TYPE}}{defptr}{"U".$devicelink->{linkuserid}});
|
||||
}
|
||||
}
|
||||
|
||||
@ -979,7 +979,7 @@ sub withings_getDevices($) {
|
||||
withings_getSessionKey($hash);
|
||||
|
||||
my ($err,$data) = HttpUtils_BlockingGet({
|
||||
url => $hash->{'.https'}."://scalews.health.nokia.com/index/service/association",
|
||||
url => $hash->{'.https'}."://scalews.withings.com/cgi-bin/association",
|
||||
timeout => 10,
|
||||
noshutdown => 1,
|
||||
data => {sessionid => $hash->{SessionKey}, accountid => $hash->{AccountID} , type => '-1', enrich => 't' , appname => 'my2', appliver=> $hash->{helper}{appliver}, apppfm => 'web', action => 'getbyaccountid'},
|
||||
@ -1067,10 +1067,10 @@ sub withings_getDeviceLink($) {
|
||||
withings_getSessionKey( $hash->{IODev} );
|
||||
|
||||
my ($err,$data) = HttpUtils_BlockingGet({
|
||||
url => $hash->{'.https'}."://scalews.health.nokia.com/index/service/v2/link",
|
||||
url => $hash->{'.https'}."://scalews.health.nokia.com/cgi-bin/association",
|
||||
timeout => 10,
|
||||
noshutdown => 1,
|
||||
data => {sessionid => $hash->{IODev}->{SessionKey}, deviceid => $hash->{Device} , appname => 'my2', appliver=> $hash->{IODev}->{helper}{appliver}, apppfm => 'web', action => 'get'},
|
||||
data => {sessionid => $hash->{IODev}->{SessionKey}, appname => 'hmw', appliver=> $hash->{IODev}->{helper}{appliver}, enrich => 't', action => 'getbyaccountid'},
|
||||
});
|
||||
|
||||
#my $ua = LWP::UserAgent->new;
|
||||
@ -1087,7 +1087,13 @@ sub withings_getDeviceLink($) {
|
||||
return undef;
|
||||
}
|
||||
|
||||
return $json->{body};
|
||||
foreach my $association (@{$json->{body}{associations}}) {
|
||||
next if( !defined($association->{deviceid}) );
|
||||
next if( $association->{deviceid} ne $hash->{Device} );
|
||||
return $association->{deviceproperties};
|
||||
}
|
||||
|
||||
return undef;
|
||||
}
|
||||
|
||||
|
||||
@ -1512,7 +1518,7 @@ sub withings_poll($;$) {
|
||||
withings_getDeviceProperties($hash) if($force > 1 || $lastProperties <= ($now - $intervalProperties));
|
||||
withings_getDeviceReadingsBedside($hash) if($force || $lastData <= ($now - $intervalData));
|
||||
}
|
||||
elsif(defined($hash->{modelID}) && $hash->{modelID} eq '61') {
|
||||
elsif(defined($hash->{modelID}) && ($hash->{modelID} eq '61' || $hash->{modelID} eq '62' || $hash->{modelID} eq '63')) {
|
||||
withings_getDeviceProperties($hash) if($force > 1 || $lastProperties <= ($now - $intervalProperties));
|
||||
withings_getUserReadingsSleep($hash) if($force || $lastData <= ($now - $intervalData));
|
||||
withings_getUserReadingsSleepDebug($hash) if($force || $lastDebug <= ($now - $intervalDebug));
|
||||
|
Loading…
Reference in New Issue
Block a user