Custom Component error

Hi,

please I need some help because I can’t get a grip on the error/solution.

I have a working (HASSIO) HA v82.1 with custom components for temp sensor, cover and light. The custom components are just wrappers for mqtt messages. The only parameters are the name of the output in the 3rd party domotics (qbus) and the name in HA.

I duplicated this system and upgraded to v92.2 and now i get this error while checking the configuration:
Controleer je configuratie als je onlangs wijzigingen hebt aangebracht en zeker wilt weten dat ze geldig zijn
Ongeldige configuratie
Platform not found: cover.qbus

The configuration is (qbus error, mqtt OK):
cover:

  • platform: qbus
    name: slaapkamer_vierkant
    name_qbus: r pa vkt
  • platform: mqtt
    command_topic: “home-assistant/cover/set”

I already updated my custom component to the new style (with folder and manifest) and the temp sensors are working. I have not checked the lights yet …

Any idea where this error comes from?

TIA 4U all
Mario

Did you also rename the qbus.py (or whatever the name was) to sensor.py (as this is required for the new style, or light.py if it is a light component or any other domain that the component is supposed to represent)?

Did you restart HA?

I know these questions might sound trivial, but the new style and/or config could be the reason it isn’t working (yet).

yes I did rename the components and restart HA
I’m thinking it has something to do with the imports in my custom_component, but no clue :frowning:
(cfr 0.92: HEOS, Somfy MyLink, Genius Hub)

import asyncio
import logging
import datetime as dt
import homeassistant.components.mqtt as mqtt
import homeassistant.helpers.config_validation as cv

from homeassistant.core import callback
from homeassistant.exceptions import TemplateError

from homeassistant.components.cover import (
CoverDevice,
SUPPORT_OPEN, SUPPORT_CLOSE, SUPPORT_STOP,
SUPPORT_SET_POSITION, ATTR_POSITION)
from homeassistant.const import (
CONF_NAME, CONF_VALUE_TEMPLATE, CONF_OPTIMISTIC, STATE_OPEN,
STATE_CLOSED, STATE_UNKNOWN)
from homeassistant.components.mqtt import (
CONF_STATE_TOPIC, CONF_COMMAND_TOPIC, CONF_QOS, CONF_RETAIN,
valid_publish_topic, valid_subscribe_topic)

from homeassistant.components.cover import (ATTR_CURRENT_POSITION, STATE_CLOSED, STATE_OPEN, STATE_UNKNOWN, STATE_OPENING)

#INFO: We want to do some logging. This means that we import the Python logging module and create an alias.
_LOGGER = logging.getLogger(name)

#INFO: keys for the variabels in configuration.yaml
CFG_MQTT_TOPIC = ‘domotica/qbus/shutter’
CFG_YML_HA_NAME = ‘name’
CFG_YML_QBUS_NAME = ‘name_qbus’

#SUPPORT_SET_POSITION
OPEN_CLOSE_FEATURES = (SUPPORT_OPEN | SUPPORT_CLOSE | SUPPORT_STOP | SUPPORT_SET_POSITION)

@asyncio.coroutine
def async_setup_platform(hass, config, async_add_devices, discovery_info=None):
“”“Set up the Qbus Cover/shutter.”""
_LOGGER.info(“COVER .::. The ‘qbus_cover’ ASYNC platform is starting!”)
async_add_devices([QbusCover(CoverDevice, hass, config)])
_LOGGER.info("COVER .::. The ‘qbus_sensor’ ASYNC platform has finished! ")
return True

class QbusCover(CoverDevice):
“”“Representation of a qbus cover/shutter”""
def init(self, Cover, hass, config):
“”“Initialize QBUS cover/shutter light.”""
_LOGGER.info(“COVER .::. init - begin”)
self._name = config.get(CFG_YML_HA_NAME)
_LOGGER.info("COVER .::. init - name: " + self._name)
self._entity_id = ‘cover.’ + self._name

    self._name_qbus = (config.get(CFG_YML_QBUS_NAME) + "").replace(" ", "_")
    self._mqtt_topic_event = CFG_MQTT_TOPIC_COVER + "/event/" + self._name_qbus + "/status"
    self._mqtt_topic_sync = CFG_MQTT_TOPIC_COVER + "/sync/" + self._name_qbus + "/status"
    self._mqtt_topic_command = CFG_MQTT_TOPIC_COVER + "/command/" + self._name_qbus

    #self._optimistic = True
    self._feature_position = True
    self._busy = False  #deel 1 - zonder positie, bijhouden dat open/close is ingezet dan bij STOP definitief maken
    self._qos = 0
    self._retain = False
   
    #een beetje autoconfig tijdens ontwikkeling
    if (dt.datetime.today().hour > 21) or (dt.datetime.today().hour < 8):
        #init at night
        self._state = True
        self._position = 0
    else:
        #init during the day
        self._state = False
        self._position = 100  #tss 0 en 100  --- 100 = rolluik beneden  #standaard dus open
    _LOGGER.info("COVER .::. __init__ - start position : " + str(self._position) + " @ " + str(dt.datetime.today().hour))
    _LOGGER.info("COVER .::. __init__ - end")

Hei, I have found it!!!

I needed to add a platform schema for the cover. Strangely enough this was not necessary for the light or sensor, notwithstanding that both are a similar concept.

Setting a dedicated development environment (elementary OS, visual studio code and venv) in stead of HASSIO+VSC was a good choice, reading the developer manual again (back to basics) helped me (this project is already 2 years ongoing and started with way less info) and the option to log only custom_component debug helped also.

TX community and hopefully this info will help someone someday.

PLATFORM_SCHEMA = PLATFORM_SCHEMA.extend({
vol.Required(CFG_YML_HA_NAME): cv.string,
vol.Required(CFG_YML_QBUS_NAME): cv.string,
vol.Optional(CFG_YML_QBUS_TIME_UP): cv.positive_int,
vol.Optional(CFG_YML_QBUS_TIME_DOWN): cv.positive_int,
vol.Optional(CFG_YML_QBUS_TIME_UP_OFFSET): cv.positive_int,

})

ogger:
default: info
logs:
custom_components.qbus: debug

What did script did you use to integrate QBUS? Is it working reliably ?

it is a 2 part solution:

  • part 1: qbus2mqtt gateway in c# (using their dll) on windows that translates mqtt messages in qbus commands and qbus events into mqtt messages
  • part 2: custom components in HA (python)

yezz i’m quiet satisfied with the result! fast sync, no memory leaks, automation with nodered via HA works like a charm, … and all realized as a non-pro developer :slight_smile:

I’m gonna try if the program can be recompiled to .net core and make an addon or standalone docker image.

do you also have qbus installed?

Hi,

It’s not for me but for a friend for who I’m installing HA. Tried the OpenHAB implementation, but it leaves lots to be desired. Using the physical “all off” button, less than half or the items are updated in the UI :frowning:

Could you point me to the qbus2mqtt c# ?

it is my creation
i signed a NDA when receiving the dll so I can not give you this code without checking what was in the NDA

maybe you can ask qbus engineers for the dll, then I can give you the c#

Yeah, might have to do that. Thanks for the info !

one last remark, it is for the controller CTD02E