From dde2a2cc33de1b1e01935a2a528d51df01e0f812 Mon Sep 17 00:00:00 2001 From: manuel Date: Wed, 26 Nov 2025 10:56:48 +0100 Subject: Add fan control to couchlight --- esphome/config/my_components/mycc1101/__init__.py | 22 +++++++++++++ esphome/config/my_components/mycc1101/mycc1101.h | 39 +++++++++++++++++++++++ 2 files changed, 61 insertions(+) create mode 100644 esphome/config/my_components/mycc1101/__init__.py create mode 100644 esphome/config/my_components/mycc1101/mycc1101.h (limited to 'esphome/config/my_components') diff --git a/esphome/config/my_components/mycc1101/__init__.py b/esphome/config/my_components/mycc1101/__init__.py new file mode 100644 index 0000000..14261fb --- /dev/null +++ b/esphome/config/my_components/mycc1101/__init__.py @@ -0,0 +1,22 @@ +import esphome.codegen as cg +from esphome.components import spi, remote_base +import esphome.config_validation as cv +from esphome.const import CONF_ID, CONF_PROTOCOL, CONF_CODE +from esphome.components import cc1101 +from types import FunctionType + +cc1101.MULTI_CONF_NO_DEFAULT = True +AUTO_LOAD = ["cc1101"] +DEPENDENCIES = cc1101.DEPENDENCIES + +ns = cg.esphome_ns.namespace("cc1101") +MyCC1101Component = ns.class_("MyCC1101Component", cc1101.CC1101Component)#, cg.Component, spi.SPIDevice) + +CONFIG_SCHEMA = cc1101.CONFIG_SCHEMA.extend( + { + cv.GenerateID(): cv.declare_id(MyCC1101Component), + } +) + +to_code = cc1101.to_code + diff --git a/esphome/config/my_components/mycc1101/mycc1101.h b/esphome/config/my_components/mycc1101/mycc1101.h new file mode 100644 index 0000000..95f714d --- /dev/null +++ b/esphome/config/my_components/mycc1101/mycc1101.h @@ -0,0 +1,39 @@ +#pragma once + +#include "esphome/components/cc1101/cc1101.h" +#include "esphome/components/cc1101/cc1101defs.h" + +namespace esphome { +namespace cc1101 { + +static const char *const TAG = "mycc1101"; + +class MyCC1101Component : public CC1101Component { + public: + void idle() { + ESP_LOGD(TAG, "idle"); + this->send_(Command::IDLE); + } + + void power_down() { + ESP_LOGD(TAG, "power_down"); + this->send_(Command::IDLE); + this->send_(Command::PWD); + } + + void wakeup() { + ESP_LOGD(TAG, "wakeup"); + this->cs_->digital_write(false); + delayMicroseconds(10); + this->cs_->digital_write(true); + delayMicroseconds(200); + + this->send_(Command::IDLE); + + // set patable after after wakeup + this->set_output_power(this->output_power_requested_); + } +}; + +} // namespace cc1101 +} // namespace esphome -- cgit v1.2.3