Skip to content

Commit

Permalink
Tweak demo, add some translations, tweak media players (#21271)
Browse files Browse the repository at this point in the history
Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com>
  • Loading branch information
bramkragten and coderabbitai[bot] authored Jul 4, 2024
1 parent 1ceef7c commit c07e112
Show file tree
Hide file tree
Showing 5 changed files with 94 additions and 23 deletions.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
74 changes: 66 additions & 8 deletions demo/src/configs/sections/entities.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { convertEntities } from "../../../../src/fake_data/entity";
import { DemoConfig } from "../types";

export const demoEntitiesSections: DemoConfig["entities"] = () =>
export const demoEntitiesSections: DemoConfig["entities"] = (localize) =>
convertEntities({
"cover.living_room_garden_shutter": {
entity_id: "cover.living_room_garden_shutter",
Expand Down Expand Up @@ -113,11 +113,30 @@ export const demoEntitiesSections: DemoConfig["entities"] = () =>
},
"media_player.living_room_nest_mini": {
entity_id: "media_player.living_room_nest_mini",
state: "off",
state: "on",
attributes: {
device_class: "speaker",
friendly_name: "Living room Nest Mini",
supported_features: 152461,
volume_level: 0.18,
is_volume_muted: false,
media_content_type: "music",
media_duration: 300,
media_position: 0,
media_position_updated_at: new Date(
// 23 seconds in
new Date().getTime() - 23000
).toISOString(),
media_title: "I Wasn't Born To Follow",
media_artist: "The Byrds",
media_album_name: "The Notorious Byrd Brothers",
source_list: ["It's A Party", "Radio HSL", "Retro 70s and 80s"],
shuffle: false,
night_sound: false,
speech_enhance: false,
friendly_name: localize(
"ui.panel.page-demo.config.sections.entities.media_player.living_room_nest_mini"
),
entity_picture: "/assets/sections/images/media_player_family_room.jpg",
supported_features: 64063,
},
},
"cover.kitchen_shutter": {
Expand Down Expand Up @@ -168,8 +187,27 @@ export const demoEntitiesSections: DemoConfig["entities"] = () =>
state: "on",
attributes: {
device_class: "speaker",
friendly_name: "Kitchen Nest Audio",
supported_features: 152461,
volume_level: 0.18,
is_volume_muted: false,
media_content_type: "music",
media_duration: 300,
media_position: 0,
media_position_updated_at: new Date(
// 23 seconds in
new Date().getTime() - 23000
).toISOString(),
media_title: "I Wasn't Born To Follow",
media_artist: "The Byrds",
media_album_name: "The Notorious Byrd Brothers",
source_list: ["It's A Party", "Radio HSL", "Retro 70s and 80s"],
shuffle: false,
night_sound: false,
speech_enhance: false,
friendly_name: localize(
"ui.panel.page-demo.config.sections.entities.media_player.kitchen_nest_audio"
),
entity_picture: "/assets/sections/images/media_player_family_room.jpg",
supported_features: 64063,
},
},
"binary_sensor.tesla_wall_connector_vehicle_connected": {
Expand Down Expand Up @@ -333,8 +371,28 @@ export const demoEntitiesSections: DemoConfig["entities"] = () =>
entity_id: "media_player.study_nest_hub",
state: "off",
attributes: {
friendly_name: "Study Nest Hub",
supported_features: 152461,
device_class: "speaker",
volume_level: 0.18,
is_volume_muted: false,
media_content_type: "music",
media_duration: 300,
media_position: 0,
media_position_updated_at: new Date(
// 23 seconds in
new Date().getTime() - 23000
).toISOString(),
media_title: "I Wasn't Born To Follow",
media_artist: "The Byrds",
media_album_name: "The Notorious Byrd Brothers",
source_list: ["It's A Party", "Radio HSL", "Retro 70s and 80s"],
shuffle: false,
night_sound: false,
speech_enhance: false,
friendly_name: localize(
"ui.panel.page-demo.config.sections.entities.media_player.study_nest_hub"
),
entity_picture: "/assets/sections/images/media_player_family_room.jpg",
supported_features: 64063,
},
},
"sensor.standing_desk_height": {
Expand Down
21 changes: 9 additions & 12 deletions demo/src/configs/sections/lovelace.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { isFrontpageEmbed } from "../../util/is_frontpage";
import { DemoConfig } from "../types";

export const demoLovelaceSections: DemoConfig["lovelace"] = () => ({
export const demoLovelaceSections: DemoConfig["lovelace"] = (localize) => ({
title: "Home Assistant Demo",
views: [
{
Expand All @@ -14,7 +14,7 @@ export const demoLovelaceSections: DemoConfig["lovelace"] = () => ({
? []
: [
{
title: "Welcome 👋",
title: `${localize("ui.panel.page-demo.config.sections.titles.welcome")} 👋`,
cards: [{ type: "custom:ha-demo-card" }],
},
]),
Expand Down Expand Up @@ -53,10 +53,9 @@ export const demoLovelaceSections: DemoConfig["lovelace"] = () => ({
{
type: "tile",
entity: "media_player.living_room_nest_mini",
name: "Nest Mini",
},
],
title: "🛋️ Living room ",
title: `🛋️ ${localize("ui.panel.page-demo.config.sections.titles.living_room")} `,
},
{
type: "grid",
Expand Down Expand Up @@ -89,10 +88,9 @@ export const demoLovelaceSections: DemoConfig["lovelace"] = () => ({
{
type: "tile",
entity: "media_player.kitchen_nest_audio",
name: "Nest Audio",
},
],
title: "👩‍🍳 Kitchen",
title: `👩‍🍳 ${localize("ui.panel.page-demo.config.sections.titles.kitchen")}`,
},
{
type: "grid",
Expand Down Expand Up @@ -134,7 +132,7 @@ export const demoLovelaceSections: DemoConfig["lovelace"] = () => ({
color: "dark-grey",
},
],
title: "⚡️ Energy",
title: `⚡️ ${localize("ui.panel.page-demo.config.sections.titles.energy")}`,
},
{
type: "grid",
Expand Down Expand Up @@ -171,7 +169,7 @@ export const demoLovelaceSections: DemoConfig["lovelace"] = () => ({
state_content: ["preset_mode", "current_temperature"],
},
],
title: "🌤️ Climate",
title: `🌤️ ${localize("ui.panel.page-demo.config.sections.titles.climate")}`,
},
{
type: "grid",
Expand All @@ -189,7 +187,6 @@ export const demoLovelaceSections: DemoConfig["lovelace"] = () => ({
{
type: "tile",
entity: "media_player.study_nest_hub",
name: "Nest Hub",
},
{
type: "tile",
Expand All @@ -199,7 +196,7 @@ export const demoLovelaceSections: DemoConfig["lovelace"] = () => ({
icon: "mdi:desk",
},
],
title: "🧑‍💻 Study",
title: `🧑‍💻 ${localize("ui.panel.page-demo.config.sections.titles.study")}`,
},
{
type: "grid",
Expand Down Expand Up @@ -233,7 +230,7 @@ export const demoLovelaceSections: DemoConfig["lovelace"] = () => ({
name: "Illuminance",
},
],
title: "🌳 Outdoor",
title: `🌳 ${localize("ui.panel.page-demo.config.sections.titles.outdoor")}`,
},
{
type: "grid",
Expand Down Expand Up @@ -263,7 +260,7 @@ export const demoLovelaceSections: DemoConfig["lovelace"] = () => ({
icon: "mdi:home-assistant",
},
],
title: "🎉 Updates",
title: `🎉 ${localize("ui.panel.page-demo.config.sections.titles.updates")}`,
},
],
},
Expand Down
3 changes: 1 addition & 2 deletions src/dialogs/more-info/controls/more-info-media_player.ts
Original file line number Diff line number Diff line change
Expand Up @@ -63,8 +63,7 @@ class MoreInfoMediaPlayer extends LitElement {
`
)}
</div>
${!__DEMO__ &&
!isUnavailableState(stateObj.state) &&
${!isUnavailableState(stateObj.state) &&
supportsFeature(stateObj, MediaPlayerEntityFeature.BROWSE_MEDIA)
? html`
<mwc-button
Expand Down
19 changes: 18 additions & 1 deletion src/translations/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -6630,7 +6630,24 @@
},
"sections": {
"description": "This dashboard is using the sections view released in Home Assistant 2024.3. Learn more about it in this {blog_post}.",
"description_blog_post": "blog post"
"description_blog_post": "blog post",
"titles": {
"welcome": "Welcome",
"living_room": "Living room",
"study": "Study",
"kitchen": "Kitchen",
"outdoor": "Outdoor",
"energy": "Energy",
"climate": "Climate",
"updates": "Updates"
},
"entities": {
"media_player": {
"living_room_nest_mini": "Nest mini",
"kitchen_nest_audio": "Nest Audio",
"study_nest_hub": "Nest Hub"
}
}
}
}
},
Expand Down

0 comments on commit c07e112

Please sign in to comment.