Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ratgdo32disco #337

Open
wants to merge 32 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 9 commits
Commits
Show all changes
32 commits
Select commit Hold shift + click to select a range
f68d126
ratgdo32
PaulWieland Oct 28, 2024
516eb29
correct yaml
PaulWieland Nov 7, 2024
8068dbe
ignore bugs
PaulWieland Nov 7, 2024
1e15dae
Add disco to build/webtools
PaulWieland Nov 10, 2024
fd43050
closing delay max
PaulWieland Nov 10, 2024
eee6f5e
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] Nov 10, 2024
be6ec93
add branch
PaulWieland Nov 10, 2024
52bc8cc
Merge branch 'ratgdo32' of https://github.com/ratgdo/esphome-ratgdo i…
PaulWieland Nov 10, 2024
ae8d1a3
add branch
PaulWieland Nov 10, 2024
ee0f0bc
LED GPIO
PaulWieland Nov 10, 2024
1f9b4a4
temp switch gh pages to ratgdo32 branch
PaulWieland Nov 12, 2024
53a2589
ratgdo32 branch
PaulWieland Nov 12, 2024
f0cf81b
Update build.yml
PaulWieland Nov 12, 2024
e919ff5
Create ratgdo32_disco.jpg
PaulWieland Nov 12, 2024
4ee1ddf
diagrams
PaulWieland Nov 12, 2024
fbcc2ae
Update index.html
PaulWieland Nov 12, 2024
12af660
Update index.html
PaulWieland Nov 12, 2024
8dd09d2
display diagram
PaulWieland Nov 13, 2024
c11a748
display diagram
PaulWieland Nov 13, 2024
eb90d3f
add v32
PaulWieland Nov 15, 2024
af632d1
Update README.md
PaulWieland Dec 4, 2024
9479f79
Create ratgdo32.jpg
PaulWieland Dec 4, 2024
336252b
Update index.html
PaulWieland Dec 4, 2024
690a2b6
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] Dec 4, 2024
1bfea01
Update index.html
PaulWieland Dec 4, 2024
f58247e
Merge branch 'ratgdo32' of https://github.com/ratgdo/esphome-ratgdo i…
PaulWieland Dec 4, 2024
b2f6ec1
high ceiling & day light sensor adjustments
PaulWieland Dec 6, 2024
9714d65
update driver instructions
PaulWieland Dec 18, 2024
89a5c28
Change maxDistance
PaulWieland Dec 27, 2024
494af2b
Fix out of range data
PaulWieland Dec 30, 2024
055a36d
Add ota firmware download button
PaulWieland Dec 31, 2024
b7e5b35
update min-distance to 100mm
PaulWieland Dec 31, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 18 additions & 0 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,24 @@ jobs:
- file: v25iboard_drycontact.yaml
name: V2.5i Board Dry Contact
manifest_filename: v25iboard_drycontact-manifest.json
- file: v32board.yaml
name: V32 Board Security+ 2.0
manifest_filename: v32board-manifest.json
- file: v32board_secplusv1.yaml
name: V32 Board Security+ 1.0
manifest_filename: v32board_secplusv1-manifest.json
- file: v32board_drycontact.yaml
name: V32 Board Board Dry Contact
manifest_filename: v32board_drycontact-manifest.json
- file: v32disco.yaml
name: V32 Disco Board Security+ 2.0
manifest_filename: v32disco-manifest.json
- file: v32disco_secplusv1.yaml
name: V32 Disco Board Security+ 1.0
manifest_filename: v32disco_secplusv1-manifest.json
- file: v32disco_drycontact.yaml
name: V32 Disco Board Dry Contact
manifest_filename: v32disco_drycontact-manifest.json
fail-fast: false
steps:
- name: Checkout source code
Expand Down
5 changes: 4 additions & 1 deletion base.yaml
Original file line number Diff line number Diff line change
@@ -1,10 +1,13 @@
---

external_components:
- source:
type: git
url: https://github.com/ratgdo/esphome-ratgdo
ref: ratgdo32
refresh: 1s
# - source:
# type: local
# path: components

safe_mode:

Expand Down
7 changes: 5 additions & 2 deletions base_drycontact.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,13 @@

external_components:
- source:
# type: local
# path: components
type: git
url: https://github.com/ratgdo/esphome-ratgdo
ref: ratgdo32
refresh: 1s
# - source:
# type: local
# path: components

safe_mode:

Expand All @@ -20,6 +22,7 @@ text_sensor:
ratgdo:
id: ${id_prefix}
output_gdo_pin: ${uart_tx_pin}
input_gdo_pin: ${uart_rx_pin}
input_obst_pin: ${input_obst_pin}
dry_contact_open_sensor: ${id_prefix}_dry_contact_open
dry_contact_close_sensor: ${id_prefix}_dry_contact_close
Expand Down
4 changes: 4 additions & 0 deletions base_secplusv1.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,11 @@ external_components:
- source:
type: git
url: https://github.com/ratgdo/esphome-ratgdo
ref: ratgdo32
refresh: 1s
# - source:
# type: local
# path: components

safe_mode:

Expand Down
3 changes: 3 additions & 0 deletions components/ratgdo/binary_sensor/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,9 @@
"obstruction": SensorType.RATGDO_SENSOR_OBSTRUCTION,
"motor": SensorType.RATGDO_SENSOR_MOTOR,
"button": SensorType.RATGDO_SENSOR_BUTTON,
"vehicle_detected": SensorType.RATGDO_SENSOR_VEHICLE_DETECTED,
"vehicle_arriving": SensorType.RATGDO_SENSOR_VEHICLE_ARRIVING,
"vehicle_leaving": SensorType.RATGDO_SENSOR_VEHICLE_LEAVING,
}


Expand Down
22 changes: 22 additions & 0 deletions components/ratgdo/binary_sensor/ratgdo_binary_sensor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,22 @@ namespace ratgdo {
this->parent_->subscribe_button_state([=](ButtonState state) {
this->publish_state(state == ButtonState::PRESSED);
});
} else if (this->binary_sensor_type_ == SensorType::RATGDO_SENSOR_VEHICLE_DETECTED) {
this->publish_initial_state(false);
this->parent_->subscribe_vehicle_detected_state([=](VehicleDetectedState state) {
this->publish_state(state == VehicleDetectedState::YES);
this->parent_->presence_change(state == VehicleDetectedState::YES);
});
} else if (this->binary_sensor_type_ == SensorType::RATGDO_SENSOR_VEHICLE_ARRIVING) {
this->publish_initial_state(false);
this->parent_->subscribe_vehicle_arriving_state([=](VehicleArrivingState state) {
this->publish_state(state == VehicleArrivingState::YES);
});
} else if (this->binary_sensor_type_ == SensorType::RATGDO_SENSOR_VEHICLE_LEAVING) {
this->publish_initial_state(false);
this->parent_->subscribe_vehicle_leaving_state([=](VehicleLeavingState state) {
this->publish_state(state == VehicleLeavingState::YES);
});
}
}

Expand All @@ -42,6 +58,12 @@ namespace ratgdo {
ESP_LOGCONFIG(TAG, " Type: Motor");
} else if (this->binary_sensor_type_ == SensorType::RATGDO_SENSOR_BUTTON) {
ESP_LOGCONFIG(TAG, " Type: Button");
} else if (this->binary_sensor_type_ == SensorType::RATGDO_SENSOR_VEHICLE_DETECTED) {
ESP_LOGCONFIG(TAG, " Type: VehicleDetected");
} else if (this->binary_sensor_type_ == SensorType::RATGDO_SENSOR_VEHICLE_ARRIVING) {
ESP_LOGCONFIG(TAG, " Type: VehicleArriving");
} else if (this->binary_sensor_type_ == SensorType::RATGDO_SENSOR_VEHICLE_LEAVING) {
ESP_LOGCONFIG(TAG, " Type: VehicleLeaving");
}
}

Expand Down
5 changes: 4 additions & 1 deletion components/ratgdo/binary_sensor/ratgdo_binary_sensor.h
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,10 @@ namespace ratgdo {
RATGDO_SENSOR_MOTION,
RATGDO_SENSOR_OBSTRUCTION,
RATGDO_SENSOR_MOTOR,
RATGDO_SENSOR_BUTTON
RATGDO_SENSOR_BUTTON,
RATGDO_SENSOR_VEHICLE_DETECTED,
RATGDO_SENSOR_VEHICLE_ARRIVING,
RATGDO_SENSOR_VEHICLE_LEAVING,
};

class RATGDOBinarySensor : public binary_sensor::BinarySensor, public RATGDOClient, public Component {
Expand Down
2 changes: 2 additions & 0 deletions components/ratgdo/number/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@
"rolling_code_counter": NumberType.RATGDO_ROLLING_CODE_COUNTER,
"opening_duration": NumberType.RATGDO_OPENING_DURATION,
"closing_duration": NumberType.RATGDO_CLOSING_DURATION,
"closing_delay": NumberType.RATGDO_CLOSING_DELAY,
"target_distance_measurement": NumberType.RATGDO_TARGET_DISTANCE_MEASUREMENT,
}


Expand Down
24 changes: 24 additions & 0 deletions components/ratgdo/number/ratgdo_number.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,10 @@ namespace ratgdo {
ESP_LOGCONFIG(TAG, " Type: Opening Duration");
} else if (this->number_type_ == RATGDO_CLOSING_DURATION) {
ESP_LOGCONFIG(TAG, " Type: Closing Duration");
} else if (this->number_type_ == RATGDO_CLOSING_DELAY) {
ESP_LOGCONFIG(TAG, " Type: Closing Delay");
} else if (this->number_type_ == RATGDO_TARGET_DISTANCE_MEASUREMENT) {
ESP_LOGCONFIG(TAG, " Type: Target Distance Measurement");
}
}

Expand Down Expand Up @@ -66,6 +70,14 @@ namespace ratgdo {
this->parent_->subscribe_closing_duration([=](float value) {
this->update_state(value);
});
} else if (this->number_type_ == RATGDO_CLOSING_DELAY) {
this->parent_->subscribe_closing_delay([=](uint32_t value) {
this->update_state(value);
});
} else if (this->number_type_ == RATGDO_TARGET_DISTANCE_MEASUREMENT) {
// this->parent_->subscribe_target_distance_measurement([=](float value) {
// this->update_state(value);
// });
}
}

Expand All @@ -76,12 +88,20 @@ namespace ratgdo {
this->traits.set_step(0.1);
this->traits.set_min_value(0.0);
this->traits.set_max_value(180.0);
} else if (this->number_type_ == RATGDO_CLOSING_DELAY) {
this->traits.set_step(1);
this->traits.set_min_value(0.0);
this->traits.set_max_value(60.0);
} else if (this->number_type_ == RATGDO_ROLLING_CODE_COUNTER) {
this->traits.set_max_value(0xfffffff);
} else if (this->number_type_ == RATGDO_CLIENT_ID) {
this->traits.set_step(0x1000);
this->traits.set_min_value(0x539);
this->traits.set_max_value(0x7ff539);
} else if (this->number_type_ == RATGDO_TARGET_DISTANCE_MEASUREMENT) {
this->traits.set_step(1);
this->traits.set_min_value(5);
this->traits.set_max_value(3500);
}
}

Expand All @@ -102,9 +122,13 @@ namespace ratgdo {
this->parent_->set_opening_duration(value);
} else if (this->number_type_ == RATGDO_CLOSING_DURATION) {
this->parent_->set_closing_duration(value);
} else if (this->number_type_ == RATGDO_CLOSING_DELAY) {
this->parent_->set_closing_delay(value);
} else if (this->number_type_ == RATGDO_CLIENT_ID) {
value = normalize_client_id(value);
this->parent_->call_protocol(SetClientID { static_cast<uint32_t>(value) });
} else if (this->number_type_ == RATGDO_TARGET_DISTANCE_MEASUREMENT) {
this->parent_->set_target_distance_measurement(value);
}
this->update_state(value);
}
Expand Down
2 changes: 2 additions & 0 deletions components/ratgdo/number/ratgdo_number.h
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@ namespace ratgdo {
RATGDO_ROLLING_CODE_COUNTER,
RATGDO_OPENING_DURATION,
RATGDO_CLOSING_DURATION,
RATGDO_CLOSING_DELAY,
RATGDO_TARGET_DISTANCE_MEASUREMENT,
};

class RATGDONumber : public number::Number, public RATGDOClient, public Component {
Expand Down
36 changes: 36 additions & 0 deletions components/ratgdo/output/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
import esphome.codegen as cg
import esphome.config_validation as cv
from esphome.components import rtttl
from esphome.const import CONF_ID
CONF_RTTTL = "rtttl"
CONF_SONG = "song"


from .. import RATGDO_CLIENT_SCHMEA, ratgdo_ns, register_ratgdo_child

DEPENDENCIES = ["esp32","ratgdo","rtttl"]

RATGDOOutput = ratgdo_ns.class_("RATGDOOutput", cg.Component)
OutputType = ratgdo_ns.enum("OutputType")

CONF_TYPE = "type"
TYPES = {
"beeper": OutputType.RATGDO_BEEPER
}

CONFIG_SCHEMA = cv.Schema(
{
cv.Required(CONF_ID): cv.declare_id(RATGDOOutput),
cv.Required(CONF_TYPE): cv.enum(TYPES, lower=True),
cv.Required(CONF_RTTTL): cv.use_id(rtttl),
cv.Required(CONF_SONG): cv.string
}
).extend(RATGDO_CLIENT_SCHMEA)

async def to_code(config):
var = cg.new_Pvariable(config[CONF_ID])
await cg.register_component(var, config)
rtttl = await cg.get_variable(config[CONF_RTTTL])
cg.add(var.set_rtttl(rtttl))
cg.add(var.set_song(config[CONF_SONG]))
await register_ratgdo_child(var, config)
58 changes: 58 additions & 0 deletions components/ratgdo/output/ratgdo_output.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
#include "ratgdo_output.h"
#include "../ratgdo_state.h"
#include "esphome/core/log.h"

namespace esphome {
namespace ratgdo {

static const char* TAG = "ratgdo.output";

void RATGDOOutput::setup()
{
ESP_LOGD(TAG, "Output was setup");

if (this->output_type_ == OutputType::RATGDO_BEEPER) {
this->beeper_->add_on_finished_playback_callback([=] { this->finished_playback(); });

this->parent_->subscribe_vehicle_arriving_state([=](VehicleArrivingState state) {
if (state == VehicleArrivingState::YES) {
this->play();
}
});

this->parent_->subscribe_door_action_delayed([=](DoorActionDelayed state) {
if (state == DoorActionDelayed::YES) {
this->play();
this->repeat_ = true;
} else if (state == DoorActionDelayed::NO) {
this->repeat_ = false;
}
});
}
}

void RATGDOOutput::play()
{
this->beeper_->play(this->rtttlSong_);
}

void RATGDOOutput::finished_playback()
{
if (this->repeat_)
this->play();
}

void RATGDOOutput::dump_config()
{
if (this->output_type_ == OutputType::RATGDO_BEEPER) {
ESP_LOGCONFIG(TAG, " Type: Beeper");
}
}

void RATGDOOutput::set_output_type(OutputType output_type_)
{
this->output_type_ = output_type_;
}

} // namespace ratgdo
} // namespace esphome
32 changes: 32 additions & 0 deletions components/ratgdo/output/ratgdo_output.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
#pragma once

#include "../ratgdo.h"
#include "esphome/components/rtttl/rtttl.h"
#include "esphome/core/component.h"

namespace esphome {
namespace ratgdo {

enum OutputType {
RATGDO_BEEPER
};

class RATGDOOutput : public RATGDOClient, public Component {
public:
void setup() override;
void play();
void finished_playback();
void dump_config() override;
void set_output_type(OutputType output_type);
void set_song(std::string rtttlSong) { this->rtttlSong_ = rtttlSong; }
void set_rtttl(rtttl::Rtttl* output) { this->beeper_ = output; }

protected:
OutputType output_type_;
rtttl::Rtttl* beeper_;
std::string rtttlSong_;
bool repeat_;
};

} // namespace ratgdo
} // namespace esphome
Loading
Loading