修复类型错误 TypeError: '>' not supported between instances of 'str' and 'int'
此错误来自自定义集成。 日志: homeassistant 来源: custom_components/ha_cloud_music/media_player.py:122 集成: 云音乐 (文档) 首次发生: 03:19:49 (118 全部发生) 上次记录: 03:23:43 Error doing job: Future exception was never retrieved Traceback (most recent call last): File "/usr/local/lib/python3.12/concurrent/futures/thread.py", line 58, in run result = self.fn(*self.args, **self.kwargs) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/config/custom_components/ha_cloud_music/media_player.py", line 71, in media_player_interval mp.interval(now) File "/config/custom_components/ha_cloud_music/media_player.py", line 122, in interval if self.before_state['media_duration'] > 0 and self.before_state['media_duration'] - self.before_state['media_duration'] <= 5: ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ TypeError: '>' not supported between instances of 'str' and 'int'
This commit is contained in:
parent
cebe9b1b98
commit
3edaf9e16a
|
@ -116,6 +116,8 @@ class CloudMusicMediaPlayer(MediaPlayerEntity):
|
|||
self._attr_media_position_updated_at = datetime.datetime.now()
|
||||
# 判断是否下一曲
|
||||
if self.before_state is not None:
|
||||
media_duration = int(self.before_state['media_duration'])
|
||||
self.before_state['media_duration'] = media_duration
|
||||
# 判断音乐总时长
|
||||
if self.before_state['media_duration'] > 0 and self.before_state['media_duration'] - self.before_state['media_duration'] <= 5:
|
||||
# 判断源音乐播放器状态
|
||||
|
@ -247,4 +249,4 @@ class CloudMusicMediaPlayer(MediaPlayerEntity):
|
|||
media_player = self.media_player
|
||||
if media_player is not None:
|
||||
service_data.update({ 'entity_id': media_player.entity_id })
|
||||
await self.hass.services.async_call('media_player', service, service_data)
|
||||
await self.hass.services.async_call('media_player', service, service_data)
|
||||
|
|
Loading…
Reference in New Issue