mirror of
https://github.com/home-assistant/core.git
synced 2025-05-22 06:47: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 . import YouTubeDataUpdateCoordinator
|
||||||
from .const import (
|
from .const import (
|
||||||
ATTR_LATEST_VIDEO,
|
ATTR_LATEST_VIDEO,
|
||||||
|
ATTR_PUBLISHED_AT,
|
||||||
ATTR_SUBSCRIBER_COUNT,
|
ATTR_SUBSCRIBER_COUNT,
|
||||||
ATTR_THUMBNAIL,
|
ATTR_THUMBNAIL,
|
||||||
ATTR_TITLE,
|
ATTR_TITLE,
|
||||||
@ -47,7 +48,8 @@ SENSOR_TYPES = [
|
|||||||
value_fn=lambda channel: channel[ATTR_LATEST_VIDEO][ATTR_TITLE],
|
value_fn=lambda channel: channel[ATTR_LATEST_VIDEO][ATTR_TITLE],
|
||||||
entity_picture_fn=lambda channel: channel[ATTR_LATEST_VIDEO][ATTR_THUMBNAIL],
|
entity_picture_fn=lambda channel: channel[ATTR_LATEST_VIDEO][ATTR_THUMBNAIL],
|
||||||
attributes_fn=lambda channel: {
|
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(
|
YouTubeSensorEntityDescription(
|
||||||
|
@ -37,7 +37,15 @@
|
|||||||
"entity": {
|
"entity": {
|
||||||
"sensor": {
|
"sensor": {
|
||||||
"latest_upload": {
|
"latest_upload": {
|
||||||
"name": "Latest upload"
|
"name": "Latest upload",
|
||||||
|
"state_attributes": {
|
||||||
|
"video_id": {
|
||||||
|
"name": "Video ID"
|
||||||
|
},
|
||||||
|
"published_at": {
|
||||||
|
"name": "Published at"
|
||||||
|
}
|
||||||
|
}
|
||||||
},
|
},
|
||||||
"subscribers": {
|
"subscribers": {
|
||||||
"name": "Subscribers"
|
"name": "Subscribers"
|
||||||
|
@ -5,6 +5,7 @@
|
|||||||
'entity_picture': 'https://i.ytimg.com/vi/wysukDrMdqU/sddefault.jpg',
|
'entity_picture': 'https://i.ytimg.com/vi/wysukDrMdqU/sddefault.jpg',
|
||||||
'friendly_name': 'Google for Developers Latest upload',
|
'friendly_name': 'Google for Developers Latest upload',
|
||||||
'icon': 'mdi:youtube',
|
'icon': 'mdi:youtube',
|
||||||
|
'published_at': '2023-05-11T00:20:46Z',
|
||||||
'video_id': 'wysukDrMdqU',
|
'video_id': 'wysukDrMdqU',
|
||||||
}),
|
}),
|
||||||
'context': <ANY>,
|
'context': <ANY>,
|
||||||
|
Loading…
x
Reference in New Issue
Block a user