mirror of
https://github.com/esphome/esphome.git
synced 2025-11-19 16:25:50 +00:00
Co-authored-by: Ben Buxton <bb@cactii.net> Co-authored-by: Otto Winter <otto@otto-winter.com> Co-authored-by: Stefan Agner <stefan@agner.ch> Co-authored-by: Jesse Hills <3060199+jesserockz@users.noreply.github.com> Co-authored-by: René Klomp <rene@klomp.ws> Co-authored-by: Oxan van Leeuwen <oxan@oxanvanleeuwen.nl> Co-authored-by: Geoff Davis <geoff@geoffdavis.com> Co-authored-by: Paulus Schoutsen <paulus@home-assistant.io> Co-authored-by: dentra <dentra@users.noreply.github.com> Co-authored-by: Guillermo Ruffino <glm.net@gmail.com> Co-authored-by: Franck Nijhof <frenck@frenck.nl> Co-authored-by: Barry Loong <loongyh@users.noreply.github.com> Co-authored-by: Sergey V. DUDANOV <sergey.dudanov@gmail.com> Co-authored-by: Balazs Scheidler <bazsi77@gmail.com>
37 lines
1.1 KiB
Python
37 lines
1.1 KiB
Python
import esphome.codegen as cg
|
|
import esphome.config_validation as cv
|
|
from esphome.components import cover, ble_client
|
|
from esphome.const import CONF_ID, CONF_PIN
|
|
|
|
CODEOWNERS = ["@buxtronix"]
|
|
DEPENDENCIES = ["ble_client"]
|
|
AUTO_LOAD = ["am43"]
|
|
|
|
CONF_INVERT_POSITION = "invert_position"
|
|
|
|
am43_ns = cg.esphome_ns.namespace("am43")
|
|
Am43Component = am43_ns.class_(
|
|
"Am43Component", cover.Cover, ble_client.BLEClientNode, cg.Component
|
|
)
|
|
|
|
CONFIG_SCHEMA = (
|
|
cover.COVER_SCHEMA.extend(
|
|
{
|
|
cv.GenerateID(): cv.declare_id(Am43Component),
|
|
cv.Optional(CONF_PIN, default=8888): cv.int_range(min=0, max=0xFFFF),
|
|
cv.Optional(CONF_INVERT_POSITION, default=False): cv.boolean,
|
|
}
|
|
)
|
|
.extend(ble_client.BLE_CLIENT_SCHEMA)
|
|
.extend(cv.COMPONENT_SCHEMA)
|
|
)
|
|
|
|
|
|
def to_code(config):
|
|
var = cg.new_Pvariable(config[CONF_ID])
|
|
cg.add(var.set_pin(config[CONF_PIN]))
|
|
cg.add(var.set_invert_position(config[CONF_INVERT_POSITION]))
|
|
yield cg.register_component(var, config)
|
|
yield cover.register_cover(var, config)
|
|
yield ble_client.register_ble_node(var, config)
|