Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat/device-output-cli #12

Merged
merged 4 commits into from
Mar 30, 2023
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Next Next commit
Switched to typer
  • Loading branch information
Jelloeater committed Mar 30, 2023
commit e68a8484879d84243eb829a5a257702ed2bc528a
28 changes: 28 additions & 0 deletions hubitatcontrol/__main__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
import typer
from hubitatcontrol import get_hub


def print_device_list_types():
import os

from dotenv import load_dotenv

envs = load_dotenv()
if envs:
host_env = os.getenv("HUBITAT_HOST")
token_env = os.getenv("HUBITAT_API_TOKEN")
app_id_env = os.getenv("HUBITAT_API_APP_ID")
h = get_hub(host=host_env, token=token_env, app_id=app_id_env)
else:
h = hub_creds()
for i in h.devices:
d = h.get_device(i)
# TODO Need to finish device type output


def hub_creds(host_env, token_env, app_id_env):
return get_hub(host=host_env, token=token_env, app_id=app_id_env)


if __name__ == "__main__":
typer.run(print_device_list_types)
27 changes: 24 additions & 3 deletions poetry.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ classifiers = ["Development Status :: 5 - Production/Stable",
[tool.poetry.dependencies]
python = "^3.10"
requests = "*"
typer = "*"

[tool.pytest.ini_options]
pythonpath = ["."]
Expand Down
6 changes: 6 additions & 0 deletions tests/test_main.py
Original file line number Diff line number Diff line change
Expand Up @@ -104,3 +104,9 @@ def test_set_color_map():
assert test_bulb.level == level
assert test_bulb.hue == hue
assert test_bulb.saturation == saturation


def test_cli():
from hubitatcontrol.__main__ import print_device_list_types

print_device_list_types()