Skip to content

Commit 7b463e4

Browse files
author
Ted Roberts
committed
Release 0.2.70
1 parent 187d8a7 commit 7b463e4

4 files changed

Lines changed: 69 additions & 1 deletion

File tree

custom_components/novastar_h/manifest.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,5 +21,5 @@
2121
}
2222
],
2323
"zeroconf": ["_novastar._tcp.local."],
24-
"version": "0.2.69"
24+
"version": "0.2.70"
2525
}

custom_components/novastar_h/sensor.py

Lines changed: 62 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
from __future__ import annotations
22

3+
from dataclasses import asdict
34
from typing import Any
45

56
from homeassistant.components.sensor import (
@@ -106,6 +107,7 @@ async def async_setup_entry(
106107
NovastarTempStatusSensor(entry, coordinator, device_info),
107108
NovastarDeviceStatusSensor(entry, coordinator, device_info),
108109
NovastarSignalStatusSensor(entry, coordinator, device_info),
110+
NovastarScreensSensor(entry, coordinator, device_info),
109111
NovastarInputsSensor(entry, coordinator, device_info),
110112
NovastarLayersSensor(entry, coordinator, device_info),
111113
NovastarActiveLayerCountSensor(entry, coordinator, device_info),
@@ -282,6 +284,66 @@ def native_value(self) -> str | None:
282284
return None
283285

284286

287+
class NovastarScreensSensor(CoordinatorEntity[NovastarCoordinator], SensorEntity):
288+
"""Sensor entity summarizing discovered screens."""
289+
290+
_attr_has_entity_name = True
291+
_attr_name = "Screens"
292+
_attr_translation_key = "screens"
293+
294+
def __init__(
295+
self,
296+
entry: ConfigEntry,
297+
coordinator: NovastarCoordinator,
298+
device_info: NovastarDeviceInfo,
299+
) -> None:
300+
"""Initialize the screens sensor entity."""
301+
super().__init__(coordinator)
302+
self._entry = entry
303+
self._device_info = device_info
304+
self._attr_unique_id = f"{entry.entry_id}_screens"
305+
306+
@property
307+
def device_info(self):
308+
"""Return device info."""
309+
model = "H Series"
310+
if self._device_info.model_id:
311+
model = f"H Series (Model {self._device_info.model_id})"
312+
return {
313+
"identifiers": {(DOMAIN, self._entry.entry_id)},
314+
"manufacturer": "Novastar",
315+
"model": model,
316+
"name": self._entry.data.get(CONF_NAME, DEFAULT_NAME),
317+
"sw_version": self._device_info.firmware,
318+
"serial_number": self._device_info.serial,
319+
}
320+
321+
@property
322+
def available(self) -> bool:
323+
"""Return True if entity is available."""
324+
return self.coordinator.last_update_success
325+
326+
@property
327+
def native_value(self) -> str:
328+
"""Return summary as '<total> Total'."""
329+
if not self.coordinator.data:
330+
return "0 Total"
331+
332+
total = len(self.coordinator.data.screens)
333+
return f"{total} Total"
334+
335+
@property
336+
def extra_state_attributes(self) -> dict[str, Any]:
337+
"""Return full screens list."""
338+
if not self.coordinator.data:
339+
return {"screens": []}
340+
341+
return {
342+
"screen_count": len(self.coordinator.data.screens),
343+
"screens": [asdict(screen) for screen in self.coordinator.data.screens],
344+
}
345+
346+
285347
class NovastarInputsSensor(CoordinatorEntity[NovastarCoordinator], SensorEntity):
286348
"""Sensor entity summarizing discovered inputs."""
287349

custom_components/novastar_h/strings.json

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -154,6 +154,9 @@
154154
"signal_status": {
155155
"name": "Signal Power Status"
156156
},
157+
"screens": {
158+
"name": "Screens"
159+
},
157160
"inputs": {
158161
"name": "Inputs"
159162
},

custom_components/novastar_h/translations/en.json

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -154,6 +154,9 @@
154154
"signal_status": {
155155
"name": "Signal Power Status"
156156
},
157+
"screens": {
158+
"name": "Screens"
159+
},
157160
"inputs": {
158161
"name": "Inputs"
159162
},

0 commit comments

Comments
 (0)