smile
January 17, 2020, 11:36pm
21
Custom component give a error
Log Details (ERROR)
Fri Jan 17 2020 19:51:31 GMT+0100 (Central European Standard Time)
Error during setup of component min_renovasjon
Traceback (most recent call last):
File "/usr/src/homeassistant/homeassistant/setup.py", line 170, in _async_setup_component
hass, processed_config
File "/config/custom_components/min_renovasjon/__init__.py", line 48, in async_setup
min_renovasjon = MinRenovasjon(street_name, street_code, house_no, county_id, date_format)
File "/config/custom_components/min_renovasjon/__init__.py", line 61, in __init__
self._kalender_list = self._get_calendar_list()
File "/config/custom_components/min_renovasjon/__init__.py", line 121, in _get_calendar_list
kalender_list = self._parse_calendar_list(tommekalender, fraksjoner)
File "/config/custom_components/min_renovasjon/__init__.py", line 140, in _parse_calendar_list
for calender_entry in tommekalender_json:
TypeError: 'bool' object is not iterable
ktpx
(Kjell T.)
January 19, 2020, 9:46pm
23
Remember to update to new county numbers, btw.
If you want a countdown, instead of dates in the sensors:
{% for entry in value_json %}
{% if entry.FraksjonId == 2 %}
{{ (as_timestamp(entry.Tommedatoer[0]) - as_timestamp(now())) | timestamp_custom("%d")| int }}
{% endif %}
{% endfor %}
smile
January 21, 2020, 3:45pm
24
With new code it gets 401 errors, with old code it gets TypeError: ‘bool’ object is not iterable
smurfen
October 17, 2020, 12:32pm
25
Hi!
Trying hard to get this to work, I added the 3 files in ha under custom_components\min_renovasjon.
Then added this to my sensors.yaml
- platform: rest
scan_interval: 1800
name: Renovasjon Restavfall
device_class: timestamp
resource: https://norkartrenovasjon.azurewebsites.net/proxyserver.ashx?server=https://komteksky.norkart.no/komtek.renovasjonwebapi/api/tommekalender/?kommunenr=xxxx&gatenavn=veinavn&gatekode=xxxxxxxxx&husnr=xx
headers:
Content-Type: undefined
Kommunenr: xxxx
RenovasjonAppKey: xxxxx-xxxxx-xxxx-xxxxx
value_template: '{{(as_timestamp(value_json[0].Tommedatoer[0]) + 32400) | timestamp_utc}}'
But i am getting “invalid date” as result.
Any tips will be highly appreciated!
Hello. There is a while since this discussion was active. But as I just used some time to get this running myself I will share the result.
Adressekode can easily be found here: Adresser API - Swagger UI
RenovasjonAppKey can be found by using developer tools in you browser while doing a search on a website and looking for it under networking.
FraksjonsId are avalible through this api: https://komteksky.norkart.no/komtek.renovasjonwebapi/api/fraksjoner
rest:
- resource: https://norkartrenovasjon.azurewebsites.net/proxyserver.ashx?server=https://komteksky.norkart.no/komtek.renovasjonwebapi/api/tommekalender/?kommunenr=xxx&gatenavn=xxx&gatekode=xxx&husnr=xxx
scan_interval: 43200 # once every 12 hours
headers:
User-Agent: Home Assistant
RenovasjonAppKey: xxxx
Kommunenr: xxx
sensor:
- name: Renovasjon - Restavfall
icon: mdi:trash-can-outline
value_template: >
{% for entry in value_json %}
{% if entry.FraksjonId == 1 %}
{{ entry.Tommedatoer[0].split('T')[0] }}
{% endif %}
{% endfor %}
device_class: date
- name: Renovasjon - Papiravfall
icon: mdi:file-outline
value_template: >
{% for entry in value_json %}
{% if entry.FraksjonId == 2 %}
{{ entry.Tommedatoer[0].split('T')[0] }}
{% endif %}
{% endfor %}
device_class: date
- name: Renovasjon - Matavfall
icon: mdi:food-apple-outline
value_template: >
{% for entry in value_json %}
{% if entry.FraksjonId == 3 %}
{{ entry.Tommedatoer[0].split('T')[0] }}
{% endif %}
{% endfor %}
device_class: date
- name: Renovasjon - Glass- og metallemballasje
icon: mdi:glass-fragile
value_template: >
{% for entry in value_json %}
{% if entry.FraksjonId == 4 %}
{{ entry.Tommedatoer[0].split('T')[0] }}
{% endif %}
{% endfor %}
device_class: date
- name: Renovasjon - Plastemballasje
icon: mdi:delete-outline
value_template: >
{% for entry in value_json %}
{% if entry.FraksjonId == 7 %}
{{ entry.Tommedatoer[0].split('T')[0] }}
{% endif %}
{% endfor %}
device_class: date