Skip to content

Commit 8de2d3a

Browse files
authored
1 parent d3313d3 commit 8de2d3a

2 files changed

Lines changed: 9 additions & 1 deletion

File tree

custom_components/openhasp/__init__.py

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,7 @@
5858
CONF_PROPERTIES,
5959
CONF_TOPIC,
6060
CONF_TRACK,
61+
CONF_SUBTOPIC,
6162
DATA_IMAGES,
6263
DATA_LISTENER,
6364
DISCOVERED_MANUFACTURER,
@@ -119,6 +120,7 @@ def hasp_object(value):
119120
vol.Optional(CONF_TRACK, default=None): vol.Any(cv.entity_id, None),
120121
vol.Optional(CONF_PROPERTIES, default={}): PROPERTY_SCHEMA,
121122
vol.Optional(CONF_EVENT, default={}): EVENT_SCHEMA,
123+
vol.Optional(CONF_SUBTOPIC): cv.string,
122124
}
123125
)
124126

@@ -725,7 +727,11 @@ def __init__(self, hass, plate_topic, config):
725727

726728
self.hass = hass
727729
self.obj_id = config[CONF_OBJID]
728-
self.command_topic = f"{plate_topic}/command/{self.obj_id}."
730+
subtopic = config.get("subtopic")
731+
if subtopic:
732+
self.command_topic = f"{plate_topic}/command/{subtopic}/{self.obj_id}."
733+
else:
734+
self.command_topic = f"{plate_topic}/command/{self.obj_id}."
729735
self.state_topic = f"{plate_topic}/state/{self.obj_id}"
730736
self.cached_properties = {}
731737

custom_components/openhasp/const.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,8 @@
2828
CONF_NODE = "node"
2929
CONF_HWID = "hwid"
3030
CONF_INPUT = "input"
31+
CONF_SUBTOPIC = "subtopic"
32+
3133

3234
DATA_LISTENER = "listener"
3335
DATA_IMAGES = "images"

0 commit comments

Comments
 (0)