Replies: 2 comments
-
Hi Jo, I'm currently running two instances of SHC by myself, one of them at my parents' home with with KNX-based electrical system with over a hundred items as well. My current for setting up these projects is to create a Python package with multiple modules, each of them containing the SHC connectable object instances as plain module-level variables. In addition, I have a special module for defining the interfaces (also as plain module-level variables) and modules which contain the all the logic handler functions for some cohesive functionality. I can then import the objects from other modules as required. I have planned to provide an example in the SHC repository to demonstrate that approach (#16), but I hadn't have the time yet to create it. The basic package layout would look somehow like this:
The room-specific Python modules look somehow like this: import shc
import shc.misc
from shc.web.widgets import Switch, icon
from ..interfaces import knx_interface, datalogging_interfaces, web_interface
from .. import general
...
ceiling_lights = shc.Variable(bool, __name__ + ".ceiling_lights")\
.connect(shc.misc.TwoWayPipe(bool)
.connect_right(knx_interface.group(KNXGAD(1, 1, 4), "1", init=True))
.connect_right(general.central_all_lights, send=False))\
.connect(datalogging_interfaces.variable(bool, __name__ + ".ceiling_lights"))
...
page = web_interface.page('kitchen', "Kitchen", menu_entry="ground", menu_sub_label="Kitchen", menu_sub_icon="utensils")
page.add_item(Switch(icon('lightbulb', "Ceiling Lights"), 'yellow').connect(ceiling_lights))
... The from shc.web.widgets import ToggleButton, icon, ImageMap
from ..interfaces import web_interface
from . import kitchen
page = web.page('ground', "Ground Floor")
...
page.new_segment(full_width=True)
page.add_item(ImageMap(Path(__file__).parent.parent / "assets" / "groundplan_ground.png", [
...
(0.51, 0.665, ToggleButton(icon('lightbulb'), color='yellow', outline=True).connect(kitchen.ceiling_lights)),
...
]) And the logic modules can access the objects from the room modules in just the same way: import shc.timer
import shc.misc
from . import ground_floor, general
# Presence simulation kitchen
timer_kitchen_lights = shc.timer.TimerSwitch(
on=[shc.timer.At(hour=18, minute=50, random=datetime.timedelta(minutes=15))],
off=[shc.timer.At(hour=20, minute=5, random=datetime.timedelta(minutes=5))])
ground_floor.kitchen.ceiling_lights.connect(shc.misc.BreakableSubscription(
timer_kitchen_lights.EX.and_(general.weather.dawn.EX < 80.0),
general.presence_simulation_activated)) |
Beta Was this translation helpful? Give feedback.
-
Great that what exactly what I was looking for. Thanks a lot. |
Beta Was this translation helpful? Give feedback.
-
Hi,
1st of all great project 👍
I'm currently starting to migrate from openhab to smarthomeconnect 😄 I was wondering whether some of the experienced developers/users can share a more complex setup/program. How to you configure alle your items. Do you have a centralized approach or class or schema for doing so? I have hundreds of items that I need to maintain. Same for the rules.
Of course I can implement something myself and I'm looking forward to do so. But still having some thoughts/approaches from the Pros would help. Maybe there are some architectural recommendations etc.
Thanks
Jo
Beta Was this translation helpful? Give feedback.
All reactions