mirror of
https://github.com/home-assistant/core.git
synced 2025-05-21 14:27:07 +00:00
Add upload date to Youtube state attributes (#96976)
This commit is contained in:
parent
8495da1964
commit
fb460d343e
@ -15,6 +15,7 @@ from homeassistant.helpers.typing import StateType
|
||||
from . import YouTubeDataUpdateCoordinator
|
||||
from .const import (
|
||||
ATTR_LATEST_VIDEO,
|
||||
ATTR_PUBLISHED_AT,
|
||||
ATTR_SUBSCRIBER_COUNT,
|
||||
ATTR_THUMBNAIL,
|
||||
ATTR_TITLE,
|
||||
@ -47,7 +48,8 @@ SENSOR_TYPES = [
|
||||
value_fn=lambda channel: channel[ATTR_LATEST_VIDEO][ATTR_TITLE],
|
||||
entity_picture_fn=lambda channel: channel[ATTR_LATEST_VIDEO][ATTR_THUMBNAIL],
|
||||
attributes_fn=lambda channel: {
|
||||
ATTR_VIDEO_ID: channel[ATTR_LATEST_VIDEO][ATTR_VIDEO_ID]
|
||||
ATTR_VIDEO_ID: channel[ATTR_LATEST_VIDEO][ATTR_VIDEO_ID],
|
||||
ATTR_PUBLISHED_AT: channel[ATTR_LATEST_VIDEO][ATTR_PUBLISHED_AT],
|
||||
},
|
||||
),
|
||||
YouTubeSensorEntityDescription(
|
||||
|
@ -37,7 +37,15 @@
|
||||
"entity": {
|
||||
"sensor": {
|
||||
"latest_upload": {
|
||||
"name": "Latest upload"
|
||||
"name": "Latest upload",
|
||||
"state_attributes": {
|
||||
"video_id": {
|
||||
"name": "Video ID"
|
||||
},
|
||||
"published_at": {
|
||||
"name": "Published at"
|
||||
}
|
||||
}
|
||||
},
|
||||
"subscribers": {
|
||||
"name": "Subscribers"
|
||||
|
@ -5,6 +5,7 @@
|
||||
'entity_picture': 'https://i.ytimg.com/vi/wysukDrMdqU/sddefault.jpg',
|
||||
'friendly_name': 'Google for Developers Latest upload',
|
||||
'icon': 'mdi:youtube',
|
||||
'published_at': '2023-05-11T00:20:46Z',
|
||||
'video_id': 'wysukDrMdqU',
|
||||
}),
|
||||
'context': <ANY>,
|
||||
|
Loading…
x
Reference in New Issue
Block a user