Giter Site home page Giter Site logo

ha-constant-modifier's Introduction

ha-constant-modifier

This is a custom component for Home Assistant that can be used to modify, patch or overwrite constants in other components. Authored by @puddly

Installation

To install, place the constant_modifier in your Home Assistant configuration directory under the custom_components folder

Configuration

Add to configuration.yaml any constants you need to modify. For example

constant_modifier:
  homeassistant.components.websocket_api.http:
    MAX_PENDING_MSG: 4096
    PENDING_MSG_PEAK: 2048

  zhaquirks.xiaomi:
    MotionCluster.reset_s: 5

Note

This component was created to battle the issue of "Client exceeded max pending messages" when the websocket queue fills in Home Assistant. This seems to be an uncommon issue when using Node-RED and node-red-contrib-home-assistant-websocket in large installations.

ha-constant-modifier's People

Contributors

puddly avatar walthowd avatar

Stargazers

 avatar  avatar  avatar

Watchers

 avatar  avatar

Forkers

puddly

ha-constant-modifier's Issues

Exception when trying to use with recent HA version like 2023.09

Seems the last change to this is quite old and it causes configuration load exceptions for the home assistant object since it has now mandatory arguments as described here:
https://developers.home-assistant.io/blog/2023/08/29/homeassistant-changed-signature?_highlight=homeassistant%28

With following changes I could get the ha-constant-modifier to work with HA 2023.10:
Updated imports:

from homeassistant.core import HomeAssistant
from homeassistant.config import load_yaml_config_file, YAML_CONFIG_FILE
from homeassistant.__main__ import get_arguments
from homeassistant.util.yaml import SECRET_YAML, Secrets, load_yaml

here is the updated def get_ha_config() to use the required config file parameter and the secrets parameter.
PS: From the code it appears that Secret is optional and defaults to Null, but since I use Secrets includes in my config I guess this must be specified as well when you want to duplicate the changed HA startup sequence

def get_ha_config():
    """
    Duplicate enough of the HA startup sequence to extract the config *really* early.
    """

    args = get_arguments()

    try:
        hass = HomeAssistant()  # pylint: disable=no-value-for-parameter
        hass.config.config_dir = os.path.abspath(os.path.join(os.getcwd(), args.config))
    except TypeError:
        hass = HomeAssistant(os.path.abspath(os.path.join(os.getcwd(), args.config)))  # pylint: disable=too-many-function-args

    return load_yaml_config_file(hass.config.path(YAML_CONFIG_FILE),Secrets(hass.config.path(hass.config.config_dir)))

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.