Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 5 additions & 4 deletions homeassistant/components/kaleidescape/entity.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
from __future__ import annotations

import logging
from typing import TYPE_CHECKING, cast
from typing import TYPE_CHECKING

from homeassistant.core import callback
from homeassistant.helpers.entity import DeviceInfo, Entity
Expand All @@ -19,18 +19,19 @@
class KaleidescapeEntity(Entity):
"""Defines a base Kaleidescape entity."""

_attr_has_entity_name = True
_attr_should_poll = False

def __init__(self, device: KaleidescapeDevice) -> None:
"""Initialize entity."""
self._device = device

self._attr_should_poll = False
self._attr_unique_id = device.serial_number
self._attr_name = f"{KALEIDESCAPE_NAME} {device.system.friendly_name}"
self._attr_device_info = DeviceInfo(
identifiers={(KALEIDESCAPE_DOMAIN, self._device.serial_number)},
# Instead of setting the device name to the entity name, kaleidescape
# should be updated to set has_entity_name = True
name=cast(str | None, self.name),
name=f"{KALEIDESCAPE_NAME} {device.system.friendly_name}",
model=self._device.system.type,
manufacturer=KALEIDESCAPE_NAME,
sw_version=f"{self._device.system.kos_version}",
Expand Down
1 change: 1 addition & 0 deletions homeassistant/components/kaleidescape/media_player.py
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,7 @@ class KaleidescapeMediaPlayer(KaleidescapeEntity, MediaPlayerEntity):
| MediaPlayerEntityFeature.NEXT_TRACK
| MediaPlayerEntityFeature.PREVIOUS_TRACK
)
_attr_name = None

async def async_turn_on(self) -> None:
"""Send leave standby command."""
Expand Down
2 changes: 2 additions & 0 deletions homeassistant/components/kaleidescape/remote.py
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,8 @@ async def async_setup_entry(
class KaleidescapeRemote(KaleidescapeEntity, RemoteEntity):
"""Representation of a Kaleidescape device."""

_attr_name = None

@property
def is_on(self) -> bool:
"""Return true if device is on."""
Expand Down
33 changes: 16 additions & 17 deletions homeassistant/components/kaleidescape/sensor.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,113 +39,113 @@ class KaleidescapeSensorEntityDescription(
SENSOR_TYPES: tuple[KaleidescapeSensorEntityDescription, ...] = (
KaleidescapeSensorEntityDescription(
key="media_location",
name="Media Location",
translation_key="media_location",
icon="mdi:monitor",
value_fn=lambda device: device.automation.movie_location,
),
KaleidescapeSensorEntityDescription(
key="play_status",
name="Play Status",
translation_key="play_status",
icon="mdi:monitor",
value_fn=lambda device: device.movie.play_status,
),
KaleidescapeSensorEntityDescription(
key="play_speed",
name="Play Speed",
translation_key="play_speed",
icon="mdi:monitor",
value_fn=lambda device: device.movie.play_speed,
),
KaleidescapeSensorEntityDescription(
key="video_mode",
name="Video Mode",
translation_key="video_mode",
icon="mdi:monitor-screenshot",
entity_category=EntityCategory.DIAGNOSTIC,
value_fn=lambda device: device.automation.video_mode,
),
KaleidescapeSensorEntityDescription(
key="video_color_eotf",
name="Video Color EOTF",
translation_key="video_color_eotf",
icon="mdi:monitor-eye",
entity_category=EntityCategory.DIAGNOSTIC,
value_fn=lambda device: device.automation.video_color_eotf,
),
KaleidescapeSensorEntityDescription(
key="video_color_space",
name="Video Color Space",
translation_key="video_color_space",
icon="mdi:monitor-eye",
entity_category=EntityCategory.DIAGNOSTIC,
value_fn=lambda device: device.automation.video_color_space,
),
KaleidescapeSensorEntityDescription(
key="video_color_depth",
name="Video Color Depth",
translation_key="video_color_depth",
icon="mdi:monitor-eye",
entity_category=EntityCategory.DIAGNOSTIC,
value_fn=lambda device: device.automation.video_color_depth,
),
KaleidescapeSensorEntityDescription(
key="video_color_sampling",
name="Video Color Sampling",
translation_key="video_color_sampling",
icon="mdi:monitor-eye",
entity_category=EntityCategory.DIAGNOSTIC,
value_fn=lambda device: device.automation.video_color_sampling,
),
KaleidescapeSensorEntityDescription(
key="screen_mask_ratio",
name="Screen Mask Ratio",
translation_key="screen_mask_ratio",
icon="mdi:monitor-screenshot",
entity_category=EntityCategory.DIAGNOSTIC,
value_fn=lambda device: device.automation.screen_mask_ratio,
),
KaleidescapeSensorEntityDescription(
key="screen_mask_top_trim_rel",
name="Screen Mask Top Trim Rel",
translation_key="screen_mask_top_trim_rel",
icon="mdi:monitor-screenshot",
entity_category=EntityCategory.DIAGNOSTIC,
native_unit_of_measurement=PERCENTAGE,
value_fn=lambda device: device.automation.screen_mask_top_trim_rel / 10.0,
),
KaleidescapeSensorEntityDescription(
key="screen_mask_bottom_trim_rel",
name="Screen Mask Bottom Trim Rel",
translation_key="screen_mask_bottom_trim_rel",
icon="mdi:monitor-screenshot",
entity_category=EntityCategory.DIAGNOSTIC,
native_unit_of_measurement=PERCENTAGE,
value_fn=lambda device: device.automation.screen_mask_bottom_trim_rel / 10.0,
),
KaleidescapeSensorEntityDescription(
key="screen_mask_conservative_ratio",
name="Screen Mask Conservative Ratio",
translation_key="screen_mask_conservative_ratio",
icon="mdi:monitor-screenshot",
entity_category=EntityCategory.DIAGNOSTIC,
value_fn=lambda device: device.automation.screen_mask_conservative_ratio,
),
KaleidescapeSensorEntityDescription(
key="screen_mask_top_mask_abs",
name="Screen Mask Top Mask Abs",
translation_key="screen_mask_top_mask_abs",
icon="mdi:monitor-screenshot",
entity_category=EntityCategory.DIAGNOSTIC,
native_unit_of_measurement=PERCENTAGE,
value_fn=lambda device: device.automation.screen_mask_top_mask_abs / 10.0,
),
KaleidescapeSensorEntityDescription(
key="screen_mask_bottom_mask_abs",
name="Screen Mask Bottom Mask Abs",
translation_key="screen_mask_bottom_mask_abs",
icon="mdi:monitor-screenshot",
entity_category=EntityCategory.DIAGNOSTIC,
native_unit_of_measurement=PERCENTAGE,
value_fn=lambda device: device.automation.screen_mask_bottom_mask_abs / 10.0,
),
KaleidescapeSensorEntityDescription(
key="cinemascape_mask",
name="Cinemascape Mask",
translation_key="cinemascape_mask",
icon="mdi:monitor-star",
entity_category=EntityCategory.DIAGNOSTIC,
value_fn=lambda device: device.automation.cinemascape_mask,
),
KaleidescapeSensorEntityDescription(
key="cinemascape_mode",
name="Cinemascape Mode",
translation_key="cinemascape_mode",
icon="mdi:monitor-star",
entity_category=EntityCategory.DIAGNOSTIC,
value_fn=lambda device: device.automation.cinemascape_mode,
Expand Down Expand Up @@ -177,7 +177,6 @@ def __init__(
super().__init__(device)
self.entity_description = entity_description
self._attr_unique_id = f"{self._attr_unique_id}-{entity_description.key}"
self._attr_name = f"{self._attr_name} {entity_description.name}"

@property
def native_value(self) -> StateType:
Expand Down
52 changes: 52 additions & 0 deletions homeassistant/components/kaleidescape/strings.json
Original file line number Diff line number Diff line change
Expand Up @@ -21,5 +21,57 @@
"cannot_connect": "[%key:common::config_flow::error::cannot_connect%]",
"unsupported": "Unsupported device"
}
},
"entity": {
"sensor": {
"media_location": {
"name": "Media location"
},
"play_status": {
"name": "Play status"
},
"play_speed": {
"name": "Play speed"
},
"video_mode": {
"name": "Video mode"
},
"video_color_eotf": {
"name": "Video color EOTF"
},
"video_color_space": {
"name": "Video color space"
},
"video_color_depth": {
"name": "Video color depth"
},
"video_color_sampling": {
"name": "Video color sampling"
},
"screen_mask_ratio": {
"name": "Screen mask ratio"
},
"screen_mask_top_trim_rel": {
"name": "Screen mask top trim relative"
},
"screen_mask_bottom_trim_rel": {
"name": "Screen mask bottom trim relative"
},
"screen_mask_conservative_ratio": {
"name": "Screen mask conservative ratio"
},
"screen_mask_top_mask_abs": {
"name": "Screen mask top mask absolute"
},
"screen_mask_bottom_mask_abs": {
"name": "Screen mask bottom mask absolute"
},
"cinemascape_mask": {
"name": "Cinemascape mask"
},
"cinemascape_mode": {
"name": "Cinemascape mode"
}
}
}
}
4 changes: 2 additions & 2 deletions tests/components/kaleidescape/test_sensor.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ async def test_sensors(
assert entity
assert entity.state == "none"
assert (
entity.attributes.get(ATTR_FRIENDLY_NAME) == f"{FRIENDLY_NAME} Media Location"
entity.attributes.get(ATTR_FRIENDLY_NAME) == f"{FRIENDLY_NAME} Media location"
)
assert entry
assert entry.unique_id == f"{MOCK_SERIAL}-media_location"
Expand All @@ -36,7 +36,7 @@ async def test_sensors(
entry = er.async_get(hass).async_get(f"{ENTITY_ID}_play_status")
assert entity
assert entity.state == "none"
assert entity.attributes.get(ATTR_FRIENDLY_NAME) == f"{FRIENDLY_NAME} Play Status"
assert entity.attributes.get(ATTR_FRIENDLY_NAME) == f"{FRIENDLY_NAME} Play status"
assert entry
assert entry.unique_id == f"{MOCK_SERIAL}-play_status"

Expand Down