From ea7868f237e26f4784c384f933d7f12ccf2b2b6a Mon Sep 17 00:00:00 2001 From: Bram van Dartel Date: Wed, 12 Feb 2020 00:43:00 +0100 Subject: [PATCH 1/2] add count_today option --- custom_components/afvalwijzer/manifest.json | 2 +- custom_components/afvalwijzer/sensor.py | 10 +++++++--- custom_updater.json | 2 +- info.md | 1 + 4 files changed, 10 insertions(+), 5 deletions(-) diff --git a/custom_components/afvalwijzer/manifest.json b/custom_components/afvalwijzer/manifest.json index 0081643..b2c391d 100644 --- a/custom_components/afvalwijzer/manifest.json +++ b/custom_components/afvalwijzer/manifest.json @@ -3,7 +3,7 @@ "name": "Afvalwijzer", "documentation": "https://github.com/xirixiz/Home-Assistant-Sensor-Afvalwijzer", "requirements": [ - "afvaldienst==0.6.2" + "afvaldienst==0.6.4" ], "dependencies": [], "codeowners": [ diff --git a/custom_components/afvalwijzer/sensor.py b/custom_components/afvalwijzer/sensor.py index 8bb307a..26560ea 100644 --- a/custom_components/afvalwijzer/sensor.py +++ b/custom_components/afvalwijzer/sensor.py @@ -3,7 +3,7 @@ @ Description : Afvalwijzer Json/Scraper Sensor - It queries mijnafvalwijzer.nl or afvalstoffendienstkalender.nl. """ -VERSION = '4.1.4' +VERSION = '4.1.5' from Afvaldienst import Afvaldienst from datetime import date, datetime, timedelta @@ -27,6 +27,7 @@ CONST_ZIPCODE = 'zipcode' CONST_HOUSENUMBER = 'housenumber' CONST_SUFFIX = 'suffix' +CONST_COUNT_TODAY = 'count_today' CONST_LABEL = 'default_label' SCAN_INTERVAL = timedelta(seconds=30) @@ -39,6 +40,7 @@ vol.Required(CONST_ZIPCODE): cv.string, vol.Required(CONST_HOUSENUMBER): cv.string, vol.Optional(CONST_SUFFIX, default=""): cv.string, + vol.Optional(CONST_COUNT_TODAY, default="no"): cv.string, vol.Optional(CONST_LABEL, default="Geen"): cv.string, }) @@ -49,13 +51,14 @@ async def async_setup_platform(hass, config, async_add_entities, discovery_info= zipcode = config.get(CONST_ZIPCODE) housenumber = config.get(CONST_HOUSENUMBER) suffix = config.get(CONST_SUFFIX) + count_today = config.get(CONST_COUNT_TODAY) _LOGGER.debug("Afvalwijzer provider = %s", provider) _LOGGER.debug("Afvalwijzer zipcode = %s", zipcode) _LOGGER.debug("Afvalwijzer housenumber = %s", housenumber) try: - afvaldienst = Afvaldienst(provider, zipcode, housenumber, suffix) + afvaldienst = Afvaldienst(provider, zipcode, housenumber, suffix, count_today) except ValueError as err: _LOGGER.error("Check afvaldienst platform settings %s", err.args) raise @@ -150,9 +153,10 @@ def update(self): zipcode = self._config.get(CONST_ZIPCODE) housenumber = self._config.get(CONST_HOUSENUMBER) suffix = self._config.get(CONST_SUFFIX) + count_today = self._config.het(CONST_COUNT_TODAY) try: - afvaldienst = Afvaldienst(provider, zipcode, housenumber, suffix) + afvaldienst = Afvaldienst(provider, zipcode, housenumber, suffix, count_today) except ValueError as err: _LOGGER.error("Check afvaldienst platform settings %s", err.args) raise diff --git a/custom_updater.json b/custom_updater.json index 90edfc7..7f29103 100644 --- a/custom_updater.json +++ b/custom_updater.json @@ -1,6 +1,6 @@ { "sensor.afvalwijzer": { - "version": "4.1.4", + "version": "4.1.5", "local_location": "/custom_components/afvalwijzer/__init__.py", "remote_location": "https://raw.githubusercontent.com/xirixiz/Home-Assistant-Sensor-Afvalwijzer/master/custom_components/afvalwijzer/__init__.py", "visit_repo": "https://github.com/xirixiz/Home-Assistant-Sensor-Afvalwijzer/", diff --git a/info.md b/info.md index daf0307..b376077 100644 --- a/info.md +++ b/info.md @@ -8,5 +8,6 @@ zipcode: postcode # Required housenumber: huisnummer # Required suffix: toevoeging # Optional + count_today: vandaag meetellen # Optional - Default = no default_label: label # Optional - Default is 'Geen' ``` \ No newline at end of file From 52ecc5d13544fbb5a6da16761fd0a17b30a116bb Mon Sep 17 00:00:00 2001 From: Bram van Dartel Date: Wed, 12 Feb 2020 00:49:49 +0100 Subject: [PATCH 2/2] add count_today option --- custom_components/afvalwijzer/sensor.py | 4 ++-- readme.md | 9 +-------- 2 files changed, 3 insertions(+), 10 deletions(-) diff --git a/custom_components/afvalwijzer/sensor.py b/custom_components/afvalwijzer/sensor.py index 26560ea..a8896b4 100644 --- a/custom_components/afvalwijzer/sensor.py +++ b/custom_components/afvalwijzer/sensor.py @@ -153,7 +153,7 @@ def update(self): zipcode = self._config.get(CONST_ZIPCODE) housenumber = self._config.get(CONST_HOUSENUMBER) suffix = self._config.get(CONST_SUFFIX) - count_today = self._config.het(CONST_COUNT_TODAY) + count_today = self._config.get(CONST_COUNT_TODAY) try: afvaldienst = Afvaldienst(provider, zipcode, housenumber, suffix, count_today) @@ -191,4 +191,4 @@ def update(self): except ValueError as err: _LOGGER.error("Check trash_schedule_firstwastedate %s", err.args) self.trash_schedule_firstwastedate = self._config.get(CONST_LABEL) - raise + raise \ No newline at end of file diff --git a/readme.md b/readme.md index 906c05d..3768750 100644 --- a/readme.md +++ b/readme.md @@ -59,7 +59,6 @@ logger: default: info logs: custom_components.afvalwijzer: debug - custom_components.sensor.afvalwijzer: debug ``` ## Example configuration @@ -73,16 +72,10 @@ Here's an example of my own Home Asisstant config: https://github.com/xirixiz/ho zipcode: postcode # Required housenumber: huisnummer # Required suffix: toevoeging # Optional + count_today: vandaag meetellen # Optional - Default = no default_label: label # Optional - Default is 'Geen' ``` -```yaml -- platform: afvalwijzer # Required - provider: mijnafvalwijzer # Optional - mijnafvalwijzer (default) or afvalstoffendienstkalender - zipcode: 1111AA # Required - housenumber: 11 # Required -``` - ###### INPUT BOOLEAN (FOR AUTOMATION) ```yaml input_boolean: