ABC consistent not implemented behavior (#2359)

This commit is contained in:
Paulus Schoutsen 2016-06-24 21:27:40 -07:00 committed by GitHub
parent c616115419
commit 68df3deee0
22 changed files with 56 additions and 41 deletions

View file

@ -4,7 +4,6 @@ Use serial protocol of acer projector to obtain state of the projector.
This component allows to control almost all projectors from acer using
their RS232 serial communication protocol.
"""
import logging
import re
@ -61,7 +60,8 @@ class AcerSwitch(SwitchDevice):
write_timeout=write_timeout, **kwargs)
self._serial_port = serial_port
self._name = name
self._state = STATE_UNKNOWN
self._state = False
self._available = False
self._attributes = {
LAMP_HOURS: STATE_UNKNOWN,
INPUT_SOURCE: STATE_UNKNOWN,
@ -100,14 +100,19 @@ class AcerSwitch(SwitchDevice):
return match.group(1)
return STATE_UNKNOWN
@property
def available(self):
"""Return if projector is available."""
return self._available
@property
def name(self):
"""Return name of the projector."""
return self._name
@property
def state(self):
"""Return the current state of the projector."""
def is_on(self):
"""Return if the projector is turned on."""
return self._state
@property
@ -120,11 +125,13 @@ class AcerSwitch(SwitchDevice):
msg = CMD_DICT[LAMP]
awns = self._write_read_format(msg)
if awns == 'Lamp 1':
self._state = STATE_ON
self._state = True
self._available = True
elif awns == 'Lamp 0':
self._state = STATE_OFF
self._state = False
self._available = True
else:
self._state = STATE_UNKNOWN
self._available = False
for key in self._attributes.keys():
msg = CMD_DICT.get(key, None)