org.openheating.Switches

Description

  • Based on a configuration, takes care about switches.

  • Exposes every switch as a D-Bus object.

  • Implements simulation mode where switches are represented as files containing a boolean value, the switch state. Really cool when you are on a train and the backpack is too small for an entire heating plant.

Sample Configuration File

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
# -*- python -*-

from openheating.base import gpio
from openheating.base.switch import FileSwitch

import os


_switches = [
    ('ww_nimm',  'Nimm die Warmwasserpumpe!',  17),
    ('ww',  'Schalt die Warmwasserpumpe!',  27),
    ('hk_nimm',  'Nimm die Heizkreispumpe!',  22),
    ('hk',  'Schalt die Heizkreispumpe!',  10),
    ('relay_4',  'Relay 4',   9),
    ('relay_5',  'Relay 5',  11),
    ('relay_6',  'Relay 6',  13),
    ('relay_7',  'Relay 7',  19),
    ('relay_8',  'Relay 8',  18),
    ('relay_9',  'Relay 9',  23),
    ('relay_10', 'Relay 10', 24),
    ('relay_11', 'Relay 11', 25),
    ('relay_12', 'Relay 12', 12),
    ('relay_13', 'Relay 13', 16),
    ('relay_14', 'Relay 14', 20),
    ('relay_15', 'Relay 15', 21),
]

for name, description, pin in _switches:
    # *in real life*: instantiates a gpio.output (which is a callable)
    # with the rest of the arguments.

    # *in simulated life*: all but name and description is ignored,
    # and a FileSwitch instance is created.
    ADD_SWITCH(name, description, gpio.output, chiplabel = 'pinctrl-bcm2835', offset = pin)