Пример #1
0
        relay.save_state = relay.state

        MESSAGES[relay.name + "_state"] = relay.state

        if debug:
            print(relay.state)


relay_pin_1 = 12
relay_pin_2 = 13

relay_on = 1
relay_off = 0

relay_1 = relay_control.RELAY(name="sw1",
                              pin_num=relay_pin_1,
                              on_value=relay_on)
relay_2 = relay_control.RELAY(name="sw2",
                              pin_num=relay_pin_2,
                              on_value=relay_on)

relay_1.set_callback(relay_cb)
relay_2.set_callback(relay_cb)

#BUTTON
button_pin_1 = 0
button_pin_2 = 2

b2 = button_control.PinButton(button_pin_1,
                              Pin.PULL_UP,
                              debug=True,
Пример #2
0
    if relay.save_state != relay.state:
        relay.save_state = relay.state

        MESSAGES[relay.name + "_state"] = relay.state

        if debug:
            print(relay.state)


relay_pin_1 = 12

relay_on = 1024
relay_off = 0

relay_1 = relay_control.RELAY(name="sw1",
                              pin_num=relay_pin_1,
                              on_value=relay_off)

relay_1.set_callback(relay_cb)


def get_value_human(value):

    if value == "OFF":
        return relay_off
    if value == "ON":
        return relay_on
    return None


def set_value_human(value):