Skip to content

Commit

Permalink
Add attribute for lamp hours
Browse files Browse the repository at this point in the history
  • Loading branch information
TheRealKillaruna committed Jan 7, 2024
1 parent 2b38622 commit 5ed4361
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 3 deletions.
1 change: 1 addition & 0 deletions custom_components/pjlink2/const.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
ATTR_PROJECTOR_NAME = "projector_name"
ATTR_RESOLUTION_X = "x_resolution"
ATTR_RESOLUTION_Y = "y_resolution"
ATTR_LAMP_HOURS = "lamp_hours"

class ProjectorState(StrEnum):
OFF = "off"
Expand Down
4 changes: 2 additions & 2 deletions custom_components/pjlink2/manifest.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,10 @@
"codeowners": ["@TheRealKillaruna"],
"config_flow": false,
"dependencies": [],
"documentation": "https://github.com/TheRealKillaruna/pjlink2",
"documentation": "https://github.com/TheRealKillaruna/ha-pjlink2",
"domain": "pjlink2",
"iot_class": "calculated",
"name": "PJLink2",
"requirements": ["aiopjlink==1.0.5"],
"version": "0.1"
"version": "0.2"
}
4 changes: 3 additions & 1 deletion custom_components/pjlink2/sensor.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@

import voluptuous as vol

from .const import DOMAIN, CONF_ENCODING, DEFAULT_ENCODING, DEFAULT_PORT, DEFAULT_TIMEOUT, ATTR_PRODUCT_NAME, ATTR_MANUFACTURER_NAME, ATTR_PROJECTOR_NAME, ATTR_RESOLUTION_X, ATTR_RESOLUTION_Y, ProjectorState
from .const import DOMAIN, CONF_ENCODING, DEFAULT_ENCODING, DEFAULT_PORT, DEFAULT_TIMEOUT, ATTR_PRODUCT_NAME, ATTR_MANUFACTURER_NAME, ATTR_PROJECTOR_NAME, ATTR_RESOLUTION_X, ATTR_RESOLUTION_Y, ATTR_LAMP_HOURS, ProjectorState


_LOGGER = logging.getLogger(__name__)
Expand Down Expand Up @@ -122,6 +122,8 @@ async def async_update(self) -> None:
res = await Sources(self._projector).resolution()
self.attrs[ATTR_RESOLUTION_X] = res[0]
self.attrs[ATTR_RESOLUTION_Y] = res[1]
lmpHrs = await Lamp(self._projector).hours()
self.attrs[ATTR_LAMP_HOURS] = lmpHrs
else:
if ATTR_RESOLUTION_X in self.attrs: del self.attrs[ATTR_RESOLUTION_X]
if ATTR_RESOLUTION_Y in self.attrs: del self.attrs[ATTR_RESOLUTION_Y]
Expand Down

0 comments on commit 5ed4361

Please sign in to comment.