Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
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
22 changes: 11 additions & 11 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ jobs:
# This prevent upcoming jobs to do the same individually
prepare-base:
name: Prepare base dependencies
runs-on: ubuntu-latest
runs-on: ubuntu-20.04
steps:
- name: Check out code from GitHub
uses: actions/checkout@v2
Expand Down Expand Up @@ -65,7 +65,7 @@ jobs:

lint-bandit:
name: Check bandit
runs-on: ubuntu-latest
runs-on: ubuntu-20.04
needs: prepare-base
steps:
- name: Check out code from GitHub
Expand Down Expand Up @@ -109,7 +109,7 @@ jobs:

lint-black:
name: Check black
runs-on: ubuntu-latest
runs-on: ubuntu-20.04
needs: prepare-base
steps:
- name: Check out code from GitHub
Expand Down Expand Up @@ -153,7 +153,7 @@ jobs:

lint-codespell:
name: Check codespell
runs-on: ubuntu-latest
runs-on: ubuntu-20.04
needs: prepare-base
steps:
- name: Check out code from GitHub
Expand Down Expand Up @@ -200,7 +200,7 @@ jobs:

lint-executable-shebangs:
name: Check executables
runs-on: ubuntu-latest
runs-on: ubuntu-20.04
needs: prepare-base
steps:
- name: Check out code from GitHub
Expand Down Expand Up @@ -247,7 +247,7 @@ jobs:

lint-flake8:
name: Check flake8
runs-on: ubuntu-latest
runs-on: ubuntu-20.04
needs: prepare-base
steps:
- name: Check out code from GitHub
Expand Down Expand Up @@ -294,7 +294,7 @@ jobs:

lint-isort:
name: Check isort
runs-on: ubuntu-latest
runs-on: ubuntu-20.04
needs: prepare-base
steps:
- name: Check out code from GitHub
Expand Down Expand Up @@ -338,7 +338,7 @@ jobs:

lint-json:
name: Check JSON
runs-on: ubuntu-latest
runs-on: ubuntu-20.04
needs: prepare-base
steps:
- name: Check out code from GitHub
Expand Down Expand Up @@ -385,7 +385,7 @@ jobs:

lint-pyupgrade:
name: Check pyupgrade
runs-on: ubuntu-latest
runs-on: ubuntu-20.04
needs: prepare-base
steps:
- name: Check out code from GitHub
Expand Down Expand Up @@ -429,7 +429,7 @@ jobs:

lint-yaml:
name: Check YAML
runs-on: ubuntu-latest
runs-on: ubuntu-20.04
needs: prepare-base
steps:
- name: Check out code from GitHub
Expand Down Expand Up @@ -475,7 +475,7 @@ jobs:
pre-commit run --hook-stage manual yamllint --all-files --show-diff-on-failure
pylint:
name: Check pylint
runs-on: ubuntu-latest
runs-on: ubuntu-20.04
steps:
- uses: actions/checkout@v2
- name: Set up python ${{ env.DEFAULT_PYTHON }}
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/codeql-analysis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ on:
jobs:
analyze:
name: Analyze
runs-on: ubuntu-latest
runs-on: ubuntu-20.04

strategy:
fail-fast: false
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/python-package.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ on:

jobs:
build:
runs-on: ubuntu-latest
runs-on: ubuntu-20.04
strategy:
matrix:
python-version: ["3.6", "3.7", "3.8", "3.9", "3.10"]
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/python-publish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ on:

jobs:
deploy:
runs-on: ubuntu-latest
runs-on: ubuntu-20.04

steps:
- uses: actions/checkout@v2
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/release_draft.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ on:

jobs:
update_release_draft:
runs-on: ubuntu-latest
runs-on: ubuntu-20.04
steps:
- uses: release-drafter/release-drafter@master
env:
Expand Down
4 changes: 2 additions & 2 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ repos:
- --skip="./.*,*.csv,*.json"
- --quiet-level=2
exclude_types: [csv, json]
- repo: https://gitlab.com/pycqa/flake8
- repo: https://github.com/pycqa/flake8
rev: 3.9.2
hooks:
- id: flake8
Expand All @@ -36,7 +36,7 @@ repos:
- --format=custom
- --configfile=tests/bandit.yaml
- repo: https://github.com/PyCQA/isort
rev: 5.10.1
rev: 5.12.0
hooks:
- id: isort
args: ["--profile", "black"]
Expand Down
5 changes: 2 additions & 3 deletions pyhiveapi/apyhiveapi/api/hive_async_api.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
"""Hive API Module."""
# pylint: skip-file
import json
import operator
from typing import Optional

import requests
Expand All @@ -10,7 +9,7 @@
from pyquery import PyQuery

from ..helper.const import HTTP_UNAUTHORIZED
from ..helper.hive_exceptions import FileInUse, NoApiToken, HiveApiError
from ..helper.hive_exceptions import FileInUse, HiveApiError, NoApiToken

urllib3.disable_warnings(urllib3.exceptions.InsecureRequestWarning)

Expand Down Expand Up @@ -89,7 +88,7 @@ async def request(
f"Something has gone wrong calling {url} - "
f"HTTP status is - {resp.status}"
)

raise HiveApiError

def getLoginInfo(self):
Expand Down
2 changes: 1 addition & 1 deletion pyhiveapi/apyhiveapi/api/hive_auth_async.py
Original file line number Diff line number Diff line change
Expand Up @@ -537,7 +537,7 @@ async def refresh_token(self, token):
if self.client is None:
await self.async_init()
result = None
auth_params = ({"REFRESH_TOKEN": token},)
auth_params = {"REFRESH_TOKEN": token}
if self.device_key is not None:
auth_params = {
"REFRESH_TOKEN": token,
Expand Down
2 changes: 2 additions & 0 deletions pyhiveapi/apyhiveapi/helper/const.py
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,7 @@
"DOG_BARK": "self.session.hub.getDogBarkStatus(device)",
"GLASS_BREAK": "self.session.hub.getGlassBreakStatus(device)",
"Camera_Temp": "self.session.camera.getCameraTemperature(device)",
"Current_Temperature": "self.session.heating.getCurrentTemperature(device)",
"Heating_Current_Temperature": "self.session.heating.getCurrentTemperature(device)",
"Heating_Target_Temperature": "self.session.heating.getTargetTemperature(device)",
"Heating_State": "self.session.heating.getState(device)",
Expand Down Expand Up @@ -133,6 +134,7 @@
# ],
"motionsensor": [
'addList("binary_sensor", p)',
'addList("sensor", p, haName=" Current Temperature", hiveType="Current_Temperature", category="diagnostic")',
],
"contactsensor": ['addList("binary_sensor", p)'],
}
Expand Down
17 changes: 10 additions & 7 deletions pyhiveapi/apyhiveapi/session.py
Original file line number Diff line number Diff line change
Expand Up @@ -166,7 +166,7 @@ async def updateInterval(self, new_interval: timedelta):
Args:
new_interval (int): New interval for polling.
"""
if type(new_interval) == int:
if isinstance(new_interval, int):
new_interval = timedelta(seconds=new_interval)

interval = new_interval
Expand Down Expand Up @@ -371,11 +371,10 @@ async def getCamera(self, device):
cameraRecording = self.openFile("camera.json")
elif self.tokens is not None:
cameraImage = await self.api.getCameraImage(device)
hasCameraRecording = bool(["parsed"]["events"][0]["hasRecording"])
if (
cameraImage["parsed"]["events"][0]["hasRecording"] is True
and hasCameraRecording
):
hasCameraRecording = bool(
cameraImage["parsed"]["events"][0]["hasRecording"]
)
if hasCameraRecording:
cameraRecording = await self.api.getCameraRecording(
device, cameraImage["parsed"]["events"][0]["eventId"]
)
Expand Down Expand Up @@ -529,7 +528,11 @@ async def createDevices(self):
p = self.data.products[aProduct]
if "error" in p:
continue
if p.get("isGroup", False):
# Only consider single items or heating groups
if (
p.get("isGroup", False)
and self.data.products[aProduct]["type"] not in HIVE_TYPES["Heating"]
):
continue
product_list = PRODUCTS.get(self.data.products[aProduct]["type"], [])
for code in product_list:
Expand Down