From b1b3459a999b7950e9347d384909c98fdb63d846 Mon Sep 17 00:00:00 2001 From: Andrey Khrolenok Date: Tue, 28 Apr 2020 02:12:18 +0300 Subject: [PATCH 1/3] Fix dev-setup.sh and add Idea config --- .gitignore | 76 ++++++++++++++++++- .idea/ha-iaquk.iml | 11 +++ .../inspectionProfiles/profiles_settings.xml | 6 ++ .idea/misc.xml | 7 ++ .idea/modules.xml | 8 ++ .idea/vcs.xml | 6 ++ .pre-commit-config.yaml | 2 +- dev-setup.sh | 6 +- 8 files changed, 117 insertions(+), 5 deletions(-) create mode 100644 .idea/ha-iaquk.iml create mode 100644 .idea/inspectionProfiles/profiles_settings.xml create mode 100644 .idea/misc.xml create mode 100644 .idea/modules.xml create mode 100644 .idea/vcs.xml diff --git a/.gitignore b/.gitignore index 96a250c..92b9467 100644 --- a/.gitignore +++ b/.gitignore @@ -1,5 +1,3 @@ -/.idea/ - # Byte-compiled / optimized / DLL files __pycache__/ *.py[cod] @@ -107,3 +105,77 @@ venv.bak/ /test*.py /dev-config + + + +# Covers JetBrains IDEs: IntelliJ, RubyMine, PhpStorm, AppCode, PyCharm, CLion, Android Studio, WebStorm and Rider +# Reference: https://intellij-support.jetbrains.com/hc/en-us/articles/206544839 + +# User-specific stuff +.idea/**/workspace.xml +.idea/**/tasks.xml +.idea/**/usage.statistics.xml +.idea/**/dictionaries +.idea/**/shelf + +# Generated files +.idea/**/contentModel.xml + +# Sensitive or high-churn files +.idea/**/dataSources/ +.idea/**/dataSources.ids +.idea/**/dataSources.local.xml +.idea/**/sqlDataSources.xml +.idea/**/dynamic.xml +.idea/**/uiDesigner.xml +.idea/**/dbnavigator.xml + +# Gradle +.idea/**/gradle.xml +.idea/**/libraries + +# Gradle and Maven with auto-import +# When using Gradle or Maven with auto-import, you should exclude module files, +# since they will be recreated, and may cause churn. Uncomment if using +# auto-import. +# .idea/artifacts +# .idea/compiler.xml +# .idea/jarRepositories.xml +# .idea/modules.xml +# .idea/*.iml +# .idea/modules +# *.iml +# *.ipr + +# CMake +cmake-build-*/ + +# Mongo Explorer plugin +.idea/**/mongoSettings.xml + +# File-based project format +*.iws + +# IntelliJ +out/ + +# mpeltonen/sbt-idea plugin +.idea_modules/ + +# JIRA plugin +atlassian-ide-plugin.xml + +# Cursive Clojure plugin +.idea/replstate.xml + +# Crashlytics plugin (for Android Studio and IntelliJ) +com_crashlytics_export_strings.xml +crashlytics.properties +crashlytics-build.properties +fabric.properties + +# Editor-based Rest Client +.idea/httpRequests + +# Android studio 3.1+ serialized cache file +.idea/caches/build_file_checksums.ser diff --git a/.idea/ha-iaquk.iml b/.idea/ha-iaquk.iml new file mode 100644 index 0000000..6711606 --- /dev/null +++ b/.idea/ha-iaquk.iml @@ -0,0 +1,11 @@ + + + + + + + + + + \ No newline at end of file diff --git a/.idea/inspectionProfiles/profiles_settings.xml b/.idea/inspectionProfiles/profiles_settings.xml new file mode 100644 index 0000000..105ce2d --- /dev/null +++ b/.idea/inspectionProfiles/profiles_settings.xml @@ -0,0 +1,6 @@ + + + + \ No newline at end of file diff --git a/.idea/misc.xml b/.idea/misc.xml new file mode 100644 index 0000000..6649a8c --- /dev/null +++ b/.idea/misc.xml @@ -0,0 +1,7 @@ + + + + + + \ No newline at end of file diff --git a/.idea/modules.xml b/.idea/modules.xml new file mode 100644 index 0000000..37df04d --- /dev/null +++ b/.idea/modules.xml @@ -0,0 +1,8 @@ + + + + + + + + \ No newline at end of file diff --git a/.idea/vcs.xml b/.idea/vcs.xml new file mode 100644 index 0000000..94a25f7 --- /dev/null +++ b/.idea/vcs.xml @@ -0,0 +1,6 @@ + + + + + + \ No newline at end of file diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 355cd94..661d817 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -11,7 +11,7 @@ repos: language: system types: [python] - repo: https://github.com/pre-commit/pre-commit-hooks - rev: v2.4.0 + rev: v2.5.0 hooks: - id: check-json - id: check-yaml diff --git a/dev-setup.sh b/dev-setup.sh index f2bb4fe..fde4a44 100755 --- a/dev-setup.sh +++ b/dev-setup.sh @@ -1,10 +1,12 @@ #!/bin/sh +pip3 install pre-commit pip3 install -r requirements.txt -r requirements-dev.txt --user pre-commit install pre-commit autoupdate chmod a+x update_tracker.py -if [ -d /run/user/1001/gvfs/smb-share:server=hassio,share=config/ ]; then - ln -s /run/user/1001/gvfs/smb-share:server=hassio,share=config/ dev-config +CONFIG=/run/user/$(id -u)/gvfs/smb-share:server=hassio,share=config/ +if [ -d "$CONFIG" ] && [ ! -e dev-config ]; then + ln -s "$CONFIG" dev-config fi From 60503f29216ecac8b0df8db7f95dfefdf45ee710 Mon Sep 17 00:00:00 2001 From: Andrey Khrolenok Date: Tue, 28 Apr 2020 11:56:09 +0300 Subject: [PATCH 2/3] Fix calculation coefficients --- custom_components/iaquk/__init__.py | 7 ++++--- custom_components/iaquk/const.py | 2 +- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/custom_components/iaquk/__init__.py b/custom_components/iaquk/__init__.py index d61fbbf..3eb7a13 100644 --- a/custom_components/iaquk/__init__.py +++ b/custom_components/iaquk/__init__.py @@ -168,7 +168,7 @@ def iaq_index(self) -> Optional[int]: """Get IAQ index.""" return self._iaq_index - # pylint: disable=r1705 + # pylint: disable=R1705 @property def iaq_level(self) -> Optional[str]: """Get IAQ level.""" @@ -244,6 +244,7 @@ def _get_number_state(self, entity_id, entity_unit=None, source_type='', if entity_unit is not None: target_unit = next(iter(entity_unit)) if unit not in entity_unit: + # pylint: disable=R1705 if mweight is None: _LOGGER.error('Entity %s has inappropriate "%s" units ' 'for %s source. Ignored.', entity_id, unit, @@ -254,13 +255,13 @@ def _get_number_state(self, entity_id, entity_unit=None, source_type='', if 'ppb' in (unit, target_unit): mweight /= 1000 if unit in {'ppm', 'ppb'}: - entity_unit[unit] = 0.0409 * mweight + entity_unit[unit] = mweight / 24.45 else: entity_unit[unit] = 24.45 / mweight try: value = float(value) - except: # pylint: disable=w0702 + except: # pylint: disable=W0702 return None if entity_unit is not None and unit != target_unit: diff --git a/custom_components/iaquk/const.py b/custom_components/iaquk/const.py index 4899e56..8891815 100644 --- a/custom_components/iaquk/const.py +++ b/custom_components/iaquk/const.py @@ -54,7 +54,7 @@ 'µg/m^3': 1000, } -MWEIGTH_TVOC = 78.9516 # g/mol +MWEIGTH_TVOC = 56.1060 # g/mol MWEIGTH_HCHO = 30.0260 # g/mol MWEIGTH_CO = 28.0100 # g/mol MWEIGTH_NO2 = 46.0100 # g/mol From 568b80af2b1e69ca900c82bfa82fd02c15feab94 Mon Sep 17 00:00:00 2001 From: Andrey Khrolenok Date: Tue, 28 Apr 2020 11:59:37 +0300 Subject: [PATCH 3/3] Bump version --- custom_components/iaquk/const.py | 2 +- tracker.json | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/custom_components/iaquk/const.py b/custom_components/iaquk/const.py index 8891815..ba23578 100644 --- a/custom_components/iaquk/const.py +++ b/custom_components/iaquk/const.py @@ -2,7 +2,7 @@ # Base component constants DOMAIN = "iaquk" -VERSION = "1.3.0" +VERSION = "1.3.1" ISSUE_URL = "https://github.com/Limych/ha-iaquk/issues" ATTRIBUTION = None DATA_IAQUK = 'iaquk' diff --git a/tracker.json b/tracker.json index 9e2ca5b..9ff5866 100644 --- a/tracker.json +++ b/tracker.json @@ -1,6 +1,6 @@ { "iaquk": { - "version": "1.3.0", + "version": "1.3.1", "local_location": "/custom_components/iaquk/__init__.py", "remote_location": "https://raw.githubusercontent.com/Limych/ha-iaquk/master/custom_components/iaquk/__init__.py", "visit_repo": "https://github.com/Limych/ha-iaquk",