Skip to content

Added a switch to control beamers from acer#1913

Merged
balloob merged 1 commit intohome-assistant:devfrom
deisi:beamer
May 4, 2016
Merged

Added a switch to control beamers from acer#1913
balloob merged 1 commit intohome-assistant:devfrom
deisi:beamer

Conversation

@deisi
Copy link
Copy Markdown
Contributor

@deisi deisi commented Apr 25, 2016

Description:
Allows to control a RS232 connected projectors from acer.

Almost all Projectors from Acer have a serial RS232 interface and can be controlled via it. This switch component allows to determine the state of the projector and to turn it on or off. It further reads the Lamp Hours, Input Source and if possible the state of the ECO Mode as attributes.

Example entry for configuration.yaml (if applicable):

switch:
  platform: acer_projector
  # pipe the projector is connected to
  filename: /dev/ttyUSB0
  # optional 
  name: Projector
  # optional in seconds
  timeout: 1
  # optional in seconds
  write_timeout: 1

I would totally understand if you say that this PR can not be merged because a projector is not a switch.
Up to now I have not introduced a new device class to HA and using a switch was the easiest. What is the general opinion on this?

Checklist:

If code communicates with devices:

  • Local tests with tox run successfully. Your PR cannot be merged unless tests pass
  • New dependencies have been added to the REQUIREMENTS variable (example).
  • New dependencies are only imported inside functions that use them (example).
  • New dependencies have been added to requirements_all.txt by running script/gen_requirements_all.py.
  • New files were added to .coveragerc.

If the code does not interact with devices:

  • Local tests with tox run successfully. Your PR cannot be merged unless tests pass
  • Tests have been added to verify that the new code works.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

PySerial 3 introduced a new API. Are you sure that your component works if you are using PySerial 2 or do you need to restrict the version ?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I have only tested version3. I guess ist best if I just restrict the version.

@deisi
Copy link
Copy Markdown
Contributor Author

deisi commented May 1, 2016

Changed beamer to projector and limited the pyserial version to be >= 3.0.

@deisi
Copy link
Copy Markdown
Contributor Author

deisi commented May 1, 2016

Okay, Currently it doesnt work with these REQUIREMENTS. I get

ERROR:homeassistant.components.switch:Error while setting up platform acer_projector
Traceback (most recent call last):
  File "/home/malte/home-assistant/homeassistant/helpers/entity_component.py", line 94, in _setup_platform
    discovery_info)
  File "/home/malte/home-assistant/homeassistant/components/switch/acer_projector.py", line 49, in setup_platform
    devices.append(AcerSwitch(serial_port, name, timeout, write_timeout))
  File "/home/malte/home-assistant/homeassistant/components/switch/acer_projector.py", line 62, in __init__
    write_timeout=write_timeout)
  File "/home/malte/.homeassistant/deps/serial/serialutil.py", line 180, in __init__
    self.open()
  File "/home/malte/.homeassistant/deps/serial/serialposix.py", line 311, in open
    self._update_dtr_state()
  File "/home/malte/.homeassistant/deps/serial/serialposix.py", line 605, in _update_dtr_state
    fcntl.ioctl(self.fd, TIOCMBIS, TIOCM_DTR_str)
OSError: [Errno 22] Invalid argument

But I don't get why. In an interactive session it works.

@deisi
Copy link
Copy Markdown
Contributor Author

deisi commented May 1, 2016

So the problem is, with:

REQUIREMENTS = ['pyserial']

it works. I use pyserial from arch linux repo witch is: python-pyserial 3.0.1.
With REQUIREMENTS = ['pyserial==3.0.1'] HA installes something into /home/malte/.homeassistant/deps/ and things go wrong.

@balloob
Copy link
Copy Markdown
Member

balloob commented May 2, 2016

Well that's Home Assistant installing the version from pypi.

Since PySerial changed their API, you need to filter out the versions that do not support the API that you are using.

@deisi
Copy link
Copy Markdown
Contributor Author

deisi commented May 2, 2016

Ah Okay, I will test what version works ASAP.

On 02.05.2016 08:04, Paulus Schoutsen wrote:

Well that's Home Assistant installing the version from pypi.

Since PySerial changed their API, you need to filter out the versions
that do not support the API that you are using.


You are receiving this because you authored the thread.
Reply to this email directly or view it on GitHub
#1913 (comment)

@MartinHjelmare
Copy link
Copy Markdown
Member

The stacktrace your seeing is similar to rgis reported bug in pyserial:
pyserial/pyserial#59

A fix has been merged in master but there's no new release yet.

This is the same problem as reported in:
#868

@deisi
Copy link
Copy Markdown
Contributor Author

deisi commented May 3, 2016

I see. I will try with pyserial 2.7 then. Lets see what version works.
Thanks for the Info.

On 02.05.2016 10:50, Martin Hjelmare wrote:

The stacktrace your seeing is similar to rgis reported bug in pyserial:
pyserial/pyserial#59 pyserial/pyserial#59

A fix has been merged in master but there's no new release yet.

This is the same problem as reported in:
#868 #868


You are receiving this because you authored the thread.
Reply to this email directly or view it on GitHub
#1913 (comment)

@balloob balloob merged commit b2abe55 into home-assistant:dev May 4, 2016
@home-assistant home-assistant locked and limited conversation to collaborators Mar 17, 2017
@deisi deisi deleted the beamer branch May 22, 2017 18:40
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants