From f9911f7c944af45aa618adc2b76a7f125785db0d Mon Sep 17 00:00:00 2001 From: Jochen Scheib Date: Tue, 23 Jan 2024 18:45:58 +0100 Subject: [PATCH] Add Garage Door Vent button to HCPBridge cover example and fix schema --- .github/.gitignore | 5 +++++ .github/example_build_hcpbridge.yaml | 11 ++++++++++- components/hcpbridge/cover/__init__.py | 6 +++--- 3 files changed, 18 insertions(+), 4 deletions(-) create mode 100644 .github/.gitignore diff --git a/.github/.gitignore b/.github/.gitignore new file mode 100644 index 0000000..d8b4157 --- /dev/null +++ b/.github/.gitignore @@ -0,0 +1,5 @@ +# Gitignore settings for ESPHome +# This is an example and may include too much for your use-case. +# You can modify this file to suit your needs. +/.esphome/ +/secrets.yaml diff --git a/.github/example_build_hcpbridge.yaml b/.github/example_build_hcpbridge.yaml index f6d0f69..78fc0ee 100644 --- a/.github/example_build_hcpbridge.yaml +++ b/.github/example_build_hcpbridge.yaml @@ -29,6 +29,7 @@ hcpbridge: cover: - platform: hcpbridge name: Garage Door + id: garagedoor_cover switch: - platform: hcpbridge @@ -38,4 +39,12 @@ wifi: ssid: "My Network" password: "My Password" -api: \ No newline at end of file +api: + + +button: + platform: template + name: "Garage Door Vent" + on_press: + - lambda: |- + id(garagedoor_cover).on_go_to_vent(); \ No newline at end of file diff --git a/components/hcpbridge/cover/__init__.py b/components/hcpbridge/cover/__init__.py index 08c2003..f9f49fd 100644 --- a/components/hcpbridge/cover/__init__.py +++ b/components/hcpbridge/cover/__init__.py @@ -2,7 +2,7 @@ import esphome.config_validation as cv import esphome.codegen as cg from esphome.const import ( - CONF_OUTPUT_ID + CONF_ID ) from .. import hcpbridge_ns, HCPBridge, CONF_HCPBridge_ID @@ -13,13 +13,13 @@ CONFIG_SCHEMA = cv.All( cover.COVER_SCHEMA.extend({ - cv.GenerateID(CONF_OUTPUT_ID): cv.declare_id(HCPBridgeCover), + cv.GenerateID(): cv.declare_id(HCPBridgeCover), cv.GenerateID(CONF_HCPBridge_ID): cv.use_id(HCPBridge), }).extend(cv.polling_component_schema("500ms")), ) async def to_code(config): - var = cg.new_Pvariable(config[CONF_OUTPUT_ID]) + var = cg.new_Pvariable(config[CONF_ID]) await cg.register_component(var, config) await cover.register_cover(var, config) parent = await cg.get_variable(config[CONF_HCPBridge_ID])