Compare commits

..

18 Commits

Author SHA1 Message Date
1badaaf232 NSPanels no longer need an explicit esp_http_client - fixed in the ext component
Some checks failed
CI / YAML lint (push) Has been cancelled
CI / ESPHome config validation (push) Has been cancelled
2026-02-26 19:16:29 +01:00
5600203e6b Add --- to make valid yaml's and fix all commented indentations 2026-02-24 08:53:20 +01:00
1b5ef340e4 Remove empty line
Some checks failed
CI / YAML lint (push) Has been cancelled
CI / ESPHome config validation (push) Has been cancelled
2026-02-21 10:14:58 +01:00
082286ba87 Remove version/platform from can devices 2026-02-21 09:56:32 +01:00
baad6eda7c Real data for LLDP 2026-02-21 09:55:04 +01:00
9eeeef6a57 NSPanel's need esp_http_client 2026-02-21 09:54:27 +01:00
a966f6adb4 Templated gate beacon on_press and on_release
Some checks failed
CI / YAML lint (push) Has been cancelled
CI / ESPHome config validation (push) Has been cancelled
2026-02-19 14:23:27 +01:00
2ef5945c9f Add indent-sequences: whatever to support more compact indent 2026-02-19 12:21:00 +01:00
3ca7b2390d Use image files from assets directory 2026-02-19 12:10:33 +01:00
38791e3313 Move fonts (not being used for now) and images to assets directory. Remove obsolete .h files. 2026-02-19 12:07:56 +01:00
d03d889e81 Remove unused local components directory 2026-02-19 11:54:26 +01:00
4ee29295ac Remove debug ota.h and its include from mcu-lvgl
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-02-19 11:36:52 +01:00
dd033f69bb Refactor vehicle beacon configs and clean up gate
Extract shared M5ATOM vehicle code (esp32, on_loop, LED effects) into
common/vehicle_base.yaml, reducing each vehicle file from ~136 to 20
lines. Remove dead commented-out code from on_loop lambda.

Gate: fix on_multi_click and select indentation, change
esp32_ble_tracker id from ${name} to ${device} (lowercase),
remove unused commented-out gate_flash GPIO sensor.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-02-19 11:32:23 +01:00
7c9aae0a7d Fix trailing spaces and missing newlines in all mcu-*.yaml files
Bulk cleanup: remove trailing whitespace and ensure files end with a
newline. Structural issues (indentation, bracket spacing) left for
per-file fixes.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-02-19 11:22:12 +01:00
c88ccfbdb8 Use ESPHome dev branch in CI to match production
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-02-19 11:18:38 +01:00
b18ce4a2da Fix yamllint errors in POW configs, update CI and lint config
- Fix UART list indentation (yamllint error)
- Remove trailing spaces in display lambda
- Add missing newline at end of file
- Add ON/OFF to yamllint truthy allowed values
- Fix invalid comments rule option in .yamllint.yml
- Lint only changed files in CI (avoids blocking PRs with pre-existing issues)

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-02-19 11:14:51 +01:00
d4967c6411 Add CI: ESPHome config validation and YAML lint
- yamllint on all YAML files with ESPHome-friendly rules
  (allows True/False, long lines for lambdas, no forced document-start)
- ESPHome config validation on changed mcu-*.yaml files per push/PR

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-02-19 11:05:09 +01:00
a8b71d99dd Fix and improve POW dishwasher and washer configs
- Remove redundant interval block overriding status_led behavior
- Add UART id and reference it explicitly in cse7766
- Replace manual power factor template with native cse7766 power_factor sensor
- Remove redundant switch_led control from bi-stable relay actions
- Fix stray quote in energy sensor name (dishwasher)

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-02-19 10:56:34 +01:00
93 changed files with 700 additions and 2863 deletions

53
.github/workflows/ci.yml vendored Normal file
View File

@@ -0,0 +1,53 @@
name: CI
on:
push:
branches: [main]
pull_request:
jobs:
yamllint:
name: YAML lint
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Get changed YAML files
id: changed
uses: tj-actions/changed-files@v46
with:
files: "**/*.yaml"
- uses: ibiqlik/action-yamllint@v3
if: steps.changed.outputs.any_changed == 'true'
with:
config_file: .yamllint.yml
file_or_dir: ${{ steps.changed.outputs.all_changed_files }}
validate:
name: ESPHome config validation
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Get changed device configs
id: changed
uses: tj-actions/changed-files@v46
with:
files: "mcu-*.yaml"
- name: Install ESPHome (dev)
if: steps.changed.outputs.any_changed == 'true'
run: pip install git+https://github.com/esphome/esphome.git@dev
- name: Prepare secrets
if: steps.changed.outputs.any_changed == 'true'
run: cp secrets.yaml.default secrets.yaml
- name: Validate changed configs
if: steps.changed.outputs.any_changed == 'true'
run: |
for f in ${{ steps.changed.outputs.all_changed_files }}; do
echo "Validating $f..."
esphome config "$f"
done

27
.yamllint.yml Normal file
View File

@@ -0,0 +1,27 @@
extends: default
rules:
# ESPHome uses True/False (Python style) and yes/no
truthy:
allowed-values: ["true", "false", "True", "False", "yes", "no", "on", "off", "ON", "OFF"]
check-keys: false
# Lambdas and long substitutions can exceed 80 chars
line-length:
max: 200
level: warning
# Not all files use --- document start marker
document-start: disable
# ESPHome uses both indented and non-indented sequences
indentation:
spaces: 2
indent-sequences: whatever
check-multi-line-strings: false
# Some files have trailing spaces; warn only
trailing-spaces: enable
comments:
require-starting-space: false

View File

@@ -1,311 +0,0 @@
// Must disable logging if using logging in main.cpp or in other custom components for the
// __c causes a section type conflict with __c thingy
// you can enable logging and use it if you enable this in logger:
/*
logger:
level: DEBUG
esp8266_store_log_strings_in_flash: False
*/
//#define APE_LOGGING
// take advantage of LOG_ defines to decide which code to include
#ifdef LOG_BINARY_OUTPUT
#define APE_BINARY_OUTPUT
#endif
#ifdef LOG_BINARY_SENSOR
#define APE_BINARY_SENSOR
#endif
#ifdef LOG_SENSOR
#define APE_SENSOR
#endif
static const char *TAGape = "ape";
#define APE_CMD_DIGITAL_READ 0
#define APE_CMD_WRITE_ANALOG 2
#define APE_CMD_WRITE_DIGITAL_HIGH 3
#define APE_CMD_WRITE_DIGITAL_LOW 4
#define APE_CMD_SETUP_PIN_OUTPUT 5
#define APE_CMD_SETUP_PIN_INPUT_PULLUP 6
#define APE_CMD_SETUP_PIN_INPUT 7
// 8 analog registers.. A0 to A7
// A4 and A5 not supported due to I2C
#define CMD_ANALOG_READ_A0 0b1000 // 0x8
// ....
#define CMD_ANALOG_READ_A7 0b1111 // 0xF
#define CMD_SETUP_ANALOG_INTERNAL 0x10
#define CMD_SETUP_ANALOG_DEFAULT 0x11
#define get_ape(constructor) static_cast<ArduinoPortExpander *>(constructor.get_component(0))
#define ape_binary_output(ape, pin) get_ape(ape)->get_binary_output(pin)
#define ape_binary_sensor(ape, pin) get_ape(ape)->get_binary_sensor(pin)
#define ape_analog_input(ape, pin) get_ape(ape)->get_analog_input(pin)
class ArduinoPortExpander;
using namespace esphome;
#ifdef APE_BINARY_OUTPUT
class ApeBinaryOutput : public output::BinaryOutput
{
public:
ApeBinaryOutput(ArduinoPortExpander *parent, uint8_t pin)
{
this->parent_ = parent;
this->pin_ = pin;
}
void write_state(bool state) override;
uint8_t get_pin() { return this->pin_; }
protected:
ArduinoPortExpander *parent_;
uint8_t pin_;
// Pins are setup as output after the state is written, Arduino has no open drain outputs, after setting an output it will either sink or source thus activating outputs writen to false during a flick.
bool setup_{true};
bool state_{false};
friend class ArduinoPortExpander;
};
#endif
#ifdef APE_BINARY_SENSOR
class ApeBinarySensor : public binary_sensor::BinarySensor
{
public:
ApeBinarySensor(ArduinoPortExpander *parent, uint8_t pin)
{
this->pin_ = pin;
}
uint8_t get_pin() { return this->pin_; }
protected:
uint8_t pin_;
};
#endif
#ifdef APE_SENSOR
class ApeAnalogInput : public sensor::Sensor
{
public:
ApeAnalogInput(ArduinoPortExpander *parent, uint8_t pin)
{
this->pin_ = pin;
}
uint8_t get_pin() { return this->pin_; }
protected:
uint8_t pin_;
};
#endif
class ArduinoPortExpander : public Component, public I2CDevice
{
public:
ArduinoPortExpander(I2CBus *bus, uint8_t address, bool vref_default = false)
{
set_i2c_address(address);
set_i2c_bus(bus);
this->vref_default_ = vref_default;
}
void setup() override
{
#ifdef APE_LOGGING
ESP_LOGCONFIG(TAGape, "Setting up ArduinoPortExpander at %#02x ...", address_);
#endif
/* We cannot setup as usual as arduino boots later than esp8266
Poll i2c bus for our Arduino for a n seconds instead of failing fast,
also this is important as pin setup (INPUT_PULLUP, OUTPUT it's done once)
*/
this->configure_timeout_ = millis() + 5000;
}
void loop() override
{
if (millis() < this->configure_timeout_)
{
bool try_configure = millis() % 100 > 50;
if (try_configure == this->configure_)
return;
this->configure_ = try_configure;
if (ERROR_OK == this->read_register(APE_CMD_DIGITAL_READ, const_cast<uint8_t *>(this->read_buffer_), 3))
{
#ifdef APE_LOGGING
ESP_LOGCONFIG(TAGape, "ArduinoPortExpander found at %#02x", address_);
#endif
delay(10);
if (this->vref_default_)
{
this->write_register(CMD_SETUP_ANALOG_DEFAULT, nullptr, 0); // 0: unused
}
// Config success
this->configure_timeout_ = 0;
this->status_clear_error();
#ifdef APE_BINARY_SENSOR
for (ApeBinarySensor *pin : this->input_pins_)
{
App.feed_wdt();
uint8_t pinNo = pin->get_pin();
#ifdef APE_LOGGING
ESP_LOGCONFIG(TAGape, "Setup input pin %d", pinNo);
#endif
this->write_register(APE_CMD_SETUP_PIN_INPUT_PULLUP, &pinNo, 1);
delay(20);
}
#endif
#ifdef APE_BINARY_OUTPUT
for (ApeBinaryOutput *output : this->output_pins_)
{
if (!output->setup_)
{ // this output has a valid value already
this->write_state(output->pin_, output->state_, true);
App.feed_wdt();
delay(20);
}
}
#endif
#ifdef APE_SENSOR
for (ApeAnalogInput *sensor : this->analog_pins_)
{
App.feed_wdt();
uint8_t pinNo = sensor->get_pin();
#ifdef APE_LOGGING
ESP_LOGCONFIG(TAGape, "Setup analog input pin %d", pinNo);
#endif
this->write_register(APE_CMD_SETUP_PIN_INPUT, &pinNo, 1);
delay(20);
}
#endif
return;
}
// Still not answering
return;
}
if (this->configure_timeout_ != 0 && millis() > this->configure_timeout_)
{
#ifdef APE_LOGGING
ESP_LOGE(TAGape, "ArduinoPortExpander NOT found at %#02x", address_);
#endif
this->mark_failed();
return;
}
#ifdef APE_BINARY_SENSOR
if (ERROR_OK != this->read_register(APE_CMD_DIGITAL_READ, const_cast<uint8_t *>(this->read_buffer_), 3))
{
#ifdef APE_LOGGING
ESP_LOGE(TAGape, "Error reading. Reconfiguring pending.");
#endif
this->status_set_error();
this->configure_timeout_ = millis() + 5000;
return;
}
for (ApeBinarySensor *pin : this->input_pins_)
{
uint8_t pinNo = pin->get_pin();
uint8_t bit = pinNo % 8;
uint8_t value = pinNo < 8 ? this->read_buffer_[0] : pinNo < 16 ? this->read_buffer_[1] : this->read_buffer_[2];
bool ret = value & (1 << bit);
if (this->initial_state_)
pin->publish_initial_state(ret);
else
pin->publish_state(ret);
}
#endif
#ifdef APE_SENSOR
for (ApeAnalogInput *pin : this->analog_pins_)
{
uint8_t pinNo = pin->get_pin();
pin->publish_state(analogRead(pinNo));
}
#endif
this->initial_state_ = false;
}
#ifdef APE_SENSOR
uint16_t analogRead(uint8_t pin)
{
bool ok = (ERROR_OK == this->read_register((uint8_t)(CMD_ANALOG_READ_A0 + pin), const_cast<uint8_t *>(this->read_buffer_), 2));
#ifdef APE_LOGGING
ESP_LOGVV(TAGape, "analog read pin: %d ok: %d byte0: %d byte1: %d", pin, ok, this->read_buffer_[0], this->read_buffer_[1]);
#endif
uint16_t value = this->read_buffer_[0] | ((uint16_t)this->read_buffer_[1] << 8);
return value;
}
#endif
#ifdef APE_BINARY_OUTPUT
output::BinaryOutput *get_binary_output(uint8_t pin)
{
ApeBinaryOutput *output = new ApeBinaryOutput(this, pin);
output_pins_.push_back(output);
return output;
}
#endif
#ifdef APE_BINARY_SENSOR
binary_sensor::BinarySensor *get_binary_sensor(uint8_t pin)
{
ApeBinarySensor *binarySensor = new ApeBinarySensor(this, pin);
input_pins_.push_back(binarySensor);
return binarySensor;
}
#endif
#ifdef APE_SENSOR
sensor::Sensor *get_analog_input(uint8_t pin)
{
ApeAnalogInput *input = new ApeAnalogInput(this, pin);
analog_pins_.push_back(input);
return input;
}
#endif
void write_state(uint8_t pin, bool state, bool setup = false)
{
if (this->configure_timeout_ != 0)
return;
#ifdef APE_LOGGING
ESP_LOGD(TAGape, "Writing %d to pin %d", state, pin);
#endif
this->write_register(state ? APE_CMD_WRITE_DIGITAL_HIGH : APE_CMD_WRITE_DIGITAL_LOW, &pin, 1);
if (setup)
{
App.feed_wdt();
delay(20);
#ifdef APE_LOGGING
ESP_LOGI(TAGape, "Setup output pin %d", pin);
#endif
this->write_register(APE_CMD_SETUP_PIN_OUTPUT, &pin, 1);
}
}
protected:
bool configure_{true};
bool initial_state_{true};
uint8_t read_buffer_[3]{0, 0, 0};
unsigned long configure_timeout_{5000};
bool vref_default_{false};
#ifdef APE_BINARY_OUTPUT
std::vector<ApeBinaryOutput *> output_pins_;
#endif
#ifdef APE_BINARY_SENSOR
std::vector<ApeBinarySensor *> input_pins_;
#endif
#ifdef APE_SENSOR
std::vector<ApeAnalogInput *> analog_pins_;
#endif
};
#ifdef APE_BINARY_OUTPUT
void ApeBinaryOutput::write_state(bool state)
{
this->state_ = state;
this->parent_->write_state(this->pin_, state, this->setup_);
this->setup_ = false;
}
#endif

View File

Before

Width:  |  Height:  |  Size: 14 KiB

After

Width:  |  Height:  |  Size: 14 KiB

View File

Before

Width:  |  Height:  |  Size: 172 KiB

After

Width:  |  Height:  |  Size: 172 KiB

View File

@@ -0,0 +1,9 @@
- if:
condition:
and:
- switch.is_on: ${enable_id}
- switch.is_on: auto_close
- lambda: 'return id(beacon_count) == 1;'
then:
- button.press: gate_close
- lambda: 'id(beacon_count) -= 1;'

View File

@@ -0,0 +1,9 @@
- lambda: 'id(beacon_count) += 1;'
- if:
condition:
and:
- switch.is_on: ${enable_id}
- switch.is_on: auto_open
- lambda: 'return id(beacon_count) == 1;'
then:
- button.press: gate_open

105
common/vehicle_base.yaml Normal file
View File

@@ -0,0 +1,105 @@
esp32:
variant: esp32
framework:
type: esp-idf
external_components:
- source: components
# PINOUTS: M5ATOM
# IR G12
# NEO G27
# BUTTON G39
# I2C0 SDA G26
# I2C0 SCL G32
# I2C1 SDA G25
# I2C1 SCL G21
# UART0 RX G3
# UART0 TX G1
# UART1 RX G23
# UART1 TX G33
# 1-WIRE G22
# NC G19
esphome:
on_loop:
then:
lambda: |-
static uint32_t last_state = 0;
auto state = App.get_app_state();
if (state != last_state) {
if (state & STATUS_LED_ERROR) {
auto call = id(led).turn_on();
call.set_effect("ERROR");
call.perform();
} else if (state & STATUS_LED_WARNING) {
auto call = id(led).turn_on();
call.set_effect("BOOT");
call.perform();
} else {
auto call = id(led).turn_on();
call.set_effect("BEACON");
call.perform();
}
last_state = state;
}
light:
- platform: esp32_rmt_led_strip
name: LED
id: led
rgb_order: GRB
pin: 27
num_leds: 1
chipset: ws2812
restore_mode: ALWAYS_OFF
effects:
- strobe:
name: "BEACON"
colors:
- state: true
red: 0%
green: 0%
blue: 50%
duration: 200ms
- state: false
duration: 200ms
- state: true
red: 0%
green: 0%
blue: 50%
duration: 200ms
- state: false
duration: 10s
- lambda:
name: "ERROR"
update_interval: 0.5s
lambda: |-
static bool state = false;
auto call = id(led).turn_on();
call.set_transition_length(500);
call.set_rgb(1, 0, 0);
if (!state) {
call.set_brightness(1);
} else {
// If using 0, it freaks Home Assistant UI.
call.set_brightness(0.01);
}
call.perform();
state = !state;
- lambda:
name: "BOOT"
update_interval: 0.5s
lambda: |-
static bool state = false;
auto call = id(led).turn_on();
call.set_transition_length(500);
call.set_rgb(0, 1, 0);
if (!state) {
call.set_brightness(1);
} else {
// If using 0, it freaks Home Assistant UI.
call.set_brightness(0.01);
}
call.perform();
state = !state;

View File

@@ -1,24 +0,0 @@
import esphome.codegen as cg
import esphome.config_validation as cv
from esphome.components import i2c
from esphome.const import CONF_ID, CONF_SLEEP_DURATION
DEPENDENCIES = ['i2c']
CONF_I2C_ADDR = 0x51
bm8563 = cg.esphome_ns.namespace('bm8563')
BM8563 = bm8563.class_('BM8563', cg.Component, i2c.I2CDevice)
CONFIG_SCHEMA = cv.Schema({
cv.GenerateID(): cv.declare_id(BM8563),
cv.Optional(CONF_SLEEP_DURATION): cv.positive_time_period_seconds,
}).extend(cv.COMPONENT_SCHEMA).extend(i2c.i2c_device_schema(CONF_I2C_ADDR))
def to_code(config):
var = cg.new_Pvariable(config[CONF_ID])
if CONF_SLEEP_DURATION in config:
cg.add(var.set_sleep_duration(config[CONF_SLEEP_DURATION]))
yield cg.register_component(var, config)
yield i2c.register_i2c_device(var, config)

View File

@@ -1,242 +0,0 @@
#include "esphome/core/log.h"
#include "esphome/components/i2c/i2c_bus.h"
#include "bm8563.h"
namespace esphome {
namespace bm8563 {
static const char *TAG = "bm8563.sensor";
void BM8563::setup(){
this->write_byte_16(0,0);
this->setupComplete = true;
if (this->sleep_duration_.has_value()) {
SetAlarmIRQ(*this->sleep_duration_);
}
}
void BM8563::loop(){
// if(!this->setupComplete){
// return;
// }
// BM8563_TimeTypeDef BM8563_TimeStruct;
// getTime(&BM8563_TimeStruct);
// this->publish_state(BM8563_TimeStruct.seconds);
}
void BM8563::dump_config(){
ESP_LOGCONFIG(TAG, "BM8563:");
ESP_LOGCONFIG(TAG, " Address: 0x%02X", this->address_);
ESP_LOGCONFIG(TAG, " setupComplete: %s", this->setupComplete ? "true" : "false");
if (this->sleep_duration_.has_value()) {
uint32_t duration = *this->sleep_duration_;
ESP_LOGCONFIG(TAG, " Sleep Duration: %u ms", duration);
}
}
void BM8563::set_sleep_duration(uint32_t time_s) {
this->sleep_duration_ = uint64_t(time_s);
if (this->sleep_duration_.has_value()) {
SetAlarmIRQ(*this->sleep_duration_);
}
}
bool BM8563::getVoltLow() {
uint8_t data = ReadReg(0x02);
return data & 0x80; // RTCC_VLSEC_MASK
}
uint8_t BM8563::bcd2ToByte(uint8_t value) {
uint8_t tmp = 0;
tmp = ((uint8_t)(value & (uint8_t)0xF0) >> (uint8_t)0x4) * 10;
return (tmp + (value & (uint8_t)0x0F));
}
uint8_t BM8563::byteToBcd2(uint8_t value) {
uint8_t bcdhigh = 0;
while (value >= 10) {
bcdhigh++;
value -= 10;
}
return ((uint8_t)(bcdhigh << 4) | value);
}
void BM8563::getTime(BM8563_TimeTypeDef* BM8563_TimeStruct) {
uint8_t buf[3] = {0};
this->read_register(0x02, buf, 3);
BM8563_TimeStruct->seconds = bcd2ToByte(buf[0] & 0x7f);
BM8563_TimeStruct->minutes = bcd2ToByte(buf[1] & 0x7f);
BM8563_TimeStruct->hours = bcd2ToByte(buf[2] & 0x3f);
}
void BM8563::setTime(BM8563_TimeTypeDef* BM8563_TimeStruct) {
if (BM8563_TimeStruct == NULL) {
return;
}
uint8_t buf[3] = {byteToBcd2(BM8563_TimeStruct->seconds), byteToBcd2(BM8563_TimeStruct->minutes), byteToBcd2(BM8563_TimeStruct->hours)};
this->write_register(0x02, buf, 3);
}
void BM8563::getDate(BM8563_DateTypeDef* BM8563_DateStruct) {
uint8_t buf[4] = {0};
this->read_register(0x05, buf, 4);
BM8563_DateStruct->date = bcd2ToByte(buf[0] & 0x3f);
BM8563_DateStruct->weekDay = bcd2ToByte(buf[1] & 0x07);
BM8563_DateStruct->month = bcd2ToByte(buf[2] & 0x1f);
if (buf[2] & 0x80) {
BM8563_DateStruct->year = 1900 + bcd2ToByte(buf[3] & 0xff);
} else {
BM8563_DateStruct->year = 2000 + bcd2ToByte(buf[3] & 0xff);
}
}
void BM8563::setDate(BM8563_DateTypeDef* BM8563_DateStruct) {
if (BM8563_DateStruct == NULL) {
return;
}
uint8_t buf[4] = {byteToBcd2(BM8563_DateStruct->date), byteToBcd2(BM8563_DateStruct->weekDay), 0, byteToBcd2((uint8_t)(BM8563_DateStruct->year % 100))};
if (BM8563_DateStruct->year < 2000) {
buf[3] = byteToBcd2(BM8563_DateStruct->month) | 0x80;
} else {
buf[3] = byteToBcd2(BM8563_DateStruct->month) | 0x00;
}
this->write_register(0x05, buf, 4);
}
void BM8563::WriteReg(uint8_t reg, uint8_t data) {
this->write_byte(reg, data);
}
uint8_t BM8563::ReadReg(uint8_t reg) {
uint8_t data;
this->read_register(reg, &data, 1);
return data;
}
int BM8563::SetAlarmIRQ(int afterSeconds) {
uint8_t reg_value = 0;
reg_value = ReadReg(0x01);
if (afterSeconds < 0) {
reg_value &= ~(1 << 0);
WriteReg(0x01, reg_value);
reg_value = 0x03;
WriteReg(0x0E, reg_value);
return -1;
}
uint8_t type_value = 2;
uint8_t div = 1;
if (afterSeconds > 255) {
div = 60;
type_value = 0x83;
} else {
type_value = 0x82;
}
afterSeconds = (afterSeconds / div) & 0xFF;
WriteReg(0x0F, afterSeconds);
WriteReg(0x0E, type_value);
reg_value |= (1 << 0);
reg_value &= ~(1 << 7);
WriteReg(0x01, reg_value);
return afterSeconds * div;
}
int BM8563::SetAlarmIRQ(const BM8563_TimeTypeDef &BM8563_TimeStruct) {
uint8_t irq_enable = false;
uint8_t out_buf[4] = {0x80, 0x80, 0x80, 0x80};
if (BM8563_TimeStruct.minutes >= 0) {
irq_enable = true;
out_buf[0] = byteToBcd2(BM8563_TimeStruct.minutes) & 0x7f;
}
if (BM8563_TimeStruct.hours >= 0) {
irq_enable = true;
out_buf[1] = byteToBcd2(BM8563_TimeStruct.hours) & 0x3f;
}
out_buf[2] = 0x00;
out_buf[3] = 0x00;
uint8_t reg_value = ReadReg(0x01);
if (irq_enable) {
reg_value |= (1 << 1);
} else {
reg_value &= ~(1 << 1);
}
for (int i = 0; i < 4; i++) {
WriteReg(0x09 + i, out_buf[i]);
}
WriteReg(0x01, reg_value);
return irq_enable ? 1 : 0;
}
int BM8563::SetAlarmIRQ(const BM8563_DateTypeDef &BM8563_DateStruct, const BM8563_TimeTypeDef &BM8563_TimeStruct) {
uint8_t irq_enable = false;
uint8_t out_buf[4] = {0x80, 0x80, 0x80, 0x80};
if (BM8563_TimeStruct.minutes >= 0) {
irq_enable = true;
out_buf[0] = byteToBcd2(BM8563_TimeStruct.minutes) & 0x7f;
}
if (BM8563_TimeStruct.hours >= 0) {
irq_enable = true;
out_buf[1] = byteToBcd2(BM8563_TimeStruct.hours) & 0x3f;
}
if (BM8563_DateStruct.date >= 0) {
irq_enable = true;
out_buf[2] = byteToBcd2(BM8563_DateStruct.date) & 0x3f;
}
if (BM8563_DateStruct.weekDay >= 0) {
irq_enable = true;
out_buf[3] = byteToBcd2(BM8563_DateStruct.weekDay) & 0x07;
}
uint8_t reg_value = ReadReg(0x01);
if (irq_enable) {
reg_value |= (1 << 1);
} else {
reg_value &= ~(1 << 1);
}
for (int i = 0; i < 4; i++) {
WriteReg(0x09 + i, out_buf[i]);
}
WriteReg(0x01, reg_value);
return irq_enable ? 1 : 0;
}
void BM8563::clearIRQ() {
uint8_t data = ReadReg(0x01);
WriteReg(0x01, data & 0xf3);
}
void BM8563::disableIRQ() {
clearIRQ();
uint8_t data = ReadReg(0x01);
WriteReg(0x01, data & 0xfC);
}
} // namespace bm8563
} // namespace esphome

View File

@@ -1,62 +0,0 @@
#pragma once
#include "esphome/core/component.h"
#include "esphome/components/sensor/sensor.h"
#include "esphome/components/i2c/i2c.h"
namespace esphome {
namespace bm8563 {
typedef struct
{
int8_t hours;
int8_t minutes;
int8_t seconds;
} BM8563_TimeTypeDef;
typedef struct
{
int8_t weekDay;
int8_t month;
int8_t date;
int16_t year;
} BM8563_DateTypeDef;
class BM8563 : public Component, public i2c::I2CDevice {
public:
void setup() override;
void loop() override;
void dump_config() override;
void set_sleep_duration(uint32_t time_ms);
bool getVoltLow();
void getTime(BM8563_TimeTypeDef* BM8563_TimeStruct);
void getDate(BM8563_DateTypeDef* BM8563_DateStruct);
void setTime(BM8563_TimeTypeDef* BM8563_TimeStruct);
void setDate(BM8563_DateTypeDef* BM8563_DateStruct);
int SetAlarmIRQ(int afterSeconds);
int SetAlarmIRQ(const BM8563_TimeTypeDef &BM8563_TimeStruct);
int SetAlarmIRQ(const BM8563_DateTypeDef &BM8563_DateStruct, const BM8563_TimeTypeDef &BM8563_TimeStruct);
void clearIRQ();
void disableIRQ();
void WriteReg(uint8_t reg, uint8_t data);
uint8_t ReadReg(uint8_t reg);
private:
uint8_t bcd2ToByte(uint8_t value);
uint8_t byteToBcd2(uint8_t value);
uint8_t trdata[7];
optional<uint64_t> sleep_duration_;
bool setupComplete;
};
} // namespace bm8563
} // namespace esphome

View File

@@ -1,30 +0,0 @@
import esphome.codegen as cg
import esphome.config_validation as cv
from esphome.components import i2c
from esphome.const import CONF_ID
DEPENDENCIES = ["i2c"]
MULTI_CONF = True
AUTO_LOAD = ["switch"]
CODEOWNERS = ["@brotherdust"]
m5stack_4relay_ns = cg.esphome_ns.namespace("m5stack_4relay")
M5STACK4RELAYOutput = m5stack_4relay_ns.class_(
"M5STACK4RELAYSwitchComponent", cg.Component, i2c.I2CDevice
)
CONFIG_SCHEMA = (
cv.Schema(
{
cv.GenerateID(): cv.declare_id(M5STACK4RELAYOutput),
}
)
.extend(cv.COMPONENT_SCHEMA)
.extend(i2c.i2c_device_schema(0x26))
)
def to_code(config):
var = cg.new_Pvariable(config[CONF_ID])
yield cg.register_component(var, config)
yield i2c.register_i2c_device(var, config)

View File

@@ -1,49 +0,0 @@
#include "m5stack_4relay.h"
#include <bitset>
#include "esphome/core/log.h"
namespace esphome {
namespace m5stack_4relay {
static const char *const TAG = "m5stack_4relay.switch";
void M5STACK4RELAYSwitchComponent::setup() {
ESP_LOGCONFIG(TAG, "Setting up M5STACK4RELAY (0x%02X)...", this->address_);
component_status = 0;
get_status(&component_status);
ESP_LOGD(TAG, "Setup Status 0x%02X", component_status);
}
M5STACK4RELAYChannel *M5STACK4RELAYSwitchComponent::create_channel(uint8_t channel) {
return new M5STACK4RELAYChannel(this, channel);
}
void M5STACK4RELAYSwitchComponent::get_status(uint8_t *state) { this->read_byte(RELAY_CONTROL_REG); }
bool M5STACK4RELAYSwitchComponent::set_channel_value_(uint8_t channel, bool state) {
get_status(&component_status);
ESP_LOGD(TAG, "Current status 0x%02X", component_status);
ESP_LOGD(TAG, "Desired channel: %1u", channel);
ESP_LOGD(TAG, "Desired state: %1u", state);
channel = 3 - channel;
if (state) {
component_status |= (1u << channel);
} else {
component_status &= ~(1u << channel);
}
ESP_LOGD(TAG, "New status 0x%02X", component_status);
return this->write_byte(this->address_, RELAY_CONTROL_REG, component_status);
}
void M5STACK4RELAYChannel::write_state(bool state) {
if (!this->set_channel_value_(this->channel_, state)) {
publish_state(false);
} else {
publish_state(state);
}
}
} // namespace m5stack_4relay
} // namespace esphome

View File

@@ -1,49 +0,0 @@
#pragma once
#include "esphome/components/i2c/i2c.h"
#include "esphome/components/switch/switch.h"
#include "esphome/core/component.h"
#include "esphome/core/log.h"
namespace esphome {
namespace m5stack_4relay {
class M5STACK4RELAYSwitchComponent;
class M5STACK4RELAYChannel : public switch_::Switch {
public:
M5STACK4RELAYChannel(M5STACK4RELAYSwitchComponent *parent, uint8_t channel) : parent_(parent), channel_(channel) {}
protected:
void write_state(bool state) override;
M5STACK4RELAYSwitchComponent *parent_;
uint8_t channel_;
};
class M5STACK4RELAYSwitchComponent : public Component, public i2c::I2CDevice {
public:
const uint8_t MODE_CONTROL_REG = 0x10;
const uint8_t RELAY_CONTROL_REG = 0x11;
uint8_t component_status;
M5STACK4RELAYSwitchComponent() {}
M5STACK4RELAYChannel *create_channel(uint8_t channel);
void setup() override;
float get_setup_priority() const override { return setup_priority::HARDWARE; }
protected:
friend M5STACK4RELAYChannel;
void get_status(uint8_t *state);
bool set_channel_value_(uint8_t channel, bool state);
bool read_bytes_(uint8_t a_register, uint8_t *data, uint8_t len, uint32_t conversion) {
return this->raw_receive(this->address_, data, len);
}
float value_;
};
} // namespace m5stack_4relay
} // namespace esphome

View File

@@ -1,25 +0,0 @@
import esphome.config_validation as cv
import esphome.codegen as cg
from esphome.components import switch
from esphome.const import CONF_ID, CONF_CHANNEL
from . import M5STACK4RELAYOutput, m5stack_4relay_ns
DEPENDENCIES = ["m5stack_4relay"]
M5STACK4RELAYChannel = m5stack_4relay_ns.class_("M5STACK4RELAYChannel", switch.Switch)
CONF_M5STACK_4RELAY_ID = "m5stack_4relay_id"
CONFIG_SCHEMA = switch.SWITCH_SCHEMA.extend(
{
cv.Required(CONF_ID): cv.declare_id(M5STACK4RELAYChannel),
cv.GenerateID(CONF_M5STACK_4RELAY_ID): cv.use_id(M5STACK4RELAYOutput),
cv.Required(CONF_CHANNEL): cv.int_range(min=0, max=3),
}
)
async def to_code(config):
paren = await cg.get_variable(config[CONF_M5STACK_4RELAY_ID])
rhs = paren.create_channel(config[CONF_CHANNEL])
var = cg.Pvariable(config[CONF_ID], rhs)
await switch.register_switch(var, config)

View File

@@ -1 +0,0 @@
https://github.com/TomG736/esphome-BM8563

View File

@@ -1,28 +0,0 @@
# PCA9536D i2c I/O expander
Requires a configured i2c bus
Example:
```yaml
pca9536d:
- id: my_pca
switch:
- platform: gpio
pin:
pca9536d: my_pca
number: 0
id: relay
binary_sensor:
- platform: gpio
pin:
pca9536d: my_pca
number: 1
id: button
```
# Optional parameters
`address:` defaults to 0x41

View File

@@ -1,69 +0,0 @@
import esphome.codegen as cg
import esphome.config_validation as cv
from esphome import pins
from esphome.components import i2c
from esphome.const import (
CONF_ID,
CONF_INPUT,
CONF_INVERTED,
CONF_NUMBER,
CONF_MODE,
CONF_OUTPUT,
)
DEPENDENCIES = ["i2c"]
MULTI_CONF = True
CONF_PCA9536D = "pca9536d"
pca9536d_ns = cg.esphome_ns.namespace("pca9536d")
PCA9536DGPIOMode = pca9536d_ns.enum("PCA9536DGPIOMode")
PCA9536D = pca9536d_ns.class_("PCA9536D", cg.Component, i2c.I2CDevice)
PCA9536DGPIOPin = pca9536d_ns.class_("PCA9536DGPIOPin", cg.GPIOPin)
CONFIG_SCHEMA = cv.COMPONENT_SCHEMA.extend(
{
cv.Required(CONF_ID): cv.declare_id(PCA9536D),
}
).extend(i2c.i2c_device_schema(0x41))
async def to_code(config):
var = cg.new_Pvariable(config[CONF_ID])
await cg.register_component(var, config)
await i2c.register_i2c_device(var, config)
def validate_mode(value):
if not (value[CONF_INPUT] or value[CONF_OUTPUT]):
raise cv.Invalid("Mode must be either input or output")
if value[CONF_INPUT] and value[CONF_OUTPUT]:
raise cv.Invalid("Mode must be either input or output")
return value
PCA9536D_PIN_SCHEMA = cv.Schema(
{
cv.GenerateID(): cv.declare_id(PCA9536DGPIOPin),
cv.Required(CONF_PCA9536D): cv.use_id(PCA9536D),
cv.Required(CONF_NUMBER): cv.int_range(min=0, max=7),
cv.Optional(CONF_MODE, default={}): cv.All(
{
cv.Optional(CONF_INPUT, default=False): cv.boolean,
cv.Optional(CONF_OUTPUT, default=False): cv.boolean,
},
validate_mode,
),
cv.Optional(CONF_INVERTED, default=False): cv.boolean,
}
)
@pins.PIN_SCHEMA_REGISTRY.register(CONF_PCA9536D, PCA9536D_PIN_SCHEMA)
async def pca9536d_pin_to_code(config):
var = cg.new_Pvariable(config[CONF_ID])
parent = await cg.get_variable(config[CONF_PCA9536D])
cg.add(var.set_parent(parent))
cg.add(var.set_pin(config[CONF_NUMBER]))
cg.add(var.set_inverted(config[CONF_INVERTED]))
cg.add(var.set_flags(pins.gpio_flags_expr(config[CONF_MODE])))
return var

View File

@@ -1,108 +0,0 @@
#include "pca9536d.h"
#include "esphome/core/log.h"
namespace esphome {
namespace pca9536d {
static const char *TAG = "pca9536d";
void PCA9536D::setup() {
ESP_LOGCONFIG(TAG, "Setting up PCA9536D...");
if (!this->read_gpio_()) {
ESP_LOGE(TAG, "PCA9536D not available under 0x%02X", this->address_);
this->mark_failed();
return;
}
this->write_gpio_();
}
void PCA9536D::dump_config() {
ESP_LOGCONFIG(TAG, "PCA9536D:");
LOG_I2C_DEVICE(this)
if (this->is_failed())
ESP_LOGE(TAG, "Communication with PCA9536D failed!");
}
bool PCA9536D::digital_read(uint8_t pin) {
this->read_gpio_();
return this->inputs_ & (1 << pin);
}
void PCA9536D::digital_write(uint8_t pin, bool value) {
if (value)
this->outputs_ |= (1 << pin);
else
this->outputs_ &= ~(1 << pin);
this->write_gpio_();
}
void PCA9536D::set_pin_mode(uint8_t pin, uint8_t mode) {
switch (mode) {
case gpio::FLAG_INPUT:
this->modes_ |= 1 << pin;
break;
case gpio::FLAG_OUTPUT:
this->modes_ &= ~(1 << pin);
break;
}
this->set_modes_();
}
bool PCA9536D::read_gpio_() {
if (this->is_failed())
return false;
uint8_t data;
if (!this->read_bytes(0, &data, 1)) {
this->status_set_warning();
return false;
}
this->inputs_ = data;
this->status_clear_warning();
return true;
}
bool PCA9536D::write_gpio_() {
if (this->is_failed())
return false;
uint8_t data = this->outputs_;
if (!this->write_bytes(1, &data, 1)) {
this->status_set_warning();
return false;
}
this->status_clear_warning();
return true;
}
bool PCA9536D::set_modes_() {
if (this->is_failed())
return false;
uint8_t data = this->modes_;
if (!this->write_bytes(3, &data, 1)) {
this->status_set_warning();
return false;
}
this->status_clear_warning();
return true;
}
void PCA9536DGPIOPin::setup() { this->pin_mode(this->flags_); }
bool PCA9536DGPIOPin::digital_read() { return this->parent_->digital_read(this->pin_) != this->inverted_; }
void PCA9536DGPIOPin::digital_write(bool value) { this->parent_->digital_write(this->pin_, value != this->inverted_); }
void PCA9536DGPIOPin::pin_mode(gpio::Flags flags) { this->parent_->set_pin_mode(this->pin_, flags); }
std::string PCA9536DGPIOPin::dump_summary() const {
return str_sprintf("%u via PCA9536D", pin_);
}
} // namespace pca9536d
} // namespace esphome

View File

@@ -1,52 +0,0 @@
#pragma once
#include "esphome/core/component.h"
#include "esphome/core/hal.h"
#include "esphome/components/i2c/i2c.h"
namespace esphome {
namespace pca9536d {
class PCA9536D: public Component, public i2c::I2CDevice {
public:
void setup() override;
float get_setup_priority() const { return setup_priority::IO; }
void dump_config() override;
bool digital_read(uint8_t pin);
void digital_write(uint8_t pin, bool value);
void set_pin_mode(uint8_t pin, uint8_t mode);
protected:
bool read_gpio_();
bool write_gpio_();
bool set_modes_();
// pin modes - 0 means output, 1 means input
uint8_t modes_{0xff};
uint8_t outputs_{0x00};
uint8_t inputs_{0x00};
};
class PCA9536DGPIOPin : public GPIOPin {
public:
void setup() override;
void pin_mode(gpio::Flags flags) override;
bool digital_read() override;
void digital_write(bool value) override;
std::string dump_summary() const override;
void set_parent(PCA9536D *parent) { parent_ = parent; }
void set_pin(uint8_t pin) { pin_ = pin; }
void set_inverted(bool inverted) { inverted_ = inverted; }
void set_flags(gpio::Flags flags) { flags_ = flags; }
protected:
PCA9536D *parent_;
uint8_t pin_;
bool inverted_;
gpio::Flags flags_;
};
} // namespace pca9536d
} // namespace esphome

View File

@@ -1,57 +0,0 @@
import esphome.codegen as cg
import esphome.config_validation as cv
from esphome import pins
from esphome.components import i2c
from esphome.const import CONF_ID, CONF_NUMBER, CONF_MODE, CONF_INVERTED
DEPENDENCIES = ['i2c']
MULTI_CONF = True
pca9554_ns = cg.esphome_ns.namespace('pca9554')
PCA9554GPIOMode = pca9554_ns.enum('PCA9554GPIOMode')
PCF8674_GPIO_MODES = {
'INPUT': PCA9554GPIOMode.PCA9554_INPUT,
'OUTPUT': PCA9554GPIOMode.PCA9554_OUTPUT,
}
PCA9554Component = pca9554_ns.class_('PCA9554Component', cg.Component, i2c.I2CDevice)
PCA9554GPIOPin = pca9554_ns.class_('PCA9554GPIOPin', cg.GPIOPin)
CONF_PCA9554 = 'pca9554'
CONF_PCF8575 = 'pcf8575'
CONFIG_SCHEMA = cv.Schema({
cv.Required(CONF_ID): cv.declare_id(PCA9554Component),
cv.Optional(CONF_PCF8575, default=False): cv.boolean,
}).extend(cv.COMPONENT_SCHEMA).extend(i2c.i2c_device_schema(0x20))
def to_code(config):
var = cg.new_Pvariable(config[CONF_ID])
yield cg.register_component(var, config)
yield i2c.register_i2c_device(var, config)
cg.add(var.set_pcf8575(config[CONF_PCF8575]))
def validate_pca9554_gpio_mode(value):
value = cv.string(value)
return cv.enum(PCF8674_GPIO_MODES, upper=True)(value)
PCA9554_OUTPUT_PIN_SCHEMA = cv.Schema({
cv.Required(CONF_PCA9554): cv.use_id(PCA9554Component),
cv.Required(CONF_NUMBER): cv.int_,
cv.Optional(CONF_MODE, default="OUTPUT"): validate_pca9554_gpio_mode,
cv.Optional(CONF_INVERTED, default=False): cv.boolean,
})
PCA9554_INPUT_PIN_SCHEMA = cv.Schema({
cv.Required(CONF_PCA9554): cv.use_id(PCA9554Component),
cv.Required(CONF_NUMBER): cv.int_,
cv.Optional(CONF_MODE, default="INPUT"): validate_pca9554_gpio_mode,
cv.Optional(CONF_INVERTED, default=False): cv.boolean,
})
@pins.PIN_SCHEMA_REGISTRY.register('pca9554', (PCA9554_OUTPUT_PIN_SCHEMA, PCA9554_INPUT_PIN_SCHEMA))
def pca9554_pin_to_code(config):
parent = yield cg.get_variable(config[CONF_PCA9554])
yield PCA9554GPIOPin.new(parent, config[CONF_NUMBER], config[CONF_MODE], config[CONF_INVERTED])

View File

@@ -1,96 +0,0 @@
#include "pca9554.h"
#include "esphome/core/log.h"
namespace esphome {
namespace pca9554 {
static const char *TAG = "pca9554";
void PCA9554Component::setup() {
ESP_LOGCONFIG(TAG, "Setting up PCA9554...");
if (!this->read_gpio_()) {
ESP_LOGE(TAG, "PCA9554 not available under 0x%02X", this->address_);
this->mark_failed();
return;
}
this->write_gpio_();
this->read_gpio_();
}
void PCA9554Component::dump_config() {
ESP_LOGCONFIG(TAG, "PCA9554:");
LOG_I2C_DEVICE(this)
if (this->is_failed()) {
ESP_LOGE(TAG, "Communication with PCA9554 failed!");
}
}
bool PCA9554Component::digital_read(uint8_t pin) {
this->read_gpio_();
return this->input_mask_ & (1 << pin);
}
void PCA9554Component::digital_write(uint8_t pin, bool value) {
if (value) {
this->output_mask_ |= (1 << pin);
} else {
this->output_mask_ &= ~(1 << pin);
}
this->write_gpio_();
}
void PCA9554Component::pin_mode(uint8_t pin, uint8_t mode) {
switch (mode) {
case PCA9554_OUTPUT:
// Clear mode mask bit
this->mode_mask_ &= ~(1 << pin);
// Write GPIO to enable input mode
this->write_gpio_();
break;
case PCA9554_INPUT:
// Set mode mask bit
this->mode_mask_ |= 1 << pin;
break;
default:
break;
}
}
bool PCA9554Component::read_gpio_() {
if (this->is_failed())
return false;
bool success;
uint8_t data[2];
if (!success) {
this->status_set_warning();
return false;
}
this->status_clear_warning();
return true;
}
bool PCA9554Component::write_gpio_() {
if (this->is_failed())
return false;
uint16_t value = 0;
// Pins in OUTPUT mode and where pin is HIGH.
value |= this->mode_mask_ & this->output_mask_;
// Pins in INPUT mode must also be set here
value |= ~this->mode_mask_;
uint8_t data[2];
data[0] = value;
data[1] = value >> 8;
this->status_clear_warning();
return true;
}
float PCA9554Component::get_setup_priority() const { return setup_priority::IO; }
void PCA9554GPIOPin::setup() { this->pin_mode(this->mode_); }
bool PCA9554GPIOPin::digital_read() { return this->parent_->digital_read(this->pin_) != this->inverted_; }
void PCA9554GPIOPin::digital_write(bool value) { this->parent_->digital_write(this->pin_, value != this->inverted_); }
void PCA9554GPIOPin::pin_mode(uint8_t mode) { this->parent_->pin_mode(this->pin_, mode); }
PCA9554GPIOPin::PCA9554GPIOPin(PCA9554Component *parent, uint8_t pin, uint8_t mode, bool inverted)
: GPIOPin(pin, mode, inverted), parent_(parent) {}
} // namespace pca9554
} // namespace esphome

View File

@@ -1,61 +0,0 @@
#pragma once
#include "esphome/core/component.h"
#include "esphome/core/esphal.h"
#include "esphome/components/i2c/i2c.h"
namespace esphome {
namespace pca9554 {
/// Modes for PCA9554 pins
enum PCA9554GPIOMode : uint8_t {
PCA9554_INPUT = INPUT,
PCA9554_OUTPUT = OUTPUT,
};
class PCA9554Component : public Component, public i2c::I2CDevice {
public:
PCA9554Component() = default;
/// Check i2c availability and setup masks
void setup() override;
/// Helper function to read the value of a pin.
bool digital_read(uint8_t pin);
/// Helper function to write the value of a pin.
void digital_write(uint8_t pin, bool value);
/// Helper function to set the pin mode of a pin.
void pin_mode(uint8_t pin, uint8_t mode);
float get_setup_priority() const override;
void dump_config() override;
protected:
bool read_gpio_();
bool write_gpio_();
/// Mask for the pin mode - 1 means input, 0 means output
uint16_t mode_mask_{0x00};
/// The mask to write as output state - 1 means HIGH, 0 means LOW
uint16_t output_mask_{0x00};
/// The state read in read_gpio_ - 1 means HIGH, 0 means LOW
uint16_t input_mask_{0x00};
};
/// Helper class to expose a PCA9554 pin as an internal input GPIO pin.
class PCA9554GPIOPin : public GPIOPin {
public:
PCA9554GPIOPin(PCA9554Component *parent, uint8_t pin, uint8_t mode, bool inverted = false);
void setup() override;
void pin_mode(uint8_t mode) override;
bool digital_read() override;
void digital_write(bool value) override;
protected:
PCA9554Component *parent_;
};
} // namespace pca9554
} // namespace esphome

Submodule components/sim7600 deleted from d754e306ad

View File

@@ -1,3 +0,0 @@
import esphome.codegen as cg
st7735_ns = cg.esphome_ns.namespace('st7735')

View File

@@ -1,41 +0,0 @@
import esphome.codegen as cg
import esphome.config_validation as cv
from esphome import pins
from esphome.components import display, spi
from esphome.const import CONF_ID, CONF_LAMBDA
from esphome.const import CONF_DC_PIN, CONF_CS_PIN, CONF_ID, CONF_LAMBDA, CONF_PAGES
from esphome.const import CONF_EXTERNAL_VCC, CONF_LAMBDA, CONF_MODEL, CONF_RESET_PIN, \
CONF_BRIGHTNESS
from . import st7735_ns
DEPENDENCIES = ['spi']
ST7735 = st7735_ns.class_('ST7735', cg.PollingComponent, spi.SPIDevice)
ST7735Ref = ST7735.operator('ref')
CONFIG_SCHEMA = display.FULL_DISPLAY_SCHEMA.extend({
cv.GenerateID(): cv.declare_id(ST7735),
cv.Required(CONF_RESET_PIN): pins.gpio_output_pin_schema,
cv.Required(CONF_DC_PIN): pins.gpio_output_pin_schema,
cv.Required(CONF_CS_PIN): pins.gpio_output_pin_schema,
cv.Optional(CONF_BRIGHTNESS, default=1.0): cv.percentage,
}).extend(cv.polling_component_schema('1s')).extend(spi.spi_device_schema())
def to_code(config):
var = cg.new_Pvariable(config[CONF_ID])
yield cg.register_component(var, config)
yield spi.register_spi_device(var, config)
dc = yield cg.gpio_pin_expression(config[CONF_DC_PIN])
cg.add(var.set_dc_pin(dc))
reset = yield cg.gpio_pin_expression(config[CONF_RESET_PIN])
cg.add(var.set_reset_pin(reset))
if CONF_LAMBDA in config:
lambda_ = yield cg.process_lambda(
config[CONF_LAMBDA], [(display.DisplayBufferRef, 'it')], return_type=cg.void)
cg.add(var.set_writer(lambda_))
yield display.register_display(var, config)

View File

@@ -1,351 +0,0 @@
#include "st7735.h"
#include "esphome/core/log.h"
#include "esphome/components/display/display_buffer.h"
namespace esphome {
namespace st7735 {
#define ST_CMD_DELAY 0x80 // special signifier for command lists
#define ST77XX_NOP 0x00
#define ST77XX_SWRESET 0x01
#define ST77XX_RDDID 0x04
#define ST77XX_RDDST 0x09
#define ST77XX_SLPIN 0x10
#define ST77XX_SLPOUT 0x11
#define ST77XX_PTLON 0x12
#define ST77XX_NORON 0x13
#define ST77XX_INVOFF 0x20
#define ST77XX_INVON 0x21
#define ST77XX_DISPOFF 0x28
#define ST77XX_DISPON 0x29
#define ST77XX_CASET 0x2A
#define ST77XX_RASET 0x2B
#define ST77XX_RAMWR 0x2C
#define ST77XX_RAMRD 0x2E
#define ST77XX_PTLAR 0x30
#define ST77XX_TEOFF 0x34
#define ST77XX_TEON 0x35
#define ST77XX_MADCTL 0x36
#define ST77XX_COLMOD 0x3A
#define ST77XX_MADCTL_MY 0x80
#define ST77XX_MADCTL_MX 0x40
#define ST77XX_MADCTL_MV 0x20
#define ST77XX_MADCTL_ML 0x10
#define ST77XX_MADCTL_RGB 0x00
#define ST77XX_RDID1 0xDA
#define ST77XX_RDID2 0xDB
#define ST77XX_RDID3 0xDC
#define ST77XX_RDID4 0xDD
// some flags for initR() :(
#define INITR_GREENTAB 0x00
#define INITR_REDTAB 0x01
#define INITR_BLACKTAB 0x02
#define INITR_18GREENTAB INITR_GREENTAB
#define INITR_18REDTAB INITR_REDTAB
#define INITR_18BLACKTAB INITR_BLACKTAB
#define INITR_144GREENTAB 0x01
#define INITR_MINI160x80 0x04
#define INITR_HALLOWING 0x05
// Some register settings
#define ST7735_MADCTL_BGR 0x08
#define ST7735_MADCTL_MH 0x04
#define ST7735_FRMCTR1 0xB1
#define ST7735_FRMCTR2 0xB2
#define ST7735_FRMCTR3 0xB3
#define ST7735_INVCTR 0xB4
#define ST7735_DISSET5 0xB6
#define ST7735_PWCTR1 0xC0
#define ST7735_PWCTR2 0xC1
#define ST7735_PWCTR3 0xC2
#define ST7735_PWCTR4 0xC3
#define ST7735_PWCTR5 0xC4
#define ST7735_VMCTR1 0xC5
#define ST7735_PWCTR6 0xFC
#define ST7735_GMCTRP1 0xE0
#define ST7735_GMCTRN1 0xE1
static const uint8_t PROGMEM
Rcmd1[] = { // 7735R init, part 1 (red or green tab)
15, // 15 commands in list:
ST77XX_SWRESET, ST_CMD_DELAY, // 1: Software reset, 0 args, w/delay
150, // 150 ms delay
ST77XX_SLPOUT, ST_CMD_DELAY, // 2: Out of sleep mode, 0 args, w/delay
255, // 500 ms delay
ST7735_FRMCTR1, 3, // 3: Framerate ctrl - normal mode, 3 arg:
0x01, 0x2C, 0x2D, // Rate = fosc/(1x2+40) * (LINE+2C+2D)
ST7735_FRMCTR2, 3, // 4: Framerate ctrl - idle mode, 3 args:
0x01, 0x2C, 0x2D, // Rate = fosc/(1x2+40) * (LINE+2C+2D)
ST7735_FRMCTR3, 6, // 5: Framerate - partial mode, 6 args:
0x01, 0x2C, 0x2D, // Dot inversion mode
0x01, 0x2C, 0x2D, // Line inversion mode
ST7735_INVCTR, 1, // 6: Display inversion ctrl, 1 arg:
0x07, // No inversion
ST7735_PWCTR1, 3, // 7: Power control, 3 args, no delay:
0xA2,
0x02, // -4.6V
0x84, // AUTO mode
ST7735_PWCTR2, 1, // 8: Power control, 1 arg, no delay:
0xC5, // VGH25=2.4C VGSEL=-10 VGH=3 * AVDD
ST7735_PWCTR3, 2, // 9: Power control, 2 args, no delay:
0x0A, // Opamp current small
0x00, // Boost frequency
ST7735_PWCTR4, 2, // 10: Power control, 2 args, no delay:
0x8A, // BCLK/2,
0x2A, // opamp current small & medium low
ST7735_PWCTR5, 2, // 11: Power control, 2 args, no delay:
0x8A, 0xEE,
ST7735_VMCTR1, 1, // 12: Power control, 1 arg, no delay:
0x0E,
ST77XX_INVOFF, 0, // 13: Don't invert display, no args
ST77XX_MADCTL, 1, // 14: Mem access ctl (directions), 1 arg:
0xC8, // row/col addr, bottom-top refresh
ST77XX_COLMOD, 1, // 15: set color mode, 1 arg, no delay:
0x05 }, // 16-bit color
Rcmd2green[] = { // 7735R init, part 2 (green tab only)
2, // 2 commands in list:
ST77XX_CASET, 4, // 1: Column addr set, 4 args, no delay:
0x00, 0x02, // XSTART = 0
0x00, 0x7F+0x02, // XEND = 127
ST77XX_RASET, 4, // 2: Row addr set, 4 args, no delay:
0x00, 0x01, // XSTART = 0
0x00, 0x9F+0x01 }, // XEND = 159
Rcmd2green144[] = { // 7735R init, part 2 (green 1.44 tab)
2, // 2 commands in list:
ST77XX_CASET, 4, // 1: Column addr set, 4 args, no delay:
0x00, 0x00, // XSTART = 0
0x00, 0x7F, // XEND = 127
ST77XX_RASET, 4, // 2: Row addr set, 4 args, no delay:
0x00, 0x00, // XSTART = 0
0x00, 0x7F }, // XEND = 127
Rcmd3[] = { // 7735R init, part 3 (red or green tab)
4, // 4 commands in list:
ST7735_GMCTRP1, 16 , // 1: Gamma Adjustments (pos. polarity), 16 args + delay:
0x02, 0x1c, 0x07, 0x12, // (Not entirely necessary, but provides
0x37, 0x32, 0x29, 0x2d, // accurate colors)
0x29, 0x25, 0x2B, 0x39,
0x00, 0x01, 0x03, 0x10,
ST7735_GMCTRN1, 16 , // 2: Gamma Adjustments (neg. polarity), 16 args + delay:
0x03, 0x1d, 0x07, 0x06, // (Not entirely necessary, but provides
0x2E, 0x2C, 0x29, 0x2D, // accurate colors)
0x2E, 0x2E, 0x37, 0x3F,
0x00, 0x00, 0x02, 0x10,
ST77XX_NORON, ST_CMD_DELAY, // 3: Normal display on, no args, w/delay
10, // 10 ms delay
ST77XX_DISPON, ST_CMD_DELAY, // 4: Main screen turn on, no args w/delay
100 }; // 100 ms delay
static const char *TAG = "st7735";
void ST7735::setup() {
ESP_LOGCONFIG(TAG, "Setting up SPI ST7735...");
this->spi_setup();
this->dc_pin_->setup(); // OUTPUT
this->init_reset_();
this->displayInit(Rcmd1);
this->displayInit(Rcmd2green);
this->displayInit(Rcmd3);
this->writecommand(ST7735_INVON);
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
//this->disable();
delay(120);
//this->enable();
this->writecommand(ST7735_DISPON); //Display on
delay(120);
this->init_internal_(this->get_buffer_length_());
memset(this->buffer_, 0x00, this->get_buffer_length_());
}
void ST7735::write_display_data() {
uint16_t offsetx = 26;
uint16_t offsety = 1;
uint16_t x1 = offsetx;
uint16_t x2 = x1 + get_width_internal()-1;
uint16_t y1 = offsety;
uint16_t y2 = y1 + get_height_internal()-1;
this->enable();
// set column(x) address
this->dc_pin_->digital_write(false);
this->write_byte(ST77XX_CASET);
this->dc_pin_->digital_write(true);
this->spi_master_write_addr(x1, x2);
// set Page(y) address
this->dc_pin_->digital_write(false);
this->write_byte(ST77XX_RASET);
this->dc_pin_->digital_write(true);
this->spi_master_write_addr(y1, y2);
// Memory Write
this->dc_pin_->digital_write(false);
this->write_byte(ST77XX_RAMWR);
this->dc_pin_->digital_write(true);
this->write_array(this->buffer_, this->get_buffer_length_());
this->disable();
}
void ST7735::spi_master_write_addr(uint16_t addr1, uint16_t addr2)
{
static uint8_t Byte[4];
Byte[0] = (addr1 >> 8) & 0xFF;
Byte[1] = addr1 & 0xFF;
Byte[2] = (addr2 >> 8) & 0xFF;
Byte[3] = addr2 & 0xFF;
this->dc_pin_->digital_write(true);
this->write_array(Byte, 4);
}
void ST7735::spi_master_write_color(uint16_t color, uint16_t size)
{
static uint8_t Byte[1024];
int index = 0;
for(int i=0;i<size;i++) {
Byte[index++] = (color >> 8) & 0xFF;
Byte[index++] = color & 0xFF;
}
this->dc_pin_->digital_write(true);
return write_array(Byte, size*2);
}
void ST7735::dump_config() {
LOG_DISPLAY("", "SPI ST7735", this);
LOG_PIN(" CS Pin: ", this->cs_);
LOG_PIN(" DC Pin: ", this->dc_pin_);
LOG_PIN(" Reset Pin: ", this->reset_pin_);
LOG_UPDATE_INTERVAL(this);
}
float ST7735::get_setup_priority() const {
return setup_priority::PROCESSOR;
}
void ST7735::update() {
this->do_update_();
this->write_display_data();
}
void ST7735::loop() {
}
int ST7735::get_width_internal() {
return 80;
}
int ST7735::get_height_internal() {
return 160;
}
size_t ST7735::get_buffer_length_() {
return size_t(this->get_width_internal()) * size_t(this->get_height_internal()) * 2;
}
void HOT ST7735::draw_absolute_pixel_internal(int x, int y, Color color) {
if (x >= this->get_width_internal() || x < 0 || y >= this->get_height_internal() || y < 0)
return;
const uint32_t color565 = color.to_rgb_565();
// where should the bits go in the big buffer array? math...
uint16_t pos = (x + y * this->get_width_internal()) * 2;
this->buffer_[pos++] = (color565 >> 8) & 0xff;
this->buffer_[pos] = color565 & 0xff;
}
void ST7735::displayInit(const uint8_t *addr) {
uint8_t numCommands, cmd, numArgs;
uint16_t ms;
numCommands = pgm_read_byte(addr++); // Number of commands to follow
while(numCommands--) { // For each command...
cmd = pgm_read_byte(addr++); // Read command
numArgs = pgm_read_byte(addr++); // Number of args to follow
ms = numArgs & ST_CMD_DELAY; // If hibit set, delay follows args
numArgs &= ~ST_CMD_DELAY; // Mask out delay bit
this->sendcommand(cmd, addr, numArgs);
addr += numArgs;
if(ms) {
ms = pgm_read_byte(addr++); // Read post-command delay time (ms)
if(ms == 255) ms = 500; // If 255, delay for 500 ms
delay(ms);
}
}
}
void ST7735::init_reset_() {
if (this->reset_pin_ != nullptr) {
this->reset_pin_->setup();
this->reset_pin_->digital_write(true);
delay(1);
// Trigger Reset
this->reset_pin_->digital_write(false);
delay(10);
// Wake up
this->reset_pin_->digital_write(true);
}
}
void ST7735::writecommand(uint8_t value) {
this->enable();
this->dc_pin_->digital_write(false);
this->write_byte(value);
this->dc_pin_->digital_write(true);
this->disable();
}
void ST7735::writedata(uint8_t value) {
this->dc_pin_->digital_write(true);
this->enable();
this->write_byte(value);
this->disable();
}
void ST7735::sendcommand(uint8_t cmd, const uint8_t* dataBytes, uint8_t numDataBytes) {
this->writecommand(cmd);
this->senddata(dataBytes,numDataBytes);
}
void ST7735::senddata(const uint8_t* dataBytes, uint8_t numDataBytes) {
this->dc_pin_->digital_write(true); //pull DC high to indicate data
this->cs_->digital_write(false);
this->enable();
for (uint8_t i=0; i<numDataBytes; i++) {
this->transfer_byte(pgm_read_byte(dataBytes++)); //write byte - SPI library
}
this->cs_->digital_write(true);
this->disable();
}
} // namespace st7735
} // namespace esphome

View File

@@ -1,149 +0,0 @@
#pragma once
#include "esphome/core/component.h"
#include "esphome/components/spi/spi.h"
#include "esphome/components/display/display_buffer.h"
// ST7735 specific commands used in init
#define ST7735_NOP 0x00
#define ST7735_SWRESET 0x01
#define ST7735_RDDID 0x04
#define ST7735_RDDST 0x09
#define ST7735_RDDPM 0x0A // Read display power mode
#define ST7735_RDD_MADCTL 0x0B // Read display MADCTL
#define ST7735_RDD_COLMOD 0x0C // Read display pixel format
#define ST7735_RDDIM 0x0D // Read display image mode
#define ST7735_RDDSM 0x0E // Read display signal mode
#define ST7735_RDDSR 0x0F // Read display self-diagnostic result (ST7735)
#define ST7735_SLPIN 0x10
#define ST7735_SLPOUT 0x11
#define ST7735_PTLON 0x12
#define ST7735_NORON 0x13
#define ST7735_INVOFF 0x20
#define ST7735_INVON 0x21
#define ST7735_GAMSET 0x26 // Gamma set
#define ST7735_DISPOFF 0x28
#define ST7735_DISPON 0x29
#define ST7735_CASET 0x2A
#define ST7735_RASET 0x2B
#define ST7735_RAMWR 0x2C
#define ST7735_RGBSET 0x2D // Color setting for 4096, 64K and 262K colors
#define ST7735_RAMRD 0x2E
#define ST7735_PTLAR 0x30
#define ST7735_VSCRDEF 0x33 // Vertical scrolling definition (ST7735)
#define ST7735_TEOFF 0x34 // Tearing effect line off
#define ST7735_TEON 0x35 // Tearing effect line on
#define ST7735_MADCTL 0x36 // Memory data access control
#define ST7735_IDMOFF 0x38 // Idle mode off
#define ST7735_IDMON 0x39 // Idle mode on
#define ST7735_RAMWRC 0x3C // Memory write continue (ST7735)
#define ST7735_RAMRDC 0x3E // Memory read continue (ST7735)
#define ST7735_COLMOD 0x3A
#define ST7735_RAMCTRL 0xB0 // RAM control
#define ST7735_RGBCTRL 0xB1 // RGB control
#define ST7735_PORCTRL 0xB2 // Porch control
#define ST7735_FRCTRL1 0xB3 // Frame rate control
#define ST7735_PARCTRL 0xB5 // Partial mode control
#define ST7735_GCTRL 0xB7 // Gate control
#define ST7735_GTADJ 0xB8 // Gate on timing adjustment
#define ST7735_DGMEN 0xBA // Digital gamma enable
#define ST7735_VCOMS 0xBB // VCOMS setting
#define ST7735_LCMCTRL 0xC0 // LCM control
#define ST7735_IDSET 0xC1 // ID setting
#define ST7735_VDVVRHEN 0xC2 // VDV and VRH command enable
#define ST7735_VRHS 0xC3 // VRH set
#define ST7735_VDVSET 0xC4 // VDV setting
#define ST7735_VCMOFSET 0xC5 // VCOMS offset set
#define ST7735_FRCTR2 0xC6 // FR Control 2
#define ST7735_CABCCTRL 0xC7 // CABC control
#define ST7735_REGSEL1 0xC8 // Register value section 1
#define ST7735_REGSEL2 0xCA // Register value section 2
#define ST7735_PWMFRSEL 0xCC // PWM frequency selection
#define ST7735_PWCTRL1 0xD0 // Power control 1
#define ST7735_VAPVANEN 0xD2 // Enable VAP/VAN signal output
#define ST7735_CMD2EN 0xDF // Command 2 enable
#define ST7735_PVGAMCTRL 0xE0 // Positive voltage gamma control
#define ST7735_NVGAMCTRL 0xE1 // Negative voltage gamma control
#define ST7735_DGMLUTR 0xE2 // Digital gamma look-up table for red
#define ST7735_DGMLUTB 0xE3 // Digital gamma look-up table for blue
#define ST7735_GATECTRL 0xE4 // Gate control
#define ST7735_SPI2EN 0xE7 // SPI2 enable
#define ST7735_PWCTRL2 0xE8 // Power control 2
#define ST7735_EQCTRL 0xE9 // Equalize time control
#define ST7735_PROMCTRL 0xEC // Program control
#define ST7735_PROMEN 0xFA // Program mode enable
#define ST7735_NVMSET 0xFC // NVM setting
#define ST7735_PROMACT 0xFE // Program action
// Some ready-made 16-bit ('565') color settings:
#define ST77XX_BLACK 0x0000
#define ST77XX_WHITE 0xFFFF
#define ST77XX_RED 0xF800
#define ST77XX_GREEN 0x07E0
#define ST77XX_BLUE 0x001F
#define ST77XX_CYAN 0x07FF
#define ST77XX_MAGENTA 0xF81F
#define ST77XX_YELLOW 0xFFE0
#define ST77XX_ORANGE 0xFC00
// Some ready-made 16-bit ('565') color settings:
#define ST7735_BLACK ST77XX_BLACK
#define ST7735_WHITE ST77XX_WHITE
#define ST7735_RED ST77XX_RED
#define ST7735_GREEN ST77XX_GREEN
#define ST7735_BLUE ST77XX_BLUE
#define ST7735_CYAN ST77XX_CYAN
#define ST7735_MAGENTA ST77XX_MAGENTA
#define ST7735_YELLOW ST77XX_YELLOW
#define ST7735_ORANGE ST77XX_ORANGE
namespace esphome {
namespace st7735 {
class ST7735 : public PollingComponent, public display::DisplayBuffer,
public spi::SPIDevice<spi::BIT_ORDER_MSB_FIRST, spi::CLOCK_POLARITY_HIGH, spi::CLOCK_PHASE_TRAILING,
spi::DATA_RATE_8MHZ> {
public:
void set_dc_pin(GPIOPin *dc_pin) { this->dc_pin_ = dc_pin; }
void set_reset_pin(GPIOPin *reset_pin) { this->reset_pin_ = reset_pin; }
// ========== INTERNAL METHODS ==========
// (In most use cases you won't need these)
void setup() override;
void dump_config() override;
float get_setup_priority() const override;
void update() override;
void loop() override;
void write_display_data();
protected:
GPIOPin *dc_pin_;
GPIOPin *reset_pin_{nullptr};
void displayInit(const uint8_t *addr);
void sendcommand(uint8_t cmd, const uint8_t* dataBytes, uint8_t numDataBytes);
void senddata(const uint8_t* dataBytes, uint8_t numDataBytes);
void init_reset_();
void writecommand(uint8_t value);
void writedata(uint8_t value);
void spi_master_write_addr(uint16_t addr1, uint16_t addr2);
void spi_master_write_color(uint16_t color, uint16_t size);
void draw_absolute_pixel_internal(int x, int y, Color color) override;
int get_height_internal() override;
int get_width_internal() override;
size_t get_buffer_length_();
};
} // namespace st7735
} // namespace esphome

View File

@@ -1,3 +1,4 @@
---
substitutions:
device: air-office-r
name: Office R Air
@@ -104,7 +105,7 @@ light:
move_interval: 100ms
sensor:
# https://blissair.com/what-is-pm-2-5.htm
# https://blissair.com/what-is-pm-2-5.htm
- platform: pm1006
uart_id: particle_uart
update_interval: 20s

View File

@@ -1,3 +1,4 @@
---
substitutions:
device: atoms3
name: AtomS3
@@ -32,11 +33,11 @@ pcf8574:
pcf8575: true
animation:
- file: "blinky.gif"
- file: "assets/images/blinky.gif"
id: blinky
resize: 128x128
type: RGB565
- file: "vault_boy_walking.gif"
- file: "assets/images/vault_boy_walking.gif"
id: vaultboy
resize: 168x121
type: RGB565
@@ -118,36 +119,36 @@ canbus:
bit_rate: 1000KBPS
use_extended_id: true
on_frame:
- can_id: 0x123
use_extended_id: true
then:
- lambda: |-
std::string b(x.begin(), x.end());
ESP_LOGD("can extended id 0x123", "%s", &b[0] );
- can_id: 0x123
then:
- lambda: |-
std::string b(x.begin(), x.end());
ESP_LOGD("can standard id 0x123", "%s", &b[0] );
- can_id: 0x3f1
can_id_mask: 0x7ff
use_extended_id: false
then:
- lambda: |-
std::string b(x.begin(), x.end());
ESP_LOGD("can id 0x03f1", "%s", &b[0] );
- can_id: 0x108
use_extended_id: false
then:
- lambda: |-
std::string b(x.begin(), x.end());
ESP_LOGD("can id 0x108", "%s", &b[0] );
- can_id: 0x109
use_extended_id: false
then:
- lambda: |-
std::string b(x.begin(), x.end());
ESP_LOGD("can id 0x109", "%s", &b[0] );
- can_id: 0x123
use_extended_id: true
then:
- lambda: |-
std::string b(x.begin(), x.end());
ESP_LOGD("can extended id 0x123", "%s", &b[0] );
- can_id: 0x123
then:
- lambda: |-
std::string b(x.begin(), x.end());
ESP_LOGD("can standard id 0x123", "%s", &b[0] );
- can_id: 0x3f1
can_id_mask: 0x7ff
use_extended_id: false
then:
- lambda: |-
std::string b(x.begin(), x.end());
ESP_LOGD("can id 0x03f1", "%s", &b[0] );
- can_id: 0x108
use_extended_id: false
then:
- lambda: |-
std::string b(x.begin(), x.end());
ESP_LOGD("can id 0x108", "%s", &b[0] );
- can_id: 0x109
use_extended_id: false
then:
- lambda: |-
std::string b(x.begin(), x.end());
ESP_LOGD("can id 0x109", "%s", &b[0] );
i2c:
# - id: i2c_groove
@@ -177,9 +178,9 @@ i2c:
# - platform: gpio
# pin: 1
# id: hub_1
# - platform: gpio
# pin: 2
# id: hub_2
# - platform: gpio
# pin: 2
# id: hub_2
m5stack_4relay:
id: m5stack_relay_1
@@ -229,7 +230,7 @@ switch:
- output.turn_off: motor_in1
- output.turn_off: motor_in2
# switch:
# switch:
- platform: m5stack_4relay
name: Relay 1
id: relay_1

View File

@@ -1,3 +1,4 @@
---
substitutions:
device: basement-2
name_short: Basement

View File

@@ -1,3 +1,4 @@
---
substitutions:
device: basement
name: Basement
@@ -40,35 +41,35 @@ binary_sensor:
name: Light Switch
device_class: light
on_click:
- min_length: 50ms
max_length: 350ms
then:
- homeassistant.service:
service: light.toggle
data:
entity_id: light.mcu_basement_2_light
- min_length: 351ms
max_length: 1000ms
then:
- homeassistant.service:
service: light.toggle
data:
entity_id: light.exercise_room
- min_length: 1001ms
max_length: 10000ms
then:
# - homeassistant.service:
# service: light.turn_off
# data:
# entity_id: light.basement_light
- homeassistant.service:
service: light.turn_off
data:
entity_id: light.exercise_room
- homeassistant.service:
service: light.turn_off
data:
entity_id: light.exercise_room_fan
- min_length: 50ms
max_length: 350ms
then:
- homeassistant.service:
service: light.toggle
data:
entity_id: light.mcu_basement_2_light
- min_length: 351ms
max_length: 1000ms
then:
- homeassistant.service:
service: light.toggle
data:
entity_id: light.exercise_room
- min_length: 1001ms
max_length: 10000ms
then:
# - homeassistant.service:
# service: light.turn_off
# data:
# entity_id: light.basement_light
- homeassistant.service:
service: light.turn_off
data:
entity_id: light.exercise_room
- homeassistant.service:
service: light.turn_off
data:
entity_id: light.exercise_room_fan
- platform: gpio
pin:
number: 10

View File

@@ -1,3 +1,4 @@
---
substitutions:
device: bedroom-lamp-left
name: Bedroom Lamp Left
@@ -95,7 +96,7 @@ script:
id: my_light_mode
state: white
then:
- front_panel.turn_on_leds: [ POWER, COLOR ]
- front_panel.turn_on_leds: [POWER, COLOR]
- front_panel.set_level: !lambda return id(current_brightness);
# In night light mode, turn off the front panel illumination, except
# for the power button.
@@ -105,7 +106,7 @@ script:
id: my_light_mode
state: night
then:
- front_panel.turn_on_leds: [ POWER ]
- front_panel.turn_on_leds: [POWER]
- front_panel.update_leds:
# If you want to control light presets from Home Assistant, then you can
@@ -201,18 +202,18 @@ light:
# These bindings have been setup below, using the binary_sensor for
# the color button.
presets:
# rgb:
# red: { red: 100%, green: 0%, blue: 0% }
# green: { red: 0%, green: 100%, blue: 0% }
# blue: { red: 0%, green: 0%, blue: 100% }
# yellow: { red: 100%, green: 100%, blue: 0% }
# purple: { red: 100%, green: 0%, blue: 100% }
# randomize: { effect: Fast Random }
# rgb:
# red: { red: 100%, green: 0%, blue: 0% }
# green: { red: 0%, green: 100%, blue: 0% }
# blue: { red: 0%, green: 0%, blue: 100% }
# yellow: { red: 100%, green: 100%, blue: 0% }
# purple: { red: 100%, green: 0%, blue: 100% }
# randomize: { effect: Fast Random }
white:
cold: { color_temperature: 153 mireds }
chilly: { color_temperature: 275 mireds }
luke: { color_temperature: 400 mireds }
warm: { color_temperature: 588 mireds }
cold: {color_temperature: 153 mireds}
chilly: {color_temperature: 275 mireds}
luke: {color_temperature: 400 mireds}
warm: {color_temperature: 588 mireds}
# Binary sensors can be created for handling front panel touch / release
# events. To specify what part of the front panel to look at, the "for"
@@ -224,16 +225,16 @@ binary_sensor:
id: my_power_button
for: POWER_BUTTON
on_multi_click:
- timing:
- ON for at most 0.8s
then:
- light.toggle: my_light
- timing:
- ON for at least 0.8s
then:
- light.turn_on:
id: my_light
brightness: 1%
- timing:
- ON for at most 0.8s
then:
- light.toggle: my_light
- timing:
- ON for at least 0.8s
then:
- light.turn_on:
id: my_light
brightness: 1%
# When tapping the color button, activate the next preset.
# When holding the color button, activate the next preset group.
@@ -241,17 +242,17 @@ binary_sensor:
id: my_color_button
for: COLOR_BUTTON
on_multi_click:
- timing:
- ON for at most 0.6s
then:
- preset.activate:
next: preset
- timing:
- ON for at least 0.6s
then:
- globals.set:
id: group_control
value: !lambda return !id(group_control);
- timing:
- ON for at most 0.6s
then:
- preset.activate:
next: preset
- timing:
- ON for at least 0.6s
then:
- globals.set:
id: group_control
value: !lambda return !id(group_control);
# - timing:
# - ON for at least 0.6s
# then:
@@ -271,20 +272,20 @@ sensor:
id: my_slider_level
range_from: 0.02
on_value:
- if:
condition:
lambda: |-
return id(group_control);
then:
- homeassistant.service:
service: light.turn_on
data:
light_name: bedroom_lamp
- if:
condition:
lambda: |-
return id(group_control);
then:
- homeassistant.service:
service: light.turn_on
data:
light_name: bedroom_lamp
brightness: !lambda return x;
else:
- light.turn_on:
id: my_light
brightness: !lambda return x;
else:
- light.turn_on:
id: my_light
brightness: !lambda return x;
# This text sensor propagates the currently active light mode.
# The possible light modes are: "off", "rgb", "white" and "night".

View File

@@ -1,3 +1,4 @@
---
substitutions:
device: bedroom-lamp-right
name: Bedroom Lamp Right
@@ -92,7 +93,7 @@ script:
id: my_light_mode
state: white
then:
- front_panel.turn_on_leds: [ POWER, COLOR ]
- front_panel.turn_on_leds: [POWER, COLOR]
- front_panel.set_level: !lambda return id(current_brightness);
# In night light mode, turn off the front panel illumination, except
# for the power button.
@@ -102,7 +103,7 @@ script:
id: my_light_mode
state: night
then:
- front_panel.turn_on_leds: [ POWER ]
- front_panel.turn_on_leds: [POWER]
- front_panel.update_leds:
# If you want to control light presets from Home Assistant, then you can
@@ -198,18 +199,18 @@ light:
# These bindings have been setup below, using the binary_sensor for
# the color button.
presets:
# rgb:
# red: { red: 100%, green: 0%, blue: 0% }
# green: { red: 0%, green: 100%, blue: 0% }
# blue: { red: 0%, green: 0%, blue: 100% }
# yellow: { red: 100%, green: 100%, blue: 0% }
# purple: { red: 100%, green: 0%, blue: 100% }
# randomize: { effect: Fast Random }
# rgb:
# red: { red: 100%, green: 0%, blue: 0% }
# green: { red: 0%, green: 100%, blue: 0% }
# blue: { red: 0%, green: 0%, blue: 100% }
# yellow: { red: 100%, green: 100%, blue: 0% }
# purple: { red: 100%, green: 0%, blue: 100% }
# randomize: { effect: Fast Random }
white:
cold: { color_temperature: 153 mireds }
chilly: { color_temperature: 275 mireds }
luke: { color_temperature: 400 mireds }
warm: { color_temperature: 588 mireds }
cold: {color_temperature: 153 mireds}
chilly: {color_temperature: 275 mireds}
luke: {color_temperature: 400 mireds}
warm: {color_temperature: 588 mireds}
# Binary sensors can be created for handling front panel touch / release
# events. To specify what part of the front panel to look at, the "for"

View File

@@ -1,3 +1,4 @@
---
substitutions:
device: c6-test-1
name: C6 TEST 1

View File

@@ -1,3 +1,4 @@
---
substitutions:
device: c6-test-2
name: C6 TEST 2

View File

@@ -1,3 +1,4 @@
---
substitutions:
device: cam-1
name: Cam 1

View File

@@ -1,3 +1,4 @@
---
substitutions:
device: can-node-1
name: CAN Node 1
@@ -14,8 +15,6 @@ esp32:
variant: esp32
framework:
type: esp-idf
# version: 5.4.2
# platform_version: 54.03.21
external_components:
- source: github://mrk-its/esphome-canopen@dev

View File

@@ -1,3 +1,4 @@
---
substitutions:
device: can-node-2
name: CAN Node 2
@@ -14,8 +15,6 @@ esp32:
variant: esp32
framework:
type: esp-idf
version: 5.4.2
platform_version: 54.03.21
external_components:
- source: github://mrk-its/esphome-canopen@dev

View File

@@ -1,3 +1,4 @@
---
substitutions:
device: cec-bedroom
name: Bedroom TV
@@ -52,11 +53,11 @@ uart:
baud_rate: 9600
sensor:
- platform: a02yyuw
uart_id: uart_distance
name: 'Distance'
accuracy_decimals: 2
unit_of_measurement: cm
- platform: a02yyuw
uart_id: uart_distance
name: 'Distance'
accuracy_decimals: 2
unit_of_measurement: cm
binary_sensor:
- platform: gpio
@@ -138,22 +139,22 @@ hdmi_cec:
then:
- hdmi_cec.send: # Report ARC started
destination: 0x0
data: [ 0xC1 ]
data: [0xC1]
- opcode: 0x70 # System audio mode request
then:
- hdmi_cec.send:
destination: 0x0
data: [ 0x72, 0x01 ]
data: [0x72, 0x01]
- opcode: 0x71 # Give audio status
then:
- hdmi_cec.send:
destination: 0x0
data: [ 0x7A, 0x7F ]
data: [0x7A, 0x7F]
- opcode: 0x7D # Give audio system mode status
then:
- hdmi_cec.send:
destination: 0x0
data: [ 0x7E, 0x01 ]
data: [0x7E, 0x01]
- opcode: 0x46 # Give OSD name
then:
- hdmi_cec.send:

View File

@@ -1,3 +1,4 @@
---
substitutions:
device: clock-1
name: Clock 1

View File

@@ -1,3 +1,4 @@
---
substitutions:
device: clock-living-room
name: Living room Clock
@@ -21,7 +22,7 @@ external_components:
url: https://github.com/trip5/esphome-tm1650
ref: main
refresh: 60s
components: [ tm1650 ]
components: [tm1650]
packages:
common: !include common/common.yaml

View File

@@ -1,3 +1,4 @@
---
substitutions:
device: desk-lamp
name: Desk Lamp

View File

@@ -1,3 +1,4 @@
---
substitutions:
device: dimmer
name: Dimmer

View File

@@ -1,3 +1,4 @@
---
substitutions:
device: echo-1
name: Echo 1
@@ -31,7 +32,7 @@ external_components:
# components: [ speaker, rtttl ]
# refresh: 0s
- source: github://pr#5177
components: [ rtttl ]
components: [rtttl]
refresh: 0s
packages:
@@ -48,10 +49,10 @@ api:
rtttl: !lambda 'return song;'
# i2c:
# sda: 26
# scl: 32
# scan: true #false
# frequency: 100kHz
# - sda: 26
# scl: 32
# scan: true #false
# frequency: 100kHz
# uart:
# id: particle_uart

View File

@@ -1,3 +1,4 @@
---
substitutions:
device: echo
name: Echo

View File

@@ -1,3 +1,4 @@
---
substitutions:
device: eworkbench
name: Electronics Workbench

View File

@@ -1,3 +1,4 @@
---
substitutions:
device: fireplace
name: Heating Fireplace

View File

@@ -1,3 +1,4 @@
---
substitutions:
device: gate
name: Gate
@@ -93,132 +94,46 @@ switch:
optimistic: true
restore_mode: RESTORE_DEFAULT_ON
# Bluetooth related stuff
globals:
- id: beacon_count
type: int
restore_value: no
initial_value: '0'
esp32_ble_tracker:
id: ${name}_ble_tracker
id: ${device}_ble_tracker
scan_parameters:
duration: 1min
# bluetooth_proxy:
binary_sensor:
- platform: ble_presence
id: ibeacon_auris
ibeacon_uuid: !secret ble_beacon_toyota_auris_uuid
name: "Vehicle iBeacon Auris"
timeout: 2min
on_press:
- if:
condition:
and:
- switch.is_on: enable_auris
- switch.is_on: auto_open
- binary_sensor.is_off: ibeacon_yaris
- binary_sensor.is_off: ibeacon_pcx125
- binary_sensor.is_off: ibeacon_dl650
then:
- button.press: gate_open
on_release:
- if:
condition:
and:
- switch.is_on: enable_auris
- switch.is_on: auto_close
- binary_sensor.is_off: ibeacon_yaris
- binary_sensor.is_off: ibeacon_pcx125
- binary_sensor.is_off: ibeacon_dl650
then:
- button.press: gate_close
on_press: !include {file: common/gate_beacon_open.yaml, vars: {enable_id: enable_auris}}
on_release: !include {file: common/gate_beacon_close.yaml, vars: {enable_id: enable_auris}}
- platform: ble_presence
id: ibeacon_yaris
ibeacon_uuid: !secret ble_beacon_toyota_yaris_uuid
name: "Vehicle iBeacon Yaris"
timeout: 2min
on_press:
- if:
condition:
and:
- switch.is_on: enable_yaris
- switch.is_on: auto_open
- binary_sensor.is_off: ibeacon_auris
- binary_sensor.is_off: ibeacon_pcx125
- binary_sensor.is_off: ibeacon_dl650
then:
- button.press: gate_open
on_release:
- if:
condition:
and:
- switch.is_on: enable_yaris
- switch.is_on: auto_close
- binary_sensor.is_off: ibeacon_auris
- binary_sensor.is_off: ibeacon_pcx125
- binary_sensor.is_off: ibeacon_dl650
then:
- button.press: gate_close
on_press: !include {file: common/gate_beacon_open.yaml, vars: {enable_id: enable_yaris}}
on_release: !include {file: common/gate_beacon_close.yaml, vars: {enable_id: enable_yaris}}
- platform: ble_presence
id: ibeacon_pcx125
ibeacon_uuid: !secret ble_beacon_honda_uuid
name: "Vehicle iBeacon Honda PCX125"
timeout: 2min
on_press:
- if:
condition:
and:
- switch.is_on: enable_pcx125
- switch.is_on: auto_open
- binary_sensor.is_off: ibeacon_auris
- binary_sensor.is_off: ibeacon_yaris
- binary_sensor.is_off: ibeacon_dl650
then:
- button.press: gate_open
on_release:
- if:
condition:
and:
- switch.is_on: enable_pcx125
- switch.is_on: auto_close
- binary_sensor.is_off: ibeacon_auris
- binary_sensor.is_off: ibeacon_yaris
- binary_sensor.is_off: ibeacon_dl650
then:
- button.press: gate_close
on_press: !include {file: common/gate_beacon_open.yaml, vars: {enable_id: enable_pcx125}}
on_release: !include {file: common/gate_beacon_close.yaml, vars: {enable_id: enable_pcx125}}
- platform: ble_presence
id: ibeacon_dl650
ibeacon_uuid: !secret ble_beacon_suzuki_uuid
name: "Vehicle iBeacon Suzuki DL650"
timeout: 2min
on_press:
- if:
condition:
and:
- switch.is_on: enable_dl650
- switch.is_on: auto_open
- binary_sensor.is_off: ibeacon_auris
- binary_sensor.is_off: ibeacon_yaris
- binary_sensor.is_off: ibeacon_pcx125
then:
- button.press: gate_open
on_release:
- if:
condition:
and:
- switch.is_on: enable_dl650
- switch.is_on: auto_close
- binary_sensor.is_off: ibeacon_auris
- binary_sensor.is_off: ibeacon_yaris
- binary_sensor.is_off: ibeacon_pcx125
then:
- button.press: gate_close
# - platform: gpio
# id: gate_flash
# pin:
# number: 26
# inverted: true
# mode:
# input: true
# filters:
# - delayed_on: 10ms
on_press: !include {file: common/gate_beacon_open.yaml, vars: {enable_id: enable_dl650}}
on_release: !include {file: common/gate_beacon_close.yaml, vars: {enable_id: enable_dl650}}
- platform: gpio
id: gate_ogi
pin:
@@ -230,53 +145,53 @@ binary_sensor:
- delayed_on: 10ms
entity_category: diagnostic
on_multi_click:
- timing:
- OFF for at least 1500ms
then:
- select.set:
id: gate_state
option: Closed
- logger.log: "OGI OFF => GATE CLOSED"
invalid_cooldown: 100ms
- timing:
- ON for at least 400ms
- OFF for at least 400ms
- ON for at least 400ms
- OFF for at least 400ms
then:
- select.set:
id: gate_state
option: Opening
- logger.log: "OGI SLOW BLINK => GATE OPENING"
invalid_cooldown: 100ms
- timing:
- ON for at most 300ms
- OFF for at most 300ms
- ON for at most 300ms
- OFF for at most 300ms
then:
- select.set:
id: gate_state
option: Closing
- logger.log: "OGI FAST BLINK => GATE CLOSING"
invalid_cooldown: 100ms
- timing:
- ON for at least 1500ms
then:
- select.set:
id: gate_state
option: Open
- logger.log: "OGI ON => GATE OPEN"
invalid_cooldown: 100ms
- timing:
- OFF for at least 1500ms
then:
- select.set:
id: gate_state
option: Closed
- logger.log: "OGI OFF => GATE CLOSED"
invalid_cooldown: 100ms
- timing:
- ON for at least 400ms
- OFF for at least 400ms
- ON for at least 400ms
- OFF for at least 400ms
then:
- select.set:
id: gate_state
option: Opening
- logger.log: "OGI SLOW BLINK => GATE OPENING"
invalid_cooldown: 100ms
- timing:
- ON for at most 300ms
- OFF for at most 300ms
- ON for at most 300ms
- OFF for at most 300ms
then:
- select.set:
id: gate_state
option: Closing
- logger.log: "OGI FAST BLINK => GATE CLOSING"
invalid_cooldown: 100ms
- timing:
- ON for at least 1500ms
then:
- select.set:
id: gate_state
option: Open
- logger.log: "OGI ON => GATE OPEN"
invalid_cooldown: 100ms
select:
- platform: template
name: State
id: gate_state
options:
- Open
- Closed
- Opening
- Closing
- Open
- Closed
- Opening
- Closing
initial_option: Closed
optimistic: true

View File

@@ -1,3 +1,4 @@
---
substitutions:
device: gateway
name: Gateway
@@ -54,11 +55,11 @@ ethernet:
# Enable LLDP transmission
#enabled: true
# Optional: override default port
port: "test-port"
port: eth
# Optional: override default system name
system_name: "test-system"
system_name: mcu-${device}
# Optional: override default system description
system_description: "test-description"
system_description: ${comment}
# Optional: override default "fast mode" burst packet count
tx_fast_count: 4
# Optional: override default LLDP frame transmission interval
@@ -73,19 +74,19 @@ ethernet:
# clk_mode: GPIO17_OUT
# phy_addr: 0
# power_pin: 12
# use_address: 10.17.240.245
# use_address: 10.17.240.245
# # Optional manual IP
# manual_ip:
# static_ip: 10.17.240.254
# gateway: 10.17.240.1
# subnet: 255.255.255.0
# # Optional manual IP
# manual_ip:
# static_ip: 10.17.240.254
# gateway: 10.17.240.1
# subnet: 255.255.255.0
# ethernet:
# use_address: 10.17.241.254
# use_address: 10.17.241.98
# use_address: mcu-gateway.local
# use_address: 10.17.241.254
# use_address: 10.17.241.98
# use_address: mcu-gateway.local
uart:
id: uart_modbus
@@ -190,17 +191,17 @@ sensor:
register_count: 2
filters:
- calibrate_linear:
- 50 -> 0
- 450 -> 5
- 50 -> 0
- 450 -> 5
switch:
- platform: modbus_controller
modbus_controller_id: modbus_adc_1
name: Readress MODBUS
register_type: holding
address: 0x00FD
entity_category: config
icon: "mdi:toggle-switch"
- platform: modbus_controller
modbus_controller_id: modbus_adc_1
name: Readress MODBUS
register_type: holding
address: 0x00FD
entity_category: config
icon: "mdi:toggle-switch"
esp32_ble_tracker:
scan_parameters:

View File

@@ -1,3 +1,4 @@
---
substitutions:
device: heater
name: Heater
@@ -248,13 +249,13 @@ switch:
sensor:
# - platform: ds248x
- platform: dallas_temp
# [22:06:25][D][dallas.sensor:082]: 0x1701143E35C5AA28 Feed
# [22:06:25][D][dallas.sensor:082]: 0x7301143F7F57AA28 Return
# [22:06:25][D][dallas.sensor:082]: 0xF701143E397FAA28 Heater Tank
# [22:06:25][D][dallas.sensor:082]: 0x5A041750B2C8FF28 Hot Water Tank - Bottom (Solar)
# [22:06:25][D][dallas.sensor:082]: 0xDB041750EAE2FF28 Heating Water Return (OUT from System, TO Heater)
# [22:06:25][D][dallas.sensor:082]: 0xB2041750CF1AFF28 Heating Water (OUT from Heater, TO System)
# [22:06:25][D][dallas.sensor:082]: 0x960417517301FF28 Hot Water Tank - TOP (Heater)
# [22:06:25][D][dallas.sensor:082]: 0x1701143E35C5AA28 Feed
# [22:06:25][D][dallas.sensor:082]: 0x7301143F7F57AA28 Return
# [22:06:25][D][dallas.sensor:082]: 0xF701143E397FAA28 Heater Tank
# [22:06:25][D][dallas.sensor:082]: 0x5A041750B2C8FF28 Hot Water Tank - Bottom (Solar)
# [22:06:25][D][dallas.sensor:082]: 0xDB041750EAE2FF28 Heating Water Return (OUT from System, TO Heater)
# [22:06:25][D][dallas.sensor:082]: 0xB2041750CF1AFF28 Heating Water (OUT from Heater, TO System)
# [22:06:25][D][dallas.sensor:082]: 0x960417517301FF28 Hot Water Tank - TOP (Heater)
# address: 0x320417500A93FF28 # 1. broken
# address: 0x67041750F44CFF28 # 2. broken
address: 0x960417517301FF28 # Hot Water Tank - TOP (Heater)

View File

@@ -1,3 +1,4 @@
---
substitutions:
device: kitchen
name: Kitchen

View File

@@ -1,3 +1,4 @@
---
substitutions:
device: lightening
name: Lightening detector
@@ -16,9 +17,6 @@ esp32:
framework:
type: esp-idf
external_components:
- source: components
packages:
common: !include common/common.yaml
@@ -38,11 +36,11 @@ as3935_i2c:
irq_pin: 26
binary_sensor:
# - platform: gpio
# # name: Button
# pin:
# number: 39
# inverted: true
# - platform: gpio
# # name: Button
# pin:
# number: 39
# inverted: true
- platform: as3935
name: Storm Alert
@@ -62,4 +60,3 @@ sensor:
name: Energy
distance:
name: Storm Distance

View File

@@ -1,3 +1,4 @@
---
substitutions:
device: lvgl-eworkbench
name: Electronics Workbench Display

View File

@@ -1,3 +1,4 @@
---
substitutions:
device: lvgl-trainer
name: Trainer Display
@@ -141,8 +142,8 @@ touchscreen:
i2c_id: touchscreen_bus
update_interval: 100ms
# interrupt_pin:
# number: 3
# ignore_strapping_warning: true
# number: 3
# ignore_strapping_warning: true
calibration:
x_min: 0
x_max: 479
@@ -209,14 +210,14 @@ lvgl:
log_level: WARN
color_depth: 16
default_font: montserrat_18
# on_idle:
# - timeout: !lambda "return (id(display_timeout).state * 1000);"
# then:
# - logger.log: "LVGL is idle"
# - light.turn_off:
# id: display_backlight
# transition_length: 2500ms
# - lvgl.pause:
# on_idle:
# - timeout: !lambda "return (id(display_timeout).state * 1000);"
# then:
# - logger.log: "LVGL is idle"
# - light.turn_off:
# id: display_backlight
# transition_length: 2500ms
# - lvgl.pause:
top_layer:
widgets:
- buttonmatrix:
@@ -229,21 +230,21 @@ lvgl:
# styles: header_footer
rows:
- buttons:
- id: page_prev
text: "\uF053"
on_press:
then:
lvgl.page.previous:
- id: page_home
text: "\uF015"
on_press:
then:
lvgl.page.show: main_page
- id: page_next
text: "\uF054"
on_press:
then:
lvgl.page.next:
- id: page_prev
text: "\uF053"
on_press:
then:
lvgl.page.previous:
- id: page_home
text: "\uF015"
on_press:
then:
lvgl.page.show: main_page
- id: page_next
text: "\uF054"
on_press:
then:
lvgl.page.next:
pages:
- id: main_page
widgets:

View File

@@ -1,3 +1,4 @@
---
substitutions:
device: lvgl
name: LVGL
@@ -11,7 +12,6 @@ esphome:
comment: ${comment}
platformio_options:
board_build.flash_mode: dio
includes: ota.h
esp32:
variant: esp32s3

View File

@@ -1,3 +1,4 @@
---
substitutions:
device: m5paper
name: M5Paper

View File

@@ -1,3 +1,4 @@
---
substitutions:
device: mains-power
name: Mains Power

11
mcu-nrf-dk.yaml Normal file
View File

@@ -0,0 +1,11 @@
---
esphome:
name: mcu-nrf-dk
friendly_name: mcu-nrf-dk
nrf52:
board: nrf52840_dk
bootloader: adafruit_nrf52_sd140_v7
# Enable logging
logger:

View File

@@ -1,3 +1,4 @@
---
substitutions:
device: nspanel-bedroom
name: Bedroom NSPanel
@@ -270,4 +271,3 @@ sensor:
- platform: template
id: room_temperature_id

View File

@@ -1,3 +1,4 @@
---
substitutions:
device: nspanel-dev
name: NSPanel DEV
@@ -36,6 +37,8 @@ esp32:
type: esp-idf
advanced:
minimum_chip_revision: "3.0"
include_builtin_idf_components:
- esp_http_client
external_components:
# - source:
@@ -85,7 +88,7 @@ api:
# - delay: 10s
# - lambda: 'id(nspanel_id).send_custom_command("notify~~");'
# DISABLED until https://github.com/olicooper/esphome-nspanel-lovelace-native/issues/20 is fixed
# DISABLED until https://github.com/olicooper/esphome-nspanel-lovelace-native/issues/20 is fixed
# - service: update_tft
# then:
# - lambda: |-

View File

@@ -1,3 +1,4 @@
---
substitutions:
device: nspanel-fireplace
name: Fireplace NSPanel
@@ -187,7 +188,7 @@ binary_sensor:
number: 14
inverted: true
on_click:
# - switch.toggle: relay_1
# - switch.toggle: relay_1
- min_length: 50ms
max_length: 350ms
then:
@@ -217,7 +218,7 @@ binary_sensor:
number: 27
inverted: true
on_click:
# - switch.toggle: relay_2
# - switch.toggle: relay_2
- min_length: 50ms
max_length: 350ms
then:

View File

@@ -1,3 +1,4 @@
---
substitutions:
device: nspanel-office-j
name: Office J NSPanel

View File

@@ -1,3 +1,4 @@
---
substitutions:
device: nspanel-office-r
name: Office R NSPanel

View File

@@ -1,3 +1,4 @@
---
substitutions:
device: nspanel-patio
name: Patio NSPanel
@@ -31,7 +32,6 @@ external_components:
url: https://github.com/sairon/esphome-nspanel-lovelace-ui
ref: dev
components: [nspanel_lovelace]
- source: components
packages:
common: !include common/common.yaml

View File

@@ -1,3 +1,4 @@
---
substitutions:
device: office-r
name: Office R

View File

@@ -1,3 +1,4 @@
---
substitutions:
device: patio
name: Patio

View File

@@ -1,3 +1,4 @@
---
substitutions:
device: pow-dishwasher
name: Dishwasher POW
@@ -16,24 +17,14 @@ esp32:
advanced:
minimum_chip_revision: "3.1"
interval:
- interval: 30s
then:
if:
condition:
wifi.connected:
then:
- light.turn_on: wifi_status_led
else:
- light.turn_off: wifi_status_led
packages:
common: !include common/common.yaml
uart:
rx_pin: 16
baud_rate: 4800
parity: EVEN
- id: cse7766_uart
rx_pin: 16
baud_rate: 4800
parity: EVEN
binary_sensor:
- platform: gpio
@@ -120,6 +111,7 @@ output:
sensor:
- platform: cse7766
uart_id: cse7766_uart
current:
name: Current
id: a_sensor
@@ -143,10 +135,15 @@ sensor:
then:
- light.turn_off: switch_led
energy:
name: Energy"
name: Energy
id: wh_sensor
filters:
- throttle_average: ${update_interval}
power_factor:
name: Power Factor
id: power_factor
filters:
- throttle_average: ${update_interval}
- platform: total_daily_energy
name: Total Daily Energy
@@ -155,12 +152,6 @@ sensor:
- multiply: 0.001
unit_of_measurement: kWh
- platform: template
name: Power Factor
device_class: power_factor
id: power_factor
lambda: return id(w_sensor).state / id(v_sensor).state / id(a_sensor).state;
switch:
- platform: template
name: Relay
@@ -180,7 +171,6 @@ switch:
on_turn_on:
- delay: 500ms
- switch.turn_off: relay_on # bi-stable relay so no need to keep on
- light.turn_on: switch_led
interlock: [relay_off]
- platform: gpio
@@ -191,7 +181,6 @@ switch:
on_turn_on:
- delay: 500ms
- switch.turn_off: relay_off # bi-stable relay so no need to keep on
- light.turn_off: switch_led
interlock: [relay_on]
time:

View File

@@ -1,3 +1,4 @@
---
substitutions:
device: pow-washer
name: Washer POW
@@ -16,24 +17,14 @@ esp32:
advanced:
minimum_chip_revision: "3.1"
interval:
- interval: 30s
then:
if:
condition:
wifi.connected:
then:
- light.turn_on: wifi_status_led
else:
- light.turn_off: wifi_status_led
packages:
common: !include common/common.yaml
uart:
rx_pin: 16
baud_rate: 4800
parity: EVEN
- id: cse7766_uart
rx_pin: 16
baud_rate: 4800
parity: EVEN
binary_sensor:
- platform: gpio
@@ -120,6 +111,7 @@ output:
sensor:
- platform: cse7766
uart_id: cse7766_uart
current:
name: Current
id: a_sensor
@@ -147,6 +139,11 @@ sensor:
id: wh_sensor
filters:
- throttle_average: ${update_interval}
power_factor:
name: Power Factor
id: power_factor
filters:
- throttle_average: ${update_interval}
- platform: total_daily_energy
name: Total Daily Energy
@@ -155,12 +152,6 @@ sensor:
- multiply: 0.001
unit_of_measurement: kWh
- platform: template
name: Power Factor
device_class: power_factor
id: power_factor
lambda: return id(w_sensor).state / id(v_sensor).state / id(a_sensor).state;
switch:
- platform: template
name: Relay
@@ -180,7 +171,6 @@ switch:
on_turn_on:
- delay: 500ms
- switch.turn_off: relay_on # bi-stable relay so no need to keep on
- light.turn_on: switch_led
interlock: [relay_off]
- platform: gpio
@@ -191,7 +181,6 @@ switch:
on_turn_on:
- delay: 500ms
- switch.turn_off: relay_off # bi-stable relay so no need to keep on
- light.turn_off: switch_led
interlock: [relay_on]
time:

View File

@@ -1,3 +1,4 @@
---
substitutions:
device: rf433
name: RF433 Bridge
@@ -28,11 +29,11 @@ remote_transmitter:
carrier_duty_percent: 100%
binary_sensor:
# Key Fob remote
# A: 011110110011101010100010
# B: 011110110011101010101000
# C: 011110110011101010100001
# D: 011110110011101010100100
# Key Fob remote
# A: 011110110011101010100010
# B: 011110110011101010101000
# C: 011110110011101010100001
# D: 011110110011101010100100
- platform: remote_receiver
name: "Keyfob Remote Button A"
rc_switch_raw:

View File

@@ -1,3 +1,4 @@
---
substitutions:
device: rfid-reader
name: RFID Reader

View File

@@ -1,3 +1,4 @@
---
substitutions:
device: shed
name: Shed
@@ -37,18 +38,18 @@ binary_sensor:
number: 6
inverted: true
on_click:
- min_length: 50ms
max_length: 350ms
then:
- switch.toggle: shed_light_relay
- min_length: 351ms
max_length: 1000ms
then:
- switch.toggle: garden_light_relay
- min_length: 1001ms
max_length: 10000ms
then:
- switch.toggle: socket_relay
- min_length: 50ms
max_length: 350ms
then:
- switch.toggle: shed_light_relay
- min_length: 351ms
max_length: 1000ms
then:
- switch.toggle: garden_light_relay
- min_length: 1001ms
max_length: 10000ms
then:
- switch.toggle: socket_relay
switch:
- platform: gpio

View File

@@ -1,3 +1,4 @@
---
substitutions:
device: socket-01
name: Socket 01
@@ -99,8 +100,8 @@ sensor:
name: Total Daily Power"
power_id: power
filters:
# Multiplication factor from W to kW is 0.001
- multiply: 0.001
# Multiplication factor from W to kW is 0.001
- multiply: 0.001
unit_of_measurement: kWh
icon: mdi:circle-slice-3

View File

@@ -1,3 +1,4 @@
---
substitutions:
device: socket-02
device_id: socket_02
@@ -101,8 +102,8 @@ sensor:
name: Total Daily Power
power_id: power
filters:
# Multiplication factor from W to kW is 0.001
- multiply: 0.001
# Multiplication factor from W to kW is 0.001
- multiply: 0.001
unit_of_measurement: kWh
icon: mdi:circle-slice-3

View File

@@ -1,3 +1,4 @@
---
substitutions:
device: socket-03
name: Socket 03
@@ -122,8 +123,8 @@ sensor:
power_id: power
accuracy_decimals: 5
filters:
# Multiplication factor from W to kW is 0.001
- multiply: 0.001
# Multiplication factor from W to kW is 0.001
- multiply: 0.001
unit_of_measurement: kWh
icon: mdi:circle-slice-3

View File

@@ -1,3 +1,4 @@
---
substitutions:
device: staircase-light
name: Staircase

View File

@@ -1,3 +1,4 @@
---
substitutions:
device: tft
name: TFT

View File

@@ -1,3 +1,4 @@
---
substitutions:
device: tracker
name: Tracker
@@ -94,12 +95,11 @@ external_components:
type: git
url: https://github.com/crossan007/esphome
ref: "feature/AXP192"
components: [ axp192 ]
components: [axp192]
- source: github://pr#6721
components: [ network, modem ]
components: [network, modem]
- source: github://pr#9802
components: [ modem ]
- source: components
components: [modem]
# packages:
# common: !include common/common.yaml

View File

@@ -1,3 +1,4 @@
---
substitutions:
device: tv-light
name: TV Light

View File

@@ -1,3 +1,4 @@
---
substitutions:
device: vehicle-honda-pcx125
name: Vehicle Honda PCX125
@@ -9,127 +10,13 @@ esphome:
friendly_name: ${name}
area: ${area}
comment: ${comment}
on_loop:
then:
lambda: |-
static uint32_t last_state = 0;
auto state = App.get_app_state();
if (state != last_state) {
if (state & STATUS_LED_ERROR) {
auto call = id(led).turn_on();
call.set_effect("ERROR");
call.perform();
} else if (state & STATUS_LED_WARNING) {
auto call = id(led).turn_on();
call.set_effect("BOOT");
call.perform();
} else {
//auto call = id(led).turn_off();
//call.perform();
auto call = id(led).turn_on();
call.set_effect("BEACON");
call.perform();
}
last_state = state;
}
esp32:
variant: esp32
framework:
type: esp-idf
# api:
# reboot_timeout: 0s
# wifi:
# reboot_timeout: 0s
external_components:
- source: components
packages:
common: !include common/logger.yaml
# common: !include common/common.yaml
# debug:
# PINOUTS: M5ATOM
# IR G12
# NEO G27
# BUTTON G39
# I2C0 SDA G26
# I2C0 SCL G32
# I2C1 SDA G25
# I2C1 SCL G21
# UART0 RX G3
# UART0 TX G1
# UART1 RX G23
# UART1 TX G33
# 1-WIRE G22
# NC G19
base: !include common/vehicle_base.yaml
logger: !include common/logger.yaml
esp32_ble_beacon:
type: iBeacon
uuid: !secret ble_beacon_honda_uuid
major: !secret ble_beacon_honda_major
minor: !secret ble_beacon_honda_minor
light:
- platform: esp32_rmt_led_strip
name: LED
id: led
rgb_order: GRB
pin: 27
num_leds: 1
chipset: ws2812
restore_mode: ALWAYS_OFF
effects:
- strobe:
name: "BEACON"
colors:
- state: true
red: 0%
green: 0%
blue: 50%
duration: 200ms
- state: false
duration: 200ms
- state: true
red: 0%
green: 0%
blue: 50%
duration: 200ms
- state: false
duration: 10s
- lambda:
name: "ERROR"
update_interval: 0.5s
lambda: |-
static bool state = false;
auto call = id(led).turn_on();
call.set_transition_length(500);
call.set_rgb(1, 0, 0);
if (!state) {
call.set_brightness(1);
} else {
// If using 0, it freaks Home Assistant UI.
call.set_brightness(0.01);
}
call.perform();
state = !state;
- lambda:
name: "BOOT"
update_interval: 0.5s
lambda: |-
static bool state = false;
auto call = id(led).turn_on();
call.set_transition_length(500);
call.set_rgb(0, 1, 0);
if (!state) {
call.set_brightness(1);
} else {
// If using 0, it freaks Home Assistant UI.
call.set_brightness(0.01);
}
call.perform();
state = !state;

View File

@@ -1,3 +1,4 @@
---
substitutions:
device: vehicle-suzuki-dl650
name: Vehicle Suzuki DL650
@@ -9,127 +10,13 @@ esphome:
friendly_name: ${name}
area: ${area}
comment: ${comment}
on_loop:
then:
lambda: |-
static uint32_t last_state = 0;
auto state = App.get_app_state();
if (state != last_state) {
if (state & STATUS_LED_ERROR) {
auto call = id(led).turn_on();
call.set_effect("ERROR");
call.perform();
} else if (state & STATUS_LED_WARNING) {
auto call = id(led).turn_on();
call.set_effect("BOOT");
call.perform();
} else {
//auto call = id(led).turn_off();
//call.perform();
auto call = id(led).turn_on();
call.set_effect("BEACON");
call.perform();
}
last_state = state;
}
esp32:
variant: esp32
framework:
type: esp-idf
# api:
# reboot_timeout: 0s
# wifi:
# reboot_timeout: 0s
external_components:
- source: components
packages:
common: !include common/logger.yaml
# common: !include common/common.yaml
# debug:
# PINOUTS: M5ATOM
# IR G12
# NEO G27
# BUTTON G39
# I2C0 SDA G26
# I2C0 SCL G32
# I2C1 SDA G25
# I2C1 SCL G21
# UART0 RX G3
# UART0 TX G1
# UART1 RX G23
# UART1 TX G33
# 1-WIRE G22
# NC G19
base: !include common/vehicle_base.yaml
logger: !include common/logger.yaml
esp32_ble_beacon:
type: iBeacon
uuid: !secret ble_beacon_suzuki_uuid
major: !secret ble_beacon_suzuki_major
minor: !secret ble_beacon_suzuki_minor
light:
- platform: esp32_rmt_led_strip
name: LED
id: led
rgb_order: GRB
pin: 27
num_leds: 1
chipset: ws2812
restore_mode: ALWAYS_OFF
effects:
- strobe:
name: "BEACON"
colors:
- state: true
red: 0%
green: 0%
blue: 50%
duration: 200ms
- state: false
duration: 200ms
- state: true
red: 0%
green: 0%
blue: 50%
duration: 200ms
- state: false
duration: 10s
- lambda:
name: "ERROR"
update_interval: 0.5s
lambda: |-
static bool state = false;
auto call = id(led).turn_on();
call.set_transition_length(500);
call.set_rgb(1, 0, 0);
if (!state) {
call.set_brightness(1);
} else {
// If using 0, it freaks Home Assistant UI.
call.set_brightness(0.01);
}
call.perform();
state = !state;
- lambda:
name: "BOOT"
update_interval: 0.5s
lambda: |-
static bool state = false;
auto call = id(led).turn_on();
call.set_transition_length(500);
call.set_rgb(0, 1, 0);
if (!state) {
call.set_brightness(1);
} else {
// If using 0, it freaks Home Assistant UI.
call.set_brightness(0.01);
}
call.perform();
state = !state;

View File

@@ -1,3 +1,4 @@
---
substitutions:
device: vehicle-toyota-auris-ts
name: Vehicle Toyota Auris TS
@@ -16,69 +17,12 @@ esphome:
- binary_sensor.is_off: button
then:
- wifi.disable:
on_loop:
then:
lambda: |-
static uint32_t last_state = 0;
auto state = App.get_app_state();
if (state != last_state) {
if (state & STATUS_LED_ERROR) {
auto call = id(led).turn_on();
call.set_effect("ERROR");
call.perform();
} else if (state & STATUS_LED_WARNING) {
auto call = id(led).turn_on();
call.set_effect("BOOT");
call.perform();
} else {
//auto call = id(led).turn_off();
//call.perform();
auto call = id(led).turn_on();
call.set_effect("BEACON");
call.perform();
}
last_state = state;
}
esp32:
variant: esp32
framework:
type: esp-idf
# version: 5.3.2
# platform_version: 53.03.11
external_components:
- source: components
packages:
base: !include common/vehicle_base.yaml
wifi: !include common/wifi.yaml
logger: !include common/logger.yaml
# api: !include common/api.yaml
ota: !include common/ota.yaml
# common: !include common/common.yaml
# api:
# reboot_timeout: 0s
# wifi:
# enable_on_boot: false
# debug:
# PINOUTS: M5ATOM
# IR G12
# NEO G27
# BUTTON G39
# I2C0 SDA G26
# I2C0 SCL G32
# I2C1 SDA G25
# I2C1 SCL G21
# UART0 RX G3
# UART0 TX G1
# UART1 RX G23
# UART1 TX G33
# 1-WIRE G22
# NC G19
binary_sensor:
- platform: gpio
@@ -92,63 +36,3 @@ esp32_ble_beacon:
uuid: !secret ble_beacon_toyota_auris_uuid
major: !secret ble_beacon_toyota_auris_major
minor: !secret ble_beacon_toyota_auris_minor
light:
- platform: esp32_rmt_led_strip
name: LED
id: led
rgb_order: GRB
pin: 27
num_leds: 1
chipset: ws2812
restore_mode: ALWAYS_OFF
effects:
- strobe:
name: "BEACON"
colors:
- state: true
red: 0%
green: 0%
blue: 50%
duration: 200ms
- state: false
duration: 200ms
- state: true
red: 0%
green: 0%
blue: 50%
duration: 200ms
- state: false
duration: 10s
- lambda:
name: "ERROR"
update_interval: 0.5s
lambda: |-
static bool state = false;
auto call = id(led).turn_on();
call.set_transition_length(500);
call.set_rgb(1, 0, 0);
if (!state) {
call.set_brightness(1);
} else {
// If using 0, it freaks Home Assistant UI.
call.set_brightness(0.01);
}
call.perform();
state = !state;
- lambda:
name: "BOOT"
update_interval: 0.5s
lambda: |-
static bool state = false;
auto call = id(led).turn_on();
call.set_transition_length(500);
call.set_rgb(0, 1, 0);
if (!state) {
call.set_brightness(1);
} else {
// If using 0, it freaks Home Assistant UI.
call.set_brightness(0.01);
}
call.perform();
state = !state;

View File

@@ -1,3 +1,4 @@
---
substitutions:
device: vehicle-toyota-yaris-cross
name: Vehicle Toyota Yaris Cross
@@ -9,128 +10,13 @@ esphome:
friendly_name: ${name}
area: ${area}
comment: ${comment}
on_loop:
then:
lambda: |-
static uint32_t last_state = 0;
auto state = App.get_app_state();
if (state != last_state) {
if (state & STATUS_LED_ERROR) {
auto call = id(led).turn_on();
call.set_effect("ERROR");
call.perform();
} else if (state & STATUS_LED_WARNING) {
auto call = id(led).turn_on();
call.set_effect("BOOT");
call.perform();
} else {
//auto call = id(led).turn_off();
//call.perform();
auto call = id(led).turn_on();
call.set_effect("BEACON");
call.perform();
}
last_state = state;
}
esp32:
variant: esp32
framework:
type: esp-idf
# api:
# reboot_timeout: 0s
# wifi:
# reboot_timeout: 0s
external_components:
- source: components
packages:
common: !include common/logger.yaml
# wifi: !include common/wifi.yaml
# common: !include common/common.yaml
# debug:
# PINOUTS: M5ATOM
# IR G12
# NEO G27
# BUTTON G39
# I2C0 SDA G26
# I2C0 SCL G32
# I2C1 SDA G25
# I2C1 SCL G21
# UART0 RX G3
# UART0 TX G1
# UART1 RX G23
# UART1 TX G33
# 1-WIRE G22
# NC G19
base: !include common/vehicle_base.yaml
logger: !include common/logger.yaml
esp32_ble_beacon:
type: iBeacon
uuid: !secret ble_beacon_toyota_yaris_uuid
major: !secret ble_beacon_toyota_yaris_major
minor: !secret ble_beacon_toyota_yaris_minor
light:
- platform: esp32_rmt_led_strip
name: LED
id: led
rgb_order: GRB
pin: 27
num_leds: 1
chipset: ws2812
restore_mode: ALWAYS_OFF
effects:
- strobe:
name: "BEACON"
colors:
- state: true
red: 0%
green: 0%
blue: 50%
duration: 200ms
- state: false
duration: 200ms
- state: true
red: 0%
green: 0%
blue: 50%
duration: 200ms
- state: false
duration: 10s
- lambda:
name: "ERROR"
update_interval: 0.5s
lambda: |-
static bool state = false;
auto call = id(led).turn_on();
call.set_transition_length(500);
call.set_rgb(1, 0, 0);
if (!state) {
call.set_brightness(1);
} else {
// If using 0, it freaks Home Assistant UI.
call.set_brightness(0.01);
}
call.perform();
state = !state;
- lambda:
name: "BOOT"
update_interval: 0.5s
lambda: |-
static bool state = false;
auto call = id(led).turn_on();
call.set_transition_length(500);
call.set_rgb(0, 1, 0);
if (!state) {
call.set_brightness(1);
} else {
// If using 0, it freaks Home Assistant UI.
call.set_brightness(0.01);
}
call.perform();
state = !state;

View File

@@ -1,3 +1,4 @@
---
substitutions:
device: waterproof-socket
name: Waterproof Socket

View File

@@ -1,3 +1,4 @@
---
substitutions:
device: well
name: Well

View File

@@ -1,44 +0,0 @@
#include "esphome.h"
using namespace esphome;
class SonoffOut1 : public Component, public switch_::Switch {
public:
void setup() override {
// This will be called by App.setup()
}
void write_state(bool state) override {
Serial.write(0xA0);
Serial.write(0x04);
if (state)
Serial.write(0x05);
else
Serial.write(0x00);
Serial.write(0xA1);
Serial.write('\n');
Serial.flush();
publish_state(state);
}
};
class SonoffOut2 : public Component, public switch_::Switch {
public:
void setup() override {
// This will be called by App.setup()
}
void write_state(bool state) override {
Serial.write(0xA0);
Serial.write(0x04);
if (state)
Serial.write(0x06);
else
Serial.write(0x00);
Serial.write(0xA1);
Serial.write('\n');
Serial.flush();
publish_state(state);
}
};