37_Spotify: added volume reading

git-svn-id: https://svn.fhem.de/fhem/trunk@14483 2b470e98-0d58-463d-a4d8-8e2adae1ed80
This commit is contained in:
neumann 2017-06-09 05:22:09 +00:00
parent c1832018e3
commit 1bc8fb37a1

View File

@ -807,6 +807,7 @@ sub Spotify_dispatch($$$) {
if($device->{is_active}) { if($device->{is_active}) {
Spotify_saveDevice($hash, $device, "device_active", 0); Spotify_saveDevice($hash, $device, "device_active", 0);
readingsBulkUpdateIfChanged($hash, 'volume', $device->{volume_percent});
$hash->{helper}{device_active} = $device; # found active device $hash->{helper}{device_active} = $device; # found active device
} }
@ -855,6 +856,7 @@ sub Spotify_dispatch($$$) {
if($hash->{helper}{is_active}) { if($hash->{helper}{is_active}) {
my $device = $json->{device}; my $device = $json->{device};
$hash->{helper}{device_active} = $device; $hash->{helper}{device_active} = $device;
readingsBulkUpdateIfChanged($hash, 'volume', $device->{volume_percent});
Spotify_saveDevice($hash, $device, "device_active", 0); Spotify_saveDevice($hash, $device, "device_active", 0);
} else { } else {
delete $hash->{helper}{device_active}; delete $hash->{helper}{device_active};