-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy path__init__.py
46 lines (35 loc) · 1.14 KB
/
__init__.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
import esphome.codegen as cg
import esphome.config_validation as cv
from esphome.components import uart
from esphome.const import CONF_ID
DEPENDENCIES = ["uart"]
sec_touch_ns = cg.esphome_ns.namespace("sec_touch")
SECTouchComponent = sec_touch_ns.class_(
"SECTouchComponent", cg.PollingComponent, uart.UARTDevice
)
FAN_LEVEL_IDS = (173, 174, 175, 176, 177, 178)
FAN_LABEL_IDS = (78, 79, 80, 81, 82, 83)
CONF_SEC_TOUCH_ID = "sec_touch_id"
# The total of fan pairs that the SEC-Touch shows in the screen
CONFIG_SCHEMA = cv.Schema(
{
cv.GenerateID(): cv.declare_id(SECTouchComponent),
}
)
CONFIG_SCHEMA = cv.All(
CONFIG_SCHEMA.extend(uart.UART_DEVICE_SCHEMA)
.extend(cv.COMPONENT_SCHEMA)
.extend(cv.polling_component_schema("5s")),
)
FINAL_VALIDATE_SCHEMA = uart.final_validate_device_schema(
"sec_touch",
require_tx=True,
require_rx=True,
# parity="NONE",
# stop_bits=1,
baud_rate=28800,
)
async def to_code(config):
var = cg.new_Pvariable(config[CONF_ID])
await cg.register_component(var, config)
await uart.register_uart_device(var, config)