-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
9 changed files
with
1,361 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,137 @@ | ||
Language: Cpp | ||
AccessModifierOffset: -1 | ||
AlignAfterOpenBracket: Align | ||
AlignConsecutiveAssignments: false | ||
AlignConsecutiveDeclarations: false | ||
AlignEscapedNewlines: DontAlign | ||
AlignOperands: true | ||
AlignTrailingComments: true | ||
AllowAllParametersOfDeclarationOnNextLine: true | ||
AllowShortBlocksOnASingleLine: false | ||
AllowShortCaseLabelsOnASingleLine: false | ||
AllowShortFunctionsOnASingleLine: All | ||
AllowShortIfStatementsOnASingleLine: false | ||
AllowShortLoopsOnASingleLine: false | ||
AlwaysBreakAfterReturnType: None | ||
AlwaysBreakBeforeMultilineStrings: false | ||
AlwaysBreakTemplateDeclarations: MultiLine | ||
BinPackArguments: true | ||
BinPackParameters: true | ||
BraceWrapping: | ||
AfterClass: false | ||
AfterControlStatement: false | ||
AfterEnum: false | ||
AfterFunction: false | ||
AfterNamespace: false | ||
AfterObjCDeclaration: false | ||
AfterStruct: false | ||
AfterUnion: false | ||
AfterExternBlock: false | ||
BeforeCatch: false | ||
BeforeElse: false | ||
IndentBraces: false | ||
SplitEmptyFunction: true | ||
SplitEmptyRecord: true | ||
SplitEmptyNamespace: true | ||
BreakBeforeBinaryOperators: None | ||
BreakBeforeBraces: Attach | ||
BreakBeforeInheritanceComma: false | ||
BreakInheritanceList: BeforeColon | ||
BreakBeforeTernaryOperators: true | ||
BreakConstructorInitializersBeforeComma: false | ||
BreakConstructorInitializers: BeforeColon | ||
BreakAfterJavaFieldAnnotations: false | ||
BreakStringLiterals: true | ||
ColumnLimit: 120 | ||
CommentPragmas: '^ IWYU pragma:' | ||
CompactNamespaces: false | ||
ConstructorInitializerAllOnOneLineOrOnePerLine: true | ||
ConstructorInitializerIndentWidth: 4 | ||
ContinuationIndentWidth: 4 | ||
Cpp11BracedListStyle: true | ||
DerivePointerAlignment: false | ||
DisableFormat: false | ||
ExperimentalAutoDetectBinPacking: false | ||
FixNamespaceComments: true | ||
ForEachMacros: | ||
- foreach | ||
- Q_FOREACH | ||
- BOOST_FOREACH | ||
IncludeBlocks: Preserve | ||
IncludeCategories: | ||
- Regex: '^<ext/.*\.h>' | ||
Priority: 2 | ||
- Regex: '^<.*\.h>' | ||
Priority: 1 | ||
- Regex: '^<.*' | ||
Priority: 2 | ||
- Regex: '.*' | ||
Priority: 3 | ||
IncludeIsMainRegex: '([-_](test|unittest))?$' | ||
IndentCaseLabels: true | ||
IndentPPDirectives: None | ||
IndentWidth: 2 | ||
IndentWrappedFunctionNames: false | ||
KeepEmptyLinesAtTheStartOfBlocks: false | ||
MacroBlockBegin: '' | ||
MacroBlockEnd: '' | ||
MaxEmptyLinesToKeep: 1 | ||
NamespaceIndentation: None | ||
PenaltyBreakAssignment: 2 | ||
PenaltyBreakBeforeFirstCallParameter: 1 | ||
PenaltyBreakComment: 300 | ||
PenaltyBreakFirstLessLess: 120 | ||
PenaltyBreakString: 1000 | ||
PenaltyBreakTemplateDeclaration: 10 | ||
PenaltyExcessCharacter: 1000000 | ||
PenaltyReturnTypeOnItsOwnLine: 2000 | ||
PointerAlignment: Right | ||
RawStringFormats: | ||
- Language: Cpp | ||
Delimiters: | ||
- cc | ||
- CC | ||
- cpp | ||
- Cpp | ||
- CPP | ||
- 'c++' | ||
- 'C++' | ||
CanonicalDelimiter: '' | ||
BasedOnStyle: google | ||
- Language: TextProto | ||
Delimiters: | ||
- pb | ||
- PB | ||
- proto | ||
- PROTO | ||
EnclosingFunctions: | ||
- EqualsProto | ||
- EquivToProto | ||
- PARSE_PARTIAL_TEXT_PROTO | ||
- PARSE_TEST_PROTO | ||
- PARSE_TEXT_PROTO | ||
- ParseTextOrDie | ||
- ParseTextProtoOrDie | ||
CanonicalDelimiter: '' | ||
BasedOnStyle: google | ||
ReflowComments: true | ||
SortIncludes: false | ||
SortUsingDeclarations: false | ||
SpaceAfterCStyleCast: true | ||
SpaceAfterTemplateKeyword: false | ||
SpaceBeforeAssignmentOperators: true | ||
SpaceBeforeCpp11BracedList: false | ||
SpaceBeforeCtorInitializerColon: true | ||
SpaceBeforeInheritanceColon: true | ||
SpaceBeforeParens: ControlStatements | ||
SpaceBeforeRangeBasedForLoopColon: true | ||
SpaceInEmptyParentheses: false | ||
SpacesBeforeTrailingComments: 2 | ||
SpacesInAngles: false | ||
SpacesInContainerLiterals: false | ||
SpacesInCStyleCastParentheses: false | ||
SpacesInParentheses: false | ||
SpacesInSquareBrackets: false | ||
Standard: Auto | ||
TabWidth: 2 | ||
UseTab: Never |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
#pragma once | ||
|
||
#include "esphome/core/component.h" | ||
#include "esphome/core/automation.h" | ||
#include "tcc_link.h" | ||
|
||
namespace esphome | ||
{ | ||
namespace tcc_link | ||
{ | ||
|
||
class TccLinkOnDataReceivedTrigger : public Trigger<std::vector<uint8_t>> | ||
{ | ||
public: | ||
TccLinkOnDataReceivedTrigger(TccLinkClimate *climate) | ||
{ | ||
climate->add_on_data_received_callback( | ||
[this](const struct DataFrame *frame) | ||
{ | ||
this->trigger(frame->get_data()); | ||
}); | ||
} | ||
}; | ||
|
||
} // namespace tcc_link | ||
} // namespace esphome |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,108 @@ | ||
import esphome.codegen as cg | ||
import esphome.config_validation as cv | ||
from esphome import automation | ||
from esphome.components import climate, uart, binary_sensor, sensor, switch, text_sensor, template | ||
from esphome.const import ( | ||
CONF_ID, | ||
CONF_NAME, | ||
CONF_HARDWARE_UART, | ||
CONF_BAUD_RATE, | ||
CONF_UPDATE_INTERVAL, | ||
CONF_MODE, | ||
CONF_FAN_MODE, | ||
CONF_SWING_MODE, | ||
CONF_TRIGGER_ID, | ||
DEVICE_CLASS_CONNECTIVITY, | ||
ENTITY_CATEGORY_DIAGNOSTIC, | ||
STATE_CLASS_MEASUREMENT, | ||
) | ||
|
||
DEPENDENCIES = ["uart"] | ||
AUTO_LOAD = ["climate", "binary_sensor", "sensor", "switch"] | ||
CODEOWNERS = ["@muxa"] | ||
|
||
tcc_link_ns = cg.esphome_ns.namespace("tcc_link") | ||
|
||
CONF_CONNECTED = "connected" | ||
CONF_VENT = "vent" | ||
CONF_FAILED_CRCS = "failed_crcs" | ||
|
||
CONF_ON_DATA_RECEIVED = "on_data_received" | ||
|
||
TccLinkClimate = tcc_link_ns.class_( | ||
"TccLinkClimate", climate.Climate, uart.UARTDevice, cg.Component | ||
) | ||
|
||
TccLinkVentSwitch = tcc_link_ns.class_( | ||
"TccLinkVentSwitch", switch.Switch, cg.Component | ||
) | ||
|
||
TccLinkOnDataReceivedTrigger = tcc_link_ns.class_( | ||
"TccLinkOnDataReceivedTrigger", automation.Trigger.template() | ||
) | ||
|
||
CONFIG_SCHEMA = climate.CLIMATE_SCHEMA.extend( | ||
{ | ||
cv.GenerateID(): cv.declare_id(TccLinkClimate), | ||
cv.Optional(CONF_CONNECTED): binary_sensor.binary_sensor_schema( | ||
device_class = DEVICE_CLASS_CONNECTIVITY, | ||
entity_category=ENTITY_CATEGORY_DIAGNOSTIC, | ||
), | ||
cv.Optional(CONF_VENT): cv.maybe_simple_value( | ||
switch.SWITCH_SCHEMA.extend( | ||
cv.Schema( | ||
{ | ||
cv.GenerateID(): cv.declare_id(TccLinkVentSwitch), | ||
} | ||
) | ||
), | ||
key=CONF_NAME, | ||
), | ||
cv.Optional(CONF_FAILED_CRCS): sensor.sensor_schema( | ||
accuracy_decimals=0, | ||
entity_category=ENTITY_CATEGORY_DIAGNOSTIC, | ||
state_class=STATE_CLASS_MEASUREMENT, | ||
), | ||
cv.Optional(CONF_ON_DATA_RECEIVED): automation.validate_automation( | ||
{ | ||
cv.GenerateID(CONF_TRIGGER_ID): cv.declare_id( | ||
TccLinkOnDataReceivedTrigger | ||
), | ||
} | ||
), | ||
} | ||
).extend(uart.UART_DEVICE_SCHEMA).extend(cv.COMPONENT_SCHEMA) | ||
|
||
def validate_uart(config): | ||
uart.final_validate_device_schema( | ||
"tcc_link", baud_rate=2400, require_rx=True, require_tx=False | ||
)(config) | ||
|
||
|
||
FINAL_VALIDATE_SCHEMA = validate_uart | ||
|
||
async def to_code(config): | ||
var = cg.new_Pvariable(config[CONF_ID]) | ||
|
||
await cg.register_component(var, config) | ||
await climate.register_climate(var, config) | ||
await uart.register_uart_device(var, config) | ||
|
||
if CONF_CONNECTED in config: | ||
sens = await binary_sensor.new_binary_sensor(config[CONF_CONNECTED]) | ||
cg.add(var.set_connected_binary_sensor(sens)) | ||
|
||
if CONF_FAILED_CRCS in config: | ||
sens = await sensor.new_sensor(config[CONF_FAILED_CRCS]) | ||
cg.add(var.set_failed_crcs_sensor(sens)) | ||
|
||
if CONF_VENT in config: | ||
sw = await switch.new_switch(config[CONF_VENT], var) | ||
cg.add(var.set_vent_switch(sw)) | ||
|
||
if CONF_ON_DATA_RECEIVED in config: | ||
for on_data_received in config.get(CONF_ON_DATA_RECEIVED, []): | ||
data_trigger = cg.new_Pvariable(on_data_received[CONF_TRIGGER_ID], var) | ||
await automation.build_automation( | ||
data_trigger, [(cg.std_vector.template(cg.uint8), "x")], on_data_received | ||
) |
Oops, something went wrong.