Skip to content

Update creating projector instance - #40

Open
mvdwetering wants to merge 8 commits into
pszafer:devfrom
mvdwetering:update_creating_projector_instance
Open

mvdwetering wants to merge 8 commits into
pszafer:devfrom
mvdwetering:update_creating_projector_instance

Conversation

@mvdwetering

@mvdwetering mvdwetering commented Jun 7, 2026

Copy link
Copy Markdown
Collaborator

The construction of the Projector class got more complicated with adding the password support. For HTTP it needed to be setup manually in the websession outside of Projector, for TCP there was a tcp_password option. So there were different sets of parameters needed for each type.

I reworked the construction of the Projector class so now it takes a connection. Each connection only takes the parameters it needs so it is clear what is needed for which one.

I added helper factorymethods to keep things simple for users of the package. They just call the helper and get a Projector.

Examples of typical calls

projector = epson.Projector.create_http(host=HOSTNAME, password=PASSWORD_IF_NEEDED)
projector = epson.Projector.create_tcp(host=HOSTNAME, password=PASSWORD_IF_NEEDED)
projector = epson.Projector.create_serial(url=SERIAL_X_URL)

I ended up moving the websession into ProjectorHttp() see 757753e. Setting it up in the helper seemed a bit clumsy and in general having to setup the websession manually outside for the password seems weird. This package should make it easy to connect to a projector and manually managing the authentication on the websession is not easy.
However it does mean that for ProjectorHttp now also projector.close() needs to be called to close the now internal websession. Which makes it more consistent that close is needed for all.

There is also a small change to close() as it has become async to allow awaiting the closing of the session and also needed to properly await closes on the other protocols

@mvdwetering

Copy link
Copy Markdown
Collaborator Author

@pszafer I have been making some updates recently that were all backward compatible, so I felt comfortable merging them. This however is a breaking change. I would like your input on this.

@pszafer

pszafer commented Jun 18, 2026

Copy link
Copy Markdown
Owner

Hi, nice changes!
I have a question though. Why use staticmethod? Wouldn't be better to use @classmethod ?

and use future annotations for nicer typehint syntax
@mvdwetering
mvdwetering force-pushed the update_creating_projector_instance branch from f101080 to 3ba966d Compare June 20, 2026 14:34
@mvdwetering
mvdwetering force-pushed the update_creating_projector_instance branch from 3ba966d to fde38d9 Compare June 20, 2026 14:49
@mvdwetering

Copy link
Copy Markdown
Collaborator Author

Not sure why it was a staticmethod, probably because in C++ those would be static 😅

Changed it to a classmethod.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants