Compare commits
5 Commits
d9e84d479e
...
d197cf0b16
Author | SHA1 | Date |
---|---|---|
Cossid | d197cf0b16 | |
pre-commit-ci[bot] | 98df9e7f9a | |
J. Nick Koston | d6b4c012bf | |
Paul Wieland | 5846d3bf6b | |
Cossid | a58549a23f |
|
@ -8,7 +8,7 @@ repos:
|
||||||
- id: end-of-file-fixer
|
- id: end-of-file-fixer
|
||||||
- id: check-added-large-files
|
- id: check-added-large-files
|
||||||
- repo: https://github.com/pre-commit/mirrors-clang-format
|
- repo: https://github.com/pre-commit/mirrors-clang-format
|
||||||
rev: v19.1.2
|
rev: v19.1.5
|
||||||
hooks:
|
hooks:
|
||||||
- id: clang-format
|
- id: clang-format
|
||||||
types_or:
|
types_or:
|
||||||
|
@ -16,3 +16,11 @@ repos:
|
||||||
- "c"
|
- "c"
|
||||||
- "cuda"
|
- "cuda"
|
||||||
args: [-style=Webkit, -i]
|
args: [-style=Webkit, -i]
|
||||||
|
- repo: https://github.com/PyCQA/isort
|
||||||
|
rev: 5.13.2
|
||||||
|
hooks:
|
||||||
|
- id: isort
|
||||||
|
- repo: https://github.com/psf/black
|
||||||
|
rev: 24.10.0
|
||||||
|
hooks:
|
||||||
|
- id: black
|
||||||
|
|
|
@ -3,7 +3,7 @@
|
||||||
|
|
||||||
This is a port of the ratgdo software for the v2.0/v2.5 board to ESPHome.
|
This is a port of the ratgdo software for the v2.0/v2.5 board to ESPHome.
|
||||||
|
|
||||||
[Visit the github.io page to purchase boards](https://paulwieland.github.io/ratgdo/#order)
|
[Visit the the store to purchase boards](https://ratcloud.llc)
|
||||||
|
|
||||||
## Installation
|
## Installation
|
||||||
|
|
||||||
|
|
|
@ -13,6 +13,7 @@ preferences:
|
||||||
|
|
||||||
text_sensor:
|
text_sensor:
|
||||||
- platform: version
|
- platform: version
|
||||||
|
id: ${id_prefix}_firmware_version
|
||||||
name: "Firmware Version"
|
name: "Firmware Version"
|
||||||
|
|
||||||
ratgdo:
|
ratgdo:
|
||||||
|
|
|
@ -15,6 +15,7 @@ preferences:
|
||||||
|
|
||||||
text_sensor:
|
text_sensor:
|
||||||
- platform: version
|
- platform: version
|
||||||
|
id: ${id_prefix}_firmware_version
|
||||||
name: "Firmware Version"
|
name: "Firmware Version"
|
||||||
|
|
||||||
ratgdo:
|
ratgdo:
|
||||||
|
|
|
@ -13,6 +13,7 @@ preferences:
|
||||||
|
|
||||||
text_sensor:
|
text_sensor:
|
||||||
- platform: version
|
- platform: version
|
||||||
|
id: ${id_prefix}_firmware_version
|
||||||
name: "Firmware Version"
|
name: "Firmware Version"
|
||||||
|
|
||||||
ratgdo:
|
ratgdo:
|
||||||
|
|
|
@ -2,8 +2,8 @@ import esphome.codegen as cg
|
||||||
import esphome.config_validation as cv
|
import esphome.config_validation as cv
|
||||||
import voluptuous as vol
|
import voluptuous as vol
|
||||||
from esphome import automation, pins
|
from esphome import automation, pins
|
||||||
from esphome.const import CONF_ID, CONF_TRIGGER_ID
|
|
||||||
from esphome.components import binary_sensor
|
from esphome.components import binary_sensor
|
||||||
|
from esphome.const import CONF_ID, CONF_TRIGGER_ID
|
||||||
|
|
||||||
DEPENDENCIES = ["preferences"]
|
DEPENDENCIES = ["preferences"]
|
||||||
MULTI_CONF = True
|
MULTI_CONF = True
|
||||||
|
@ -44,43 +44,59 @@ CONF_DRY_CONTACT_OPEN_SENSOR = "dry_contact_open_sensor"
|
||||||
CONF_DRY_CONTACT_CLOSE_SENSOR = "dry_contact_close_sensor"
|
CONF_DRY_CONTACT_CLOSE_SENSOR = "dry_contact_close_sensor"
|
||||||
CONF_DRY_CONTACT_SENSOR_GROUP = "dry_contact_sensor_group"
|
CONF_DRY_CONTACT_SENSOR_GROUP = "dry_contact_sensor_group"
|
||||||
|
|
||||||
|
|
||||||
def validate_protocol(config):
|
def validate_protocol(config):
|
||||||
if config.get(CONF_PROTOCOL, None) == PROTOCOL_DRYCONTACT and (CONF_DRY_CONTACT_CLOSE_SENSOR not in config or CONF_DRY_CONTACT_OPEN_SENSOR not in config):
|
if config.get(CONF_PROTOCOL, None) == PROTOCOL_DRYCONTACT and (
|
||||||
raise cv.Invalid("dry_contact_close_sensor and dry_contact_open_sensor are required when using protocol drycontact")
|
CONF_DRY_CONTACT_CLOSE_SENSOR not in config
|
||||||
if config.get(CONF_PROTOCOL, None) != PROTOCOL_DRYCONTACT and (CONF_DRY_CONTACT_CLOSE_SENSOR in config or CONF_DRY_CONTACT_OPEN_SENSOR in config):
|
or CONF_DRY_CONTACT_OPEN_SENSOR not in config
|
||||||
raise cv.Invalid("dry_contact_close_sensor and dry_contact_open_sensor are only valid when using protocol drycontact")
|
):
|
||||||
# if config.get(CONF_PROTOCOL, None) == PROTOCOL_DRYCONTACT and CONF_DRY_CONTACT_OPEN_SENSOR not in config:
|
raise cv.Invalid(
|
||||||
# raise cv.Invalid("dry_contact_open_sensor is required when using protocol drycontact")
|
"dry_contact_close_sensor and dry_contact_open_sensor are required when using protocol drycontact"
|
||||||
|
)
|
||||||
|
if config.get(CONF_PROTOCOL, None) != PROTOCOL_DRYCONTACT and (
|
||||||
|
CONF_DRY_CONTACT_CLOSE_SENSOR in config
|
||||||
|
or CONF_DRY_CONTACT_OPEN_SENSOR in config
|
||||||
|
):
|
||||||
|
raise cv.Invalid(
|
||||||
|
"dry_contact_close_sensor and dry_contact_open_sensor are only valid when using protocol drycontact"
|
||||||
|
)
|
||||||
|
# if config.get(CONF_PROTOCOL, None) == PROTOCOL_DRYCONTACT and CONF_DRY_CONTACT_OPEN_SENSOR not in config:
|
||||||
|
# raise cv.Invalid("dry_contact_open_sensor is required when using protocol drycontact")
|
||||||
return config
|
return config
|
||||||
|
|
||||||
|
|
||||||
CONFIG_SCHEMA = cv.All(
|
CONFIG_SCHEMA = cv.All(
|
||||||
cv.Schema(
|
cv.Schema(
|
||||||
{
|
{
|
||||||
cv.GenerateID(): cv.declare_id(RATGDO),
|
cv.GenerateID(): cv.declare_id(RATGDO),
|
||||||
cv.Optional(
|
cv.Optional(
|
||||||
CONF_OUTPUT_GDO, default=DEFAULT_OUTPUT_GDO
|
CONF_OUTPUT_GDO, default=DEFAULT_OUTPUT_GDO
|
||||||
): pins.gpio_output_pin_schema,
|
): pins.gpio_output_pin_schema,
|
||||||
cv.Optional(
|
cv.Optional(
|
||||||
CONF_INPUT_GDO, default=DEFAULT_INPUT_GDO
|
CONF_INPUT_GDO, default=DEFAULT_INPUT_GDO
|
||||||
): pins.gpio_input_pin_schema,
|
): pins.gpio_input_pin_schema,
|
||||||
cv.Optional(CONF_INPUT_OBST, default=DEFAULT_INPUT_OBST): cv.Any(
|
cv.Optional(CONF_INPUT_OBST, default=DEFAULT_INPUT_OBST): cv.Any(
|
||||||
cv.none, pins.gpio_input_pin_schema
|
cv.none, pins.gpio_input_pin_schema
|
||||||
),
|
),
|
||||||
cv.Optional(CONF_DISCRETE_OPEN_PIN): pins.gpio_output_pin_schema,
|
cv.Optional(CONF_DISCRETE_OPEN_PIN): pins.gpio_output_pin_schema,
|
||||||
cv.Optional(CONF_DISCRETE_CLOSE_PIN): pins.gpio_output_pin_schema,
|
cv.Optional(CONF_DISCRETE_CLOSE_PIN): pins.gpio_output_pin_schema,
|
||||||
cv.Optional(CONF_ON_SYNC_FAILED): automation.validate_automation(
|
cv.Optional(CONF_ON_SYNC_FAILED): automation.validate_automation(
|
||||||
{
|
{
|
||||||
cv.GenerateID(CONF_TRIGGER_ID): cv.declare_id(SyncFailed),
|
cv.GenerateID(CONF_TRIGGER_ID): cv.declare_id(SyncFailed),
|
||||||
}
|
}
|
||||||
),
|
),
|
||||||
cv.Optional(CONF_PROTOCOL, default=PROTOCOL_SECPLUSV2): cv.All(vol.In(
|
cv.Optional(CONF_PROTOCOL, default=PROTOCOL_SECPLUSV2): cv.All(
|
||||||
SUPPORTED_PROTOCOLS
|
vol.In(SUPPORTED_PROTOCOLS)
|
||||||
)),
|
),
|
||||||
# cv.Inclusive(CONF_DRY_CONTACT_OPEN_SENSOR,CONF_DRY_CONTACT_SENSOR_GROUP): cv.use_id(binary_sensor.BinarySensor),
|
# cv.Inclusive(CONF_DRY_CONTACT_OPEN_SENSOR,CONF_DRY_CONTACT_SENSOR_GROUP): cv.use_id(binary_sensor.BinarySensor),
|
||||||
# cv.Inclusive(CONF_DRY_CONTACT_CLOSE_SENSOR,CONF_DRY_CONTACT_SENSOR_GROUP): cv.use_id(binary_sensor.BinarySensor),
|
# cv.Inclusive(CONF_DRY_CONTACT_CLOSE_SENSOR,CONF_DRY_CONTACT_SENSOR_GROUP): cv.use_id(binary_sensor.BinarySensor),
|
||||||
cv.Optional(CONF_DRY_CONTACT_OPEN_SENSOR): cv.use_id(binary_sensor.BinarySensor),
|
cv.Optional(CONF_DRY_CONTACT_OPEN_SENSOR): cv.use_id(
|
||||||
cv.Optional(CONF_DRY_CONTACT_CLOSE_SENSOR): cv.use_id(binary_sensor.BinarySensor),
|
binary_sensor.BinarySensor
|
||||||
}
|
),
|
||||||
|
cv.Optional(CONF_DRY_CONTACT_CLOSE_SENSOR): cv.use_id(
|
||||||
|
binary_sensor.BinarySensor
|
||||||
|
),
|
||||||
|
}
|
||||||
).extend(cv.COMPONENT_SCHEMA),
|
).extend(cv.COMPONENT_SCHEMA),
|
||||||
validate_protocol,
|
validate_protocol,
|
||||||
)
|
)
|
||||||
|
@ -109,11 +125,18 @@ async def to_code(config):
|
||||||
cg.add(var.set_input_obst_pin(pin))
|
cg.add(var.set_input_obst_pin(pin))
|
||||||
|
|
||||||
if CONF_DRY_CONTACT_OPEN_SENSOR in config and config[CONF_DRY_CONTACT_OPEN_SENSOR]:
|
if CONF_DRY_CONTACT_OPEN_SENSOR in config and config[CONF_DRY_CONTACT_OPEN_SENSOR]:
|
||||||
dry_contact_open_sensor = await cg.get_variable(config[CONF_DRY_CONTACT_OPEN_SENSOR])
|
dry_contact_open_sensor = await cg.get_variable(
|
||||||
|
config[CONF_DRY_CONTACT_OPEN_SENSOR]
|
||||||
|
)
|
||||||
cg.add(var.set_dry_contact_open_sensor(dry_contact_open_sensor))
|
cg.add(var.set_dry_contact_open_sensor(dry_contact_open_sensor))
|
||||||
|
|
||||||
if CONF_DRY_CONTACT_CLOSE_SENSOR in config and config[CONF_DRY_CONTACT_CLOSE_SENSOR]:
|
if (
|
||||||
dry_contact_close_sensor = await cg.get_variable(config[CONF_DRY_CONTACT_CLOSE_SENSOR])
|
CONF_DRY_CONTACT_CLOSE_SENSOR in config
|
||||||
|
and config[CONF_DRY_CONTACT_CLOSE_SENSOR]
|
||||||
|
):
|
||||||
|
dry_contact_close_sensor = await cg.get_variable(
|
||||||
|
config[CONF_DRY_CONTACT_CLOSE_SENSOR]
|
||||||
|
)
|
||||||
cg.add(var.set_dry_contact_close_sensor(dry_contact_close_sensor))
|
cg.add(var.set_dry_contact_close_sensor(dry_contact_close_sensor))
|
||||||
|
|
||||||
for conf in config.get(CONF_ON_SYNC_FAILED, []):
|
for conf in config.get(CONF_ON_SYNC_FAILED, []):
|
||||||
|
|
|
@ -18,9 +18,7 @@ CoverOpeningTrigger = ratgdo_ns.class_(
|
||||||
CoverClosingTrigger = ratgdo_ns.class_(
|
CoverClosingTrigger = ratgdo_ns.class_(
|
||||||
"CoverClosingTrigger", automation.Trigger.template()
|
"CoverClosingTrigger", automation.Trigger.template()
|
||||||
)
|
)
|
||||||
CoverStateTrigger = ratgdo_ns.class_(
|
CoverStateTrigger = ratgdo_ns.class_("CoverStateTrigger", automation.Trigger.template())
|
||||||
"CoverStateTrigger", automation.Trigger.template()
|
|
||||||
)
|
|
||||||
|
|
||||||
CONF_ON_OPENING = "on_opening"
|
CONF_ON_OPENING = "on_opening"
|
||||||
CONF_ON_CLOSING = "on_closing"
|
CONF_ON_CLOSING = "on_closing"
|
||||||
|
|
Loading…
Reference in New Issue