Skip to content

Commit

Permalink
Merge pull request #35 from xirixiz/4.1.0
Browse files Browse the repository at this point in the history
release 4.1.0
  • Loading branch information
xirixiz authored Jan 30, 2020
2 parents 3218464 + ea2e4c0 commit 848a653
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 12 deletions.
2 changes: 1 addition & 1 deletion custom_components/afvalwijzer/manifest.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
"name": "Afvalwijzer",
"documentation": "https://github.com/xirixiz/Home-Assistant-Sensor-Afvalwijzer",
"requirements": [
"afvaldienst==0.4.0"
"afvaldienst==0.6.0"
],
"dependencies": [],
"codeowners": [
Expand Down
29 changes: 19 additions & 10 deletions custom_components/afvalwijzer/sensor.py
Original file line number Diff line number Diff line change
@@ -1,12 +1,11 @@
"""
@ Authors : Bram van Dartel
@ Date : 28/01/2020
@ Description : Afvalwijzer Json/Scraper Sensor - It queries mijnafvalwijzer.nl or afvalstoffendienstkalender.nl.
28-01-2020 - Rebuild from scratch! Use Python library! Breaking changes!
30-01-2020 - Rebuild from scratch! Use Python library! Breaking changes!
"""

VERSION = '4.0.1'
VERSION = '4.1.0'

from Afvaldienst import Afvaldienst
from datetime import date, datetime, timedelta
Expand Down Expand Up @@ -55,11 +54,11 @@ def setup_platform(hass, config, add_devices, discovery_info=None):

# Get trash types to create sensors from
trashTypesDefault = afvaldienst.trash_type_list
trashTypesAdditional = afvaldienst.trash_schedule_today_json + afvaldienst.trash_schedule_tomorrow_json + afvaldienst.trash_schedule_next_days_json + afvaldienst.trash_schedule_next_item_json
trashTypesAdditional = afvaldienst.trash_schedule_today_json + afvaldienst.trash_schedule_tomorrow_json + afvaldienst.trash_schedule_next_days_json + afvaldienst.trash_schedule_next_item_json + afvaldienst.trash_schedule_next_date_json + afvaldienst.trash_schedule_dat_json
for item in trashTypesAdditional:
trashTypesDefault.append(item['key'])

fetch_trash_data = (TrashSchedule(afvaldienst, config))
fetch_trash_data = (TrashSchedule(config))

# Setup sensors
sensors = []
Expand Down Expand Up @@ -121,17 +120,27 @@ def update(self):
if item['key'] == self._name:
self._state = item['value']

for item in self._fetch_trash_data.trash_schedule_firstwastedate:
if item['key'] == self._name:
self._state = item['value']


class TrashSchedule(object):
"""Fetch new state data for the sensor."""
def __init__(self, afvaldienst, config):
def __init__(self, config):
"""Fetch vars."""
self._afvaldienst = afvaldienst
self._config = config

@Throttle(MIN_TIME_BETWEEN_UPDATES)
def update(self):
"""Fetch new state data for the sensor."""
self.trash_schedule_default = self._afvaldienst.trash_schedulefull_json
self.trash_schedule_additional = self._afvaldienst.trash_schedule_today_json + self._afvaldienst.trash_schedule_tomorrow_json + self._afvaldienst.trash_schedule_next_days_json
self.trash_schedule_firstwastetype = self._afvaldienst.trash_schedule_next_item_json
provider = self._config.get(CONST_PROVIDER)
zipcode = self._config.get(CONST_ZIPCODE)
housenumber = self._config.get(CONST_HOUSENUMBER)
suffix = self._config.get(CONST_SUFFIX)
afvaldienst = Afvaldienst(provider, zipcode, housenumber, suffix)

self.trash_schedule_default = afvaldienst.trash_schedulefull_json
self.trash_schedule_additional = afvaldienst.trash_schedule_today_json + afvaldienst.trash_schedule_tomorrow_json + afvaldienst.trash_schedule_next_days_json + afvaldienst.trash_schedule_dat_json
self.trash_schedule_firstwastetype = afvaldienst.trash_schedule_next_item_json
self.trash_schedule_firstwastedate = afvaldienst.trash_schedule_next_date_json
2 changes: 1 addition & 1 deletion custom_updater.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"sensor.afvalwijzer": {
"version": "4.0.1",
"version": "4.1.0",
"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/",
Expand Down

0 comments on commit 848a653

Please sign in to comment.