Airly - custom component - help needed

Hi

I am trying to write new custom component for airly. My previous attempt was in November, and it worked. Now after update to 0.60.0 it stopped working. Also error I get is not very helpful… It looks like I am not passing all required parameters, even though everything is there…

Error:

2018-01-01 22:10:56 ERROR (MainThread) [homeassistant.config] Invalid config for [airly]: required key not provided @ data['platform']. Got None. (See /home/ha/.homeassistant/configuration.yaml, line 328). Please check the docs at https://home-assistant.io/components/airly/
2018-01-01 22:10:56 ERROR (MainThread) [homeassistant.setup] Error during setup of component airly
Traceback (most recent call last):
  File "/home/ha/python_libs/lib/python3.5/site-packages/homeassistant/setup.py", line 193, in _async_setup_component
    component.setup, hass, processed_config)
AttributeError: module 'custom_components.airly' has no attribute 'setup'
2018-01-01 22:11:15 ERROR (MainThread) [aiohttp.access] Error in logging
Traceback (most recent call last):
  File "/home/ha/python_libs/lib/python3.5/site-packages/aiohttp/helpers.py", line 554, in __get__
    return inst._cache[self.name]
KeyError: 'remote'

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/home/ha/python_libs/lib/python3.5/site-packages/aiohttp/helpers.py", line 521, in log
    for key, value in fmt_info:
  File "/home/ha/python_libs/lib/python3.5/site-packages/aiohttp/helpers.py", line 513, in <genexpr>
    for key, method in self._methods)
  File "/home/ha/python_libs/lib/python3.5/site-packages/aiohttp/helpers.py", line 473, in _format_a
    ip = request.remote
  File "/home/ha/python_libs/lib/python3.5/site-packages/aiohttp/helpers.py", line 556, in __get__
    val = self.wrapped(inst)
  File "/home/ha/python_libs/lib/python3.5/site-packages/aiohttp/web_request.py", line 319, in remote
    peername = transport.get_extra_info('peername')
  File "/usr/lib/python3.5/asyncio/sslproto.py", line 306, in get_extra_info
    return self._ssl_protocol._get_extra_info(name, default)
  File "/usr/lib/python3.5/asyncio/sslproto.py", line 546, in _get_extra_info
    return self._transport.get_extra_info(name, default)
AttributeError: 'NoneType' object has no attribute 'get_extra_info'

Configuration:

airly:
  api_key: SECRET
  latitude: SECRET
  longitude: SECRET
  resources:
    - pm10

And the code for the custom component:

#import urllib2
#from urllib.request
from urllib.request import Request, urlopen
import json
import string
import logging
import voluptuous as vol
import requests

from homeassistant.components.sensor import PLATFORM_SCHEMA
from homeassistant.helpers.entity import Entity
from homeassistant.const import ( CONF_API_KEY, CONF_LATITUDE, CONF_LONGITUDE,  CONF_RESOURCES, STATE_OFF, STATE_ON, CONF_TYPE)
import homeassistant.helpers.config_validation as cv
#from homeassistant.helpers.event import track_time_change

#DOMAIN = 'airly_airquality'
#DEPENDENCIES = []
#REQUIREMENTS = []

_LOGGER = logging.getLogger(__name__)

#CONF_ARG = 'arg'

SENSOR_TYPES = {
    'airQualityIndex': ['airQualityIndex'],
    'pm10': ['pn10'],
    'pm25': ['pm25'],
    'pollutionLevel': ['pollutionLevel'],
}

# Validation of the user's configuration
PLATFORM_SCHEMA = PLATFORM_SCHEMA.extend({
    vol.Required(CONF_API_KEY): cv.string,
    vol.Required(CONF_LONGITUDE): cv.string,
    vol.Required(CONF_LATITUDE): cv.string,
    vol.Optional(CONF_RESOURCES, default=['pm10']):
      vol.All(cv.ensure_list, [vol.In(SENSOR_TYPES)])
      #vol.All(cv.ensure_list, [vol.Schema({ vol.Required(CONF_TYPE): vol.In(SENSOR_TYPES),})])
})


def setup_platform(hass, config, add_devices, discovery_info=None):
    """Setup the sensor platform."""
    dev = []
    _LOGGER.error(CONF_RESOURCES)
    for resource in config[CONF_RESOURCES]:
        dev.append(AirlySensor(
            resource[CONF_TYPE], resource[CONF_ARG]))
    add_devices(dev, True)

    apikey = config.get(CONF_API_KEY)
    latitude = config.get(CONF_LATITUDE)
    longtitude = config.get(CONF_LONGITUDE)


class AirlySensor(Entity):
    """Representation of a Sensor."""

    def __init__(self, sensor_type, argument=''):
        """Initialize the sensor."""
        self._name = '{} {}'.format(SENSOR_TYPES[sensor_type][0], argument)
        self.argument = argument
        self.type = sensor_type
        self._state = None
        #"""Run once per hour."""
        #track_time_change(hass, self.update, minute=0)

    @property
    def name(self):
        """Return the name of the sensor."""
        return "Airly " + self._name.rstrip()

    @property
    def state(self):
        """Return the state of the sensor."""
        return self._state


    def update(self):
        """Fetch new state data for the sensor."""
        url = "https://airapi.airly.eu/v1/mapPoint/measurements?latitude=SECRET&longitude=SECRET"

        req = Request(url)
        req.add_header('apikey', apikey)
        a = urlopen(req)
        data = a.read()
        encoding = a.info().get_content_charset('utf-8')
        jsondata = json.loads(data.decode(encoding))
        measurements = jsondata["currentMeasurements"]
        if self.type == 'airQualityIndex':
          self._state = measurements["airQualityIndex"]
        if self.type == 'pm10':
          self._state = measurements["pm10"]
        if self.type == 'pm25':
          self._state = measurements["pm25"]
        if self.type == 'pollutionLevel':
          self._pollutionLevel = measurements["pollutionLevel"]

Anyone has any ideas whats wrong?

Hi,
Do You resolved this problem?

Unfortunatelly, not yet.