Skip to content

Commit

Permalink
Merge pull request #34 from xirixiz/4.0.1
Browse files Browse the repository at this point in the history
release 4.0.1
  • Loading branch information
xirixiz authored Jan 28, 2020
2 parents ca3e96b + 680d1d3 commit 3218464
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 15 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.3.0"
"afvaldienst==0.4.0"
],
"dependencies": [],
"codeowners": [
Expand Down
31 changes: 18 additions & 13 deletions custom_components/afvalwijzer/sensor.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
28-01-2020 - Rebuild from scratch! Use Python library! Breaking changes!
"""

VERSION = '4.0.0'
VERSION = '4.0.1'

from Afvaldienst import Afvaldienst
from datetime import date, datetime, timedelta
Expand Down Expand Up @@ -55,7 +55,7 @@ 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
trashTypesAdditional = afvaldienst.trash_schedule_today_json + afvaldienst.trash_schedule_tomorrow_json + afvaldienst.trash_schedule_next_days_json + afvaldienst.trash_schedule_next_item_json
for item in trashTypesAdditional:
trashTypesDefault.append(item['key'])

Expand All @@ -74,11 +74,11 @@ def __init__(self, hass, name, fetch_trash_data, afvaldienst, config):
"""Initialize the sensor."""
self._hass = hass
self._name = name
self.fetch_trash_data = fetch_trash_data
self._fetch_trash_data = fetch_trash_data
self._afvaldienst = afvaldienst
self.attributes = {}
self.config = config
self._state = self.config.get(CONST_LABEL)
self._attributes = {}
self._config = config
self._state = self._config.get(CONST_LABEL)

@property
def name(self):
Expand All @@ -98,25 +98,29 @@ def icon(self):
@property
def device_state_attributes(self):
"""Return the state attributes of the sensor."""
return self.attributes
return self._attributes

def update(self):
"""Fetch new state data for the sensor."""
self.fetch_trash_data.update()
self._state = self.config.get(CONST_LABEL)
self._fetch_trash_data.update()
self._state = self._config.get(CONST_LABEL)

for item in self.fetch_trash_data.trash_schedule_default:
for item in self._fetch_trash_data.trash_schedule_default:
attributes = {}
attributes['next_pickup_in_days'] = item['days_remaining']
if item['key'] == self._name:
self._state = item['value']
self.attributes = attributes
self._attributes = attributes

for item in self.fetch_trash_data.trash_schedule_additional:
for item in self._fetch_trash_data.trash_schedule_additional:
if item['key'] == self._name:
if item['value'] != 'None':
self._state = item['value']

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


class TrashSchedule(object):
"""Fetch new state data for the sensor."""
Expand All @@ -129,4 +133,5 @@ def __init__(self, afvaldienst, config):
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_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
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.0",
"version": "4.0.1",
"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 3218464

Please sign in to comment.