示例#1
0
    async def async_update(self):
        """Update state of device."""
        from epson_projector.const import (
            EPSON_CODES,
            POWER,
            CMODE,
            CMODE_LIST,
            SOURCE,
            VOLUME,
            BUSY,
            SOURCE_LIST,
        )

        is_turned_on = await self._projector.get_property(POWER)
        _LOGGER.debug("Project turn on/off status: %s", is_turned_on)
        if is_turned_on and is_turned_on == EPSON_CODES[POWER]:
            self._state = STATE_ON
            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 is_turned_on == BUSY:
            self._state = STATE_ON
        else:
            self._state = STATE_OFF
 async def async_update(self):
     """Update state of device."""
     from epson_projector.const import (
         EPSON_CODES, POWER, CMODE, CMODE_LIST, SOURCE, VOLUME, BUSY,
         SOURCE_LIST)
     is_turned_on = await self._projector.get_property(POWER)
     _LOGGER.debug("Project turn on/off status: %s", is_turned_on)
     if is_turned_on and is_turned_on == EPSON_CODES[POWER]:
         self._state = STATE_ON
         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 is_turned_on == BUSY:
         self._state = STATE_ON
     else:
         self._state = STATE_OFF
 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
示例#4
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