Help with custom component for garage door motor


I have a Raspberry Pi with some custom code that is connected to my garage door motor.
The code is basically a web server that upon receiving a request triggers the motor switch to open or close.
Now, this is working as expected, and I’m now trying to implement a custom component on HA to control it.

I’ve started using the Cover component, and implemented it as a garage_door platform, and it is showing up on HA.

Now, it is showing on HA as an entity, and not as a device. How can I make it show up as device instead? I’d like to be able to get some extra info from it, like is it open or closed, how much, etc. Also, I think this is also necessary to be able to control it via Google Assistant.

Does anyone have any clue about this?

Thanks in advance for the help!

PS: The code for the component is as follows:


"""The garage_door component."""


DOMAIN = "garage_door"


import logging.handlers
import os
import re
import requests
import voluptuous as vol
import homeassistant.helpers.config_validation as cv

from homeassistant.core import HomeAssistant as HomeAssistantType
from homeassistant.components.cover import (

from homeassistant.const import CONF_HOST

_LOGGER = logging.getLogger(__name__)

    vol.Required(CONF_HOST): cv.string,

def setup_platform(hass: HomeAssistantType, config, add_devices, discovery_info=None):
  """Set up the cover platform"""
  add_devices([GarageDoorCover(config.get(CONF_HOST))], True)

class GarageDoorCover(CoverEntity):
  def __init__(self, host): = host
    self._unique_id = re.sub(r'[\/\-\._:]+', '-',

  def name(self):
    return 'Garage door'

  def should_poll(self):
    """If this entity should be polled."""
    return True

  def supported_features(self):
    """Flag supported features."""

  def current_cover_position(self):
    return 0

  def current_cover_tilt_position(self):
    return None

  def is_opening(self):
    if self._status == None:
      return self._status

    return False

  def is_closing(self):
    if self._status == None:
      return self._status

    return self._status['transitioning']

  def is_closed(self):
    if self._status == None:
      return self._status

    return not self._status['open']

  def device_class(self):

  def unique_id(self):
    return self._unique_id

  async def async_update(self, **kwargs):
    """Update the door status"""
    await self._get_door_status()

  async def async_open_cover(self, **kwargs):
    """Open the cover."""'open cover')
    await self._async_toggle_door()

  async def async_close_cover(self, **kwargs):
    """Open the cover."""'close cover')
    await self._async_toggle_door()

  async def async_stop_cover(self, **kwargs):
    """Stop the cover."""'stop cover')

  async def _get_door_status(self, **kwargs):
    url = + '/status'
    response = requests.get(url)

    if response.status_code == 200:
      self._status = response.json()"New status: %s", self._status)
      return None

  async def _async_toggle_door(self, **kwargs):
    url = + '/toggle'
    response =

    if response.status_code == 200:"Door toggled successfully")

And it was added to the configuration as:

  - platform: garage_door
    host: http://<raspberry-pi-address>