fix
This commit is contained in:
parent
92b9dc5669
commit
64d6b259f2
|
@ -9,8 +9,6 @@ DEPENDENCIES = ["preferences"]
|
||||||
ratgdo_ns = cg.esphome_ns.namespace("ratgdo")
|
ratgdo_ns = cg.esphome_ns.namespace("ratgdo")
|
||||||
RATGDO = ratgdo_ns.class_("RATGDOComponent", cg.Component)
|
RATGDO = ratgdo_ns.class_("RATGDOComponent", cg.Component)
|
||||||
|
|
||||||
CONF_ROLLING_CODES = "rolling_codes"
|
|
||||||
|
|
||||||
|
|
||||||
CONF_OUTPUT_GDO = "output_gdo_pin"
|
CONF_OUTPUT_GDO = "output_gdo_pin"
|
||||||
DEFAULT_OUTPUT_GDO = 2 # D4 ed control terminal / GarageDoorOpener (UART1 TX) pin is D4 on D1 Mini
|
DEFAULT_OUTPUT_GDO = 2 # D4 ed control terminal / GarageDoorOpener (UART1 TX) pin is D4 on D1 Mini
|
||||||
|
@ -38,7 +36,6 @@ DEFAULT_INPUT_RPM2 = 4 # D2 RPM2 rotary encoder input OR not used if using reed
|
||||||
CONFIG_SCHEMA = cv.Schema(
|
CONFIG_SCHEMA = cv.Schema(
|
||||||
{
|
{
|
||||||
cv.GenerateID(): cv.declare_id(RATGDO),
|
cv.GenerateID(): cv.declare_id(RATGDO),
|
||||||
cv.Optional(CONF_ROLLING_CODES, default=True): cv.boolean,
|
|
||||||
cv.Optional(CONF_OUTPUT_GDO, default=DEFAULT_OUTPUT_GDO): pins.internal_gpio_input_pin_schema,
|
cv.Optional(CONF_OUTPUT_GDO, default=DEFAULT_OUTPUT_GDO): pins.internal_gpio_input_pin_schema,
|
||||||
cv.Optional(CONF_INPUT_GDO, default=DEFAULT_INPUT_GDO): pins.internal_gpio_input_pin_schema,
|
cv.Optional(CONF_INPUT_GDO, default=DEFAULT_INPUT_GDO): pins.internal_gpio_input_pin_schema,
|
||||||
cv.Optional(CONF_TRIGGER_OPEN, default=DEFAULT_TRIGGER_OPEN): pins.internal_gpio_input_pin_schema,
|
cv.Optional(CONF_TRIGGER_OPEN, default=DEFAULT_TRIGGER_OPEN): pins.internal_gpio_input_pin_schema,
|
||||||
|
@ -56,8 +53,6 @@ CONFIG_SCHEMA = cv.Schema(
|
||||||
async def to_code(config):
|
async def to_code(config):
|
||||||
var = cg.new_Pvariable(config[CONF_ID])
|
var = cg.new_Pvariable(config[CONF_ID])
|
||||||
await cg.register_component(var, config)
|
await cg.register_component(var, config)
|
||||||
cg.add(var.set_rolling_codes(config[CONF_ROLLING_CODES]))
|
|
||||||
|
|
||||||
pin = await cg.gpio_pin_expression(config[CONF_OUTPUT_GDO])
|
pin = await cg.gpio_pin_expression(config[CONF_OUTPUT_GDO])
|
||||||
cg.add(var.set_output_gdo_pin(pin))
|
cg.add(var.set_output_gdo_pin(pin))
|
||||||
pin = await cg.gpio_pin_expression(config[CONF_INPUT_GDO])
|
pin = await cg.gpio_pin_expression(config[CONF_INPUT_GDO])
|
||||||
|
|
|
@ -19,23 +19,6 @@ namespace esphome {
|
||||||
namespace ratgdo {
|
namespace ratgdo {
|
||||||
|
|
||||||
static const char* const TAG = "ratgdo";
|
static const char* const TAG = "ratgdo";
|
||||||
/*** Static Codes ***/
|
|
||||||
static const unsigned char SYNC1[] = { 0x55, 0x01, 0x00, 0x61, 0x12, 0x49, 0x2c, 0x92, 0x5b, 0x24,
|
|
||||||
0x96, 0x86, 0x0b, 0x65, 0x96, 0xd9, 0x8f, 0x26, 0x4a };
|
|
||||||
static const unsigned char SYNC2[] = { 0x55, 0x01, 0x00, 0x08, 0x34, 0x93, 0x49, 0xb4, 0x92, 0x4d,
|
|
||||||
0x20, 0x26, 0x1b, 0x4d, 0xb4, 0xdb, 0xad, 0x76, 0x93 };
|
|
||||||
static const unsigned char SYNC3[] = { 0x55, 0x01, 0x00, 0x06, 0x1b, 0x2c, 0xbf, 0x4b, 0x6d, 0xb6,
|
|
||||||
0x4b, 0x18, 0x20, 0x92, 0x09, 0x20, 0xf2, 0x11, 0x2c };
|
|
||||||
static const unsigned char SYNC4[] = { 0x55, 0x01, 0x00, 0x95, 0x29, 0x36, 0x91, 0x29, 0x36, 0x9a,
|
|
||||||
0x69, 0x05, 0x2f, 0xbe, 0xdf, 0x6d, 0x16, 0xcb, 0xe7 };
|
|
||||||
|
|
||||||
static const unsigned char DOOR_CODE[] = { 0x55, 0x01, 0x00, 0x94, 0x3f, 0xef, 0xbc, 0xfb, 0x7f, 0xbe,
|
|
||||||
0xfc, 0xa6, 0x1a, 0x4d, 0xa6, 0xda, 0x8d, 0x36, 0xb3 };
|
|
||||||
|
|
||||||
static const unsigned char LIGHT_CODE[] = { 0x55, 0x01, 0x00, 0x94, 0x3f, 0xef, 0xbc, 0xfb, 0x7f, 0xbe,
|
|
||||||
0xff, 0xa6, 0x1a, 0x4d, 0xa6, 0xda, 0x8d, 0x76, 0xb1 };
|
|
||||||
|
|
||||||
|
|
||||||
static const int STARTUP_DELAY = 2000; // delay before enabling interrupts
|
static const int STARTUP_DELAY = 2000; // delay before enabling interrupts
|
||||||
|
|
||||||
/*************************** DRY CONTACT CONTROL OF LIGHT & DOOR
|
/*************************** DRY CONTACT CONTROL OF LIGHT & DOOR
|
||||||
|
@ -460,18 +443,6 @@ namespace ratgdo {
|
||||||
this->pref_.save(&this->rollingCodeCounter);
|
this->pref_.save(&this->rollingCodeCounter);
|
||||||
}
|
}
|
||||||
|
|
||||||
void RATGDOComponent::sendSyncCodes()
|
|
||||||
{
|
|
||||||
transmit(SYNC1);
|
|
||||||
delay(65);
|
|
||||||
transmit(SYNC2);
|
|
||||||
delay(65);
|
|
||||||
transmit(SYNC3);
|
|
||||||
delay(65);
|
|
||||||
transmit(SYNC4);
|
|
||||||
delay(65);
|
|
||||||
}
|
|
||||||
|
|
||||||
void RATGDOComponent::openDoor()
|
void RATGDOComponent::openDoor()
|
||||||
{
|
{
|
||||||
if(this->doorStates[this->store_.doorState] == "open" || doorStates[this->store_.doorState] == "opening"){
|
if(this->doorStates[this->store_.doorState] == "open" || doorStates[this->store_.doorState] == "opening"){
|
||||||
|
@ -500,7 +471,6 @@ namespace ratgdo {
|
||||||
|
|
||||||
void RATGDOComponent::toggleDoor()
|
void RATGDOComponent::toggleDoor()
|
||||||
{
|
{
|
||||||
if (this->useRollingCodes_) {
|
|
||||||
getRollingCode("door1");
|
getRollingCode("door1");
|
||||||
transmit(this->txRollingCode);
|
transmit(this->txRollingCode);
|
||||||
|
|
||||||
|
@ -510,24 +480,29 @@ namespace ratgdo {
|
||||||
transmit(this->txRollingCode);
|
transmit(this->txRollingCode);
|
||||||
|
|
||||||
this->pref_.save(&this->rollingCodeCounter);
|
this->pref_.save(&this->rollingCodeCounter);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
void RATGDOComponent::lightOn(){
|
||||||
|
if(his->lightStates[this->store_.lightState] == "on"){
|
||||||
|
ESP_LOGD(TAG, "already on");
|
||||||
}else{
|
}else{
|
||||||
sendSyncCodes();
|
toggleLight();
|
||||||
ESP_LOGD(TAG, "door_code");
|
|
||||||
transmit(DOOR_CODE);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void RATGDOComponent::toggleLight()
|
void RATGDOComponent::lightOff(){
|
||||||
{
|
if(his->lightStates[this->store_.lightState] == "off"){
|
||||||
if (this->useRollingCodes_) {
|
ESP_LOGD(TAG, "already off");
|
||||||
|
}else{
|
||||||
|
toggleLight();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void RATGDOComponent::toggleLight(){
|
||||||
getRollingCode("light");
|
getRollingCode("light");
|
||||||
transmit(this->txRollingCode);
|
transmit(this->txRollingCode);
|
||||||
this->pref_.save(&this->rollingCodeCounter);
|
this->pref_.save(&this->rollingCodeCounter);
|
||||||
} else {
|
|
||||||
sendSyncCodes();
|
|
||||||
ESP_LOGD(TAG, "light_code");
|
|
||||||
transmit(LIGHT_CODE);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Lock functions
|
// Lock functions
|
||||||
|
|
|
@ -97,10 +97,8 @@ namespace ratgdo {
|
||||||
|
|
||||||
/********************************** FUNCTION DECLARATION
|
/********************************** FUNCTION DECLARATION
|
||||||
* *****************************************/
|
* *****************************************/
|
||||||
void set_rolling_codes(bool useRollingCodes);
|
|
||||||
void transmit(const uint8_t*);
|
void transmit(const uint8_t*);
|
||||||
void sync();
|
void sync();
|
||||||
void sendSyncCodes();
|
|
||||||
|
|
||||||
void obstructionLoop();
|
void obstructionLoop();
|
||||||
void sendObstructionStatus();
|
void sendObstructionStatus();
|
||||||
|
@ -133,7 +131,6 @@ namespace ratgdo {
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
ESPPreferenceObject pref_;
|
ESPPreferenceObject pref_;
|
||||||
bool useRollingCodes_ { true };
|
|
||||||
RATGDOStore store_ {};
|
RATGDOStore store_ {};
|
||||||
|
|
||||||
InternalGPIOPin* output_gdo_pin_;
|
InternalGPIOPin* output_gdo_pin_;
|
||||||
|
|
Loading…
Reference in New Issue