mirror of
https://github.com/home-assistant/core.git
synced 2025-07-21 12:17:07 +00:00
knx-read-service (#46670)
This commit is contained in:
parent
2cf46330b1
commit
194c0d2b08
@ -15,7 +15,7 @@ from xknx.io import (
|
|||||||
ConnectionType,
|
ConnectionType,
|
||||||
)
|
)
|
||||||
from xknx.telegram import AddressFilter, GroupAddress, Telegram
|
from xknx.telegram import AddressFilter, GroupAddress, Telegram
|
||||||
from xknx.telegram.apci import GroupValueResponse, GroupValueWrite
|
from xknx.telegram.apci import GroupValueRead, GroupValueResponse, GroupValueWrite
|
||||||
|
|
||||||
from homeassistant.const import (
|
from homeassistant.const import (
|
||||||
CONF_ENTITY_ID,
|
CONF_ENTITY_ID,
|
||||||
@ -75,6 +75,7 @@ SERVICE_KNX_ATTR_PAYLOAD = "payload"
|
|||||||
SERVICE_KNX_ATTR_TYPE = "type"
|
SERVICE_KNX_ATTR_TYPE = "type"
|
||||||
SERVICE_KNX_ATTR_REMOVE = "remove"
|
SERVICE_KNX_ATTR_REMOVE = "remove"
|
||||||
SERVICE_KNX_EVENT_REGISTER = "event_register"
|
SERVICE_KNX_EVENT_REGISTER = "event_register"
|
||||||
|
SERVICE_KNX_READ = "read"
|
||||||
|
|
||||||
CONFIG_SCHEMA = vol.Schema(
|
CONFIG_SCHEMA = vol.Schema(
|
||||||
{
|
{
|
||||||
@ -166,6 +167,15 @@ SERVICE_KNX_SEND_SCHEMA = vol.Any(
|
|||||||
),
|
),
|
||||||
)
|
)
|
||||||
|
|
||||||
|
SERVICE_KNX_READ_SCHEMA = vol.Schema(
|
||||||
|
{
|
||||||
|
vol.Required(SERVICE_KNX_ATTR_ADDRESS): vol.All(
|
||||||
|
cv.ensure_list,
|
||||||
|
[cv.string],
|
||||||
|
)
|
||||||
|
}
|
||||||
|
)
|
||||||
|
|
||||||
SERVICE_KNX_EVENT_REGISTER_SCHEMA = vol.Schema(
|
SERVICE_KNX_EVENT_REGISTER_SCHEMA = vol.Schema(
|
||||||
{
|
{
|
||||||
vol.Required(SERVICE_KNX_ATTR_ADDRESS): cv.string,
|
vol.Required(SERVICE_KNX_ATTR_ADDRESS): cv.string,
|
||||||
@ -210,6 +220,13 @@ async def async_setup(hass, config):
|
|||||||
schema=SERVICE_KNX_SEND_SCHEMA,
|
schema=SERVICE_KNX_SEND_SCHEMA,
|
||||||
)
|
)
|
||||||
|
|
||||||
|
hass.services.async_register(
|
||||||
|
DOMAIN,
|
||||||
|
SERVICE_KNX_READ,
|
||||||
|
hass.data[DOMAIN].service_read_to_knx_bus,
|
||||||
|
schema=SERVICE_KNX_READ_SCHEMA,
|
||||||
|
)
|
||||||
|
|
||||||
async_register_admin_service(
|
async_register_admin_service(
|
||||||
hass,
|
hass,
|
||||||
DOMAIN,
|
DOMAIN,
|
||||||
@ -423,6 +440,15 @@ class KNXModule:
|
|||||||
)
|
)
|
||||||
await self.xknx.telegrams.put(telegram)
|
await self.xknx.telegrams.put(telegram)
|
||||||
|
|
||||||
|
async def service_read_to_knx_bus(self, call):
|
||||||
|
"""Service for sending a GroupValueRead telegram to the KNX bus."""
|
||||||
|
for address in call.data.get(SERVICE_KNX_ATTR_ADDRESS):
|
||||||
|
telegram = Telegram(
|
||||||
|
destination_address=GroupAddress(address),
|
||||||
|
payload=GroupValueRead(),
|
||||||
|
)
|
||||||
|
await self.xknx.telegrams.put(telegram)
|
||||||
|
|
||||||
|
|
||||||
class KNXExposeTime:
|
class KNXExposeTime:
|
||||||
"""Object to Expose Time/Date object to KNX bus."""
|
"""Object to Expose Time/Date object to KNX bus."""
|
||||||
|
@ -10,6 +10,12 @@ send:
|
|||||||
type:
|
type:
|
||||||
description: "Optional. If set, the payload will not be sent as raw bytes, but encoded as given DPT. Knx sensor types are valid values (see https://www.home-assistant.io/integrations/sensor.knx)."
|
description: "Optional. If set, the payload will not be sent as raw bytes, but encoded as given DPT. Knx sensor types are valid values (see https://www.home-assistant.io/integrations/sensor.knx)."
|
||||||
example: "temperature"
|
example: "temperature"
|
||||||
|
read:
|
||||||
|
description: "Send GroupValueRead requests to the KNX bus. Response can be used from `knx_event` and will be processed in KNX entities."
|
||||||
|
fields:
|
||||||
|
address:
|
||||||
|
description: "Group address(es) to send read request to. Lists will read multiple group addresses."
|
||||||
|
example: "1/1/0"
|
||||||
event_register:
|
event_register:
|
||||||
description: "Add or remove single group address to knx_event filter for triggering `knx_event`s. Only addresses added with this service can be removed."
|
description: "Add or remove single group address to knx_event filter for triggering `knx_event`s. Only addresses added with this service can be removed."
|
||||||
fields:
|
fields:
|
||||||
|
Loading…
x
Reference in New Issue
Block a user