Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
30 changes: 28 additions & 2 deletions homeassistant/components/velbus/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,13 @@
import voluptuous as vol

from homeassistant.config_entries import SOURCE_IMPORT, ConfigEntry
from homeassistant.const import CONF_NAME, CONF_PORT
from homeassistant.const import CONF_ADDRESS, CONF_NAME, CONF_PORT
from homeassistant.exceptions import ConfigEntryNotReady
import homeassistant.helpers.config_validation as cv
from homeassistant.helpers.entity import Entity
from homeassistant.helpers.typing import HomeAssistantType

from .const import DOMAIN
from .const import CONF_MEMO_TEXT, DOMAIN, SERVICE_SET_MEMO_TEXT

_LOGGER = logging.getLogger(__name__)

Expand Down Expand Up @@ -80,6 +80,32 @@ def syn_clock(self, service=None):

hass.services.async_register(DOMAIN, "sync_clock", syn_clock, schema=vol.Schema({}))

def set_memo_text(service):
"""Handle Memo Text service call."""
module_address = service.data[CONF_ADDRESS]
memo_text = service.data[CONF_MEMO_TEXT]
memo_text.hass = hass
try:
controller.get_module(module_address).set_memo_text(
memo_text.async_render()
)
except velbus.util.VelbusException as err:
_LOGGER.error("An error occurred while setting memo text: %s", err)

hass.services.async_register(
DOMAIN,
SERVICE_SET_MEMO_TEXT,
set_memo_text,
vol.Schema(
{
vol.Required(CONF_ADDRESS): vol.All(
vol.Coerce(int), vol.Range(min=0, max=255)
),
vol.Optional(CONF_MEMO_TEXT, default=""): cv.template,
}
),
)

return True


Expand Down
4 changes: 4 additions & 0 deletions homeassistant/components/velbus/const.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
"""Const for Velbus."""

DOMAIN = "velbus"

CONF_MEMO_TEXT = "memo_text"

SERVICE_SET_MEMO_TEXT = "set_memo_text"
16 changes: 16 additions & 0 deletions homeassistant/components/velbus/services.yaml
Original file line number Diff line number Diff line change
@@ -1,2 +1,18 @@
sync_clock:
description: Sync the velbus modules clock to the Home Assistant clock, this is the same as the 'sync clock' from VelbusLink

set_memo_text:
description: >
Set the memo text to the display of modules like VMBGPO, VMBGPOD
Be sure the page(s) of the module is configured to display the memo text.
fields:
address:
description: >
The module address in decimal format.
The decimal addresses are displayed in front of the modules listed at the integration page.
example: '11'
memo_text:
description: >
The actual text to be displayed.
Text is limited to 64 characters.
example: 'Do not forget trash'