def __init__(self, projector, name, unique_id):
     """Initialize entity to control Epson projector."""
     self._name = name
     self._projector = projector
     self._available = False
     self._cmode = None
     self._source_list = list(DEFAULT_SOURCES.values())
     self._source = None
     self._volume = None
     self._state = None
     self._unique_id = unique_id
 def __init__(self, websession, name, host, port, encryption):
     """Initialize entity to control Epson projector."""
     self._name = name
     self._projector = epson.Projector(host,
                                       websession=websession,
                                       port=port)
     self._cmode = None
     self._source_list = list(DEFAULT_SOURCES.values())
     self._source = None
     self._volume = None
     self._state = None
    def __init__(self, websession, name, host, port, encryption):
        """Initialize entity to control Epson projector."""
        import epson_projector as epson
        from epson_projector.const import DEFAULT_SOURCES

        self._name = name
        self._projector = epson.Projector(
            host, websession=websession, port=port)
        self._cmode = None
        self._source_list = list(DEFAULT_SOURCES.values())
        self._source = None
        self._volume = None
        self._state = None
示例#4
0
 def __init__(
     self, projector: Projector, name: str, unique_id: str | None, entry: ConfigEntry
 ) -> None:
     """Initialize entity to control Epson projector."""
     self._projector = projector
     self._entry = entry
     self._attr_name = name
     self._attr_available = False
     self._cmode = None
     self._attr_source_list = list(DEFAULT_SOURCES.values())
     self._attr_unique_id = unique_id
     if unique_id:
         self._attr_device_info = DeviceInfo(
             identifiers={(DOMAIN, unique_id)},
             manufacturer="Epson",
             model="Epson",
             name="Epson projector",
             via_device=(DOMAIN, unique_id),
         )
 async def async_update(self):
     """Update state of device."""
     power_state = await self._projector.get_power()
     _LOGGER.debug("Projector status: %s", power_state)
     if not power_state or power_state == EPSON_STATE_UNAVAILABLE:
         self._available = False
         return
     self._available = True
     if power_state == EPSON_CODES[POWER]:
         self._state = STATE_ON
         self._source_list = list(DEFAULT_SOURCES.values())
         cmode = await self._projector.get_property(CMODE)
         self._cmode = CMODE_LIST.get(cmode, self._cmode)
         source = await self._projector.get_property(SOURCE)
         self._source = SOURCE_LIST.get(source, self._source)
         volume = await self._projector.get_property(VOLUME)
         if volume:
             self._volume = volume
     elif power_state == BUSY:
         self._state = STATE_ON
     else:
         self._state = STATE_OFF
示例#6
0
 async def async_update(self) -> None:
     """Update state of device."""
     power_state = await self._projector.get_power()
     _LOGGER.debug("Projector status: %s", power_state)
     if not power_state or power_state == EPSON_STATE_UNAVAILABLE:
         self._attr_available = False
         return
     self._attr_available = True
     if power_state == EPSON_CODES[POWER]:
         self._attr_state = STATE_ON
         if await self.set_unique_id():
             return
         self._attr_source_list = list(DEFAULT_SOURCES.values())
         cmode = await self._projector.get_property(CMODE)
         self._cmode = CMODE_LIST.get(cmode, self._cmode)
         source = await self._projector.get_property(SOURCE)
         self._attr_source = SOURCE_LIST.get(source, self._attr_source)
         if volume := await self._projector.get_property(VOLUME):
             try:
                 self._attr_volume_level = float(volume)
             except ValueError:
                 self._attr_volume_level = None