Magic Features

From Yombo
< docs‎ | modules
Jump to: navigation, search

Like python's magic attributes and methods which start with two underscores (__), Yombo implements a few magic features that are available inside of each module. All magic methods and attributes start with one underscore (_) and usually start with a capital letter. This allows you to use 'private' methods and attributes within your function when using all lowercase.

Magic attributes

Magic attributes are typically references to libraries that allow direct access to many features. These attributes can usually be as either a dictionary or an object.

Common magic attributes

This following is a list of commonly used magic attributes:

Less common magic attributes

Magic methods & functions

Magic methods help modules do common tasks, such as getting all devices this module is supposed to manage, the module variables defined by the user, or even check if a device is supposed to be managed by the current module.

  • _is_my_device - Determine if a device should be managed by the current module.

Magic files

Files can be created within the module directory and will automatically be loaded and utilized. Here is a list:

  • - Contains class for of devices that the module creates or extends. This is typically used to extend base Yombo devices. For example, NEST would extend the climate device type or ZWave would extend lights, switches, locks, and others.
  • - Adds more validators available to the system. These are typically used for validating user input.

Magic Folders

The following magic folders are used within a module:

  • frontend - Used by the Yombo Frontend npm build process to add files to the Yombo Frontend application. This allows modules to extend the frontend app by adding components, stores, pages, and more. Any files placed here will be copied to the frontend application during build time.
    • Extreme care should be taken to no overwrite an existing file. The current build process is blind and assumes you know what you are doing.
  • module_configs - This is a shortcut for placing files inside the following path: {{filebg|yombo-gateway/yombo/modules/module_name/frontend/pagers/dashboard/module_configs. The files here are used to configure the module.
    • Be sure to implement the hook '_dashboard_sidebar_navigation_' to add a navigation link to the dashboard sidebar menu.
This page was last edited on 15 June 2019.