Skip to content

Commit

Permalink
Provide default value for max message size
Browse files Browse the repository at this point in the history
  • Loading branch information
lukas-hetzenecker authored Aug 21, 2023
1 parent dbec885 commit 4018458
Show file tree
Hide file tree
Showing 4 changed files with 7 additions and 5 deletions.
4 changes: 2 additions & 2 deletions custom_components/remote_homeassistant/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@
CONF_INCLUDE_DOMAINS, CONF_INCLUDE_ENTITIES,
CONF_LOAD_COMPONENTS, CONF_OPTIONS, CONF_REMOTE_CONNECTION,
CONF_SERVICE_PREFIX, CONF_SERVICES, CONF_UNSUB_LISTENER,
DOMAIN, REMOTE_ID)
DOMAIN, REMOTE_ID, DEFAULT_MAX_MSG_SIZE)
from .proxy_services import ProxyServices
from .rest_api import UnsupportedVersion, async_get_discovery_info

Expand Down Expand Up @@ -72,7 +72,7 @@
vol.Optional(CONF_SECURE, default=False): cv.boolean,
vol.Optional(CONF_VERIFY_SSL, default=True): cv.boolean,
vol.Required(CONF_ACCESS_TOKEN): cv.string,
vol.Optional(CONF_MAX_MSG_SIZE, default=16*1024*1024): vol.Coerce(int),
vol.Optional(CONF_MAX_MSG_SIZE, default=DEFAULT_MAX_MSG_SIZE): vol.Coerce(int),
vol.Optional(CONF_EXCLUDE, default={}): vol.Schema(
{
vol.Optional(CONF_ENTITIES, default=[]): cv.entity_ids,
Expand Down
2 changes: 1 addition & 1 deletion custom_components/remote_homeassistant/config_flow.py
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ class ConfigFlow(config_entries.ConfigFlow, domain=DOMAIN):

def __init__(self):
"""Initialize a new ConfigFlow."""
self.prefill = {CONF_PORT: 8123, CONF_SECURE: True, CONF_MAX_MSG_SIZE: 16*1024*1024}
self.prefill = {CONF_PORT: 8123, CONF_SECURE: True, CONF_MAX_MSG_SIZE: DEFAULT_MAX_MSG_SIZE}

@staticmethod
@callback
Expand Down
2 changes: 2 additions & 0 deletions custom_components/remote_homeassistant/const.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,3 +30,5 @@

# replaces 'from homeassistant.core import SERVICE_CALL_LIMIT'
SERVICE_CALL_LIMIT = 10

DEFAULT_MAX_MSG_SIZE = 16*1024*1024
4 changes: 2 additions & 2 deletions custom_components/remote_homeassistant/sensor.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
from homeassistant.helpers.dispatcher import async_dispatcher_connect
from homeassistant.helpers.entity import DeviceInfo, Entity

from .const import DOMAIN, CONF_ENTITY_PREFIX, CONF_SECURE, CONF_MAX_MSG_SIZE
from .const import DOMAIN, CONF_ENTITY_PREFIX, CONF_SECURE, CONF_MAX_MSG_SIZE, DEFAULT_MAX_MSG_SIZE


async def async_setup_entry(hass, config_entry, async_add_entities):
Expand Down Expand Up @@ -44,7 +44,7 @@ def extra_state_attributes(self):
"port": self._entry.data[CONF_PORT],
"secure": self._entry.data.get(CONF_SECURE, False),
"verify_ssl": self._entry.data.get(CONF_VERIFY_SSL, False),
"max_msg_size": self._entry.data[CONF_MAX_MSG_SIZE],
"max_msg_size": self._entry.data.get(CONF_MAX_MSG_SIZE, DEFAULT_MAX_MSG_SIZE),
"entity_prefix": self._entry.options.get(CONF_ENTITY_PREFIX, ""),
"uuid": self.unique_id,
}
Expand Down

0 comments on commit 4018458

Please sign in to comment.