Add System Bridge display sensors (#57019)
* System Bridge - Add Display Sensors * Omit default
This commit is contained in:
parent
8b013b823b
commit
9f34d010e6
6 changed files with 60 additions and 3 deletions
|
@ -84,6 +84,7 @@ async def async_setup_entry(hass: HomeAssistant, entry: ConfigEntry) -> bool:
|
|||
while (
|
||||
coordinator.bridge.battery is None
|
||||
or coordinator.bridge.cpu is None
|
||||
or coordinator.bridge.display is None
|
||||
or coordinator.bridge.filesystem is None
|
||||
or coordinator.bridge.graphics is None
|
||||
or coordinator.bridge.information is None
|
||||
|
|
|
@ -65,6 +65,7 @@ class SystemBridgeDataUpdateCoordinator(DataUpdateCoordinator[Bridge]):
|
|||
[
|
||||
"battery",
|
||||
"cpu",
|
||||
"display",
|
||||
"filesystem",
|
||||
"graphics",
|
||||
"memory",
|
||||
|
|
|
@ -3,7 +3,7 @@
|
|||
"name": "System Bridge",
|
||||
"config_flow": true,
|
||||
"documentation": "https://www.home-assistant.io/integrations/system_bridge",
|
||||
"requirements": ["systembridge==2.1.0"],
|
||||
"requirements": ["systembridge==2.1.3"],
|
||||
"codeowners": ["@timmo001"],
|
||||
"zeroconf": ["_system-bridge._udp.local."],
|
||||
"after_dependencies": ["zeroconf"],
|
||||
|
|
|
@ -23,6 +23,7 @@ from homeassistant.const import (
|
|||
DEVICE_CLASS_VOLTAGE,
|
||||
ELECTRIC_POTENTIAL_VOLT,
|
||||
FREQUENCY_GIGAHERTZ,
|
||||
FREQUENCY_HERTZ,
|
||||
FREQUENCY_MEGAHERTZ,
|
||||
PERCENTAGE,
|
||||
POWER_WATT,
|
||||
|
@ -42,6 +43,8 @@ ATTR_SIZE: Final = "size"
|
|||
ATTR_TYPE: Final = "type"
|
||||
ATTR_USED: Final = "used"
|
||||
|
||||
PIXELS: Final = "px"
|
||||
|
||||
|
||||
@dataclass
|
||||
class SystemBridgeSensorEntityDescription(SensorEntityDescription):
|
||||
|
@ -84,6 +87,13 @@ BASE_SENSOR_TYPES: tuple[SystemBridgeSensorEntityDescription, ...] = (
|
|||
native_unit_of_measurement=ELECTRIC_POTENTIAL_VOLT,
|
||||
value=lambda bridge: bridge.cpu.cpu.voltage,
|
||||
),
|
||||
SystemBridgeSensorEntityDescription(
|
||||
key="displays_connected",
|
||||
name="Displays Connected",
|
||||
state_class=STATE_CLASS_MEASUREMENT,
|
||||
icon="mdi:monitor",
|
||||
value=lambda bridge: len(bridge.display.displays),
|
||||
),
|
||||
SystemBridgeSensorEntityDescription(
|
||||
key="kernel",
|
||||
name="Kernel",
|
||||
|
@ -225,6 +235,51 @@ async def async_setup_entry(
|
|||
for description in BATTERY_SENSOR_TYPES:
|
||||
entities.append(SystemBridgeSensor(coordinator, description))
|
||||
|
||||
for index, _ in enumerate(coordinator.data.display.displays):
|
||||
name = index + 1
|
||||
entities = [
|
||||
*entities,
|
||||
SystemBridgeSensor(
|
||||
coordinator,
|
||||
SystemBridgeSensorEntityDescription(
|
||||
key=f"display_{name}_resolution_x",
|
||||
name=f"Display {name} Resolution X",
|
||||
state_class=STATE_CLASS_MEASUREMENT,
|
||||
native_unit_of_measurement=PIXELS,
|
||||
icon="mdi:monitor",
|
||||
value=lambda bridge, i=index: bridge.display.displays[
|
||||
i
|
||||
].resolutionX,
|
||||
),
|
||||
),
|
||||
SystemBridgeSensor(
|
||||
coordinator,
|
||||
SystemBridgeSensorEntityDescription(
|
||||
key=f"display_{name}_resolution_y",
|
||||
name=f"Display {name} Resolution Y",
|
||||
state_class=STATE_CLASS_MEASUREMENT,
|
||||
native_unit_of_measurement=PIXELS,
|
||||
icon="mdi:monitor",
|
||||
value=lambda bridge, i=index: bridge.display.displays[
|
||||
i
|
||||
].resolutionY,
|
||||
),
|
||||
),
|
||||
SystemBridgeSensor(
|
||||
coordinator,
|
||||
SystemBridgeSensorEntityDescription(
|
||||
key=f"display_{name}_refresh_rate",
|
||||
name=f"Display {name} Refresh Rate",
|
||||
state_class=STATE_CLASS_MEASUREMENT,
|
||||
native_unit_of_measurement=FREQUENCY_HERTZ,
|
||||
icon="mdi:monitor",
|
||||
value=lambda bridge, i=index: bridge.display.displays[
|
||||
i
|
||||
].currentRefreshRate,
|
||||
),
|
||||
),
|
||||
]
|
||||
|
||||
for index, _ in enumerate(coordinator.data.graphics.controllers):
|
||||
if coordinator.data.graphics.controllers[index].name is not None:
|
||||
# Remove vendor from name
|
||||
|
|
|
@ -2266,7 +2266,7 @@ swisshydrodata==0.1.0
|
|||
synology-srm==0.2.0
|
||||
|
||||
# homeassistant.components.system_bridge
|
||||
systembridge==2.1.0
|
||||
systembridge==2.1.3
|
||||
|
||||
# homeassistant.components.tahoma
|
||||
tahoma-api==0.0.16
|
||||
|
|
|
@ -1303,7 +1303,7 @@ sunwatcher==0.2.1
|
|||
surepy==0.7.2
|
||||
|
||||
# homeassistant.components.system_bridge
|
||||
systembridge==2.1.0
|
||||
systembridge==2.1.3
|
||||
|
||||
# homeassistant.components.tellduslive
|
||||
tellduslive==0.10.11
|
||||
|
|
Loading…
Add table
Reference in a new issue