Skip to content

Update Vivotek component stream source#27941

Merged
MartinHjelmare merged 3 commits into
home-assistant:devfrom
HarlemSquirrel:vivotek-20191019
Nov 4, 2019
Merged

Update Vivotek component stream source#27941
MartinHjelmare merged 3 commits into
home-assistant:devfrom
HarlemSquirrel:vivotek-20191019

Conversation

@HarlemSquirrel
Copy link
Copy Markdown
Contributor

@HarlemSquirrel HarlemSquirrel commented Oct 19, 2019

Description:

  • Fix building stream URL
  • Add new stream_path configuration option

Related issue (if applicable): fixes #26942

Pull request with documentation for home-assistant.io (if applicable): home-assistant/home-assistant.io#10899

Checklist:

  • The code change is tested and works locally.
  • Local tests pass with tox. Your PR cannot be merged unless tests pass
  • There is no commented out code in this PR.
  • I have followed the development checklist

If user exposed functionality or configuration variables are added/changed:

If the code communicates with devices, web services, or third-party tools:

  • The manifest file has all fields filled out correctly. Update and include derived files by running python3 -m script.hassfest.
  • New or updated dependencies have been added to requirements_all.txt by running python3 -m script.gen_requirements_all.
  • Untested files have been added to .coveragerc.

@HarlemSquirrel HarlemSquirrel changed the title WIP Update Vivotek component stream source Update Vivotek component stream source Oct 21, 2019
Fix building stream URL
Make stream path optionally configurable.
Comment on lines +56 to +62
"rtsp://%s:%s@%s:554/%s"
% (
config[CONF_USERNAME],
config[CONF_PASSWORD],
config[CONF_IP_ADDRESS],
config[CONF_STREAM_PATH],
)
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Why not actually use f-strings here?

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 am pretty new to Python so I was not aware of f-strings. I just read through https://realpython.com/python-f-strings/ and they look pretty cool! The article did say they were introduced in Python 3.6 so as long as we don't need this code to work in < 3.6 I am happy to make the change.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

We dropped support for python <3.6, so f-strings are fine.

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.

Updated

Copy link
Copy Markdown
Contributor

@cgtobi cgtobi left a comment

Choose a reason for hiding this comment

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

LGTM

Use f-string to build stream source URL.
This improve readability and I hear it runs faster.
Copy link
Copy Markdown
Contributor

@cgtobi cgtobi left a comment

Choose a reason for hiding this comment

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

LGTM

vol.Optional(CONF_SSL, default=False): cv.boolean,
vol.Optional(CONF_VERIFY_SSL, default=True): cv.boolean,
vol.Optional(CONF_FRAMERATE, default=2): cv.positive_int,
vol.Optional(CONF_STREAM_PATH, default=DEFAULT_STREAM_SOURCE): cv.string,
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.

Is it impossible to detect this automatically?

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.

This allows choosing a different stream path mostly to allow using a different encoding. I don't see a clear standard for this at the moment so that's why it's open-ended here.

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.

Ok.

@MartinHjelmare MartinHjelmare merged commit cb2f42b into home-assistant:dev Nov 4, 2019
@lock lock Bot locked and limited conversation to collaborators Nov 5, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

New Vivotek Component/Integration - No Video

4 participants