Skip to content

Commit

Permalink
Log IMEVENT alarms and warnings and add error attribute that can be p…
Browse files Browse the repository at this point in the history
…olled
  • Loading branch information
amosyuen committed Feb 11, 2023
1 parent 0da204d commit 5afc052
Show file tree
Hide file tree
Showing 6 changed files with 52 additions and 14 deletions.
1 change: 1 addition & 0 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
{
"python.linting.pylintArgs": ["--rcfile=setup.cfg"],
"python.linting.pylintEnabled": true,
"python.linting.enabled": true,
"python.pythonPath": "venv/bin/python",
Expand Down
12 changes: 6 additions & 6 deletions .vscode/tasks.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,11 @@
"label": "Run Home Assistant on port 9123",
"type": "shell",
"command": "container start",
"problemMatcher": []
"problemMatcher": [],
"group": {
"kind": "build",
"isDefault": true
}
},
{
"label": "Run Home Assistant configuration against /config",
Expand All @@ -17,11 +21,7 @@
"label": "Upgrade Home Assistant to latest dev",
"type": "shell",
"command": "container install",
"problemMatcher": [],
"group": {
"kind": "build",
"isDefault": true
}
"problemMatcher": []
},
{
"label": "Install a specific version of Home Assistant",
Expand Down
3 changes: 3 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -30,10 +30,13 @@ This custom component is designed for Epson Home Cinema Projectors which support
- Get and set color mode
- Get filter hours
- Get lamp hours
- Get current error
- Increase or decrease volume
- Play, pause, or stop media
- Next or previous media

All the get features will be exposed as attributes on the `media_player`. Changes are exposed as services. See service documentation at https://github.com/amosyuen/ha-epson-projector-link/blob/main/custom_components/epson_projector_link/services.yaml

### Differences from HA Epson Integration

As of September 2022, the main differences with the built in [Home Assistant Epson Integration](https://www.home-assistant.io/integrations/epson/) are:
Expand Down
2 changes: 2 additions & 0 deletions custom_components/epson_projector_link/const.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
from .projector.const import PROPERTY_AUTO_IRIS_MODE
from .projector.const import PROPERTY_BRIGHTNESS
from .projector.const import PROPERTY_COLOR_MODE
from .projector.const import PROPERTY_ERR
from .projector.const import PROPERTY_LAMP_HOURS
from .projector.const import PROPERTY_MUTE
from .projector.const import PROPERTY_POWER_CONSUMPTION_MODE
Expand All @@ -24,6 +25,7 @@
PROPERTY_AUTO_IRIS_MODE: "auto_iris_mode",
PROPERTY_BRIGHTNESS: "brightness",
PROPERTY_COLOR_MODE: "color_mode",
PROPERTY_ERR: "error",
PROPERTY_LAMP_HOURS: "lamp_hours",
PROPERTY_MUTE: "is_volume_muted",
PROPERTY_POWER_CONSUMPTION_MODE: "power_consumption_mode",
Expand Down
29 changes: 29 additions & 0 deletions custom_components/epson_projector_link/projector/const.py
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@ def invert_map(map):
PROPERTY_AUTO_IRIS_MODE = "IRIS"
PROPERTY_BRIGHTNESS = "BRIGHT"
PROPERTY_COLOR_MODE = "CMODE"
PROPERTY_ERR = "ERR"
PROPERTY_LAMP_HOURS = "LAMP"
PROPERTY_MUTE = "MUTE"
PROPERTY_POWER = "PWR"
Expand Down Expand Up @@ -113,6 +114,34 @@ def invert_map(map):
}
COLOR_MODE_CODE_INVERTED_MAP = invert_map(COLOR_MODE_CODE_MAP)

#
# Errors
#
ERROR_NONE = "None"
PROPERTY_ERR_CODE_MAP = {
"00": ERROR_NONE,
"01": "Fan error",
"03": "Lamp failure at power on",
"04": "High internal temperature error",
"06": "Lamp error",
"07": "Open Lamp cover door error",
"08": "Cinema filter error",
"09": "Electric dual-layered capacitor is disconnected",
"0A": "Auto iris error",
"0B": "Subsystem Error",
"0C": "Low air flow error",
"0D": "Air filter air flow sensor error",
"0E": "Power supply unit error (Ballast)",
"0F": "Shutter error",
"10": "Cooling system error (peltiert element)",
"11": "Cooling system error (Pump)",
"12": "Static iris error",
"13": "Power supply unit error (Disagreement of Ballast)",
"14": "Exhaust shutter error",
"15": "Obstacle detection error",
"16": "IF board discernment error",
}

#
# Power
#
Expand Down
19 changes: 11 additions & 8 deletions custom_components/epson_projector_link/projector/projector.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,8 @@
from .const import PROPERTY_AUTO_IRIS_MODE
from .const import PROPERTY_BRIGHTNESS
from .const import PROPERTY_COLOR_MODE
from .const import PROPERTY_ERR
from .const import PROPERTY_ERR_CODE_MAP
from .const import PROPERTY_LAMP_HOURS
from .const import PROPERTY_MUTE
from .const import PROPERTY_POWER
Expand Down Expand Up @@ -69,6 +71,7 @@ def _parse_source_list(response):
PROPERTY_PARSER_MAP = {
PROPERTY_AUTO_IRIS_MODE: AUTO_IRIS_MODE_CODE_MAP.get,
PROPERTY_COLOR_MODE: COLOR_MODE_CODE_MAP.get,
PROPERTY_ERR: PROPERTY_ERR_CODE_MAP.get,
PROPERTY_LAMP_HOURS: int,
PROPERTY_BRIGHTNESS: int,
PROPERTY_MUTE: lambda v: v == ON,
Expand Down Expand Up @@ -280,7 +283,7 @@ async def _listen(self):
prop = response[0:key_value_separator_index]
value = response[key_value_separator_index + 1 :]
if prop == IMEVENT:
self._handle_imevent(value)
await self._handle_imevent(value)
continue

# Response from projector
Expand Down Expand Up @@ -319,11 +322,16 @@ def _handle_err(self):
if request and not request.future.done():
request.future.set_exception(ProjectorErrorResponse(error_message))

def _handle_imevent(self, value):
async def _handle_imevent(self, value):
# Event from projector
parts = value.split(" ")
_LOGGER.debug('_handle_imevent: imevent value="%s"', value)

warning_bitmask = hex_string_to_int(parts[2])
for bit, warning in IMEVENT_WARNING_BIT_MAP.items():
if (warning_bitmask & (1 << bit)) > 0:
_LOGGER.warning('_handle_imevent: imevent warning="%s"', warning)

power_code = hex_string_to_int(parts[1])
if power_code == IMEVENT_STATUS_CODE_ABNORMAL:
_LOGGER.error(
Expand All @@ -333,7 +341,7 @@ def _handle_imevent(self, value):
alarm_bitmask = hex_string_to_int(parts[3])
for bit, alarm in IMEVENT_ALARM_BIT_MAP.items():
if (alarm_bitmask & (1 << bit)) > 0:
_LOGGER.debug('_handle_imevent: imevent alarm="%s"', alarm)
_LOGGER.error('_handle_imevent: imevent alarm="%s"', alarm)
else:
power = IMEVENT_STATUS_CODE_TO_POWER_MAP.get(power_code)
if power is None:
Expand All @@ -343,11 +351,6 @@ def _handle_imevent(self, value):
else:
self._update_property(PROPERTY_POWER, power)

warning_bitmask = hex_string_to_int(parts[2])
for bit, warning in IMEVENT_WARNING_BIT_MAP.items():
if (warning_bitmask & (1 << bit)) > 0:
_LOGGER.debug('_handle_imevent: imevent warning="%s"', warning)

def _handle_property(self, prop, value):
_LOGGER.debug('_handle_property: prop=%s value="%s"', prop, value)
request = self._pop_request()
Expand Down

0 comments on commit 5afc052

Please sign in to comment.