1 """Sensor platform for Kaleidescape integration."""
3 from __future__
import annotations
5 from dataclasses
import dataclass
6 from typing
import TYPE_CHECKING
11 from .const
import DOMAIN
as KALEIDESCAPE_DOMAIN
12 from .entity
import KaleidescapeEntity
15 from collections.abc
import Callable
17 from kaleidescape
import Device
as KaleidescapeDevice
25 @dataclass(frozen=True, kw_only=True)
27 """Describes Kaleidescape sensor entity."""
29 value_fn: Callable[[KaleidescapeDevice], StateType]
32 SENSOR_TYPES: tuple[KaleidescapeSensorEntityDescription, ...] = (
35 translation_key=
"media_location",
36 value_fn=
lambda device: device.automation.movie_location,
40 translation_key=
"play_status",
41 value_fn=
lambda device: device.movie.play_status,
45 translation_key=
"play_speed",
46 value_fn=
lambda device: device.movie.play_speed,
50 translation_key=
"video_mode",
51 entity_category=EntityCategory.DIAGNOSTIC,
52 value_fn=
lambda device: device.automation.video_mode,
55 key=
"video_color_eotf",
56 translation_key=
"video_color_eotf",
57 entity_category=EntityCategory.DIAGNOSTIC,
58 value_fn=
lambda device: device.automation.video_color_eotf,
61 key=
"video_color_space",
62 translation_key=
"video_color_space",
63 entity_category=EntityCategory.DIAGNOSTIC,
64 value_fn=
lambda device: device.automation.video_color_space,
67 key=
"video_color_depth",
68 translation_key=
"video_color_depth",
69 entity_category=EntityCategory.DIAGNOSTIC,
70 value_fn=
lambda device: device.automation.video_color_depth,
73 key=
"video_color_sampling",
74 translation_key=
"video_color_sampling",
75 entity_category=EntityCategory.DIAGNOSTIC,
76 value_fn=
lambda device: device.automation.video_color_sampling,
79 key=
"screen_mask_ratio",
80 translation_key=
"screen_mask_ratio",
81 entity_category=EntityCategory.DIAGNOSTIC,
82 value_fn=
lambda device: device.automation.screen_mask_ratio,
85 key=
"screen_mask_top_trim_rel",
86 translation_key=
"screen_mask_top_trim_rel",
87 entity_category=EntityCategory.DIAGNOSTIC,
88 native_unit_of_measurement=PERCENTAGE,
89 value_fn=
lambda device: device.automation.screen_mask_top_trim_rel / 10.0,
92 key=
"screen_mask_bottom_trim_rel",
93 translation_key=
"screen_mask_bottom_trim_rel",
94 entity_category=EntityCategory.DIAGNOSTIC,
95 native_unit_of_measurement=PERCENTAGE,
96 value_fn=
lambda device: device.automation.screen_mask_bottom_trim_rel / 10.0,
99 key=
"screen_mask_conservative_ratio",
100 translation_key=
"screen_mask_conservative_ratio",
101 entity_category=EntityCategory.DIAGNOSTIC,
102 value_fn=
lambda device: device.automation.screen_mask_conservative_ratio,
105 key=
"screen_mask_top_mask_abs",
106 translation_key=
"screen_mask_top_mask_abs",
107 entity_category=EntityCategory.DIAGNOSTIC,
108 native_unit_of_measurement=PERCENTAGE,
109 value_fn=
lambda device: device.automation.screen_mask_top_mask_abs / 10.0,
112 key=
"screen_mask_bottom_mask_abs",
113 translation_key=
"screen_mask_bottom_mask_abs",
114 entity_category=EntityCategory.DIAGNOSTIC,
115 native_unit_of_measurement=PERCENTAGE,
116 value_fn=
lambda device: device.automation.screen_mask_bottom_mask_abs / 10.0,
119 key=
"cinemascape_mask",
120 translation_key=
"cinemascape_mask",
121 entity_category=EntityCategory.DIAGNOSTIC,
122 value_fn=
lambda device: device.automation.cinemascape_mask,
125 key=
"cinemascape_mode",
126 translation_key=
"cinemascape_mode",
127 entity_category=EntityCategory.DIAGNOSTIC,
128 value_fn=
lambda device: device.automation.cinemascape_mode,
134 hass: HomeAssistant, entry: ConfigEntry, async_add_entities: AddEntitiesCallback
136 """Set up the platform from a config entry."""
137 device: KaleidescapeDevice = hass.data[KALEIDESCAPE_DOMAIN][entry.entry_id]
144 """Representation of a Kaleidescape sensor."""
146 entity_description: KaleidescapeSensorEntityDescription
150 device: KaleidescapeDevice,
151 entity_description: KaleidescapeSensorEntityDescription,
153 """Initialize sensor."""
160 """Return value of sensor."""
StateType native_value(self)
None __init__(self, KaleidescapeDevice device, KaleidescapeSensorEntityDescription entity_description)
None async_setup_entry(HomeAssistant hass, ConfigEntry entry, AddEntitiesCallback async_add_entities)