diff --git a/custom_components/xiaomi_miot/media_player.py b/custom_components/xiaomi_miot/media_player.py index c26688a03..d42ee2945 100644 --- a/custom_components/xiaomi_miot/media_player.py +++ b/custom_components/xiaomi_miot/media_player.py @@ -355,6 +355,12 @@ async def async_update(self): return self._update_sub_entities('on', domain='switch') + if self._prop_state and not self._prop_state.readable: + if self.is_volume_muted is not False: + self._attr_state = MediaPlayerState.PLAYING + else: + self._attr_state = MediaPlayerState.IDLE + if self.xiaoai_device is None: await self.async_update_xiaoai_device() @@ -443,6 +449,8 @@ async def async_update_play_status(self, now=None): self._attr_media_image_remotely_accessible = False self._attr_media_duration = int(song['duration'] / 1000) if 'duration' in song else None self._attr_media_position = int(song['position'] / 1000) if 'position' in song else None + if self._attr_state == MediaPlayerState.PLAYING: + self._attr_media_position_updated_at = utcnow() if not self._attr_state: self.logger.info('%s: Got empty media info: %s', self.name_model, result) except (TypeError, ValueError, Exception) as exc: