Skip to content

Commit

Permalink
V1.1.0 (#60)
Browse files Browse the repository at this point in the history
* Set the next dev version number: 1.0.4-dev

* Include python 3.9 in tests

* Use a static python version when linting

No need for matrix support over all python version when linting.

* Fix lint.yml indent

* Update index.rst

* Include codeql-analysis

* style: fixing some code smells

* Update tox.ini

* Update test.yml

* add valve support

* fix program string

* roll back to what worked

try readd python 3.6

Revert "update formatting"

This reverts commit 5b4ec91.

update formatting

* remove python 3.6

* try to make black happy

* build: update supported python versions

* build: quote python test versions

* chore: readd removed blank line

* docs: add all-contributors config

* docs: add all-contributors config

* docs: update README.md [skip ci]

* docs: create .all-contributorsrc [skip ci]

* update tests

* Update publish.yml

* Update publish_test.yml

* Update publish_test.yml

* Update setup.cfg

* Update setup.py

* Delete setup.cfg

* Update setup.py

* Update publish.yml

* Update setup.py with new version number

* Update setup.py version number

---------

Co-authored-by: Brian Rogers <[email protected]>
Co-authored-by: allcontributors[bot] <46447321+allcontributors[bot]@users.noreply.github.com>
  • Loading branch information
3 people authored Jan 3, 2024
1 parent e078d33 commit 7f3c210
Show file tree
Hide file tree
Showing 27 changed files with 871 additions and 59 deletions.
28 changes: 28 additions & 0 deletions .all-contributorsrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
{
"files": [
"README.md"
],
"imageSize": 100,
"commit": false,
"commitType": "docs",
"commitConvention": "angular",
"contributors": [
{
"login": "brg468",
"name": "Brian Rogers",
"avatar_url": "https://avatars.githubusercontent.com/u/19143191?v=4",
"profile": "https://github.com/brg468",
"contributions": [
"code",
"doc",
"test"
]
}
],
"contributorsPerLine": 7,
"skipCi": true,
"repoType": "github",
"repoHost": "https://github.com",
"projectName": "rachiopy",
"projectOwner": "rfverbruggen"
}
4 changes: 4 additions & 0 deletions .all-contributorsrc.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
{
"projectName": "rachiopy",
"projectOwner": "rfverbruggen"
}
71 changes: 71 additions & 0 deletions .github/workflows/codeql-analysis.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,71 @@
# For most projects, this workflow file will not need changing; you simply need
# to commit it to your repository.
#
# You may wish to alter this file to override the set of languages analyzed,
# or to provide custom queries or build logic.
#
# ******** NOTE ********
# We have attempted to detect the languages in your repository. Please check
# the `language` matrix defined below to confirm you have the correct set of
# supported CodeQL languages.
#
name: "CodeQL"

on:
push:
branches: [ dev, master ]
pull_request:
# The branches below must be a subset of the branches above
branches: [ dev ]
schedule:
- cron: '28 6 * * 6'

jobs:
analyze:
name: Analyze
runs-on: ubuntu-latest
permissions:
actions: read
contents: read
security-events: write

strategy:
fail-fast: false
matrix:
language: [ 'python' ]
# CodeQL supports [ 'cpp', 'csharp', 'go', 'java', 'javascript', 'python' ]
# Learn more:
# https://docs.github.com/en/free-pro-team@latest/github/finding-security-vulnerabilities-and-errors-in-your-code/configuring-code-scanning#changing-the-languages-that-are-analyzed

steps:
- name: Checkout repository
uses: actions/checkout@v2

# Initializes the CodeQL tools for scanning.
- name: Initialize CodeQL
uses: github/codeql-action/init@v1
with:
languages: ${{ matrix.language }}
# If you wish to specify custom queries, you can do so here or in a config file.
# By default, queries listed here will override any specified in a config file.
# Prefix the list here with "+" to use these queries and those in the config file.
# queries: ./path/to/local/query, your-org/your-repo/queries@main

# Autobuild attempts to build any compiled languages (C/C++, C#, or Java).
# If this step fails, then you should remove it and run the build manually (see below)
- name: Autobuild
uses: github/codeql-action/autobuild@v1

# ℹ️ Command-line programs to run using the OS shell.
# 📚 https://git.io/JvXDl

# ✏️ If the Autobuild fails above, remove it and uncomment the following three lines
# and modify them (or add more) to build your code if your project
# uses a compiled language

#- run: |
# make bootstrap
# make release

- name: Perform CodeQL Analysis
uses: github/codeql-action/analyze@v1
10 changes: 3 additions & 7 deletions .github/workflows/lint.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,18 +6,14 @@ jobs:
# The type of runner that the job will run on
runs-on: ubuntu-latest

strategy:
matrix:
python-version: [3.6, 3.7, 3.8]

# Steps represent a sequence of tasks that will be executed as part of the job
steps:
# Checks-out your repository under $GITHUB_WORKSPACE, so your job can access it
- uses: actions/checkout@v2
- name: Set up Python ${{ matrix.python-version }}
- name: Set up Python 3.x
uses: actions/setup-python@v2
with:
python-version: ${{ matrix.python-version }}
python-version: 3.x
- name: Install dependencies
run: |
python -m pip install --upgrade pip
Expand All @@ -28,4 +24,4 @@ jobs:
- name: Run flake8
run: flake8
- name: Run pydocstyle
run: pydocstyle {posargs:rachiopy tests}
run: pydocstyle {posargs:rachiopy tests}
22 changes: 12 additions & 10 deletions .github/workflows/publish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,18 @@ on:
jobs:
build-n-publish:
name: Build and publish Python distributions to PyPI
runs-on: ubuntu-18.04
runs-on: ubuntu-latest
environment:
name: pypi
url: https://pypi.org/project/RachioPy
permissions:
id-token: write # IMPORTANT: this permission is mandatory for trusted publishing
steps:
- uses: actions/checkout@master
- name: Set up Python 3.8
uses: actions/setup-python@v1
- name: Set up Python 3.x
uses: actions/setup-python@v2
with:
python-version: 3.8
python-version: 3.x
- name: Install dependencies
run: |
python -m pip install --upgrade pip setuptools wheel
Expand All @@ -25,12 +30,9 @@ jobs:
run: python setup.py sdist bdist_wheel
- name: Publish distribution to Test PyPI
if: startsWith(github.ref, 'refs/tags')
uses: pypa/gh-action-pypi-publish@master
uses: pypa/gh-action-pypi-publish@release/v1
with:
password: ${{ secrets.test_pypi_password }}
repository_url: https://test.pypi.org/legacy/
repository-url: https://test.pypi.org/legacy/
- name: Publish distribution to PyPI
if: startsWith(github.ref, 'refs/tags')
uses: pypa/gh-action-pypi-publish@master
with:
password: ${{ secrets.pypi_password }}
uses: pypa/gh-action-pypi-publish@release/v1
20 changes: 12 additions & 8 deletions .github/workflows/publish_test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,13 +8,18 @@ on:
jobs:
build-n-publish:
name: Build and publish Python distributions to Test PyPI
runs-on: ubuntu-18.04
runs-on: ubuntu-latest
environment:
name: pypi
url: https://test.pypi.org/project/RachioPy
permissions:
id-token: write # IMPORTANT: this permission is mandatory for trusted publishing
steps:
- uses: actions/checkout@master
- name: Set up Python 3.8
uses: actions/setup-python@v1
- name: Set up Python 3.x
uses: actions/setup-python@v2
with:
python-version: 3.8
python-version: 3.x
- name: Install dependencies
run: |
python -m pip install --upgrade pip setuptools wheel
Expand All @@ -24,8 +29,7 @@ jobs:
run: python -m unittest discover -v tests
- name: Build distribution
run: python setup.py sdist bdist_wheel
- name: Publish distribution to Test PyPI
uses: pypa/gh-action-pypi-publish@master
- name: Publish package distributions to TestPyPI
uses: pypa/gh-action-pypi-publish@release/v1
with:
password: ${{ secrets.test_pypi_password }}
repository_url: https://test.pypi.org/legacy/
repository-url: https://test.pypi.org/legacy/
4 changes: 2 additions & 2 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ jobs:

strategy:
matrix:
python-version: [3.6, 3.7, 3.8]
python-version: ['3.8', '3.9', '3.10', '3.11', '3.12']

# Steps represent a sequence of tasks that will be executed as part of the job
steps:
Expand All @@ -24,4 +24,4 @@ jobs:
if [ -f requirements.txt ]; then pip install -r requirements.txt; fi
if [ -f requirements_test.txt ]; then pip install -r requirements_test.txt; fi
- name: Run unittests
run: python -m unittest discover -v tests
run: python -m unittest discover -v tests
36 changes: 32 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,9 +1,12 @@
Rachiopy
========
# Rachiopy
<!-- ALL-CONTRIBUTORS-BADGE:START - Do not remove or modify this section -->
[![All Contributors](https://img.shields.io/badge/all_contributors-1-orange.svg?style=flat-square)](#contributors-)
<!-- ALL-CONTRIBUTORS-BADGE:END -->

This python package provides a interface to the Rachio public API.

Usage
-----
## Usage

```python
from rachiopy import Rachio

Expand All @@ -13,3 +16,28 @@ r.person.info()
```

For the complete documentation visit [read the docs](https://rachiopy.readthedocs.io/en/latest/).

## Contributors

<!-- ALL-CONTRIBUTORS-LIST:START - Do not remove or modify this section -->
<!-- prettier-ignore-start -->
<!-- markdownlint-disable -->
<table>
<tbody>
<tr>
<td align="center" valign="top" width="14.28%"><a href="https://github.com/brg468"><img src="https://avatars.githubusercontent.com/u/19143191?v=4?s=100" width="100px;" alt="Brian Rogers"/><br /><sub><b>Brian Rogers</b></sub></a><br /><a href="https://github.com/rfverbruggen/rachiopy/commits?author=brg468" title="Code">💻</a> <a href="https://github.com/rfverbruggen/rachiopy/commits?author=brg468" title="Documentation">📖</a> <a href="https://github.com/rfverbruggen/rachiopy/commits?author=brg468" title="Tests">⚠️</a></td>
</tr>
</tbody>
</table>

<!-- markdownlint-restore -->
<!-- prettier-ignore-end -->

<!-- ALL-CONTRIBUTORS-LIST:END -->
<!-- prettier-ignore-start -->
<!-- markdownlint-disable -->

<!-- markdownlint-restore -->
<!-- prettier-ignore-end -->

<!-- ALL-CONTRIBUTORS-LIST:END -->
2 changes: 1 addition & 1 deletion docs/index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ Getting Started
from rachiopy import Rachio
r = Rachio("8e600a4c-0027-4a9a-9bda-dc8d5c90350d")
resp, content = r.person.getInfo()
resp, content = r.person.info()
print (resp["status"])
print (content["id"])
Expand Down
7 changes: 7 additions & 0 deletions rachiopy/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,15 @@
from rachiopy.notification import Notification
from rachiopy.schedulerule import Schedulerule
from rachiopy.zone import Zone
from rachiopy.valve import Valve
from rachiopy.summary import SummaryServce
from rachiopy.program import Program


class Rachio(RachioObject):
"""Object representing the Rachio API."""

# pylint: disable=too-many-instance-attributes
def __init__(self, authtoken: str):
"""Initialze the Rachio API wrapper.
Expand All @@ -25,3 +29,6 @@ def __init__(self, authtoken: str):
self.notification = Notification(authtoken)
self.schedulerule = Schedulerule(authtoken)
self.zone = Zone(authtoken)
self.valve = Valve(authtoken)
self.summary = SummaryServce(authtoken)
self.program = Program(authtoken)
86 changes: 86 additions & 0 deletions rachiopy/program.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,86 @@
"""Program module for the smart hose timer."""

from rachiopy.rachioobject import RachioObject


class Program(RachioObject):
"""Program class for the smart hose timer."""

def list_programs(self, valve_id: str):
"""Retreive the list of programs (schedules) for a valve.
For more info of the content in the response see:
https://rachio.readme.io/docs/programservice_listprograms
:param valve_id: Valve's unique id
:type valve_id: str
:return: The return value is a tuple of (response, content), the first
being and instance of the httplib2.Response class, the second
being a string that contains the response entity body.
:rtype: tuple
"""
path = f"program/listPrograms/{valve_id}"
return self.valve_get_request(path)

def get_program(self, program_id: str):
"""Retreive the information for a specific program.
For more info of the content in the response see:
https://rachio.readme.io/docs/programservice_getprogram
:param program_id: Program's unique id
:type program_id: str
:return: The return value is a tuple of (response, content), the first
being and instance of the httplib2.Response class, the second
being a string that contains the response entity body (Python
object if it contains JSON).
:rtype: tuple
"""
path = f"program/getProgram/{program_id}"
return self.valve_get_request(path)

def create_skip_overrides(self, program_id: str, timestamp: str):
"""Create manual skips for the specific program run time.
You can retrieve the runtimes from SummaryService.getValveDayViews
For more info of the content in the response see:
https://rachio.readme.io/docs/programservice_createskipoverrides
:param program_id: Program's unique id
:type program_id: str
:param timestamp: Timestamp of the run to skip
:type timestamp: timestamp
:return: The return value is a tuple of (response, content), the first
being and instance of the httplib2.Response class, the second
being a string that contains the response entity body (Python
object if it contains JSON).
:rtype: tuple
"""
payload = {"programId": program_id, "timestamp": timestamp}
return self.valve_post_request("program/createSkipOverrides", payload)

def delete_skip_overrides(self, program_id: str, timestamp: str):
"""Cancel program skips for the specified program run time.
You can retrieve upcoming skips from SummaryService.getValveDayViews
For more info of the content in the response see:
https://rachio.readme.io/docs/programservice_deleteskipoverrides
:param program_id: Program's unique id
:type program_id: str
:param timestamp: Timestamp of the run skip to delete
:type timestamp: timestamp
:return: The return value is a tuple of (response, content), the first
being and instance of the httplib2.Response class, the second
being a string that contains the response entity body (Python
object if it contains JSON).
:rtype: tuple
"""
payload = {"programId": program_id, "timestamp": timestamp}
return self.valve_post_request("program/deleteSkipOverrides", payload)
Loading

0 comments on commit 7f3c210

Please sign in to comment.