├── README.md
├── circuitsetup-gdo-default.yaml
├── components
└── secplus_gdo
│ ├── button
│ └── __pycache__
│ │ └── __init__.cpython-312.pyc
│ ├── cover
│ ├── automation.h
│ ├── gdo_door.h
│ ├── __init__.py
│ └── gdo_door.cpp
│ ├── sensor
│ ├── gdo_sensor.h
│ └── __init__.py
│ ├── text_sensor
│ ├── gdo_text_sensor.h
│ └── __init__.py
│ ├── binary_sensor
│ ├── gdo_binary_sensor.h
│ └── __init__.py
│ ├── select
│ ├── __init__.py
│ └── gdo_select.h
│ ├── switch
│ ├── __init__.py
│ └── gdo_switch.h
│ ├── lock
│ ├── __init__.py
│ └── gdo_lock.h
│ ├── light
│ ├── __init__.py
│ └── gdo_light.h
│ ├── README.md
│ ├── __init__.py
│ ├── number
│ ├── gdo_number.h
│ └── __init__.py
│ ├── secplus_gdo.h
│ └── secplus_gdo.cpp
├── .gitignore
├── packages
├── warning-led.yaml
├── debug.yaml
├── pre-close-warning-tones.yaml
├── status-led.yaml
├── garage-door-wired-sensor.yaml
├── garage-door-opener-button.yaml
├── gdo
│ └── binary-sensor.yaml
├── garage-door-cover-wired.yaml
├── wifi-esp32.yaml
├── temp-sensor.yaml
├── core-esp32-s3.yaml
├── buzzer-rtttl.yaml
├── garage-door-cover.yaml
└── secplus-gdo.yaml
├── circuitsetup-gdo-dry-contact.yaml
├── circuitsetup-secplus-garage-door-opener.yaml
└── LICENSE
/README.md:
--------------------------------------------------------------------------------
1 |
2 |
--------------------------------------------------------------------------------
/circuitsetup-gdo-default.yaml:
--------------------------------------------------------------------------------
1 | packages:
2 | circuitsetup.secplus-garage-door-opener: github://CircuitSetup/circuitsetup-esphome/circuitsetup-secplus-garage-door-opener.yaml@master
3 |
--------------------------------------------------------------------------------
/components/secplus_gdo/button/__pycache__/__init__.cpython-312.pyc:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/CircuitSetup/circuitsetup-esphome/master/components/secplus_gdo/button/__pycache__/__init__.cpython-312.pyc
--------------------------------------------------------------------------------
/.gitignore:
--------------------------------------------------------------------------------
1 | # Gitignore settings for ESPHome
2 | # This is an example and may include too much for your use-case.
3 | # You can modify this file to suit your needs.
4 | /.esphome/
5 | /secrets.yaml
6 | __pycache__/
7 | .vscode
8 | *.code-workspace
9 |
--------------------------------------------------------------------------------
/packages/warning-led.yaml:
--------------------------------------------------------------------------------
1 | output:
2 | - id: warning_led_output
3 | platform: gpio
4 | pin: $warning_leds_pin
5 |
6 | light:
7 | - id: warning_led
8 | platform: binary
9 | output: warning_led_output
10 | effects:
11 | - strobe:
12 | internal: true
13 |
--------------------------------------------------------------------------------
/packages/debug.yaml:
--------------------------------------------------------------------------------
1 | debug:
2 | update_interval: 30s
3 |
4 | text_sensor:
5 | - platform: debug
6 | reset_reason:
7 | name: "Reboot Reason"
8 | id: reboot_reason_sensor
9 | entity_category: diagnostic
10 |
11 | sensor:
12 | - platform: debug
13 | free:
14 | name: "Heap Free"
15 | id: heap_free_sensor
16 | entity_category: diagnostic
17 |
--------------------------------------------------------------------------------
/packages/pre-close-warning-tones.yaml:
--------------------------------------------------------------------------------
1 | button:
2 | - platform: template
3 | id: pre_close_warning
4 | name: Pre-close Warning
5 | on_press:
6 | then:
7 | - light.turn_on:
8 | id: warning_led
9 | effect: strobe
10 | - button.press: warning_tone
11 | - delay: $garage_door_close_warning_duration
12 | - light.turn_off: warning_led
--------------------------------------------------------------------------------
/packages/status-led.yaml:
--------------------------------------------------------------------------------
1 | globals:
2 | - id: blink_on_state
3 | type: bool
4 | initial_value: $blink_on_state
5 |
6 | light:
7 | - platform: status_led
8 | id: blue_status_led
9 | pin:
10 | number: $status_led
11 | inverted: $status_led_inverted
12 |
13 | script:
14 | - id: blink_status_led
15 | then:
16 | - light.turn_on: blue_status_led
17 | - delay: 100ms
18 | - light.turn_off: blue_status_led
19 |
--------------------------------------------------------------------------------
/packages/garage-door-wired-sensor.yaml:
--------------------------------------------------------------------------------
1 | binary_sensor:
2 | - pin:
3 | number: $wired_sensor_pin
4 | mode: INPUT_PULLUP
5 | device_class: garage_door
6 | id: garage_door_input
7 | name: Wired Sensor
8 | platform: gpio
9 | filters:
10 | - delayed_on_off: $sensor_debounce_time
11 | on_state:
12 | - if:
13 | condition:
14 | lambda: return id(blink_on_state);
15 | then:
16 | - script.execute: blink_status_led
17 |
--------------------------------------------------------------------------------
/packages/garage-door-opener-button.yaml:
--------------------------------------------------------------------------------
1 | output:
2 | - id: garage_door_opener_output
3 | platform: gpio
4 | pin: $door_control_pin
5 |
6 | button:
7 | - platform: output
8 | id: garage_door_opener_button
9 | output: garage_door_opener_output
10 | duration: $garage_door_opener_momentary_duration
11 | internal: true
12 | on_press:
13 | - if:
14 | condition:
15 | lambda: return id(blink_on_state);
16 | then:
17 | - script.execute: blink_status_led
18 |
--------------------------------------------------------------------------------
/packages/gdo/binary-sensor.yaml:
--------------------------------------------------------------------------------
1 | # Configure a GDO input as an external binary sensor
2 | defaults:
3 | inverted: "false"
4 |
5 | binary_sensor:
6 | - platform: gpio
7 | pin:
8 | number: ${pin}
9 | mode: INPUT_PULLUP
10 | inverted: ${inverted}
11 | name: ${name}
12 | filters:
13 | - delayed_on_off: ${sensor_debounce_time}
14 | on_state:
15 | - if:
16 | condition:
17 | lambda: return id(blink_on_state);
18 | then:
19 | - script.execute: blink_status_led
20 |
--------------------------------------------------------------------------------
/packages/garage-door-cover-wired.yaml:
--------------------------------------------------------------------------------
1 | <<: !include garage-door-cover.yaml
2 |
3 | binary_sensor:
4 | - id: !extend garage_door_input
5 | on_state:
6 | - if:
7 | condition:
8 | lambda: return x;
9 | then:
10 | - cover.template.publish:
11 | id: garage_door
12 | state: OPEN
13 | current_operation: IDLE
14 | else:
15 | - cover.template.publish:
16 | id: garage_door
17 | state: CLOSED
18 | current_operation: IDLE
19 |
--------------------------------------------------------------------------------
/components/secplus_gdo/cover/automation.h:
--------------------------------------------------------------------------------
1 | #pragma once
2 |
3 | #include "esphome/core/automation.h"
4 |
5 | namespace esphome {
6 | namespace secplus_gdo {
7 | class GDODoor;
8 |
9 | class CoverClosingStartTrigger : public Trigger<> {
10 | public:
11 | explicit CoverClosingStartTrigger([[maybe_unused]] GDODoor* gdo_door) {}
12 | };
13 |
14 | class CoverClosingEndTrigger : public Trigger<> {
15 | public:
16 | explicit CoverClosingEndTrigger([[maybe_unused]] GDODoor* gdo_door) {}
17 | };
18 | } // namespace secplus_gdo
19 | } // namespace esphome
20 |
21 |
--------------------------------------------------------------------------------
/packages/wifi-esp32.yaml:
--------------------------------------------------------------------------------
1 | wifi:
2 | on_connect:
3 | - delay: 5s
4 | - ble.disable:
5 | on_disconnect:
6 | - ble.enable:
7 | # Enable fallback hotspot (captive portal) in case wifi connection fails
8 | ap:
9 |
10 | improv_serial:
11 | captive_portal:
12 |
13 | esp32_improv:
14 | authorizer: none
15 |
16 | sensor:
17 | - platform: wifi_signal
18 | name: WiFi Signal
19 | id: wifi_signal_db
20 | entity_category: diagnostic
21 |
22 | - platform: copy
23 | source_id: wifi_signal_db
24 | id: wifi_signal_pct
25 | name: WiFi Signal %
26 | filters:
27 | - lambda: return min(max(2 * (x + 100.0), 0.0), 100.0);
28 | unit_of_measurement: "%"
29 | entity_category: diagnostic
30 | device_class: ""
31 |
32 | text_sensor:
33 | - platform: wifi_info
34 | ip_address:
35 | name: IP Address
36 | id: wifi_ip_address_sensor
37 | entity_category: diagnostic
38 |
39 |
40 |
--------------------------------------------------------------------------------
/components/secplus_gdo/sensor/gdo_sensor.h:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (C) 2024 Konnected Inc.
3 | *
4 | * This program is free software: you can redistribute it and/or modify
5 | * it under the terms of the GNU General Public License as published by
6 | * the Free Software Foundation, either version 3 of the License, or
7 | * (at your option) any later version.
8 | *
9 | * This program is distributed in the hope that it will be useful,
10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 | * GNU General Public License for more details.
13 | *
14 | * You should have received a copy of the GNU General Public License
15 | * along with this program. If not, see .
16 | */
17 |
18 | # pragma once
19 |
20 | #include "esphome/core/component.h"
21 | #include "esphome/components/sensor/sensor.h"
22 |
23 | namespace esphome {
24 | namespace secplus_gdo {
25 |
26 | class GDOStat : public sensor::Sensor, public Component {};
27 |
28 | } // namespace secplus_gdo
29 | } // namespace esphome
--------------------------------------------------------------------------------
/components/secplus_gdo/text_sensor/gdo_text_sensor.h:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (C) 2025 CircuitSetup
3 | *
4 | * This program is free software: you can redistribute it and/or modify
5 | * it under the terms of the GNU General Public License as published by
6 | * the Free Software Foundation, either version 3 of the License, or
7 | * (at your option) any later version.
8 | *
9 | * This program is distributed in the hope that it will be useful,
10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 | * GNU General Public License for more details.
13 | *
14 | * You should have received a copy of the GNU General Public License
15 | * along with this program. If not, see .
16 | */
17 |
18 | #pragma once
19 |
20 | #include "esphome/core/component.h"
21 | #include "esphome/components/text_sensor/text_sensor.h"
22 |
23 | namespace esphome {
24 | namespace secplus_gdo {
25 |
26 | class GDOTextSensor : public text_sensor::TextSensor, public Component {};
27 |
28 | } // namespace secplus_gdo
29 | } // namespace esphome
30 |
--------------------------------------------------------------------------------
/components/secplus_gdo/binary_sensor/gdo_binary_sensor.h:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (C) 2024 Konnected Inc.
3 | *
4 | * This program is free software: you can redistribute it and/or modify
5 | * it under the terms of the GNU General Public License as published by
6 | * the Free Software Foundation, either version 3 of the License, or
7 | * (at your option) any later version.
8 | *
9 | * This program is distributed in the hope that it will be useful,
10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 | * GNU General Public License for more details.
13 | *
14 | * You should have received a copy of the GNU General Public License
15 | * along with this program. If not, see .
16 | */
17 |
18 | # pragma once
19 |
20 | #include "esphome/core/component.h"
21 | #include "esphome/components/binary_sensor/binary_sensor.h"
22 |
23 | namespace esphome {
24 | namespace secplus_gdo {
25 |
26 | class GDOBinarySensor : public binary_sensor::BinarySensor, public Component {};
27 |
28 | } // namespace secplus_gdo
29 | } // namespace esphome
--------------------------------------------------------------------------------
/components/secplus_gdo/select/__init__.py:
--------------------------------------------------------------------------------
1 | import esphome.codegen as cg
2 | import esphome.config_validation as cv
3 | from esphome.components import select
4 | from esphome.const import CONF_ID, CONF_INITIAL_OPTION
5 |
6 | from .. import CONF_SECPLUS_GDO_ID, SECPLUS_GDO, SECPLUS_GDO_CONFIG_SCHEMA, secplus_gdo_ns
7 |
8 | DEPENDENCIES = ["secplus_gdo"]
9 |
10 | GDOSelect = secplus_gdo_ns.class_("GDOSelect", select.Select, cg.Component)
11 |
12 | CONF_PROTOCOL_SELECT_OPTIONS = ["auto", "security+1.0", "security+2.0", "security+1.0 with smart panel"]
13 |
14 | CONFIG_SCHEMA = (
15 | select.select_schema(GDOSelect)
16 | .extend(
17 | {
18 | cv.GenerateID(CONF_SECPLUS_GDO_ID): cv.use_id(SECPLUS_GDO),
19 | cv.Optional(CONF_INITIAL_OPTION, "auto"): cv.one_of(*CONF_PROTOCOL_SELECT_OPTIONS, lower=True),
20 | }
21 | )
22 | .extend(SECPLUS_GDO_CONFIG_SCHEMA)
23 | )
24 |
25 | async def to_code(config):
26 | s = await select.new_select(config, options=CONF_PROTOCOL_SELECT_OPTIONS)
27 | await cg.register_component(s, config)
28 | cg.add(s.set_initial_option(config[CONF_INITIAL_OPTION]))
29 | parent = await cg.get_variable(config[CONF_SECPLUS_GDO_ID])
30 | cg.add(parent.register_protocol_select(s))
31 |
--------------------------------------------------------------------------------
/components/secplus_gdo/switch/__init__.py:
--------------------------------------------------------------------------------
1 | import esphome.codegen as cg
2 | import esphome.config_validation as cv
3 | from esphome.components import switch
4 | from esphome.const import CONF_ID
5 |
6 | from .. import SECPLUS_GDO_CONFIG_SCHEMA, secplus_gdo_ns, CONF_SECPLUS_GDO_ID
7 |
8 | DEPENDENCIES = ["secplus_gdo"]
9 |
10 | GDOSwitch = secplus_gdo_ns.class_("GDOSwitch", switch.Switch, cg.Component)
11 |
12 | CONF_TYPE = "type"
13 | TYPES = {
14 | "learn": "register_learn",
15 | "toggle_only": "register_toggle_only",
16 | }
17 |
18 |
19 | CONFIG_SCHEMA = (
20 | switch.switch_schema(GDOSwitch)
21 | .extend(
22 | {
23 | cv.Required(CONF_TYPE): cv.enum(TYPES, lower=True),
24 | }
25 | )
26 | .extend(SECPLUS_GDO_CONFIG_SCHEMA)
27 | )
28 |
29 |
30 | async def to_code(config):
31 | var = cg.new_Pvariable(config[CONF_ID])
32 | await switch.register_switch(var, config)
33 | await cg.register_component(var, config)
34 | parent = await cg.get_variable(config[CONF_SECPLUS_GDO_ID])
35 | fcall = str(parent) + "->" + str(TYPES[config[CONF_TYPE]])
36 | text = fcall + "(" + str(var) + ")"
37 | cg.add((cg.RawExpression(text)))
38 | text = "secplus_gdo::SwitchType::" + str(config[CONF_TYPE]).upper()
39 | cg.add(var.set_type(cg.RawExpression(text)))
40 |
--------------------------------------------------------------------------------
/components/secplus_gdo/lock/__init__.py:
--------------------------------------------------------------------------------
1 | """
2 | /*
3 | * Copyright (C) 2024 Konnected Inc.
4 | *
5 | * This program is free software: you can redistribute it and/or modify
6 | * it under the terms of the GNU General Public License as published by
7 | * the Free Software Foundation, either version 3 of the License, or
8 | * (at your option) any later version.
9 | *
10 | * This program is distributed in the hope that it will be useful,
11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 | * GNU General Public License for more details.
14 | *
15 | * You should have received a copy of the GNU General Public License
16 | * along with this program. If not, see .
17 | */
18 | """
19 |
20 | import esphome.codegen as cg
21 | import esphome.config_validation as cv
22 | from esphome.components import lock
23 |
24 | from .. import SECPLUS_GDO_CONFIG_SCHEMA, secplus_gdo_ns, CONF_SECPLUS_GDO_ID
25 |
26 | DEPENDENCIES = ["secplus_gdo"]
27 |
28 | GDOLock = secplus_gdo_ns.class_("GDOLock", lock.Lock, cg.Component)
29 |
30 | CONFIG_SCHEMA = (
31 | lock.lock_schema(GDOLock)
32 | .extend(
33 | {
34 | cv.GenerateID(): cv.declare_id(GDOLock),
35 | }
36 | )
37 | .extend(SECPLUS_GDO_CONFIG_SCHEMA)
38 | )
39 |
40 |
41 |
42 | async def to_code(config):
43 | var = await lock.new_lock(config)
44 | await cg.register_component(var, config)
45 | parent = await cg.get_variable(config[CONF_SECPLUS_GDO_ID])
46 | cg.add(parent.register_lock(var))
47 |
--------------------------------------------------------------------------------
/packages/temp-sensor.yaml:
--------------------------------------------------------------------------------
1 | i2c:
2 | sda: $sda
3 | scl: $scl
4 | frequency: 200kHz
5 | sensor:
6 | - platform: hdc1080
7 | temperature:
8 | name: $garage_temp_name
9 | id: garage_temp_sensor
10 | # convert to Fahrenheit
11 | filters:
12 | - lambda: |-
13 | // convert to fahrenheit
14 | float temp_f = x * (9.0 / 5.0) + 32.0;
15 | return temp_f * ${temp_adjust};
16 | unit_of_measurement: "°F"
17 | humidity:
18 | name: $garage_humidity_name
19 | filters:
20 | - lambda: |-
21 | // Compute current dew point (Magnus formula simplified)
22 | float temp_f = id(garage_temp_sensor).state;
23 | float rh = x;
24 | float temp_c = (temp_f - 32.0) * 5.0 / 9.0;
25 | float gamma = log(rh / 100.0) + (17.625 * temp_c) / (243.04 + temp_c);
26 | float dew_point_c = (243.04 * gamma) / (17.625 - gamma);
27 | float dew_point_f = (dew_point_c * 9.0 / 5.0) + 32.0;
28 |
29 | // Apply dew point offset
30 | float corrected_dew_point_f = dew_point_f + ${dew_point_offset};
31 |
32 | // Reverse calculate humidity from corrected dew point
33 | float corrected_dew_point_c = (corrected_dew_point_f - 32.0) * 5.0 / 9.0;
34 | float gamma_corr = (17.625 * corrected_dew_point_c) / (243.04 + corrected_dew_point_c);
35 | float rh_corrected = 100.0 * exp(gamma_corr - (17.625 * temp_c) / (243.04 + temp_c));
36 |
37 | return rh_corrected;
38 | address: 0x40
39 | update_interval: $temp_update_interval
40 |
--------------------------------------------------------------------------------
/components/secplus_gdo/light/__init__.py:
--------------------------------------------------------------------------------
1 | """
2 | /*
3 | * Copyright (C) 2024 Konnected Inc.
4 | *
5 | * This program is free software: you can redistribute it and/or modify
6 | * it under the terms of the GNU General Public License as published by
7 | * the Free Software Foundation, either version 3 of the License, or
8 | * (at your option) any later version.
9 | *
10 | * This program is distributed in the hope that it will be useful,
11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 | * GNU General Public License for more details.
14 | *
15 | * You should have received a copy of the GNU General Public License
16 | * along with this program. If not, see .
17 | */
18 | """
19 |
20 | import esphome.codegen as cg
21 | import esphome.config_validation as cv
22 | from esphome.components import light
23 | from esphome.const import CONF_OUTPUT_ID # New in 2023.5
24 |
25 | from .. import SECPLUS_GDO_CONFIG_SCHEMA, secplus_gdo_ns, CONF_SECPLUS_GDO_ID
26 |
27 | DEPENDENCIES = ["secplus_gdo"]
28 |
29 | GDOLight = secplus_gdo_ns.class_(
30 | "GDOLight", light.LightOutput, cg.Component
31 | )
32 |
33 |
34 | CONFIG_SCHEMA = light.LIGHT_SCHEMA.extend(
35 | {cv.GenerateID(CONF_OUTPUT_ID): cv.declare_id(GDOLight)}
36 | ).extend(SECPLUS_GDO_CONFIG_SCHEMA)
37 |
38 |
39 | async def to_code(config):
40 | var = cg.new_Pvariable(config[CONF_OUTPUT_ID])
41 | await cg.register_component(var, config)
42 | await light.register_light(var, config)
43 | parent = await cg.get_variable(config[CONF_SECPLUS_GDO_ID])
44 | cg.add(parent.register_light(var))
45 |
--------------------------------------------------------------------------------
/packages/core-esp32-s3.yaml:
--------------------------------------------------------------------------------
1 | esphome:
2 | name: $name
3 | friendly_name: $friendly_name
4 | name_add_mac_suffix: true
5 | min_version: '2024.12.0' # Includes ESP-IDF 5.1
6 | project:
7 | name: $project_name
8 | version: $project_version
9 | platformio_options:
10 | board_build.flash_mode: dio
11 |
12 | on_boot:
13 | - priority: 800.0
14 | then:
15 | - text_sensor.template.publish:
16 | id: device_id
17 | state: !lambda return get_mac_address();
18 | - text_sensor.template.publish:
19 | id: project_version
20 | state: !lambda return ESPHOME_PROJECT_VERSION;
21 |
22 | esp32:
23 | board: esp32-s3-devkitc-1
24 | framework:
25 | type: esp-idf
26 | version: recommended
27 | sdkconfig_options:
28 | CONFIG_LWIP_MAX_SOCKETS: "16"
29 |
30 | substitutions:
31 | status_led_inverted: "false"
32 |
33 | text_sensor:
34 | - platform: template
35 | name: Device ID
36 | id: device_id
37 | entity_category: diagnostic
38 | update_interval: never
39 | - platform: version
40 | name: ESPHome Version
41 | id: esphome_version_sensor
42 | hide_timestamp: true
43 | - platform: template
44 | name: Project version
45 | id: project_version
46 | entity_category: diagnostic
47 | update_interval: never
48 |
49 | sensor:
50 | - platform: uptime
51 | name: Uptime
52 | id: uptime_sensor
53 | entity_category: diagnostic
54 |
55 | button:
56 | - platform: restart
57 | name: Restart
58 | id: restart_button
59 | entity_category: config
60 |
61 | ####
62 | # OTA UPDATES
63 | # Enables over-the-air updates
64 | # more: https://esphome.io/components/ota.html
65 | ota:
66 | - platform: esphome
67 | id: circuitsetup_ota
68 |
--------------------------------------------------------------------------------
/components/secplus_gdo/README.md:
--------------------------------------------------------------------------------
1 | # secplus_gdo
2 |
3 | ## Documentation and Example Usage
4 |
5 | See [packages/secplus-gdo.yaml](https://github.com/CircuitSetup/circuitsetup-esphome/blob/master/packages/secplus-gdo.yaml) for a complete example.
6 |
7 | ### Setup
8 | Import the component into your ESPHome config:
9 |
10 | ```
11 | external_components:
12 | - source: github://CircuitSetup/circuitsetup-esphome@master
13 | components: [ secplus_gdo ]
14 | ```
15 |
16 | Include the component:
17 | ```
18 | secplus_gdo:
19 | id: cs_gdo
20 | input_gdo_pin: ${uart_rx_pin}
21 | output_gdo_pin: ${uart_tx_pin}
22 | ```
23 |
24 | ### Cover
25 |
26 | ```
27 | cover:
28 | - platform: secplus_gdo
29 | name: Garage Door
30 | secplus_gdo_id: cs_gdo
31 | id: gdo_door
32 | pre_close_warning_duration: 5s
33 | pre_close_warning_start:
34 | - button.press: pre_close_warning
35 |
36 | ```
37 |
38 | #### Configuration options
39 |
40 | * **secplus_gdo_id** (**Required**, string): The ID of the component set above.
41 | * **pre_close_warning_duration** (_Optional_, Time): Duration of the pre-close warning
42 | * **pre_close_warning_start** (_Optional_, Action): Action(s) to execute the pre-close warning
43 | * **pre_close_warning_end** (_Optional_, Action): Action(s) to execute when the pre-close warning stops
44 | * **toggle_only** (_Optional_, boolean)_: When true, all open/close commands are sent as a toggle door actions to the garage opener. This is a compatibility fix for some openers, such as some Merlin brand openers that are known to only respond to toggle commands and don't respond to discrete open/close commands.
45 |
46 | ### Binary Sensors
47 |
48 | ```yaml
49 | binary_sensor:
50 | - platform: secplus_gdo
51 | type: wireless_remote
52 | secplus_gdo_id: cs_gdo
53 | name: Wireless Remote
54 | ```
55 |
56 | * **type** (**Required**, string): Sensor type. Use `wireless_remote` to detect when the door is triggered by a wireless remote.
57 |
--------------------------------------------------------------------------------
/components/secplus_gdo/text_sensor/__init__.py:
--------------------------------------------------------------------------------
1 | """
2 | /*
3 | * Copyright (C) 2025 CircuitSetup
4 | *
5 | * This program is free software: you can redistribute it and/or modify
6 | * it under the terms of the GNU General Public License as published by
7 | * the Free Software Foundation, either version 3 of the License, or
8 | * (at your option) any later version.
9 | *
10 | * This program is distributed in the hope that it will be useful,
11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 | * GNU General Public License for more details.
14 | *
15 | * You should have received a copy of the GNU General Public License
16 | * along with this program. If not, see .
17 | */
18 | """
19 |
20 | import esphome.codegen as cg
21 | import esphome.config_validation as cv
22 | from esphome.components import text_sensor
23 | from esphome.const import CONF_ID
24 |
25 | from .. import SECPLUS_GDO_CONFIG_SCHEMA, secplus_gdo_ns, CONF_SECPLUS_GDO_ID
26 |
27 | DEPENDENCIES = ["secplus_gdo"]
28 |
29 | GDOTextSensor = secplus_gdo_ns.class_(
30 | "GDOTextSensor", text_sensor.TextSensor, cg.Component
31 | )
32 |
33 | CONF_TYPE = "type"
34 | TYPES = {
35 | "battery": "register_battery",
36 | }
37 |
38 | CONFIG_SCHEMA = (
39 | text_sensor.text_sensor_schema(GDOTextSensor)
40 | .extend(
41 | {
42 | cv.Required(CONF_TYPE): cv.enum(TYPES, lower=True),
43 | }
44 | )
45 | .extend(SECPLUS_GDO_CONFIG_SCHEMA)
46 | )
47 |
48 | async def to_code(config):
49 | var = cg.new_Pvariable(config[CONF_ID])
50 | await text_sensor.register_text_sensor(var, config)
51 | await cg.register_component(var, config)
52 | parent = await cg.get_variable(config[CONF_SECPLUS_GDO_ID])
53 | fcall = str(parent) + "->" + str(TYPES[config[CONF_TYPE]])
54 | text = fcall + "(std::bind(&" + str(GDOTextSensor) + "::publish_state," + str(config[CONF_ID]) + ",std::placeholders::_1))"
55 | cg.add(cg.RawExpression(text))
56 |
--------------------------------------------------------------------------------
/components/secplus_gdo/__init__.py:
--------------------------------------------------------------------------------
1 | """
2 | /*
3 | * Copyright (C) 2024 Konnected Inc.
4 | *
5 | * This program is free software: you can redistribute it and/or modify
6 | * it under the terms of the GNU General Public License as published by
7 | * the Free Software Foundation, either version 3 of the License, or
8 | * (at your option) any later version.
9 | *
10 | * This program is distributed in the hope that it will be useful,
11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 | * GNU General Public License for more details.
14 | *
15 | * You should have received a copy of the GNU General Public License
16 | * along with this program. If not, see .
17 | */
18 | """
19 |
20 | import esphome.codegen as cg
21 | import esphome.config_validation as cv
22 | import voluptuous as vol
23 | from esphome import pins
24 | from esphome.const import CONF_ID
25 |
26 | DEPENDENCIES = ["preferences"]
27 | MULTI_CONF = True
28 |
29 | secplus_gdo_ns = cg.esphome_ns.namespace("secplus_gdo")
30 | SECPLUS_GDO = secplus_gdo_ns.class_("GDOComponent", cg.Component)
31 |
32 | CONF_OUTPUT_GDO = "output_gdo_pin"
33 | DEFAULT_OUTPUT_GDO = ("1")
34 | CONF_INPUT_GDO = "input_gdo_pin"
35 | DEFAULT_INPUT_GDO = ("2")
36 |
37 | CONF_SECPLUS_GDO_ID = "secplus_gdo_id"
38 |
39 | CONFIG_SCHEMA = cv.Schema(
40 | {
41 | cv.GenerateID(): cv.declare_id(SECPLUS_GDO),
42 | cv.Required(CONF_OUTPUT_GDO): pins.gpio_output_pin_schema,
43 | cv.Required(CONF_INPUT_GDO): pins.gpio_input_pin_schema,
44 | }
45 | ).extend(cv.COMPONENT_SCHEMA)
46 |
47 | SECPLUS_GDO_CONFIG_SCHEMA = cv.Schema(
48 | {
49 | cv.Required(CONF_SECPLUS_GDO_ID): cv.use_id(SECPLUS_GDO),
50 | }
51 | )
52 |
53 | async def to_code(config):
54 | var = cg.new_Pvariable(config[CONF_ID])
55 | await cg.register_component(var, config)
56 | cg.add_define("GDO_UART_TX_PIN", config[CONF_OUTPUT_GDO]['number'])
57 | cg.add_define("GDO_UART_RX_PIN", config[CONF_INPUT_GDO]['number'])
58 |
--------------------------------------------------------------------------------
/components/secplus_gdo/switch/gdo_switch.h:
--------------------------------------------------------------------------------
1 | /************************************
2 | *
3 | * Copyright (C) 2024 Konnected.io
4 | *
5 | * GNU GENERAL PUBLIC LICENSE
6 | ************************************/
7 |
8 | #pragma once
9 |
10 | #include "esphome/components/switch/switch.h"
11 | #include "esphome/core/preferences.h"
12 | #include "esphome/core/component.h"
13 | #include "gdo.h"
14 |
15 | namespace esphome {
16 | namespace secplus_gdo {
17 |
18 | enum SwitchType {
19 | LEARN,
20 | TOGGLE_ONLY,
21 | };
22 |
23 | class GDOSwitch : public switch_::Switch, public Component {
24 | public:
25 | void dump_config() override {}
26 | void setup() override {
27 | bool value = false;
28 | this->pref_ = global_preferences->make_preference(this->get_object_id_hash());
29 | if (!this->pref_.load(&value)) {
30 | value = false;
31 | }
32 |
33 | this->write_state(value);
34 | }
35 |
36 | void write_state(bool state) override {
37 | if (state == this->state) {
38 | return;
39 | }
40 |
41 | if (this->type_ == SwitchType::TOGGLE_ONLY) {
42 | if (this->f_control) {
43 | this->f_control(state);
44 | this->pref_.save(&state);
45 | }
46 | }
47 |
48 | if (this->type_ == SwitchType::LEARN) {
49 | if (state) {
50 | gdo_activate_learn();
51 | } else {
52 | gdo_deactivate_learn();
53 | }
54 | }
55 |
56 | this->publish_state(state);
57 | }
58 |
59 | void set_type(SwitchType type) { this->type_ = type; }
60 | void set_control_function(std::function f) { f_control = f; }
61 |
62 | protected:
63 | SwitchType type_{SwitchType::LEARN};
64 | std::function f_control{nullptr};
65 | ESPPreferenceObject pref_;
66 | };
67 |
68 | } // namespace secplus_gdo
69 | } // namespace esphome
70 |
--------------------------------------------------------------------------------
/packages/buzzer-rtttl.yaml:
--------------------------------------------------------------------------------
1 | output:
2 | - platform: ledc
3 | pin: $warning_beep_pin
4 | id: rtttl_out
5 |
6 | rtttl:
7 | output: rtttl_out
8 |
9 | button:
10 | - platform: template
11 | id: warning_tone
12 | name: "Play sound"
13 | internal: true
14 | on_press:
15 | then:
16 | - rtttl.play: $warning_tone_rtttl
17 |
18 | script:
19 | - id: error_tone_1
20 | then:
21 | - rtttl.play: $error_tone
22 |
23 | api:
24 | services:
25 | # Call the play_rtttl service to play any RTTTL song in the garage
26 | - service: play_rtttl
27 | variables:
28 | song_str: string
29 | then:
30 | - rtttl.play:
31 | rtttl: !lambda 'return song_str;'
32 |
33 |
34 | substitutions:
35 | ominous_warning: ominous:d=4,o=6,b=160:16e,16f,16g,16f,16e,16f,16g,16f,16e,16f,16g,16f,16e,16f,16g,16f,16e,16f,16g,16f,16e,16f,16g,16f,16e,16f,16g,16f,16e,16f,16g,16f,16e,16f,16g,16f,16e,16f,16g,16f
36 | charming_warning: charming:d=4,o=5,b=120:16e6,16f6,16g6,16a6,16b6,16a6,16g6,16f6,16e6,16d6,16c6,16b5,16c6,16d6,16e6,16f6
37 | mario: mario:d=4,o=5,b=100:16e6,16e6,32p,8e6,16c6,8e6,8g6,8p,8g,8p,8c6,16p,8g,16p,8e,16p,8a,8b,16a#,8a,16g.,16e6,16g6,8a6,16f6,8g6,8e6,16c6,16d6,8b,16p,8c6,16p,8g,16p,8e,16p,8a,8b,16a#,8a,16g.,16e6,16g6,8a6,16f6,8g6,8e6,16c6,16d6,8b,8p,16g6,16f#6,16f6,16d#6,16p,16e6,16p,16g#,16a,16c6,16p,16a,16c6,16d6,8p,16g6,16f#6,16f6,16d#6,16p,16e6,16p,16c7,16p,16c7,16c7,p,16g6,16f#6,16f6,16d#6,16p,16e6,16p,16g#,16a,16c6,16p,16a,16c6,16d6,8p,16d#6,8p,16d6,8p,16c6
38 | mission_impossible: MissionImp:d=16,o=6,b=95:32d,32d#,32d,32d#,32d,32d#,32d,32d#,32d,32d,32d#,32e,32f,32f#,32g,g,8p,g,8p,a#,p,c7,p,g,8p,g,8p,f,p,f#,p,g,8p,g,8p,a#,p,c7,p,g,8p,g,8p,f,p,f#,p,a#,g,2d,32p,a#,g,2c#,32p,a#,g,2c,a#5,8c,2p,32p,a#5,g5,2f#,32p,a#5,g5,2f,32p,a#5,g5,2e,d#,8d
39 | urgent: Urgent:d=8,o=6,b=500:c,e,d7,c,e,a#,c,e,a,c,e,g,c,e,a,c,e,a#,c,e,d7
40 | mosaic_1: Mosaic:d=8,o=6,b=400:c,e,g,e,c,g,e,g,c,g,c,e,c,g,e,g,e,c
41 | mosiac_2: Mosaic:d=8,o=6,b=400:c,e,g,e,c,g,e,g,c,g,c,e,c,g,e,g,e,c,p,c5,e5,g5,e5,c5,g5,e5,g5,c5,g5,c5,e5,c5,g5,e5,g5,e5,c5
42 | error_tone: err:d=16,o=4,b=100:d#,d#,d#
43 | warning_tone_rtttl: $ominous_warning
44 |
45 |
--------------------------------------------------------------------------------
/components/secplus_gdo/binary_sensor/__init__.py:
--------------------------------------------------------------------------------
1 | """
2 | /*
3 | * Copyright (C) 2024 Konnected Inc.
4 | *
5 | * This program is free software: you can redistribute it and/or modify
6 | * it under the terms of the GNU General Public License as published by
7 | * the Free Software Foundation, either version 3 of the License, or
8 | * (at your option) any later version.
9 | *
10 | * This program is distributed in the hope that it will be useful,
11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 | * GNU General Public License for more details.
14 | *
15 | * You should have received a copy of the GNU General Public License
16 | * along with this program. If not, see .
17 | */
18 | """
19 |
20 | import esphome.codegen as cg
21 | import esphome.config_validation as cv
22 | from esphome.components import binary_sensor
23 | from esphome.const import CONF_ID
24 |
25 | from .. import SECPLUS_GDO_CONFIG_SCHEMA, secplus_gdo_ns, CONF_SECPLUS_GDO_ID
26 |
27 | DEPENDENCIES = ["secplus_gdo"]
28 |
29 | GDOBinarySensor = secplus_gdo_ns.class_(
30 | "GDOBinarySensor", binary_sensor.BinarySensor, cg.Component
31 | )
32 |
33 | CONF_TYPE = "type"
34 | TYPES = {
35 | "motion": "register_motion",
36 | "obstruction": "register_obstruction",
37 | "motor": "register_motor",
38 | "button": "register_button",
39 | "sync": "register_sync",
40 | "wireless_remote": "register_wireless_remote",
41 | }
42 |
43 |
44 | CONFIG_SCHEMA = (
45 | binary_sensor.binary_sensor_schema(GDOBinarySensor)
46 | .extend(
47 | {
48 | cv.Required(CONF_TYPE): cv.enum(TYPES, lower=True),
49 | }
50 | )
51 | .extend(SECPLUS_GDO_CONFIG_SCHEMA)
52 | )
53 |
54 |
55 | async def to_code(config):
56 | var = cg.new_Pvariable(config[CONF_ID])
57 | await binary_sensor.register_binary_sensor(var, config)
58 | await cg.register_component(var, config)
59 | parent = await cg.get_variable(config[CONF_SECPLUS_GDO_ID])
60 | fcall = str(parent) + "->" + str(TYPES[config[CONF_TYPE]])
61 | text = fcall + "(std::bind(&" + str(GDOBinarySensor) + "::publish_state," + str(config[CONF_ID]) + ",std::placeholders::_1))"
62 | cg.add((cg.RawExpression(text)))
63 |
64 |
--------------------------------------------------------------------------------
/components/secplus_gdo/sensor/__init__.py:
--------------------------------------------------------------------------------
1 | """
2 | /*
3 | * Copyright (C) 2024 Konnected Inc.
4 | *
5 | * This program is free software: you can redistribute it and/or modify
6 | * it under the terms of the GNU General Public License as published by
7 | * the Free Software Foundation, either version 3 of the License, or
8 | * (at your option) any later version.
9 | *
10 | * This program is distributed in the hope that it will be useful,
11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 | * GNU General Public License for more details.
14 | *
15 | * You should have received a copy of the GNU General Public License
16 | * along with this program. If not, see .
17 | */
18 | """
19 |
20 | import esphome.codegen as cg
21 | import esphome.config_validation as cv
22 | from esphome.components import sensor
23 | from esphome.const import CONF_ID
24 |
25 | from .. import SECPLUS_GDO_CONFIG_SCHEMA, secplus_gdo_ns, CONF_SECPLUS_GDO_ID
26 |
27 | DEPENDENCIES = ["secplus_gdo"]
28 |
29 | GDOStat = secplus_gdo_ns.class_("GDOStat", sensor.Sensor, cg.Component)
30 |
31 | CONF_TYPE = "type"
32 | TYPES = {
33 | "openings": "register_openings",
34 | "paired_devices_total": "register_paired_total",
35 | "paired_devices_remotes": "register_paired_remotes",
36 | "paired_devices_keypads": "register_paired_keypads",
37 | "paired_devices_wall_controls": "register_paired_wall_controls",
38 | "paired_devices_accessories":"register_paired_accessories",
39 | }
40 |
41 |
42 | CONFIG_SCHEMA = (
43 | sensor.sensor_schema(GDOStat)
44 | .extend(
45 | {
46 | cv.Required(CONF_TYPE): cv.enum(TYPES, lower=True),
47 | }
48 | )
49 | .extend(SECPLUS_GDO_CONFIG_SCHEMA)
50 | )
51 |
52 |
53 | async def to_code(config):
54 | var = cg.new_Pvariable(config[CONF_ID])
55 | await sensor.register_sensor(var, config)
56 | await cg.register_component(var, config)
57 | parent = await cg.get_variable(config[CONF_SECPLUS_GDO_ID])
58 | fcall = str(parent) + "->" + str(TYPES[config[CONF_TYPE]])
59 | text = fcall + "(std::bind(&" + str(GDOStat) + "::publish_state," + str(config[CONF_ID]) + ",std::placeholders::_1))"
60 | cg.add((cg.RawExpression(text)))
--------------------------------------------------------------------------------
/components/secplus_gdo/number/gdo_number.h:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (C) 2024 Konnected Inc.
3 | *
4 | * This program is free software: you can redistribute it and/or modify
5 | * it under the terms of the GNU General Public License as published by
6 | * the Free Software Foundation, either version 3 of the License, or
7 | * (at your option) any later version.
8 | *
9 | * This program is distributed in the hope that it will be useful,
10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 | * GNU General Public License for more details.
13 | *
14 | * You should have received a copy of the GNU General Public License
15 | * along with this program. If not, see .
16 | */
17 |
18 | # pragma once
19 |
20 | #include "esphome/core/component.h"
21 | #include "esphome/core/preferences.h"
22 | #include "esphome/components/number/number.h"
23 |
24 | namespace esphome {
25 | namespace secplus_gdo {
26 |
27 | class GDONumber : public number::Number, public Component {
28 | public:
29 | void dump_config() override {}
30 | void setup() override {
31 | float value;
32 | this->pref_ = global_preferences->make_preference(this->get_object_id_hash());
33 | if (!this->pref_.load(&value)) {
34 | value = 0;
35 | }
36 |
37 | this->control(value);
38 | }
39 |
40 | void update_state(float value) {
41 | if (value == this->state) {
42 | return;
43 | }
44 |
45 | this->state = value;
46 | this->publish_state(value);
47 | this->pref_.save(&value);
48 | }
49 |
50 | void control(float value) override {
51 | if (value == this->state) {
52 | return;
53 | }
54 |
55 | if (this->f_control) {
56 | this->f_control(value);
57 | this->update_state(value);
58 | }
59 | }
60 |
61 | void set_control_function(std::function f) { f_control = f; }
62 |
63 | protected:
64 | ESPPreferenceObject pref_;
65 | std::function f_control{nullptr};
66 | };
67 | } // namespace secplus_gdo
68 | } // namespace esphome
--------------------------------------------------------------------------------
/components/secplus_gdo/lock/gdo_lock.h:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (C) 2024 Konnected Inc.
3 | *
4 | * This program is free software: you can redistribute it and/or modify
5 | * it under the terms of the GNU General Public License as published by
6 | * the Free Software Foundation, either version 3 of the License, or
7 | * (at your option) any later version.
8 | *
9 | * This program is distributed in the hope that it will be useful,
10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 | * GNU General Public License for more details.
13 | *
14 | * You should have received a copy of the GNU General Public License
15 | * along with this program. If not, see .
16 | */
17 |
18 | #pragma once
19 |
20 | #include "esphome/components/lock/lock.h"
21 | #include "esphome/core/component.h"
22 | #include "gdo.h"
23 |
24 | namespace esphome {
25 | namespace secplus_gdo {
26 |
27 | class GDOLock : public lock::Lock, public Component {
28 | public:
29 | void set_state(gdo_lock_state_t state) {
30 | if (state == this->lock_state_) {
31 | return;
32 | }
33 |
34 | this->lock_state_ = state;
35 | ESP_LOGI(TAG, "Lock state: %s", gdo_lock_state_to_string(state));
36 | this->publish_state(state == GDO_LOCK_STATE_LOCKED ?
37 | lock::LockState::LOCK_STATE_LOCKED :
38 | lock::LockState::LOCK_STATE_UNLOCKED);
39 | }
40 |
41 | void control(const lock::LockCall& call) override {
42 | if (!this->synced_) {
43 | return;
44 | }
45 |
46 | auto state = *call.get_state();
47 |
48 | if (state == lock::LockState::LOCK_STATE_LOCKED) {
49 | gdo_lock();
50 | } else if (state == lock::LockState::LOCK_STATE_UNLOCKED) {
51 | gdo_unlock();
52 | }
53 | }
54 |
55 | void set_sync_state(bool synced) {
56 | this->synced_ = synced;
57 | }
58 |
59 | private:
60 | gdo_lock_state_t lock_state_{GDO_LOCK_STATE_MAX};
61 | bool synced_{false};
62 | static constexpr const char* TAG = "GDOLock";
63 | };
64 |
65 | } // namespace secplus_gdo
66 | } // namespace esphome
67 |
--------------------------------------------------------------------------------
/components/secplus_gdo/select/gdo_select.h:
--------------------------------------------------------------------------------
1 | /************************************
2 | *
3 | * Copyright (C) 2024 Konnected.io
4 | *
5 | * GNU GENERAL PUBLIC LICENSE
6 | ************************************/
7 |
8 | #pragma once
9 |
10 | #include "esphome/components/select/select.h"
11 | #include "esphome/core/component.h"
12 | #include "esphome/core/preferences.h"
13 | #include "esphome/core/application.h"
14 | #include "../secplus_gdo.h"
15 | #include "gdo.h"
16 |
17 | namespace esphome {
18 | namespace secplus_gdo {
19 |
20 | class GDOSelect : public select::Select, public Component {
21 | public:
22 | void setup() override {
23 | std::string value;
24 | size_t index;
25 | this->pref_ = global_preferences->make_preference(this->get_object_id_hash());
26 | if (!this->pref_.load(&index)) {
27 | value = this->initial_option_;
28 | } else if (!this->has_index(index)) {
29 | value = this->initial_option_;
30 | } else {
31 | value = this->at(index).value();
32 | }
33 |
34 | this->control(value);
35 | }
36 |
37 | void set_initial_option(const std::string &initial_option) { this->initial_option_ = initial_option; }
38 |
39 | void update_state(gdo_protocol_type_t protocol) {
40 | if (this->has_index(protocol)) {
41 | std::string value = this->at(protocol).value();
42 | if (this->has_state() && value != this->current_option()) {
43 | this->pref_.save(&protocol);
44 | }
45 |
46 | this->publish_state(value);
47 | }
48 | }
49 |
50 | protected:
51 | void control(const std::string &value) override {
52 | auto idx = this->index_of(value);
53 | if (idx.has_value()) {
54 | gdo_protocol_type_t protocol = static_cast(idx.value());
55 | this->update_state(protocol);
56 | if (gdo_set_protocol(protocol) != ESP_OK) {
57 | vTaskDelay(pdMS_TO_TICKS(100));
58 | App.safe_reboot();
59 | }
60 | }
61 | }
62 |
63 | std::string initial_option_;
64 | ESPPreferenceObject pref_;
65 | };
66 |
67 | } // namespace secplus_gdo
68 | } // namespace esphome
69 |
--------------------------------------------------------------------------------
/components/secplus_gdo/light/gdo_light.h:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (C) 2024 Konnected Inc.
3 | *
4 | * This program is free software: you can redistribute it and/or modify
5 | * it under the terms of the GNU General Public License as published by
6 | * the Free Software Foundation, either version 3 of the License, or
7 | * (at your option) any later version.
8 | *
9 | * This program is distributed in the hope that it will be useful,
10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 | * GNU General Public License for more details.
13 | *
14 | * You should have received a copy of the GNU General Public License
15 | * along with this program. If not, see .
16 | */
17 |
18 | #pragma once
19 |
20 | #include "esphome/core/component.h"
21 | #include "esphome/components/binary/light/binary_light_output.h"
22 | #include "gdo.h"
23 |
24 | namespace esphome {
25 | namespace secplus_gdo {
26 |
27 | class GDOLight : public binary::BinaryLightOutput, public Component {
28 | public:
29 | void setup_state(light::LightState *state) override { this->state_ = state; }
30 |
31 | void write_state(light::LightState *state) override {
32 | if (!this->synced_) {
33 | return;
34 | }
35 |
36 | bool binary;
37 | state->current_values_as_binary(&binary);
38 | if (binary)
39 | gdo_light_on();
40 | else
41 | gdo_light_off();
42 | }
43 |
44 | void set_state(gdo_light_state_t state) {
45 | if (state == this->light_state_) {
46 | return;
47 | }
48 |
49 | this->light_state_ = state;
50 | ESP_LOGI(TAG, "Light state: %s", gdo_light_state_to_string(state));
51 | bool is_on = state == GDO_LIGHT_STATE_ON;
52 | this->state_->current_values.set_state(is_on);
53 | this->state_->remote_values.set_state(is_on);
54 | this->state_->publish_state();
55 | }
56 |
57 | void set_sync_state(bool synced) {
58 | this->synced_ = synced;
59 | }
60 |
61 | private:
62 | light::LightState *state_{nullptr};
63 | gdo_light_state_t light_state_{GDO_LIGHT_STATE_MAX};
64 | static constexpr auto TAG{"GDOLight"};
65 | bool synced_{false};
66 | }; // GDOLight
67 | } // namespace secplus_gdo
68 | } // namespace esphome
69 |
--------------------------------------------------------------------------------
/components/secplus_gdo/number/__init__.py:
--------------------------------------------------------------------------------
1 | """
2 | /*
3 | * Copyright (C) 2024 Konnected Inc.
4 | *
5 | * This program is free software: you can redistribute it and/or modify
6 | * it under the terms of the GNU General Public License as published by
7 | * the Free Software Foundation, either version 3 of the License, or
8 | * (at your option) any later version.
9 | *
10 | * This program is distributed in the hope that it will be useful,
11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 | * GNU General Public License for more details.
14 | *
15 | * You should have received a copy of the GNU General Public License
16 | * along with this program. If not, see .
17 | */
18 | """
19 |
20 | import esphome.codegen as cg
21 | import esphome.config_validation as cv
22 | from esphome.components import number
23 | from esphome.const import CONF_ID
24 |
25 | from .. import SECPLUS_GDO_CONFIG_SCHEMA, secplus_gdo_ns, CONF_SECPLUS_GDO_ID
26 |
27 | DEPENDENCIES = ["secplus_gdo"]
28 |
29 | GDONumber = secplus_gdo_ns.class_("GDONumber", number.Number, cg.Component)
30 |
31 | CONF_TYPE = "type"
32 | TYPES = {
33 | "open_duration": "register_open_duration",
34 | "close_duration": "register_close_duration",
35 | "client_id": "register_client_id",
36 | "rolling_code": "register_rolling_code",
37 | }
38 |
39 | CONFIG_SCHEMA = (
40 | number.number_schema(GDONumber)
41 | .extend(
42 | {
43 | cv.Required(CONF_TYPE): cv.enum(TYPES, lower=True),
44 | }
45 | )
46 | .extend(SECPLUS_GDO_CONFIG_SCHEMA)
47 | )
48 |
49 | async def to_code(config):
50 | var = cg.new_Pvariable(config[CONF_ID])
51 | if "duration" in str(config[CONF_TYPE]):
52 | await number.register_number(var, config, min_value=0x0, max_value=0xffff, step=1)
53 | elif "client_id" in str(config[CONF_TYPE]):
54 | await number.register_number(var, config, min_value=0x666, max_value=0x7ff666, step=1)
55 | else:
56 | await number.register_number(var, config, min_value=0x0, max_value=0xffffffff, step=1)
57 | await cg.register_component(var, config)
58 | parent = await cg.get_variable(config[CONF_SECPLUS_GDO_ID])
59 | fcall = str(parent) + "->" + str(TYPES[config[CONF_TYPE]])
60 | text = fcall + "(" + str(var) + ")"
61 | cg.add((cg.RawExpression(text)))
62 | text = "gdo_set_" + str(config[CONF_TYPE])
63 | cg.add(var.set_control_function(cg.RawExpression(text)))
64 |
--------------------------------------------------------------------------------
/packages/garage-door-cover.yaml:
--------------------------------------------------------------------------------
1 | cover:
2 | - platform: template
3 | name: $garage_door_cover_name
4 | id: garage_door
5 | device_class: garage
6 |
7 | # Opens the garage door only if the garage door is currently closed
8 | open_action:
9 | - if:
10 | condition:
11 | lambda: return id(garage_door).position == COVER_CLOSED;
12 | then:
13 | - button.press: garage_door_opener_button
14 | - cover.template.publish:
15 | id: garage_door
16 | current_operation: OPENING
17 | else:
18 | - script.execute: error_tone_1
19 | - lambda: ESP_LOGW("circuitsetup.gdo","Garage door is already open. Ignoring open action.");
20 |
21 |
22 | # Closes the garage door only if the garage door is currently open.
23 | # Triggers the pre-close warning before closing
24 | close_action:
25 | - if:
26 | condition:
27 | lambda: return id(garage_door).position == COVER_OPEN;
28 | then:
29 | - button.press: pre_close_warning
30 | - delay: $garage_door_close_warning_duration
31 | - button.press: garage_door_opener_button
32 | - cover.template.publish:
33 | id: garage_door
34 | current_operation: CLOSING
35 | else:
36 | - script.execute: error_tone_1
37 | - lambda: ESP_LOGW("circuitsetup.gdo","Garage door is already closed. Ignoring close action.");
38 |
39 | # Toggles the garage door open or closed
40 | # If the action would cause the door to close, then the pre-close warning is
41 | # triggered prior to closing
42 | toggle_action:
43 | - if:
44 | condition:
45 | lambda: return id(garage_door).position == COVER_OPEN;
46 | then:
47 | - button.press: pre_close_warning
48 | - delay: $garage_door_close_warning_duration
49 | - cover.template.publish:
50 | id: garage_door
51 | current_operation: CLOSING
52 | else:
53 | - cover.template.publish:
54 | id: garage_door
55 | current_operation: OPENING
56 | - button.press: garage_door_opener_button
57 |
58 | # Triggers the garage door button to stop only if the garage door is known to be moving
59 | stop_action:
60 | - if:
61 | condition:
62 | not:
63 | lambda: return id(garage_door).current_operation == CoverOperation::COVER_OPERATION_IDLE;
64 | then:
65 | - button.press: garage_door_opener_button
66 | - cover.template.publish:
67 | id: garage_door
68 | current_operation: IDLE
69 |
--------------------------------------------------------------------------------
/components/secplus_gdo/cover/gdo_door.h:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (C) 2024 Konnected Inc.
3 | *
4 | * This program is free software: you can redistribute it and/or modify
5 | * it under the terms of the GNU General Public License as published by
6 | * the Free Software Foundation, either version 3 of the License, or
7 | * (at your option) any later version.
8 | *
9 | * This program is distributed in the hope that it will be useful,
10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 | * GNU General Public License for more details.
13 | *
14 | * You should have received a copy of the GNU General Public License
15 | * along with this program. If not, see .
16 | */
17 |
18 | #pragma once
19 |
20 | #include "esphome/components/cover/cover.h"
21 | #include "esphome/core/component.h"
22 | #include "automation.h"
23 | #include "gdo.h"
24 |
25 | namespace esphome {
26 | namespace secplus_gdo {
27 |
28 | class GDOComponent;
29 |
30 | using namespace esphome::cover;
31 | class GDODoor : public cover::Cover, public Component {
32 | public:
33 | [[nodiscard]] cover::CoverTraits get_traits() override {
34 | CoverTraits traits;
35 | traits.set_supports_stop(true);
36 | traits.set_supports_toggle(true);
37 | traits.set_supports_position(true);
38 | return traits;
39 | }
40 |
41 | void register_door_closing_warn_start_trigger(CoverClosingStartTrigger *trigger) {
42 | this->pre_close_start_trigger = trigger;
43 | }
44 |
45 | void register_door_closing_warn_end_trigger(CoverClosingEndTrigger *trigger) {
46 | this->pre_close_end_trigger = trigger;
47 | }
48 |
49 | void set_sync_state(bool synced) {
50 | this->synced_ = synced;
51 | }
52 |
53 | void do_action(const cover::CoverCall& call);
54 | void do_action_after_warning(cover::CoverCall call);
55 | void set_pre_close_warning_duration(uint32_t ms) { this->pre_close_duration_ = ms; }
56 | void set_toggle_only(bool val) { this->toggle_only_ = val; }
57 | void set_state(gdo_door_state_t state, float position);
58 | void set_parent(GDOComponent *parent) { this->parent_ = parent; }
59 |
60 | protected:
61 | void control(const cover::CoverCall& call);
62 |
63 | CoverClosingStartTrigger *pre_close_start_trigger{nullptr};
64 | CoverClosingEndTrigger *pre_close_end_trigger{nullptr};
65 | uint32_t pre_close_duration_{0};
66 | bool pre_close_active_{false};
67 | bool toggle_only_{false};
68 | optional target_position_{0};
69 | CoverOperation prev_operation{COVER_OPERATION_IDLE};
70 | gdo_door_state_t state_{GDO_DOOR_STATE_UNKNOWN};
71 | bool synced_{false};
72 | GDOComponent *parent_{nullptr};
73 | };
74 | } // namespace secplus_gdo
75 | } // namespace esphome
76 |
--------------------------------------------------------------------------------
/components/secplus_gdo/cover/__init__.py:
--------------------------------------------------------------------------------
1 | """
2 | /*
3 | * Copyright (C) 2024 Konnected Inc.
4 | *
5 | * This program is free software: you can redistribute it and/or modify
6 | * it under the terms of the GNU General Public License as published by
7 | * the Free Software Foundation, either version 3 of the License, or
8 | * (at your option) any later version.
9 | *
10 | * This program is distributed in the hope that it will be useful,
11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 | * GNU General Public License for more details.
14 | *
15 | * You should have received a copy of the GNU General Public License
16 | * along with this program. If not, see .
17 | */
18 | """
19 |
20 | import esphome.codegen as cg
21 | import esphome.config_validation as cv
22 | from esphome import automation
23 | from esphome.components import cover
24 | from esphome.const import CONF_TRIGGER_ID
25 |
26 | from .. import SECPLUS_GDO_CONFIG_SCHEMA, secplus_gdo_ns, CONF_SECPLUS_GDO_ID
27 |
28 | DEPENDENCIES = ["secplus_gdo"]
29 |
30 | GDODoor = secplus_gdo_ns.class_("GDODoor", cover.Cover, cg.Component)
31 |
32 | CoverClosingStartTrigger = secplus_gdo_ns.class_(
33 | "CoverClosingStartTrigger", automation.Trigger.template()
34 | )
35 |
36 | CoverClosingEndTrigger = secplus_gdo_ns.class_(
37 | "CoverClosingEndTrigger", automation.Trigger.template()
38 | )
39 |
40 | CONF_PRE_CLOSE_WARNING_DURATION = "pre_close_warning_duration"
41 | CONF_PRE_CLOSE_WARNING_START = "pre_close_warning_start"
42 | CONF_PRE_CLOSE_WARNING_END = "pre_close_warning_end"
43 |
44 | CONFIG_SCHEMA = (
45 | cover.cover_schema(GDODoor)
46 | .extend(
47 | {
48 | cv.Optional(CONF_PRE_CLOSE_WARNING_DURATION, default=0): cv.positive_time_period_milliseconds,
49 | cv.Optional(CONF_PRE_CLOSE_WARNING_START): automation.validate_automation(
50 | {cv.GenerateID(CONF_TRIGGER_ID): cv.declare_id(CoverClosingStartTrigger)}
51 | ),
52 | cv.Optional(CONF_PRE_CLOSE_WARNING_END): automation.validate_automation(
53 | {cv.GenerateID(CONF_TRIGGER_ID): cv.declare_id(CoverClosingEndTrigger)}
54 | ),
55 | }
56 | ).extend(SECPLUS_GDO_CONFIG_SCHEMA)
57 | )
58 |
59 | async def to_code(config):
60 | var = await cover.new_cover(config)
61 | await cg.register_component(var, config)
62 | parent = await cg.get_variable(config[CONF_SECPLUS_GDO_ID])
63 | cg.add(parent.register_door(var))
64 | cg.add(var.set_pre_close_warning_duration(config[CONF_PRE_CLOSE_WARNING_DURATION]))
65 | for conf in config.get(CONF_PRE_CLOSE_WARNING_START, []):
66 | trigger = cg.new_Pvariable(conf[CONF_TRIGGER_ID], var)
67 | await automation.build_automation(trigger, [], conf)
68 | cg.add(var.register_door_closing_warn_start_trigger(trigger))
69 | for conf in config.get(CONF_PRE_CLOSE_WARNING_END, []):
70 | trigger = cg.new_Pvariable(conf[CONF_TRIGGER_ID], var)
71 | await automation.build_automation(trigger, [], conf)
72 | cg.add(var.register_door_closing_warn_end_trigger(trigger))
73 |
--------------------------------------------------------------------------------
/packages/secplus-gdo.yaml:
--------------------------------------------------------------------------------
1 | script:
2 | - id: pc_warn
3 | then:
4 | - button.press: pre_close_warning
5 |
6 | secplus_gdo:
7 | id: cs_gdo
8 | input_gdo_pin: ${uart_rx_pin}
9 | output_gdo_pin: ${uart_tx_pin}
10 |
11 | light:
12 | - platform: secplus_gdo
13 | name: $garage_light_name
14 | secplus_gdo_id: cs_gdo
15 | id: gdo_light
16 |
17 | cover:
18 | - platform: secplus_gdo
19 | name: $garage_door_cover_name
20 | secplus_gdo_id: cs_gdo
21 | id: gdo_door
22 | pre_close_warning_duration: $garage_door_close_warning_duration
23 | pre_close_warning_start:
24 | - script.execute:
25 | id: pc_warn
26 | pre_close_warning_end:
27 | - script.stop: pc_warn
28 | - light.turn_off: warning_led
29 |
30 | sensor:
31 | - platform: secplus_gdo
32 | secplus_gdo_id: cs_gdo
33 | id: gdo_openings
34 | type: openings
35 | name: $garage_openings_name
36 | unit_of_measurement: openings
37 | icon: mdi:open-in-app
38 |
39 | text_sensor:
40 | - platform: secplus_gdo
41 | secplus_gdo_id: cs_gdo
42 | id: gdo_battery
43 | name: $garage_battery_name
44 | type: battery
45 | icon: mdi:battery
46 |
47 | lock:
48 | - platform: secplus_gdo
49 | id: gdo_lock_remotes
50 | secplus_gdo_id: cs_gdo
51 | name: $garage_lock_name
52 |
53 | binary_sensor:
54 | - platform: secplus_gdo
55 | name: $garage_motion_name
56 | id: gdo_motion
57 | secplus_gdo_id: cs_gdo
58 | device_class: motion
59 | type: motion
60 | - platform: secplus_gdo
61 | name: $garage_obstruction_name
62 | id: gdo_obst
63 | secplus_gdo_id: cs_gdo
64 | device_class: problem
65 | type: obstruction
66 | - platform: secplus_gdo
67 | name: $garage_motor_name
68 | id: gdo_motor
69 | secplus_gdo_id: cs_gdo
70 | device_class: running
71 | type: motor
72 | - platform: secplus_gdo
73 | name: $garage_button_name
74 | id: gdo_button
75 | secplus_gdo_id: cs_gdo
76 | type: button
77 | - platform: secplus_gdo
78 | name: $garage_wireless_remote_name
79 | id: gdo_wireless_remote
80 | secplus_gdo_id: cs_gdo
81 | type: wireless_remote
82 | icon: mdi:remote
83 | - platform: secplus_gdo
84 | name: $garage_sync_name
85 | id: gdo_synced
86 | secplus_gdo_id: cs_gdo
87 | type: sync
88 | device_class: connectivity
89 |
90 | switch:
91 | - platform: secplus_gdo
92 | id: gdo_learn
93 | type: learn
94 | secplus_gdo_id: cs_gdo
95 | name: Learn
96 | icon: mdi:plus-box
97 | - platform: secplus_gdo
98 | id: gdo_toggle_only
99 | type: toggle_only
100 | secplus_gdo_id: cs_gdo
101 | name: Toggle Only
102 | icon: mdi:plus-box
103 | entity_category: config
104 |
105 | select:
106 | - platform: secplus_gdo
107 | id: gdo_protocol
108 | secplus_gdo_id: cs_gdo
109 | name: Security+ protocol
110 | icon: mdi:settings
111 | entity_category: config
112 |
113 | button:
114 | - platform: factory_reset
115 | name: Factory Reset
116 | id: hard_reset
117 | entity_category: config
118 | - platform: template
119 | name: Reset door timings
120 | id: reset_door_timings
121 | entity_category: config
122 | on_press:
123 | - number.set:
124 | id: gdo_open_duration
125 | value: 0
126 | - number.set:
127 | id: gdo_close_duration
128 | value: 0
129 | - button.press:
130 | id: restart_button
131 | - platform: template
132 | name: Re-sync
133 | id: resync
134 | entity_category: config
135 | on_press:
136 | - if:
137 | condition:
138 | lambda: 'return id(gdo_client_id).state;'
139 | then:
140 | - number.increment:
141 | id: gdo_client_id
142 | else:
143 | - number.set:
144 | id: gdo_client_id
145 | value: 0x667
146 | - number.set:
147 | id: gdo_rolling_code
148 | value: 0
149 | - button.press:
150 | id: restart_button
151 |
152 | number:
153 | - platform: secplus_gdo
154 | name: Opening duration
155 | secplus_gdo_id: cs_gdo
156 | entity_category: config
157 | id: gdo_open_duration
158 | type: open_duration
159 | unit_of_measurement: "ms"
160 | internal: true
161 |
162 | - platform: secplus_gdo
163 | name: Closing duration
164 | secplus_gdo_id: cs_gdo
165 | entity_category: config
166 | id: gdo_close_duration
167 | type: close_duration
168 | unit_of_measurement: "ms"
169 | internal: true
170 |
171 | - platform: secplus_gdo
172 | name: Client ID
173 | secplus_gdo_id: cs_gdo
174 | entity_category: config
175 | id: gdo_client_id
176 | type: client_id
177 | mode: box
178 | internal: true
179 |
180 | - platform: secplus_gdo
181 | name: Rolling Code
182 | secplus_gdo_id: cs_gdo
183 | entity_category: config
184 | id: gdo_rolling_code
185 | type: rolling_code
186 | mode: box
187 | internal: true
188 |
189 | wifi:
190 | on_connect:
191 | lambda: id(cs_gdo).start_gdo();
192 |
--------------------------------------------------------------------------------
/circuitsetup-gdo-dry-contact.yaml:
--------------------------------------------------------------------------------
1 | ####
2 | ##
3 | ## CircuitSetup Security+ Garage Door Opener
4 | ## Firmware configuration for ESPHome
5 | ##
6 | ## filename: circuitsetup-gdo-dry-contact.yaml
7 | ## GitHub: https://github.com/circuitsetup/circuitsetup-esphome
8 | ##
9 | ## Copyright© 2023 Konnected Inc.
10 | ##
11 | ## Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation
12 | ## files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy,
13 | ## modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software
14 | ## is furnished to do so, subject to the following conditions:
15 | ##
16 | ## The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
17 | ##
18 | ## THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
19 | ## OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
20 | ## LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
21 | ## IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
22 | ##
23 | ####
24 |
25 | ####
26 | # INTRODUCTION
27 | #
28 | # This ESPHome based firmware configuration is designed for the CircuitSetup Security+ Garage Door Opener which is built on the ESP32-S3.
29 | # The Garage Door Opener retrofits an older style traditional garage door opener with a dry-contact trigger and has the
30 | # following features which are included as packages below:
31 | #
32 | # 1. Wired contact sensor for detecting open/closed state of garage door
33 | # 2. Emulates a garage door opener button wired to a dry contact relay to open/close the garage door.
34 | # 3. Adds a Garage Door "Cover" entity that is exposed to Home Assistant. The cover entity incorporates the state of the
35 | # garage door and controls to open/close/stop it.
36 | # 4. Flashes an onboard LED and beeps an onboard piezo sounder as a warning before automatically closing.
37 | # 5. Provides garage temp and humidity
38 |
39 | ####
40 | # GENERAL SETTINGS
41 | # Customize these variables to your preferences and needs
42 | # more: https://esphome.io/guides/configuration-types.html#substitutions
43 | substitutions:
44 |
45 | ####
46 | # NAME
47 | # By default, the name of the ESPHome device is "circuitsetup-gdo-xxxxxx" where xxxxxx is a unique identifier. The device's
48 | # hostname on your network is also defined by the name, defaulting to "circuitsetup-xxxxxx.local". Edit this variable to
49 | # customize the name and hostname. Note: only lowercase characters, numbers and hyphen(-) are allowed.
50 | name: circuitsetup-gdo
51 | friendly_name: Garage Door Opener
52 | project_name: circuitsetup.gdo-dry-contact
53 | project_version: "1.0"
54 | garage_door_cover_name: Garage Door
55 | garage_temp_name: Garage Temp
56 | garage_humidity_name: Garage Humidity
57 | temp_update_interval: 60s
58 | temp_adjust: "0.8825" # 1-0.1175 - 11.75% decrease
59 | dew_point_offset: "1.3" # Offset in °F to correct sensor's lower dew point read
60 |
61 | ####
62 | # GARAGE DOOR OPENER MOMENTARY DURATION
63 | # Duration to make the relay contact closure for the garage door opener button circuit.
64 | garage_door_opener_momentary_duration: 300ms
65 |
66 | ####
67 | # GARAGE DOOR CLOSE WARNING DURATION
68 | # Duration to blink the warning LED and beep the buzzer before the garage door closes.
69 | garage_door_close_warning_duration: 5s
70 |
71 | ####
72 | # ADDITIONAL SETTTINGS
73 | sensor_debounce_time: 200ms
74 | blink_on_state: "true"
75 |
76 | ####
77 | # INTERNAL MAPPINGS
78 | # DO NOT EDIT these when using circuitsetup hardware
79 | door_control_pin: GPIO7 # Aux Out
80 | wired_sensor_pin: GPIO5 # Aux In 1
81 | warning_beep_pin: GPIO4
82 | warning_leds_pin: GPIO3
83 | status_led: GPIO18
84 | sda: GPIO16
85 | scl: GPIO15
86 |
87 | ####
88 | # PACKAGES
89 | # Each package includes a Garage Door Opener feature described
90 | # Remove or comment out any packages that you do not need or want.
91 | packages:
92 |
93 | remote_package:
94 | url: https://github.com/circuitsetup/circuitsetup-esphome
95 | ref: master
96 | refresh: 1d
97 | files:
98 |
99 | ####
100 | # CORE
101 | # This package is required and sets up core ESPHome features.
102 | - packages/core-esp32-s3.yaml
103 |
104 | ####
105 | # GARAGE DOOR WIRED SENSOR
106 | # Enables a wired contact sensor for reporting the open or closed state of the garage door
107 | # via the physical INPUT terminals.
108 | - packages/garage-door-wired-sensor.yaml
109 |
110 | ####
111 | # GARAGE DOOR COVER
112 | # The Garage Door Cover is the main user interface entity representing a garage door in Home Assistant.
113 | # more: https://www.home-assistant.io/integrations/cover/
114 | # WIRED SENSOR
115 | - packages/garage-door-cover-wired.yaml
116 |
117 | ####
118 | # GARAGE DOOR OPENER BUTTON
119 | # Enables the garage door opener relay labeled DOOR on the CircuitSetup Garage Door Opener as a button entity. When
120 | # pressed, the relay will close the dry contact, simulating a physical press of the garage door opener wall button.
121 | - packages/garage-door-opener-button.yaml
122 |
123 | ####
124 | # WARNING LED
125 | # Enables the onboard warning LED light, with strobe effect. Used to visually warn of garage door automatic closing.
126 | # warning_led: !include packages/warning-led.yaml
127 | - packages/warning-led.yaml
128 |
129 | ####
130 | # WIFI
131 | # Enables WiFi connectivity and diagnostics. Uncommet below to enable WiFi.
132 | # wifi: !include packages/wifi.yaml
133 | - packages/wifi-esp32.yaml
134 |
135 | ####
136 | # PRE-CLOSE WARNING
137 | # Enables a pleasant and customizable pre-close warning tone using the onboard piezo buzzer. Used to audibly
138 | # warn of a garage door automatic closing.
139 | - packages/buzzer-rtttl.yaml
140 | - packages/pre-close-warning-tones.yaml
141 |
142 | ####
143 | # STATUS LED
144 | # Enables the onboard blue status LED as an activity/error indicator
145 | # status_led: !include packages/status-led.yaml
146 | - packages/status-led.yaml
147 |
148 | ####
149 | # TEMP SENSOR
150 | # The on-board temp & humidity sensor
151 | - packages/temp-sensor.yaml
152 |
153 | ####
154 | # DASHBOARD IMPORT
155 | # Enables automatic discovery and upgrades via ESPHome Dashboard
156 | # more: https://esphome.io/guides/getting_started_hassio.html
157 | dashboard_import:
158 | package_import_url: github://CircuitSetup/circuitsetup-esphome/circuitsetup-gdo-dry-contact.yaml@master
159 | import_full_config: false
160 |
161 | ####
162 | # LOGGER
163 | # more: https://esphome.io/components/logger.html
164 | logger:
165 | level: DEBUG
166 | logs:
167 | ledc.output: INFO
168 | sensor: INFO
169 | json: INFO
170 | api: DEBUG
171 |
172 | ####
173 | # NATIVE API
174 | # Enables the native ESPHome API
175 | # more: https://esphome.io/components/api.html
176 | api:
177 |
178 | esp32_improv:
179 | authorizer: none
180 |
181 | web_server:
182 |
--------------------------------------------------------------------------------
/circuitsetup-secplus-garage-door-opener.yaml:
--------------------------------------------------------------------------------
1 | ####
2 | ##
3 | ## CircuitSetup Security+ Garage Door Opener
4 | ## Firmware configuration for ESPHome
5 | ##
6 | ## filename: circuitsetup-secplus-garage-door-opener.yaml
7 | ## GitHub: https://github.com/CircuitSetup/circuitsetup-esphome
8 | ##
9 | ## Copyright© 2023 Konnected Inc.
10 | ##
11 | ## Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation
12 | ## files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy,
13 | ## modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software
14 | ## is furnished to do so, subject to the following conditions:
15 | ##
16 | ## The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
17 | ##
18 | ## THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
19 | ## OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
20 | ## LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
21 | ## IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
22 | ##
23 | ####
24 |
25 | ####
26 | # INTRODUCTION
27 | #
28 | # This ESPHome based firmware configuration is designed for the CircuitSetup Security+ Garage Door Opener, which is built on the ESP32-S3.
29 | # It allows you to use a Security+ Garage Door Opener in Home Assistant, and adds the following:
30 | #
31 | # 1. Gets opened/closed door state and obstruction sensor data
32 | # 2. Emulates a Security+ garage door opener button.
33 | # 3. Adds a Garage Door "Cover" entity that is exposed to Home Assistant. The cover entity incorporates the state of the
34 | # garage door and controls to open/close/stop it.
35 | # 4. Adds control of opener light
36 | # 5. Flashes an onboard LED and beeps an onboard piezo sounder as a warning before automatically closing.
37 |
38 | ####
39 | # GENERAL SETTINGS
40 | # Customize these variables to your preferences and needs
41 | # more: https://esphome.io/guides/configuration-types.html#substitutions
42 |
43 | substitutions:
44 |
45 | ####
46 | # NAME
47 | # By default, the name of the ESPHome device is "circuitsetup-gdo-xxxxxx" where xxxxxx is a unique identifier. The device's
48 | # hostname on your network is also defined by the name, defaulting to "circuitsetup-gdo-xxxxxx.local". Edit this variable to
49 | # customize the name and hostname. Note: only lowercase characters, numbers and hyphen(-) are allowed.
50 | name: circuitsetup-gdo
51 | friendly_name: Garage Door Opener
52 | project_name: circuitsetup.secplus-garage-door-opener
53 | project_version: "1.3"
54 | garage_door_cover_name: Garage Door
55 | garage_light_name: Garage Light
56 | garage_openings_name: Garage Openings
57 | garage_temp_name: Garage Temp
58 | garage_humidity_name: Garage Humidity
59 | garage_lock_name: Lock
60 | garage_motion_name: Motion
61 | garage_obstruction_name: Obstruction
62 | garage_motor_name: Motor
63 | garage_button_name: Wall Button
64 | garage_wireless_remote_name: Wireless Remote
65 | garage_sync_name: Synced
66 | garage_battery_name: Battery
67 | temp_update_interval: 60s
68 | temp_adjust: "0.8825" # 1-0.1175 - 11.75% decrease
69 | dew_point_offset: "1.3" # Offset in °F to correct sensor's lower dew point reading
70 |
71 |
72 | ####
73 | # GARAGE DOOR CLOSE WARNING DURATION
74 | # Duration to blink the warning LED and beep the buzzer before the garage door closes.
75 | garage_door_close_warning_duration: 5s
76 |
77 | ####
78 | # ADDITIONAL SETTTINGS
79 | sensor_debounce_time: 200ms
80 | blink_on_state: "true"
81 |
82 | ####
83 | # INTERNAL MAPPINGS
84 | # DO NOT EDIT these when using CircuitSetup hardware
85 | uart_tx_pin: GPIO1
86 | uart_rx_pin: GPIO2
87 | warning_beep_pin: GPIO4
88 | warning_leds_pin: GPIO3
89 | status_led: GPIO18
90 | input1: GPIO5
91 | input2: GPIO6
92 | sda: GPIO16
93 | scl: GPIO15
94 |
95 | external_components:
96 | - source: github://CircuitSetup/circuitsetup-esphome@master
97 | components: [ secplus_gdo ]
98 |
99 | # Un-comment below and comment above for local modification
100 | # - source:
101 | # type: local
102 | # path: components
103 | # components: [ secplus_gdo ]
104 |
105 | ####
106 | # PACKAGES
107 | # Each package includes a Garage Door Opener feature described
108 | # Remove or comment out any packages that you do not need or want.
109 | packages:
110 |
111 | remote_package:
112 | url: https://github.com/CircuitSetup/circuitsetup-esphome
113 | ref: master
114 | refresh: 1d
115 | files:
116 |
117 | ####
118 | # CORE
119 | # This package is required and sets up core ESPHome features.
120 | - packages/core-esp32-s3.yaml
121 |
122 | ####
123 | # WIFI
124 | # Enables WiFi connectivity and diagnostics. Uncommet below to enable WiFi.
125 | # wifi: !include packages/wifi-esp32.yaml
126 | - packages/wifi-esp32.yaml
127 |
128 | ####
129 | # WARNING LED
130 | # Enables the onboard warning LED light, with strobe effect. Used to visually warn of garage door automatic closing.
131 | # warning_led: !include packages/warning-led.yaml
132 | - packages/warning-led.yaml
133 |
134 | ####
135 | # PRE-CLOSE WARNING
136 | # Enables a pleasant and customizable pre-close warning tone using the onboard piezo buzzer. Used to audibly
137 | # warn of a garage door automatic closing.
138 | - packages/buzzer-rtttl.yaml
139 | - packages/pre-close-warning-tones.yaml
140 |
141 | ####
142 | # STATUS LED
143 | # Enables the onboard blue status LED as an activity/error indicator
144 | # status_led: !include packages/status-led.yaml
145 | - packages/status-led.yaml
146 |
147 | ####
148 | # TEMP SENSOR
149 | # The on-board temp & humidity sensor
150 | - packages/temp-sensor.yaml
151 |
152 | ####
153 | # SECPLUS GDO
154 | # The logic and capabilities of the GDO communication
155 | - packages/secplus-gdo.yaml
156 | - packages/debug.yaml
157 |
158 | ####
159 | # DASHBOARD IMPORT
160 | # Enables automatic discovery and upgrades via ESPHome Dashboard
161 | # more: https://esphome.io/guides/getting_started_hassio.html
162 | dashboard_import:
163 | package_import_url: github://CircuitSetup/circuitsetup-esphome/circuitsetup-secplus-garage-door-opener.yaml@master
164 | import_full_config: false
165 |
166 | ####
167 | # LOGGER
168 | # more: https://esphome.io/components/logger.html
169 | logger:
170 | hardware_uart: UART0 # force CP2102N/TTL header
171 | baud_rate: 115200
172 | deassert_rts_dtr: true # avoids missing boot logs on auto-reset boards
173 | level: VERBOSE
174 | logs:
175 | esp-idf: DEBUG
176 | api: DEBUG
177 | api.service: DEBUG
178 | esp32_ble: DEBUG
179 | esp32_ble_server: DEBUG
180 | scheduler: DEBUG
181 | esp32.preferences: DEBUG
182 | sensor.filter: DEBUG
183 | rtttl: DEBUG
184 | cover: DEBUG
185 | sensor: DEBUG
186 | ledc.output: INFO
187 | json: INFO
188 |
189 | ####
190 | # NATIVE API
191 | # Enables the native ESPHome API
192 | # more: https://esphome.io/components/api.html
193 | api:
194 |
195 | web_server:
196 |
197 | esphome:
198 | platformio_options:
199 | lib_deps:
200 | - https://github.com/CircuitSetup/gdolib
201 | build_flags:
202 | - -Wl,--wrap=esp_panic_handler
203 |
--------------------------------------------------------------------------------
/components/secplus_gdo/secplus_gdo.h:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (C) 2024 Konnected Inc.
3 | *
4 | * This program is free software: you can redistribute it and/or modify
5 | * it under the terms of the GNU General Public License as published by
6 | * the Free Software Foundation, either version 3 of the License, or
7 | * (at your option) any later version.
8 | *
9 | * This program is distributed in the hope that it will be useful,
10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 | * GNU General Public License for more details.
13 | *
14 | * You should have received a copy of the GNU General Public License
15 | * along with this program. If not, see .
16 | */
17 |
18 | #pragma once
19 |
20 | #include "esphome/core/component.h"
21 | #include "number/gdo_number.h"
22 | #include "esphome/core/defines.h"
23 | #include "select/gdo_select.h"
24 | #include "switch/gdo_switch.h"
25 | #include "cover/gdo_door.h"
26 | #include "light/gdo_light.h"
27 | #include "lock/gdo_lock.h"
28 | #include "gdo.h"
29 | #include
30 | #include
31 |
32 | namespace esphome {
33 | namespace secplus_gdo {
34 | class GDOComponent : public Component {
35 | public:
36 | void setup() override;
37 | void loop() override {};
38 | void dump_config() override;
39 | void on_shutdown() override { gdo_deinit(); }
40 | void start_gdo() { start_gdo_ = true; }
41 |
42 | // Use Late priority so we do not start the GDO lib until all saved preferences are loaded
43 | [[nodiscard]] float get_setup_priority() const override { return setup_priority::BEFORE_CONNECTION; }
44 |
45 | void register_protocol_select(GDOSelect *select) { this->protocol_select_ = select; }
46 | void set_protocol_state(gdo_protocol_type_t protocol) { if (this->protocol_select_) {
47 | this->protocol_select_->update_state(protocol); }
48 | }
49 |
50 | void register_motion(std::function &&f) { f_motion = std::move(f); }
51 | void set_motion_state(gdo_motion_state_t state) { if (f_motion) { f_motion(state == GDO_MOTION_STATE_DETECTED); } }
52 |
53 | void register_obstruction(std::function &&f) { f_obstruction = std::move(f); }
54 | void set_obstruction(gdo_obstruction_state_t state) {
55 | if (f_obstruction) { f_obstruction(state == GDO_OBSTRUCTION_STATE_OBSTRUCTED); }
56 | }
57 |
58 | void register_button(std::function &&f) { f_button = std::move(f); }
59 | void set_button_state(gdo_button_state_t state) {
60 | if (state == GDO_BUTTON_STATE_PRESSED) {
61 | button_triggered_ = true;
62 | }
63 | if (f_button) {
64 | f_button(state == GDO_BUTTON_STATE_PRESSED);
65 | }
66 | }
67 |
68 | void register_motor(std::function &&f) { f_motor = std::move(f); }
69 | void set_motor_state(gdo_motor_state_t state) {
70 | if (f_motor) {
71 | f_motor(state == GDO_MOTOR_STATE_ON);
72 | }
73 | if (state == GDO_MOTOR_STATE_ON) {
74 | if (!button_triggered_ && !cover_triggered_ && f_wireless_remote) {
75 | f_wireless_remote(true);
76 | this->set_timeout("wireless_remote_off", 500, [this]() {
77 | if (f_wireless_remote) {
78 | f_wireless_remote(false);
79 | }
80 | });
81 | }
82 | button_triggered_ = false;
83 | cover_triggered_ = false;
84 | }
85 | }
86 |
87 | void register_wireless_remote(std::function &&f) { f_wireless_remote = std::move(f); }
88 |
89 | void notify_cover_command() { cover_triggered_ = true; }
90 |
91 | void register_sync(std::function &&f) { f_sync = std::move(f); }
92 |
93 | void register_battery(std::function &&f) { f_battery = std::move(f); }
94 | void set_battery_state(gdo_battery_state_t state) {
95 | if (f_battery && state != GDO_BATT_STATE_UNKNOWN) {
96 | f_battery(gdo_battery_state_to_string(state));
97 | }
98 | }
99 |
100 | void register_openings(std::function &&f) { f_openings = std::move(f); }
101 | void set_openings(uint16_t openings) { if (f_openings) { f_openings(openings); } }
102 |
103 | void register_door(GDODoor *door) { this->door_ = door; door->set_parent(this); }
104 | void set_door_state(gdo_door_state_t state, float position) { if (this->door_) { this->door_->set_state(state, position); } }
105 |
106 | void register_light(GDOLight *light) { this->light_ = light; }
107 | void set_light_state(gdo_light_state_t state) { if (this->light_) { this->light_->set_state(state); } }
108 |
109 | void register_lock(GDOLock *lock) { this->lock_ = lock; }
110 | void set_lock_state(gdo_lock_state_t state) { if (this->lock_) { this->lock_->set_state(state); } }
111 |
112 | void register_learn(GDOSwitch *sw) { this->learn_switch_ = sw; }
113 | void set_learn_state(gdo_learn_state_t state) { if (this->learn_switch_) {
114 | this->learn_switch_->write_state(state == GDO_LEARN_STATE_ACTIVE); }
115 | }
116 |
117 | void register_open_duration(GDONumber* num) { open_duration_ = num; }
118 | void set_open_duration(uint16_t ms ) { if (open_duration_) { open_duration_->update_state(ms); } }
119 |
120 | void register_close_duration(GDONumber* num) { close_duration_ = num; }
121 | void set_close_duration(uint16_t ms ) { if (close_duration_) { close_duration_->update_state(ms); } }
122 |
123 | void register_client_id(GDONumber* num) { client_id_ = num; }
124 | void set_client_id(uint32_t num) { if (client_id_) { client_id_->update_state(num); } }
125 |
126 | void register_rolling_code(GDONumber* num) { rolling_code_ = num; }
127 | void set_rolling_code(uint32_t num) { if (rolling_code_) { rolling_code_->update_state(num); } }
128 |
129 | void register_toggle_only(GDOSwitch *sw) { this->toggle_only_switch_ = sw; }
130 |
131 | void set_sync_state(bool synced);
132 |
133 | protected:
134 | gdo_status_t status_{};
135 | std::function f_openings{nullptr};
136 | std::function f_motion{nullptr};
137 | std::function f_obstruction{nullptr};
138 | std::function f_button{nullptr};
139 | std::function f_motor{nullptr};
140 | std::function f_wireless_remote{nullptr};
141 | std::function f_sync{nullptr};
142 | GDODoor* door_{nullptr};
143 | GDOLight* light_{nullptr};
144 | GDOLock* lock_{nullptr};
145 | GDONumber* open_duration_{nullptr};
146 | GDONumber* close_duration_{nullptr};
147 | GDONumber* client_id_{nullptr};
148 | GDONumber* rolling_code_{nullptr};
149 | GDOSelect* protocol_select_{nullptr};
150 | GDOSwitch* learn_switch_{nullptr};
151 | GDOSwitch* toggle_only_switch_{nullptr};
152 | bool start_gdo_{false};
153 | bool cover_triggered_{false};
154 | bool button_triggered_{false};
155 | std::function f_battery{nullptr};
156 |
157 | }; // GDOComponent
158 | } // namespace secplus_gdo
159 | } // namespace esphome
160 |
--------------------------------------------------------------------------------
/components/secplus_gdo/secplus_gdo.cpp:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (C) 2024 Konnected Inc.
3 | *
4 | * This program is free software: you can redistribute it and/or modify
5 | * it under the terms of the GNU General Public License as published by
6 | * the Free Software Foundation, either version 3 of the License, or
7 | * (at your option) any later version.
8 | *
9 | * This program is distributed in the hope that it will be useful,
10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 | * GNU General Public License for more details.
13 | *
14 | * You should have received a copy of the GNU General Public License
15 | * along with this program. If not, see .
16 | */
17 |
18 | #include "secplus_gdo.h"
19 | #include "esphome/core/application.h"
20 | #include "esphome/core/log.h"
21 | #include "inttypes.h"
22 | #include
23 | #include "driver/gpio.h"
24 |
25 | namespace esphome {
26 | namespace secplus_gdo {
27 |
28 | constexpr char TAG[] = "secplus_gdo";
29 |
30 | static void gdo_event_handler(const gdo_status_t* status, gdo_cb_event_t event, void *arg) {
31 | GDOComponent *gdo = static_cast(arg);
32 | switch (event) {
33 | case GDO_CB_EVENT_SYNCED:
34 | ESP_LOGI(TAG, "Synced: %s, protocol: %s", status->synced ? "true" : "false", gdo_protocol_type_to_string(status->protocol));
35 | if (status->protocol == GDO_PROTOCOL_SEC_PLUS_V2) {
36 | ESP_LOGI(TAG, "Client ID: %" PRIu32 ", Rolling code: %" PRIu32, status->client_id, status->rolling_code);
37 | if (status->synced) {
38 | // Save the last successful ClientID rolling code value to NVS for use on reboot
39 | gdo->set_client_id(status->client_id);
40 | gdo->set_rolling_code(status->rolling_code);
41 | }
42 | }
43 |
44 | if (!status->synced) {
45 | if (gdo_set_rolling_code(status->rolling_code + 100) != ESP_OK) {
46 | ESP_LOGE(TAG, "Failed to set rolling code");
47 | } else {
48 | ESP_LOGI(TAG, "Rolling code set to %" PRIu32 ", retryng sync", status->rolling_code);
49 | gdo_sync();
50 | }
51 | } else {
52 | gdo->set_protocol_state(status->protocol);
53 | }
54 |
55 | gdo->set_sync_state(status->synced);
56 | break;
57 | case GDO_CB_EVENT_LIGHT:
58 | gdo->set_light_state(status->light);
59 | break;
60 | case GDO_CB_EVENT_LOCK:
61 | gdo->set_lock_state(status->lock);
62 | break;
63 | case GDO_CB_EVENT_DOOR_POSITION: {
64 | float position = (float)(10000 - status->door_position)/10000.0f;
65 | gdo->set_door_state(status->door, position);
66 | if (status->door != GDO_DOOR_STATE_OPENING && status->door != GDO_DOOR_STATE_CLOSING) {
67 | gdo->set_motor_state(GDO_MOTOR_STATE_OFF);
68 | }
69 | break;
70 | }
71 | case GDO_CB_EVENT_LEARN:
72 | //ESP_LOGI(TAG, "Learn: %s", gdo_learn_state_to_string(status->learn));
73 | break;
74 | case GDO_CB_EVENT_OBSTRUCTION:
75 | ESP_LOGI(TAG, "Obstruction: %s", gdo_obstruction_state_to_string(status->obstruction));
76 | gdo->set_obstruction(status->obstruction);
77 | break;
78 | case GDO_CB_EVENT_MOTION:
79 | ESP_LOGI(TAG, "Motion: %s", gdo_motion_state_to_string(status->motion));
80 | gdo->set_motion_state(status->motion);
81 | break;
82 | case GDO_CB_EVENT_BATTERY:
83 | ESP_LOGI(TAG, "Battery: %s", gdo_battery_state_to_string(status->battery));
84 | gdo->set_battery_state(status->battery);
85 | break;
86 | case GDO_CB_EVENT_BUTTON:
87 | ESP_LOGI(TAG, "Button: %s", gdo_button_state_to_string(status->button));
88 | gdo->set_button_state(status->button);
89 | break;
90 | case GDO_CB_EVENT_MOTOR:
91 | ESP_LOGI(TAG, "Motor: %s", gdo_motor_state_to_string(status->motor));
92 | gdo->set_motor_state(status->motor);
93 | break;
94 | case GDO_CB_EVENT_OPENINGS:
95 | ESP_LOGI(TAG, "Openings: %d", status->openings);
96 | gdo->set_openings(status->openings);
97 | break;
98 | case GDO_CB_EVENT_TTC:
99 | ESP_LOGI(TAG, "Time to close: %d", status->ttc_seconds);
100 | break;
101 | case GDO_CB_EVENT_PAIRED_DEVICES:
102 | ESP_LOGI(TAG, "Paired devices: %d remotes, %d keypads, %d wall controls, %d accessories, %d total",
103 | status->paired_devices.total_remotes, status->paired_devices.total_keypads,
104 | status->paired_devices.total_wall_controls, status->paired_devices.total_accessories,
105 | status->paired_devices.total_all);
106 | break;
107 | case GDO_CB_EVENT_OPEN_DURATION_MEASUREMENT:
108 | ESP_LOGI(TAG, "Open duration: %d", status->open_ms);
109 | gdo->set_open_duration(status->open_ms);
110 | break;
111 | case GDO_CB_EVENT_CLOSE_DURATION_MEASUREMENT:
112 | ESP_LOGI(TAG, "Close duration: %d", status->close_ms);
113 | gdo->set_close_duration(status->close_ms);
114 | break;
115 | default:
116 | ESP_LOGI(TAG, "Unknown event: %d", event);
117 | break;
118 | }
119 | }
120 |
121 | void GDOComponent::setup() {
122 | // Set the toggle only state and control here because we cannot guarantee the cover instance was created before the switch
123 | this->door_->set_toggle_only(this->toggle_only_switch_->state);
124 | this->toggle_only_switch_->set_control_function(
125 | std::bind_front(&esphome::secplus_gdo::GDODoor::set_toggle_only, this->door_));
126 |
127 | gdo_config_t gdo_conf = {
128 | .uart_num = UART_NUM_1,
129 | .obst_from_status = true,
130 | .invert_uart = true,
131 | .uart_tx_pin = (gpio_num_t)GDO_UART_TX_PIN,
132 | .uart_rx_pin = (gpio_num_t)GDO_UART_RX_PIN,
133 | .obst_in_pin = (gpio_num_t)-1,
134 | };
135 |
136 | gdo_init(&gdo_conf);
137 | gdo_get_status(&this->status_);
138 | if (this->start_gdo_) {
139 | gdo_start(gdo_event_handler, this);
140 | ESP_LOGI(TAG, "secplus GDO started!");
141 | } else {
142 | // check every 500ms for readiness before starting GDO
143 | this->set_interval("gdo_start", 500, [this]() {
144 | if (this->start_gdo_) {
145 | gdo_start(gdo_event_handler, this);
146 | ESP_LOGI(TAG, "secplus GDO started!");
147 | this->cancel_interval("gdo_start");
148 | }
149 | });
150 |
151 | }
152 | }
153 |
154 | void GDOComponent::dump_config() {
155 | ESP_LOGCONFIG(TAG, "Setting up secplus GDO ...");
156 | }
157 |
158 | void GDOComponent::set_sync_state(bool synced) {
159 | if (this->door_) {
160 | this->door_->set_sync_state(synced);
161 | }
162 |
163 | if (this->light_) {
164 | this->light_->set_sync_state(synced);
165 | }
166 |
167 | if (this->lock_) {
168 | this->lock_->set_sync_state(synced);
169 | }
170 |
171 | if (this->f_sync) {
172 | this->f_sync(synced);
173 | }
174 | }
175 |
176 | } // namespace secplus_gdo
177 | } // namespace esphome
178 |
179 | // Need to wrap the panic handler to disable the GDO TX pin and pull the output high to
180 | // prevent spuriously triggering the GDO to open when the ESP32 panics.
181 | extern "C" {
182 | #include "hal/gpio_hal.h"
183 |
184 | void __real_esp_panic_handler(void*);
185 |
186 | void __wrap_esp_panic_handler(void* info) {
187 | esp_rom_printf("PANIC: DISABLING GDO UART TX PIN!\n");
188 | PIN_FUNC_SELECT(GPIO_PIN_MUX_REG[(gpio_num_t)GDO_UART_TX_PIN], PIN_FUNC_GPIO);
189 | gpio_set_direction((gpio_num_t)GDO_UART_TX_PIN, GPIO_MODE_INPUT);
190 | gpio_pulldown_en((gpio_num_t)GDO_UART_TX_PIN);
191 |
192 | // Call the original panic handler
193 | __real_esp_panic_handler(info);
194 | }
195 | } //extern "C"
196 |
--------------------------------------------------------------------------------
/components/secplus_gdo/cover/gdo_door.cpp:
--------------------------------------------------------------------------------
1 | #include "esphome/core/log.h"
2 | #include "gdo_door.h"
3 | #include "../secplus_gdo.h"
4 | #include
5 |
6 | namespace esphome {
7 | namespace secplus_gdo {
8 |
9 | constexpr char TAG[] = "gdo_cover";
10 |
11 | void GDODoor::set_state(gdo_door_state_t state, float position) {
12 | if (this->pre_close_active_) {
13 | // If we are in the pre-close state and the door is closing,
14 | // then it was triggered by something else and we need to cancel the pre-close
15 | if (state == GDO_DOOR_STATE_CLOSING) {
16 | this->cancel_timeout("pre_close");
17 | this->pre_close_active_ = false;
18 | if (this->pre_close_end_trigger) {
19 | this->pre_close_end_trigger->trigger();
20 | }
21 | } else {
22 | // If we are in the pre-close state, and the door is not closing, then do not update
23 | // the state so that the stop button remains active on the front end to cancel the closing operation
24 | return;
25 | }
26 | }
27 |
28 | ESP_LOGI(TAG, "Door state: %s, position: %.0f%%", gdo_door_state_to_string(state), position * 100.0f);
29 | this->prev_operation = this->current_operation; // save the previous operation
30 |
31 | switch (state) {
32 | case GDO_DOOR_STATE_OPEN:
33 | this->position = COVER_OPEN;
34 | this->current_operation = COVER_OPERATION_IDLE;
35 | break;
36 | case GDO_DOOR_STATE_CLOSED:
37 | this->position = COVER_CLOSED;
38 | this->current_operation = COVER_OPERATION_IDLE;
39 | break;
40 | case GDO_DOOR_STATE_OPENING:
41 | this->current_operation = COVER_OPERATION_OPENING;
42 | this->position = position;
43 | break;
44 | case GDO_DOOR_STATE_CLOSING:
45 | this->current_operation = COVER_OPERATION_CLOSING;
46 | this->position = position;
47 | break;
48 | case GDO_DOOR_STATE_STOPPED: // falls through
49 | case GDO_DOOR_STATE_MAX: // falls through
50 | default:
51 | this->current_operation = COVER_OPERATION_IDLE;
52 | this->position = position;
53 | break;
54 | }
55 |
56 | #ifdef USE_MQTT // if MQTT component is enabled, do not publish the same state more than once
57 | if (this->state_ == state && this->current_operation == this->prev_operation) { return; }
58 | #endif
59 |
60 | this->publish_state(false);
61 | this->state_ = state;
62 | }
63 |
64 | void GDODoor::do_action_after_warning(cover::CoverCall call) {
65 |
66 | if (this->pre_close_active_) {
67 | return;
68 | }
69 |
70 | this->set_state(GDO_DOOR_STATE_CLOSING, this->position);
71 |
72 | ESP_LOGD(TAG, "WARNING for %dms", this->pre_close_duration_);
73 | if (this->pre_close_start_trigger) {
74 | this->pre_close_start_trigger->trigger();
75 | }
76 |
77 | this->set_timeout("pre_close", this->pre_close_duration_, [this, call = std::move(call)]() {
78 | this->pre_close_active_ = false;
79 | if (this->pre_close_end_trigger) {
80 | this->pre_close_end_trigger->trigger();
81 | }
82 | this->do_action(call);
83 | });
84 |
85 | this->pre_close_active_ = true;
86 | }
87 |
88 | void GDODoor::do_action(const cover::CoverCall& call) {
89 | if (this->parent_) {
90 | this->parent_->notify_cover_command();
91 | }
92 | if (call.get_toggle()) {
93 | ESP_LOGD(TAG, "Sending TOGGLE action");
94 | gdo_door_toggle();
95 | return;
96 | }
97 |
98 | if (call.get_position().has_value()) {
99 | auto pos = *call.get_position();
100 | if (pos == COVER_OPEN) {
101 | if (this->toggle_only_) {
102 | ESP_LOGD(TAG, "Sending TOGGLE action");
103 | gdo_door_toggle();
104 | if (this->state_ == GDO_DOOR_STATE_STOPPED && this->prev_operation == COVER_OPERATION_OPENING) {
105 | // If the door was stopped while opening, then we need to toggle to stop, then toggle again to open,
106 | this->set_timeout("stop_door", 1000, []() {
107 | gdo_door_stop();
108 | });
109 | this->set_timeout("open_door", 2000, []() {
110 | gdo_door_toggle();
111 | });
112 | }
113 | } else {
114 | ESP_LOGD(TAG, "Sending OPEN action");
115 | gdo_door_open();
116 | }
117 | } else if (pos == COVER_CLOSED) {
118 | if (this->toggle_only_) {
119 | ESP_LOGD(TAG, "Sending TOGGLE action");
120 | gdo_door_toggle();
121 | if (this->state_ == GDO_DOOR_STATE_STOPPED && this->prev_operation == COVER_OPERATION_CLOSING) {
122 | // If the door was stopped while closing, then we need to toggle to stop, then toggle again to close,
123 | this->set_timeout("stop_door", 1000, []() {
124 | gdo_door_stop();
125 | });
126 | this->set_timeout("close_door", 2000, []() {
127 | gdo_door_toggle();
128 | });
129 | }
130 | } else {
131 | ESP_LOGD(TAG, "Sending CLOSE action");
132 | gdo_door_close();
133 | }
134 | } else {
135 | ESP_LOGD(TAG, "Moving garage door to position %f", pos);
136 | gdo_door_move_to_target(10000 - (pos * 10000));
137 | }
138 | }
139 | }
140 |
141 | void GDODoor::control(const cover::CoverCall& call) {
142 | if (!this->synced_) {
143 | this->publish_state(false);
144 | return;
145 | }
146 |
147 | if (call.get_stop()) {
148 | ESP_LOGD(TAG, "Stop command received");
149 | if (this->pre_close_active_) {
150 | ESP_LOGD(TAG, "Canceling pending action");
151 | this->cancel_timeout("pre_close");
152 | this->pre_close_active_ = false;
153 | if (this->pre_close_end_trigger) {
154 | this->pre_close_end_trigger->trigger();
155 | }
156 | this->set_state(GDO_DOOR_STATE_STOPPED, this->position);
157 | }
158 |
159 | gdo_door_stop();
160 | return;
161 | }
162 |
163 | if (call.get_toggle()) {
164 | ESP_LOGD(TAG, "Toggle command received");
165 | if (this->position != COVER_CLOSED) {
166 | this->target_position_ = COVER_CLOSED;
167 | this->do_action_after_warning(call);
168 | } else {
169 | this->target_position_ = COVER_OPEN;
170 | this->do_action(call);
171 | }
172 |
173 | return;
174 | }
175 |
176 | if (call.get_position().has_value()) {
177 | auto pos = *call.get_position();
178 | if (this->position == pos) {
179 | ESP_LOGD(TAG, "Door is already %s", pos == COVER_OPEN ? "open" : "closed");
180 | this->publish_state(false);
181 | return;
182 | }
183 |
184 | if ((this->current_operation == COVER_OPERATION_OPENING && pos > this->position) ||
185 | (this->current_operation == COVER_OPERATION_CLOSING && pos < this->position)) {
186 | ESP_LOGD(TAG, "Door is already moving in target direction; target position: %.0f%%", *this->target_position_);
187 | this->publish_state(false);
188 | return;
189 | }
190 |
191 | if (this->pre_close_active_) {
192 | // don't start the pre-close again if the door is already going to close.
193 | if (pos < this->position) {
194 | ESP_LOGD(TAG, "Door is already closing");
195 | this->publish_state(false);
196 | return;
197 | }
198 |
199 | ESP_LOGD(TAG, "Canceling pending action");
200 | this->cancel_timeout("pre_close");
201 | this->pre_close_active_ = false;
202 | if (this->pre_close_end_trigger) {
203 | this->pre_close_end_trigger->trigger();
204 | }
205 | }
206 |
207 | if (this->current_operation == COVER_OPERATION_OPENING ||
208 | this->current_operation == COVER_OPERATION_CLOSING) {
209 | ESP_LOGD(TAG, "Door is in motion - Sending STOP action");
210 | gdo_door_stop();
211 | }
212 |
213 | if (pos == COVER_OPEN) {
214 | ESP_LOGD(TAG, "Open command received");
215 | this->do_action(call);
216 | } else if (pos == COVER_CLOSED) {
217 | ESP_LOGD(TAG, "Close command received");
218 | this->do_action_after_warning(call);
219 | } else {
220 | ESP_LOGD(TAG, "Move to position %f command received", pos);
221 | if (pos < this->position) {
222 | ESP_LOGV(TAG, "Current position: %f; Intended position: %f; Door will move down after warning", this->position, pos);
223 | this->do_action_after_warning(call);
224 | } else {
225 | ESP_LOGV(TAG, "Current position: %f; Intended position: %f; Door will move up immediately", this->position, pos);
226 | this->do_action(call);
227 | }
228 | }
229 |
230 | this->target_position_ = pos;
231 | }
232 | }
233 |
234 | } // namespace secplus_gdo
235 | } // namespace esphome
236 |
--------------------------------------------------------------------------------
/LICENSE:
--------------------------------------------------------------------------------
1 | # ESPHome License
2 |
3 | Copyright (c) 2024 Konnected Inc.
4 |
5 | The ESPHome License is made up of two base licenses: MIT and the GNU GENERAL PUBLIC LICENSE.
6 | The C++/runtime codebase of the this project (file extensions .c, .cpp, .h, .hpp, .tcc, .ino) are published under the GPLv3 license. The python codebase, YAML configuration files, and all other parts of this codebase are published under the MIT license.
7 |
8 | Both MIT and GPLv3 licenses are attached to this document.
9 |
10 | ## MIT License
11 |
12 | Copyright (c) 2024 Konnected Inc.
13 |
14 | Permission is hereby granted, free of charge, to any person obtaining a copy
15 | of this software and associated documentation files (the "Software"), to deal
16 | in the Software without restriction, including without limitation the rights
17 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
18 | copies of the Software, and to permit persons to whom the Software is
19 | furnished to do so, subject to the following conditions:
20 |
21 | The above copyright notice and this permission notice shall be included in all
22 | copies or substantial portions of the Software.
23 |
24 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
25 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
26 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
27 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
28 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
29 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
30 | SOFTWARE.
31 |
32 | ## GPLv3 License
33 |
34 | GNU GENERAL PUBLIC LICENSE
35 | Version 3, 29 June 2007
36 |
37 | Copyright (C) 2007 Free Software Foundation, Inc.
38 | Everyone is permitted to copy and distribute verbatim copies
39 | of this license document, but changing it is not allowed.
40 |
41 | Preamble
42 |
43 | The GNU General Public License is a free, copyleft license for
44 | software and other kinds of works.
45 |
46 | The licenses for most software and other practical works are designed
47 | to take away your freedom to share and change the works. By contrast,
48 | the GNU General Public License is intended to guarantee your freedom to
49 | share and change all versions of a program--to make sure it remains free
50 | software for all its users. We, the Free Software Foundation, use the
51 | GNU General Public License for most of our software; it applies also to
52 | any other work released this way by its authors. You can apply it to
53 | your programs, too.
54 |
55 | When we speak of free software, we are referring to freedom, not
56 | price. Our General Public Licenses are designed to make sure that you
57 | have the freedom to distribute copies of free software (and charge for
58 | them if you wish), that you receive source code or can get it if you
59 | want it, that you can change the software or use pieces of it in new
60 | free programs, and that you know you can do these things.
61 |
62 | To protect your rights, we need to prevent others from denying you
63 | these rights or asking you to surrender the rights. Therefore, you have
64 | certain responsibilities if you distribute copies of the software, or if
65 | you modify it: responsibilities to respect the freedom of others.
66 |
67 | For example, if you distribute copies of such a program, whether
68 | gratis or for a fee, you must pass on to the recipients the same
69 | freedoms that you received. You must make sure that they, too, receive
70 | or can get the source code. And you must show them these terms so they
71 | know their rights.
72 |
73 | Developers that use the GNU GPL protect your rights with two steps:
74 | (1) assert copyright on the software, and (2) offer you this License
75 | giving you legal permission to copy, distribute and/or modify it.
76 |
77 | For the developers' and authors' protection, the GPL clearly explains
78 | that there is no warranty for this free software. For both users' and
79 | authors' sake, the GPL requires that modified versions be marked as
80 | changed, so that their problems will not be attributed erroneously to
81 | authors of previous versions.
82 |
83 | Some devices are designed to deny users access to install or run
84 | modified versions of the software inside them, although the manufacturer
85 | can do so. This is fundamentally incompatible with the aim of
86 | protecting users' freedom to change the software. The systematic
87 | pattern of such abuse occurs in the area of products for individuals to
88 | use, which is precisely where it is most unacceptable. Therefore, we
89 | have designed this version of the GPL to prohibit the practice for those
90 | products. If such problems arise substantially in other domains, we
91 | stand ready to extend this provision to those domains in future versions
92 | of the GPL, as needed to protect the freedom of users.
93 |
94 | Finally, every program is threatened constantly by software patents.
95 | States should not allow patents to restrict development and use of
96 | software on general-purpose computers, but in those that do, we wish to
97 | avoid the special danger that patents applied to a free program could
98 | make it effectively proprietary. To prevent this, the GPL assures that
99 | patents cannot be used to render the program non-free.
100 |
101 | The precise terms and conditions for copying, distribution and
102 | modification follow.
103 |
104 | TERMS AND CONDITIONS
105 |
106 | 0. Definitions.
107 |
108 | "This License" refers to version 3 of the GNU General Public License.
109 |
110 | "Copyright" also means copyright-like laws that apply to other kinds of
111 | works, such as semiconductor masks.
112 |
113 | "The Program" refers to any copyrightable work licensed under this
114 | License. Each licensee is addressed as "you". "Licensees" and
115 | "recipients" may be individuals or organizations.
116 |
117 | To "modify" a work means to copy from or adapt all or part of the work
118 | in a fashion requiring copyright permission, other than the making of an
119 | exact copy. The resulting work is called a "modified version" of the
120 | earlier work or a work "based on" the earlier work.
121 |
122 | A "covered work" means either the unmodified Program or a work based
123 | on the Program.
124 |
125 | To "propagate" a work means to do anything with it that, without
126 | permission, would make you directly or secondarily liable for
127 | infringement under applicable copyright law, except executing it on a
128 | computer or modifying a private copy. Propagation includes copying,
129 | distribution (with or without modification), making available to the
130 | public, and in some countries other activities as well.
131 |
132 | To "convey" a work means any kind of propagation that enables other
133 | parties to make or receive copies. Mere interaction with a user through
134 | a computer network, with no transfer of a copy, is not conveying.
135 |
136 | An interactive user interface displays "Appropriate Legal Notices"
137 | to the extent that it includes a convenient and prominently visible
138 | feature that (1) displays an appropriate copyright notice, and (2)
139 | tells the user that there is no warranty for the work (except to the
140 | extent that warranties are provided), that licensees may convey the
141 | work under this License, and how to view a copy of this License. If
142 | the interface presents a list of user commands or options, such as a
143 | menu, a prominent item in the list meets this criterion.
144 |
145 | 1. Source Code.
146 |
147 | The "source code" for a work means the preferred form of the work
148 | for making modifications to it. "Object code" means any non-source
149 | form of a work.
150 |
151 | A "Standard Interface" means an interface that either is an official
152 | standard defined by a recognized standards body, or, in the case of
153 | interfaces specified for a particular programming language, one that
154 | is widely used among developers working in that language.
155 |
156 | The "System Libraries" of an executable work include anything, other
157 | than the work as a whole, that (a) is included in the normal form of
158 | packaging a Major Component, but which is not part of that Major
159 | Component, and (b) serves only to enable use of the work with that
160 | Major Component, or to implement a Standard Interface for which an
161 | implementation is available to the public in source code form. A
162 | "Major Component", in this context, means a major essential component
163 | (kernel, window system, and so on) of the specific operating system
164 | (if any) on which the executable work runs, or a compiler used to
165 | produce the work, or an object code interpreter used to run it.
166 |
167 | The "Corresponding Source" for a work in object code form means all
168 | the source code needed to generate, install, and (for an executable
169 | work) run the object code and to modify the work, including scripts to
170 | control those activities. However, it does not include the work's
171 | System Libraries, or general-purpose tools or generally available free
172 | programs which are used unmodified in performing those activities but
173 | which are not part of the work. For example, Corresponding Source
174 | includes interface definition files associated with source files for
175 | the work, and the source code for shared libraries and dynamically
176 | linked subprograms that the work is specifically designed to require,
177 | such as by intimate data communication or control flow between those
178 | subprograms and other parts of the work.
179 |
180 | The Corresponding Source need not include anything that users
181 | can regenerate automatically from other parts of the Corresponding
182 | Source.
183 |
184 | The Corresponding Source for a work in source code form is that
185 | same work.
186 |
187 | 2. Basic Permissions.
188 |
189 | All rights granted under this License are granted for the term of
190 | copyright on the Program, and are irrevocable provided the stated
191 | conditions are met. This License explicitly affirms your unlimited
192 | permission to run the unmodified Program. The output from running a
193 | covered work is covered by this License only if the output, given its
194 | content, constitutes a covered work. This License acknowledges your
195 | rights of fair use or other equivalent, as provided by copyright law.
196 |
197 | You may make, run and propagate covered works that you do not
198 | convey, without conditions so long as your license otherwise remains
199 | in force. You may convey covered works to others for the sole purpose
200 | of having them make modifications exclusively for you, or provide you
201 | with facilities for running those works, provided that you comply with
202 | the terms of this License in conveying all material for which you do
203 | not control copyright. Those thus making or running the covered works
204 | for you must do so exclusively on your behalf, under your direction
205 | and control, on terms that prohibit them from making any copies of
206 | your copyrighted material outside their relationship with you.
207 |
208 | Conveying under any other circumstances is permitted solely under
209 | the conditions stated below. Sublicensing is not allowed; section 10
210 | makes it unnecessary.
211 |
212 | 3. Protecting Users' Legal Rights From Anti-Circumvention Law.
213 |
214 | No covered work shall be deemed part of an effective technological
215 | measure under any applicable law fulfilling obligations under article
216 | 11 of the WIPO copyright treaty adopted on 20 December 1996, or
217 | similar laws prohibiting or restricting circumvention of such
218 | measures.
219 |
220 | When you convey a covered work, you waive any legal power to forbid
221 | circumvention of technological measures to the extent such circumvention
222 | is effected by exercising rights under this License with respect to
223 | the covered work, and you disclaim any intention to limit operation or
224 | modification of the work as a means of enforcing, against the work's
225 | users, your or third parties' legal rights to forbid circumvention of
226 | technological measures.
227 |
228 | 4. Conveying Verbatim Copies.
229 |
230 | You may convey verbatim copies of the Program's source code as you
231 | receive it, in any medium, provided that you conspicuously and
232 | appropriately publish on each copy an appropriate copyright notice;
233 | keep intact all notices stating that this License and any
234 | non-permissive terms added in accord with section 7 apply to the code;
235 | keep intact all notices of the absence of any warranty; and give all
236 | recipients a copy of this License along with the Program.
237 |
238 | You may charge any price or no price for each copy that you convey,
239 | and you may offer support or warranty protection for a fee.
240 |
241 | 5. Conveying Modified Source Versions.
242 |
243 | You may convey a work based on the Program, or the modifications to
244 | produce it from the Program, in the form of source code under the
245 | terms of section 4, provided that you also meet all of these conditions:
246 |
247 | a) The work must carry prominent notices stating that you modified
248 | it, and giving a relevant date.
249 |
250 | b) The work must carry prominent notices stating that it is
251 | released under this License and any conditions added under section
252 | 7. This requirement modifies the requirement in section 4 to
253 | "keep intact all notices".
254 |
255 | c) You must license the entire work, as a whole, under this
256 | License to anyone who comes into possession of a copy. This
257 | License will therefore apply, along with any applicable section 7
258 | additional terms, to the whole of the work, and all its parts,
259 | regardless of how they are packaged. This License gives no
260 | permission to license the work in any other way, but it does not
261 | invalidate such permission if you have separately received it.
262 |
263 | d) If the work has interactive user interfaces, each must display
264 | Appropriate Legal Notices; however, if the Program has interactive
265 | interfaces that do not display Appropriate Legal Notices, your
266 | work need not make them do so.
267 |
268 | A compilation of a covered work with other separate and independent
269 | works, which are not by their nature extensions of the covered work,
270 | and which are not combined with it such as to form a larger program,
271 | in or on a volume of a storage or distribution medium, is called an
272 | "aggregate" if the compilation and its resulting copyright are not
273 | used to limit the access or legal rights of the compilation's users
274 | beyond what the individual works permit. Inclusion of a covered work
275 | in an aggregate does not cause this License to apply to the other
276 | parts of the aggregate.
277 |
278 | 6. Conveying Non-Source Forms.
279 |
280 | You may convey a covered work in object code form under the terms
281 | of sections 4 and 5, provided that you also convey the
282 | machine-readable Corresponding Source under the terms of this License,
283 | in one of these ways:
284 |
285 | a) Convey the object code in, or embodied in, a physical product
286 | (including a physical distribution medium), accompanied by the
287 | Corresponding Source fixed on a durable physical medium
288 | customarily used for software interchange.
289 |
290 | b) Convey the object code in, or embodied in, a physical product
291 | (including a physical distribution medium), accompanied by a
292 | written offer, valid for at least three years and valid for as
293 | long as you offer spare parts or customer support for that product
294 | model, to give anyone who possesses the object code either (1) a
295 | copy of the Corresponding Source for all the software in the
296 | product that is covered by this License, on a durable physical
297 | medium customarily used for software interchange, for a price no
298 | more than your reasonable cost of physically performing this
299 | conveying of source, or (2) access to copy the
300 | Corresponding Source from a network server at no charge.
301 |
302 | c) Convey individual copies of the object code with a copy of the
303 | written offer to provide the Corresponding Source. This
304 | alternative is allowed only occasionally and noncommercially, and
305 | only if you received the object code with such an offer, in accord
306 | with subsection 6b.
307 |
308 | d) Convey the object code by offering access from a designated
309 | place (gratis or for a charge), and offer equivalent access to the
310 | Corresponding Source in the same way through the same place at no
311 | further charge. You need not require recipients to copy the
312 | Corresponding Source along with the object code. If the place to
313 | copy the object code is a network server, the Corresponding Source
314 | may be on a different server (operated by you or a third party)
315 | that supports equivalent copying facilities, provided you maintain
316 | clear directions next to the object code saying where to find the
317 | Corresponding Source. Regardless of what server hosts the
318 | Corresponding Source, you remain obligated to ensure that it is
319 | available for as long as needed to satisfy these requirements.
320 |
321 | e) Convey the object code using peer-to-peer transmission, provided
322 | you inform other peers where the object code and Corresponding
323 | Source of the work are being offered to the general public at no
324 | charge under subsection 6d.
325 |
326 | A separable portion of the object code, whose source code is excluded
327 | from the Corresponding Source as a System Library, need not be
328 | included in conveying the object code work.
329 |
330 | A "User Product" is either (1) a "consumer product", which means any
331 | tangible personal property which is normally used for personal, family,
332 | or household purposes, or (2) anything designed or sold for incorporation
333 | into a dwelling. In determining whether a product is a consumer product,
334 | doubtful cases shall be resolved in favor of coverage. For a particular
335 | product received by a particular user, "normally used" refers to a
336 | typical or common use of that class of product, regardless of the status
337 | of the particular user or of the way in which the particular user
338 | actually uses, or expects or is expected to use, the product. A product
339 | is a consumer product regardless of whether the product has substantial
340 | commercial, industrial or non-consumer uses, unless such uses represent
341 | the only significant mode of use of the product.
342 |
343 | "Installation Information" for a User Product means any methods,
344 | procedures, authorization keys, or other information required to install
345 | and execute modified versions of a covered work in that User Product from
346 | a modified version of its Corresponding Source. The information must
347 | suffice to ensure that the continued functioning of the modified object
348 | code is in no case prevented or interfered with solely because
349 | modification has been made.
350 |
351 | If you convey an object code work under this section in, or with, or
352 | specifically for use in, a User Product, and the conveying occurs as
353 | part of a transaction in which the right of possession and use of the
354 | User Product is transferred to the recipient in perpetuity or for a
355 | fixed term (regardless of how the transaction is characterized), the
356 | Corresponding Source conveyed under this section must be accompanied
357 | by the Installation Information. But this requirement does not apply
358 | if neither you nor any third party retains the ability to install
359 | modified object code on the User Product (for example, the work has
360 | been installed in ROM).
361 |
362 | The requirement to provide Installation Information does not include a
363 | requirement to continue to provide support service, warranty, or updates
364 | for a work that has been modified or installed by the recipient, or for
365 | the User Product in which it has been modified or installed. Access to a
366 | network may be denied when the modification itself materially and
367 | adversely affects the operation of the network or violates the rules and
368 | protocols for communication across the network.
369 |
370 | Corresponding Source conveyed, and Installation Information provided,
371 | in accord with this section must be in a format that is publicly
372 | documented (and with an implementation available to the public in
373 | source code form), and must require no special password or key for
374 | unpacking, reading or copying.
375 |
376 | 7. Additional Terms.
377 |
378 | "Additional permissions" are terms that supplement the terms of this
379 | License by making exceptions from one or more of its conditions.
380 | Additional permissions that are applicable to the entire Program shall
381 | be treated as though they were included in this License, to the extent
382 | that they are valid under applicable law. If additional permissions
383 | apply only to part of the Program, that part may be used separately
384 | under those permissions, but the entire Program remains governed by
385 | this License without regard to the additional permissions.
386 |
387 | When you convey a copy of a covered work, you may at your option
388 | remove any additional permissions from that copy, or from any part of
389 | it. (Additional permissions may be written to require their own
390 | removal in certain cases when you modify the work.) You may place
391 | additional permissions on material, added by you to a covered work,
392 | for which you have or can give appropriate copyright permission.
393 |
394 | Notwithstanding any other provision of this License, for material you
395 | add to a covered work, you may (if authorized by the copyright holders of
396 | that material) supplement the terms of this License with terms:
397 |
398 | a) Disclaiming warranty or limiting liability differently from the
399 | terms of sections 15 and 16 of this License; or
400 |
401 | b) Requiring preservation of specified reasonable legal notices or
402 | author attributions in that material or in the Appropriate Legal
403 | Notices displayed by works containing it; or
404 |
405 | c) Prohibiting misrepresentation of the origin of that material, or
406 | requiring that modified versions of such material be marked in
407 | reasonable ways as different from the original version; or
408 |
409 | d) Limiting the use for publicity purposes of names of licensors or
410 | authors of the material; or
411 |
412 | e) Declining to grant rights under trademark law for use of some
413 | trade names, trademarks, or service marks; or
414 |
415 | f) Requiring indemnification of licensors and authors of that
416 | material by anyone who conveys the material (or modified versions of
417 | it) with contractual assumptions of liability to the recipient, for
418 | any liability that these contractual assumptions directly impose on
419 | those licensors and authors.
420 |
421 | All other non-permissive additional terms are considered "further
422 | restrictions" within the meaning of section 10. If the Program as you
423 | received it, or any part of it, contains a notice stating that it is
424 | governed by this License along with a term that is a further
425 | restriction, you may remove that term. If a license document contains
426 | a further restriction but permits relicensing or conveying under this
427 | License, you may add to a covered work material governed by the terms
428 | of that license document, provided that the further restriction does
429 | not survive such relicensing or conveying.
430 |
431 | If you add terms to a covered work in accord with this section, you
432 | must place, in the relevant source files, a statement of the
433 | additional terms that apply to those files, or a notice indicating
434 | where to find the applicable terms.
435 |
436 | Additional terms, permissive or non-permissive, may be stated in the
437 | form of a separately written license, or stated as exceptions;
438 | the above requirements apply either way.
439 |
440 | 8. Termination.
441 |
442 | You may not propagate or modify a covered work except as expressly
443 | provided under this License. Any attempt otherwise to propagate or
444 | modify it is void, and will automatically terminate your rights under
445 | this License (including any patent licenses granted under the third
446 | paragraph of section 11).
447 |
448 | However, if you cease all violation of this License, then your
449 | license from a particular copyright holder is reinstated (a)
450 | provisionally, unless and until the copyright holder explicitly and
451 | finally terminates your license, and (b) permanently, if the copyright
452 | holder fails to notify you of the violation by some reasonable means
453 | prior to 60 days after the cessation.
454 |
455 | Moreover, your license from a particular copyright holder is
456 | reinstated permanently if the copyright holder notifies you of the
457 | violation by some reasonable means, this is the first time you have
458 | received notice of violation of this License (for any work) from that
459 | copyright holder, and you cure the violation prior to 30 days after
460 | your receipt of the notice.
461 |
462 | Termination of your rights under this section does not terminate the
463 | licenses of parties who have received copies or rights from you under
464 | this License. If your rights have been terminated and not permanently
465 | reinstated, you do not qualify to receive new licenses for the same
466 | material under section 10.
467 |
468 | 9. Acceptance Not Required for Having Copies.
469 |
470 | You are not required to accept this License in order to receive or
471 | run a copy of the Program. Ancillary propagation of a covered work
472 | occurring solely as a consequence of using peer-to-peer transmission
473 | to receive a copy likewise does not require acceptance. However,
474 | nothing other than this License grants you permission to propagate or
475 | modify any covered work. These actions infringe copyright if you do
476 | not accept this License. Therefore, by modifying or propagating a
477 | covered work, you indicate your acceptance of this License to do so.
478 |
479 | 10. Automatic Licensing of Downstream Recipients.
480 |
481 | Each time you convey a covered work, the recipient automatically
482 | receives a license from the original licensors, to run, modify and
483 | propagate that work, subject to this License. You are not responsible
484 | for enforcing compliance by third parties with this License.
485 |
486 | An "entity transaction" is a transaction transferring control of an
487 | organization, or substantially all assets of one, or subdividing an
488 | organization, or merging organizations. If propagation of a covered
489 | work results from an entity transaction, each party to that
490 | transaction who receives a copy of the work also receives whatever
491 | licenses to the work the party's predecessor in interest had or could
492 | give under the previous paragraph, plus a right to possession of the
493 | Corresponding Source of the work from the predecessor in interest, if
494 | the predecessor has it or can get it with reasonable efforts.
495 |
496 | You may not impose any further restrictions on the exercise of the
497 | rights granted or affirmed under this License. For example, you may
498 | not impose a license fee, royalty, or other charge for exercise of
499 | rights granted under this License, and you may not initiate litigation
500 | (including a cross-claim or counterclaim in a lawsuit) alleging that
501 | any patent claim is infringed by making, using, selling, offering for
502 | sale, or importing the Program or any portion of it.
503 |
504 | 11. Patents.
505 |
506 | A "contributor" is a copyright holder who authorizes use under this
507 | License of the Program or a work on which the Program is based. The
508 | work thus licensed is called the contributor's "contributor version".
509 |
510 | A contributor's "essential patent claims" are all patent claims
511 | owned or controlled by the contributor, whether already acquired or
512 | hereafter acquired, that would be infringed by some manner, permitted
513 | by this License, of making, using, or selling its contributor version,
514 | but do not include claims that would be infringed only as a
515 | consequence of further modification of the contributor version. For
516 | purposes of this definition, "control" includes the right to grant
517 | patent sublicenses in a manner consistent with the requirements of
518 | this License.
519 |
520 | Each contributor grants you a non-exclusive, worldwide, royalty-free
521 | patent license under the contributor's essential patent claims, to
522 | make, use, sell, offer for sale, import and otherwise run, modify and
523 | propagate the contents of its contributor version.
524 |
525 | In the following three paragraphs, a "patent license" is any express
526 | agreement or commitment, however denominated, not to enforce a patent
527 | (such as an express permission to practice a patent or covenant not to
528 | sue for patent infringement). To "grant" such a patent license to a
529 | party means to make such an agreement or commitment not to enforce a
530 | patent against the party.
531 |
532 | If you convey a covered work, knowingly relying on a patent license,
533 | and the Corresponding Source of the work is not available for anyone
534 | to copy, free of charge and under the terms of this License, through a
535 | publicly available network server or other readily accessible means,
536 | then you must either (1) cause the Corresponding Source to be so
537 | available, or (2) arrange to deprive yourself of the benefit of the
538 | patent license for this particular work, or (3) arrange, in a manner
539 | consistent with the requirements of this License, to extend the patent
540 | license to downstream recipients. "Knowingly relying" means you have
541 | actual knowledge that, but for the patent license, your conveying the
542 | covered work in a country, or your recipient's use of the covered work
543 | in a country, would infringe one or more identifiable patents in that
544 | country that you have reason to believe are valid.
545 |
546 | If, pursuant to or in connection with a single transaction or
547 | arrangement, you convey, or propagate by procuring conveyance of, a
548 | covered work, and grant a patent license to some of the parties
549 | receiving the covered work authorizing them to use, propagate, modify
550 | or convey a specific copy of the covered work, then the patent license
551 | you grant is automatically extended to all recipients of the covered
552 | work and works based on it.
553 |
554 | A patent license is "discriminatory" if it does not include within
555 | the scope of its coverage, prohibits the exercise of, or is
556 | conditioned on the non-exercise of one or more of the rights that are
557 | specifically granted under this License. You may not convey a covered
558 | work if you are a party to an arrangement with a third party that is
559 | in the business of distributing software, under which you make payment
560 | to the third party based on the extent of your activity of conveying
561 | the work, and under which the third party grants, to any of the
562 | parties who would receive the covered work from you, a discriminatory
563 | patent license (a) in connection with copies of the covered work
564 | conveyed by you (or copies made from those copies), or (b) primarily
565 | for and in connection with specific products or compilations that
566 | contain the covered work, unless you entered into that arrangement,
567 | or that patent license was granted, prior to 28 March 2007.
568 |
569 | Nothing in this License shall be construed as excluding or limiting
570 | any implied license or other defenses to infringement that may
571 | otherwise be available to you under applicable patent law.
572 |
573 | 12. No Surrender of Others' Freedom.
574 |
575 | If conditions are imposed on you (whether by court order, agreement or
576 | otherwise) that contradict the conditions of this License, they do not
577 | excuse you from the conditions of this License. If you cannot convey a
578 | covered work so as to satisfy simultaneously your obligations under this
579 | License and any other pertinent obligations, then as a consequence you may
580 | not convey it at all. For example, if you agree to terms that obligate you
581 | to collect a royalty for further conveying from those to whom you convey
582 | the Program, the only way you could satisfy both those terms and this
583 | License would be to refrain entirely from conveying the Program.
584 |
585 | 13. Use with the GNU Affero General Public License.
586 |
587 | Notwithstanding any other provision of this License, you have
588 | permission to link or combine any covered work with a work licensed
589 | under version 3 of the GNU Affero General Public License into a single
590 | combined work, and to convey the resulting work. The terms of this
591 | License will continue to apply to the part which is the covered work,
592 | but the special requirements of the GNU Affero General Public License,
593 | section 13, concerning interaction through a network will apply to the
594 | combination as such.
595 |
596 | 14. Revised Versions of this License.
597 |
598 | The Free Software Foundation may publish revised and/or new versions of
599 | the GNU General Public License from time to time. Such new versions will
600 | be similar in spirit to the present version, but may differ in detail to
601 | address new problems or concerns.
602 |
603 | Each version is given a distinguishing version number. If the
604 | Program specifies that a certain numbered version of the GNU General
605 | Public License "or any later version" applies to it, you have the
606 | option of following the terms and conditions either of that numbered
607 | version or of any later version published by the Free Software
608 | Foundation. If the Program does not specify a version number of the
609 | GNU General Public License, you may choose any version ever published
610 | by the Free Software Foundation.
611 |
612 | If the Program specifies that a proxy can decide which future
613 | versions of the GNU General Public License can be used, that proxy's
614 | public statement of acceptance of a version permanently authorizes you
615 | to choose that version for the Program.
616 |
617 | Later license versions may give you additional or different
618 | permissions. However, no additional obligations are imposed on any
619 | author or copyright holder as a result of your choosing to follow a
620 | later version.
621 |
622 | 15. Disclaimer of Warranty.
623 |
624 | THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY
625 | APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT
626 | HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY
627 | OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO,
628 | THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
629 | PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM
630 | IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF
631 | ALL NECESSARY SERVICING, REPAIR OR CORRECTION.
632 |
633 | 16. Limitation of Liability.
634 |
635 | IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING
636 | WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR CONVEYS
637 | THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY
638 | GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE
639 | USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF
640 | DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD
641 | PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS),
642 | EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF
643 | SUCH DAMAGES.
644 |
645 | 17. Interpretation of Sections 15 and 16.
646 |
647 | If the disclaimer of warranty and limitation of liability provided
648 | above cannot be given local legal effect according to their terms,
649 | reviewing courts shall apply local law that most closely approximates
650 | an absolute waiver of all civil liability in connection with the
651 | Program, unless a warranty or assumption of liability accompanies a
652 | copy of the Program in return for a fee.
653 |
654 | END OF TERMS AND CONDITIONS
655 |
656 | How to Apply These Terms to Your New Programs
657 |
658 | If you develop a new program, and you want it to be of the greatest
659 | possible use to the public, the best way to achieve this is to make it
660 | free software which everyone can redistribute and change under these terms.
661 |
662 | To do so, attach the following notices to the program. It is safest
663 | to attach them to the start of each source file to most effectively
664 | state the exclusion of warranty; and each file should have at least
665 | the "copyright" line and a pointer to where the full notice is found.
666 |
667 |
668 | Copyright (C)
669 |
670 | This program is free software: you can redistribute it and/or modify
671 | it under the terms of the GNU General Public License as published by
672 | the Free Software Foundation, either version 3 of the License, or
673 | (at your option) any later version.
674 |
675 | This program is distributed in the hope that it will be useful,
676 | but WITHOUT ANY WARRANTY; without even the implied warranty of
677 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
678 | GNU General Public License for more details.
679 |
680 | You should have received a copy of the GNU General Public License
681 | along with this program. If not, see .
682 |
683 | Also add information on how to contact you by electronic and paper mail.
684 |
685 | If the program does terminal interaction, make it output a short
686 | notice like this when it starts in an interactive mode:
687 |
688 | Copyright (C)
689 | This program comes with ABSOLUTELY NO WARRANTY; for details type `show w'.
690 | This is free software, and you are welcome to redistribute it
691 | under certain conditions; type `show c' for details.
692 |
693 | The hypothetical commands `show w' and `show c' should show the appropriate
694 | parts of the General Public License. Of course, your program's commands
695 | might be different; for a GUI interface, you would use an "about box".
696 |
697 | You should also get your employer (if you work as a programmer) or school,
698 | if any, to sign a "copyright disclaimer" for the program, if necessary.
699 | For more information on this, and how to apply and follow the GNU GPL, see
700 | .
701 |
702 | The GNU General Public License does not permit incorporating your program
703 | into proprietary programs. If your program is a subroutine library, you
704 | may consider it more useful to permit linking proprietary applications with
705 | the library. If this is what you want to do, use the GNU Lesser General
706 | Public License instead of this License. But first, please read
707 | .
--------------------------------------------------------------------------------