mirror of
https://github.com/randybb/esphome-configs.git
synced 2026-03-03 07:14:10 +01:00
Compare commits
12 Commits
1c8c319406
...
a966f6adb4
| Author | SHA1 | Date | |
|---|---|---|---|
| a966f6adb4 | |||
| 2ef5945c9f | |||
| 3ca7b2390d | |||
| 38791e3313 | |||
| d03d889e81 | |||
| 4ee29295ac | |||
| dd033f69bb | |||
| 7c9aae0a7d | |||
| c88ccfbdb8 | |||
| b18ce4a2da | |||
| d4967c6411 | |||
| a8b71d99dd |
53
.github/workflows/ci.yml
vendored
Normal file
53
.github/workflows/ci.yml
vendored
Normal 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
27
.yamllint.yml
Normal 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
|
||||||
@@ -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
|
|
||||||
|
Before Width: | Height: | Size: 14 KiB After Width: | Height: | Size: 14 KiB |
|
Before Width: | Height: | Size: 172 KiB After Width: | Height: | Size: 172 KiB |
9
common/gate_beacon_close.yaml
Normal file
9
common/gate_beacon_close.yaml
Normal 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;'
|
||||||
9
common/gate_beacon_open.yaml
Normal file
9
common/gate_beacon_open.yaml
Normal 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
105
common/vehicle_base.yaml
Normal 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;
|
||||||
@@ -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)
|
|
||||||
|
|
||||||
@@ -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
|
|
||||||
@@ -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
|
|
||||||
@@ -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)
|
|
||||||
@@ -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
|
|
||||||
@@ -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
|
|
||||||
@@ -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)
|
|
||||||
@@ -1 +0,0 @@
|
|||||||
https://github.com/TomG736/esphome-BM8563
|
|
||||||
@@ -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
|
|
||||||
|
|
||||||
@@ -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
|
|
||||||
|
|
||||||
@@ -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
|
|
||||||
@@ -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
|
|
||||||
@@ -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])
|
|
||||||
@@ -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
|
|
||||||
@@ -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
@@ -1,3 +0,0 @@
|
|||||||
import esphome.codegen as cg
|
|
||||||
|
|
||||||
st7735_ns = cg.esphome_ns.namespace('st7735')
|
|
||||||
@@ -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)
|
|
||||||
@@ -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
|
|
||||||
@@ -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
|
|
||||||
@@ -10,7 +10,7 @@ esphome:
|
|||||||
friendly_name: ${name}
|
friendly_name: ${name}
|
||||||
area: ${area}
|
area: ${area}
|
||||||
comment: ${comment}
|
comment: ${comment}
|
||||||
|
|
||||||
esp32:
|
esp32:
|
||||||
variant: esp32
|
variant: esp32
|
||||||
framework:
|
framework:
|
||||||
@@ -18,7 +18,7 @@ esp32:
|
|||||||
|
|
||||||
packages:
|
packages:
|
||||||
common: !include common/common.yaml
|
common: !include common/common.yaml
|
||||||
|
|
||||||
i2c:
|
i2c:
|
||||||
# - id: i2c0
|
# - id: i2c0
|
||||||
sda: 32
|
sda: 32
|
||||||
@@ -109,4 +109,4 @@ sensor:
|
|||||||
uart_id: particle_uart
|
uart_id: particle_uart
|
||||||
update_interval: 20s
|
update_interval: 20s
|
||||||
pm_2_5:
|
pm_2_5:
|
||||||
name: Particulate Matter 2.5µm Concentration
|
name: Particulate Matter 2.5µm Concentration
|
||||||
|
|||||||
@@ -16,7 +16,7 @@ esphome:
|
|||||||
# id(display_tft).enable();
|
# id(display_tft).enable();
|
||||||
# id(display_tft).transfer_byte(0x11);
|
# id(display_tft).transfer_byte(0x11);
|
||||||
# id(display_tft).disable();
|
# id(display_tft).disable();
|
||||||
|
|
||||||
esp32:
|
esp32:
|
||||||
variant: esp32s3
|
variant: esp32s3
|
||||||
flash_size: 8MB
|
flash_size: 8MB
|
||||||
@@ -32,18 +32,18 @@ pcf8574:
|
|||||||
pcf8575: true
|
pcf8575: true
|
||||||
|
|
||||||
animation:
|
animation:
|
||||||
- file: "blinky.gif"
|
- file: "assets/images/blinky.gif"
|
||||||
id: blinky
|
id: blinky
|
||||||
resize: 128x128
|
resize: 128x128
|
||||||
type: RGB565
|
type: RGB565
|
||||||
- file: "vault_boy_walking.gif"
|
- file: "assets/images/vault_boy_walking.gif"
|
||||||
id: vaultboy
|
id: vaultboy
|
||||||
resize: 168x121
|
resize: 168x121
|
||||||
type: RGB565
|
type: RGB565
|
||||||
|
|
||||||
logger:
|
logger:
|
||||||
logs:
|
logs:
|
||||||
component: ERROR
|
component: ERROR
|
||||||
|
|
||||||
web_server:
|
web_server:
|
||||||
port: 80
|
port: 80
|
||||||
@@ -377,7 +377,7 @@ display:
|
|||||||
id(blinky).next_frame();
|
id(blinky).next_frame();
|
||||||
// Draw the animation my_animation at position [x=0,y=0]
|
// Draw the animation my_animation at position [x=0,y=0]
|
||||||
it.image(0, 0, id(blinky), COLOR_ON, COLOR_OFF);
|
it.image(0, 0, id(blinky), COLOR_ON, COLOR_OFF);
|
||||||
|
|
||||||
// // it.print(0, 0, id(font_default), "Hello World!");
|
// // it.print(0, 0, id(font_default), "Hello World!");
|
||||||
// // it.strftime(0, 0, id(font_default), TextAlign::TOP_LEFT, "%H:%M", id(ha_time).now());
|
// // it.strftime(0, 0, id(font_default), TextAlign::TOP_LEFT, "%H:%M", id(ha_time).now());
|
||||||
// it.rectangle(0, 0, it.get_width(), it.get_height(), id(my_blue));
|
// it.rectangle(0, 0, it.get_width(), it.get_height(), id(my_blue));
|
||||||
@@ -498,4 +498,4 @@ time:
|
|||||||
# active: true
|
# active: true
|
||||||
|
|
||||||
# esp32_improv:
|
# esp32_improv:
|
||||||
# authorizer: none
|
# authorizer: none
|
||||||
|
|||||||
@@ -16,7 +16,7 @@ esp8266:
|
|||||||
|
|
||||||
packages:
|
packages:
|
||||||
common: !include common/common_esp8266.yaml
|
common: !include common/common_esp8266.yaml
|
||||||
|
|
||||||
# Sonoff Dual R2
|
# Sonoff Dual R2
|
||||||
# GPIO10 Push Button
|
# GPIO10 Push Button
|
||||||
# GPIO00 Pin "button 0" on expansion header
|
# GPIO00 Pin "button 0" on expansion header
|
||||||
|
|||||||
@@ -15,7 +15,7 @@ esp8266:
|
|||||||
|
|
||||||
packages:
|
packages:
|
||||||
common: !include common/common_esp8266.yaml
|
common: !include common/common_esp8266.yaml
|
||||||
|
|
||||||
# Sonoff Dual R2
|
# Sonoff Dual R2
|
||||||
# Pin Function
|
# Pin Function
|
||||||
# GPIO10 Push Button
|
# GPIO10 Push Button
|
||||||
@@ -118,7 +118,7 @@ select:
|
|||||||
id(blower_auto) = false;
|
id(blower_auto) = false;
|
||||||
id(relay_1).turn_off();
|
id(relay_1).turn_off();
|
||||||
}
|
}
|
||||||
|
|
||||||
status_led:
|
status_led:
|
||||||
pin:
|
pin:
|
||||||
number: 13
|
number: 13
|
||||||
@@ -136,7 +136,7 @@ switch:
|
|||||||
icon: mdi:power-socket-fr
|
icon: mdi:power-socket-fr
|
||||||
pin: 5
|
pin: 5
|
||||||
id: relay_2
|
id: relay_2
|
||||||
|
|
||||||
time:
|
time:
|
||||||
- platform: homeassistant
|
- platform: homeassistant
|
||||||
timezone: Europe/Bratislava
|
timezone: Europe/Bratislava
|
||||||
|
|||||||
@@ -338,6 +338,6 @@ xiaomi_bslamp2:
|
|||||||
master1: output_master1
|
master1: output_master1
|
||||||
master2: output_master2
|
master2: output_master2
|
||||||
front_panel:
|
front_panel:
|
||||||
i2c: front_panel_i2c
|
i2c: front_panel_i2c
|
||||||
address: 0x2C
|
address: 0x2C
|
||||||
trigger_pin: GPIO16
|
trigger_pin: GPIO16
|
||||||
|
|||||||
@@ -319,6 +319,6 @@ xiaomi_bslamp2:
|
|||||||
master1: output_master1
|
master1: output_master1
|
||||||
master2: output_master2
|
master2: output_master2
|
||||||
front_panel:
|
front_panel:
|
||||||
i2c: front_panel_i2c
|
i2c: front_panel_i2c
|
||||||
address: 0x2C
|
address: 0x2C
|
||||||
trigger_pin: GPIO16
|
trigger_pin: GPIO16
|
||||||
|
|||||||
@@ -46,7 +46,7 @@ esp32:
|
|||||||
logger:
|
logger:
|
||||||
hardware_uart: USB_SERIAL_JTAG
|
hardware_uart: USB_SERIAL_JTAG
|
||||||
logs:
|
logs:
|
||||||
component: ERROR
|
component: ERROR
|
||||||
|
|
||||||
# web_server:
|
# web_server:
|
||||||
# port: 80
|
# port: 80
|
||||||
@@ -114,4 +114,4 @@ light:
|
|||||||
state = !state;
|
state = !state;
|
||||||
|
|
||||||
packages:
|
packages:
|
||||||
common: !include common/common.yaml
|
common: !include common/common.yaml
|
||||||
|
|||||||
@@ -46,7 +46,7 @@ esp32:
|
|||||||
logger:
|
logger:
|
||||||
hardware_uart: USB_SERIAL_JTAG
|
hardware_uart: USB_SERIAL_JTAG
|
||||||
logs:
|
logs:
|
||||||
component: ERROR
|
component: ERROR
|
||||||
|
|
||||||
# web_server:
|
# web_server:
|
||||||
# port: 80
|
# port: 80
|
||||||
@@ -114,4 +114,4 @@ light:
|
|||||||
state = !state;
|
state = !state;
|
||||||
|
|
||||||
packages:
|
packages:
|
||||||
common: !include common/common.yaml
|
common: !include common/common.yaml
|
||||||
|
|||||||
@@ -52,4 +52,4 @@ switch:
|
|||||||
# - port: 8080
|
# - port: 8080
|
||||||
# mode: stream
|
# mode: stream
|
||||||
# - port: 8081
|
# - port: 8081
|
||||||
# mode: snapshot
|
# mode: snapshot
|
||||||
|
|||||||
@@ -25,7 +25,7 @@ external_components:
|
|||||||
|
|
||||||
packages:
|
packages:
|
||||||
common: !include common/common.yaml
|
common: !include common/common.yaml
|
||||||
|
|
||||||
canbus:
|
canbus:
|
||||||
- platform: esp32_can
|
- platform: esp32_can
|
||||||
id: can_bus
|
id: can_bus
|
||||||
|
|||||||
@@ -25,7 +25,7 @@ external_components:
|
|||||||
|
|
||||||
packages:
|
packages:
|
||||||
common: !include common/common.yaml
|
common: !include common/common.yaml
|
||||||
|
|
||||||
canbus:
|
canbus:
|
||||||
- platform: esp32_can
|
- platform: esp32_can
|
||||||
id: can_bus
|
id: can_bus
|
||||||
|
|||||||
@@ -126,7 +126,7 @@ display:
|
|||||||
if ((i % 2) == 0)
|
if ((i % 2) == 0)
|
||||||
it.print("8 8 ");
|
it.print("8 8 ");
|
||||||
else
|
else
|
||||||
it.print(" 8 8");
|
it.print(" 8 8");
|
||||||
} else {
|
} else {
|
||||||
if (((i / 10) % 2) == 0) {
|
if (((i / 10) % 2) == 0) {
|
||||||
//it.set_intensity(7);
|
//it.set_intensity(7);
|
||||||
|
|||||||
@@ -76,7 +76,7 @@ display:
|
|||||||
if ((i % 2) == 0)
|
if ((i % 2) == 0)
|
||||||
it.print("8 8 ");
|
it.print("8 8 ");
|
||||||
else
|
else
|
||||||
it.print(" 8 8");
|
it.print(" 8 8");
|
||||||
} else {
|
} else {
|
||||||
if (((i / 10) % 2) == 0) {
|
if (((i / 10) % 2) == 0) {
|
||||||
//it.set_intensity(7);
|
//it.set_intensity(7);
|
||||||
|
|||||||
@@ -107,7 +107,7 @@ sensor:
|
|||||||
|
|
||||||
// positive rotation
|
// positive rotation
|
||||||
if (id(rotary).state > 0) {
|
if (id(rotary).state > 0) {
|
||||||
//
|
//
|
||||||
if (id(rotary_button).state) {
|
if (id(rotary_button).state) {
|
||||||
temp -= 5.0f;
|
temp -= 5.0f;
|
||||||
} else {
|
} else {
|
||||||
|
|||||||
@@ -35,7 +35,7 @@ esp32:
|
|||||||
framework:
|
framework:
|
||||||
type: esp-idf
|
type: esp-idf
|
||||||
|
|
||||||
|
|
||||||
packages:
|
packages:
|
||||||
common: !include common/common.yaml
|
common: !include common/common.yaml
|
||||||
|
|
||||||
|
|||||||
@@ -20,11 +20,11 @@ esp32:
|
|||||||
# type: esp-idf
|
# type: esp-idf
|
||||||
# version: 5.1.2
|
# version: 5.1.2
|
||||||
# platform_version: 6.5.0
|
# platform_version: 6.5.0
|
||||||
|
|
||||||
|
|
||||||
external_components:
|
external_components:
|
||||||
- source: components
|
- source: components
|
||||||
# - source:
|
# - source:
|
||||||
# type: git
|
# type: git
|
||||||
# url: https://github.com/nielsnl68/esphome
|
# url: https://github.com/nielsnl68/esphome
|
||||||
# ref: nvds-RTTTL_I2S
|
# ref: nvds-RTTTL_I2S
|
||||||
@@ -94,14 +94,14 @@ light:
|
|||||||
# condition:
|
# condition:
|
||||||
# lambda: return state > 0;
|
# lambda: return state > 0;
|
||||||
# then:
|
# then:
|
||||||
# - light.turn_on:
|
# - light.turn_on:
|
||||||
# id: neo_buildin
|
# id: neo_buildin
|
||||||
# red: 1.0
|
# red: 1.0
|
||||||
# green: 0.0
|
# green: 0.0
|
||||||
# blue: 0.0
|
# blue: 0.0
|
||||||
# brightness: 100%
|
# brightness: 100%
|
||||||
# else:
|
# else:
|
||||||
# - light.turn_off:
|
# - light.turn_off:
|
||||||
# id: neo_buildin
|
# id: neo_buildin
|
||||||
# # green: 0.0
|
# # green: 0.0
|
||||||
# # red: 0.0
|
# # red: 0.0
|
||||||
@@ -134,7 +134,7 @@ speaker:
|
|||||||
rtttl:
|
rtttl:
|
||||||
id: my_rtttl
|
id: my_rtttl
|
||||||
speaker: echo_speaker
|
speaker: echo_speaker
|
||||||
|
|
||||||
microphone:
|
microphone:
|
||||||
- platform: i2s_audio
|
- platform: i2s_audio
|
||||||
id: echo_microphone
|
id: echo_microphone
|
||||||
@@ -148,4 +148,4 @@ voice_assistant:
|
|||||||
- media_player.play_media:
|
- media_player.play_media:
|
||||||
id: media_out
|
id: media_out
|
||||||
media_url: !lambda |-
|
media_url: !lambda |-
|
||||||
return x;
|
return x;
|
||||||
|
|||||||
@@ -227,12 +227,12 @@ button:
|
|||||||
# http_request:
|
# http_request:
|
||||||
# useragent: esphome/${device}
|
# useragent: esphome/${device}
|
||||||
# timeout: 5s
|
# timeout: 5s
|
||||||
|
|
||||||
# # Example configuration entry
|
# # Example configuration entry
|
||||||
# interval:
|
# interval:
|
||||||
# - interval: 1min
|
# - interval: 1min
|
||||||
# then:
|
# then:
|
||||||
# # - script.execute: say_hello_server
|
# # - script.execute: say_hello_server
|
||||||
# - http_request.get:
|
# - http_request.get:
|
||||||
# url: https://esphome.io
|
# url: https://esphome.io
|
||||||
# verify_ssl: false
|
# verify_ssl: false
|
||||||
|
|||||||
@@ -2,7 +2,7 @@ substitutions:
|
|||||||
device: eworkbench
|
device: eworkbench
|
||||||
name: Electronics Workbench
|
name: Electronics Workbench
|
||||||
comment: "Office R | Electronics Workbench"
|
comment: "Office R | Electronics Workbench"
|
||||||
|
|
||||||
esphome:
|
esphome:
|
||||||
name: mcu-${device}
|
name: mcu-${device}
|
||||||
friendly_name: ${name}
|
friendly_name: ${name}
|
||||||
@@ -32,7 +32,7 @@ packages:
|
|||||||
# GPIO7 GPIO
|
# GPIO7 GPIO
|
||||||
# GPIO8 GPIO
|
# GPIO8 GPIO
|
||||||
# GPIO10 GPIO
|
# GPIO10 GPIO
|
||||||
# GPIO18 UART RX
|
# GPIO18 UART RX
|
||||||
# GPIO19 UART TX
|
# GPIO19 UART TX
|
||||||
|
|
||||||
i2c:
|
i2c:
|
||||||
@@ -257,7 +257,7 @@ time:
|
|||||||
# if ((i % 2) == 0)
|
# if ((i % 2) == 0)
|
||||||
# it.print("8 8 ");
|
# it.print("8 8 ");
|
||||||
# else
|
# else
|
||||||
# it.print(" 8 8");
|
# it.print(" 8 8");
|
||||||
# } else {
|
# } else {
|
||||||
# if (((i / 10) % 2) == 0) {
|
# if (((i / 10) % 2) == 0) {
|
||||||
# //it.set_intensity(7);
|
# //it.set_intensity(7);
|
||||||
|
|||||||
202
mcu-gate.yaml
202
mcu-gate.yaml
@@ -14,7 +14,7 @@ esp32:
|
|||||||
variant: esp32
|
variant: esp32
|
||||||
framework:
|
framework:
|
||||||
type: esp-idf
|
type: esp-idf
|
||||||
|
|
||||||
packages:
|
packages:
|
||||||
common: !include common/common.yaml
|
common: !include common/common.yaml
|
||||||
|
|
||||||
@@ -93,132 +93,46 @@ switch:
|
|||||||
optimistic: true
|
optimistic: true
|
||||||
restore_mode: RESTORE_DEFAULT_ON
|
restore_mode: RESTORE_DEFAULT_ON
|
||||||
|
|
||||||
# Bluetooth related stuff
|
globals:
|
||||||
|
- id: beacon_count
|
||||||
|
type: int
|
||||||
|
restore_value: no
|
||||||
|
initial_value: '0'
|
||||||
|
|
||||||
esp32_ble_tracker:
|
esp32_ble_tracker:
|
||||||
id: ${name}_ble_tracker
|
id: ${device}_ble_tracker
|
||||||
scan_parameters:
|
scan_parameters:
|
||||||
duration: 1min
|
duration: 1min
|
||||||
|
|
||||||
# bluetooth_proxy:
|
|
||||||
|
|
||||||
binary_sensor:
|
binary_sensor:
|
||||||
- platform: ble_presence
|
- platform: ble_presence
|
||||||
id: ibeacon_auris
|
id: ibeacon_auris
|
||||||
ibeacon_uuid: !secret ble_beacon_toyota_auris_uuid
|
ibeacon_uuid: !secret ble_beacon_toyota_auris_uuid
|
||||||
name: "Vehicle iBeacon Auris"
|
name: "Vehicle iBeacon Auris"
|
||||||
timeout: 2min
|
timeout: 2min
|
||||||
on_press:
|
on_press: !include {file: common/gate_beacon_open.yaml, vars: {enable_id: enable_auris}}
|
||||||
- if:
|
on_release: !include {file: common/gate_beacon_close.yaml, vars: {enable_id: enable_auris}}
|
||||||
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
|
|
||||||
- platform: ble_presence
|
- platform: ble_presence
|
||||||
id: ibeacon_yaris
|
id: ibeacon_yaris
|
||||||
ibeacon_uuid: !secret ble_beacon_toyota_yaris_uuid
|
ibeacon_uuid: !secret ble_beacon_toyota_yaris_uuid
|
||||||
name: "Vehicle iBeacon Yaris"
|
name: "Vehicle iBeacon Yaris"
|
||||||
timeout: 2min
|
timeout: 2min
|
||||||
on_press:
|
on_press: !include {file: common/gate_beacon_open.yaml, vars: {enable_id: enable_yaris}}
|
||||||
- if:
|
on_release: !include {file: common/gate_beacon_close.yaml, vars: {enable_id: enable_yaris}}
|
||||||
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
|
|
||||||
- platform: ble_presence
|
- platform: ble_presence
|
||||||
id: ibeacon_pcx125
|
id: ibeacon_pcx125
|
||||||
ibeacon_uuid: !secret ble_beacon_honda_uuid
|
ibeacon_uuid: !secret ble_beacon_honda_uuid
|
||||||
name: "Vehicle iBeacon Honda PCX125"
|
name: "Vehicle iBeacon Honda PCX125"
|
||||||
timeout: 2min
|
timeout: 2min
|
||||||
on_press:
|
on_press: !include {file: common/gate_beacon_open.yaml, vars: {enable_id: enable_pcx125}}
|
||||||
- if:
|
on_release: !include {file: common/gate_beacon_close.yaml, vars: {enable_id: enable_pcx125}}
|
||||||
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
|
|
||||||
- platform: ble_presence
|
- platform: ble_presence
|
||||||
id: ibeacon_dl650
|
id: ibeacon_dl650
|
||||||
ibeacon_uuid: !secret ble_beacon_suzuki_uuid
|
ibeacon_uuid: !secret ble_beacon_suzuki_uuid
|
||||||
name: "Vehicle iBeacon Suzuki DL650"
|
name: "Vehicle iBeacon Suzuki DL650"
|
||||||
timeout: 2min
|
timeout: 2min
|
||||||
on_press:
|
on_press: !include {file: common/gate_beacon_open.yaml, vars: {enable_id: enable_dl650}}
|
||||||
- if:
|
on_release: !include {file: common/gate_beacon_close.yaml, vars: {enable_id: enable_dl650}}
|
||||||
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
|
|
||||||
- platform: gpio
|
- platform: gpio
|
||||||
id: gate_ogi
|
id: gate_ogi
|
||||||
pin:
|
pin:
|
||||||
@@ -230,53 +144,53 @@ binary_sensor:
|
|||||||
- delayed_on: 10ms
|
- delayed_on: 10ms
|
||||||
entity_category: diagnostic
|
entity_category: diagnostic
|
||||||
on_multi_click:
|
on_multi_click:
|
||||||
- timing:
|
- timing:
|
||||||
- OFF for at least 1500ms
|
- OFF for at least 1500ms
|
||||||
then:
|
then:
|
||||||
- select.set:
|
- select.set:
|
||||||
id: gate_state
|
id: gate_state
|
||||||
option: Closed
|
option: Closed
|
||||||
- logger.log: "OGI OFF => GATE CLOSED"
|
- logger.log: "OGI OFF => GATE CLOSED"
|
||||||
invalid_cooldown: 100ms
|
invalid_cooldown: 100ms
|
||||||
- timing:
|
- timing:
|
||||||
- ON for at least 400ms
|
- ON for at least 400ms
|
||||||
- OFF for at least 400ms
|
- OFF for at least 400ms
|
||||||
- ON for at least 400ms
|
- ON for at least 400ms
|
||||||
- OFF for at least 400ms
|
- OFF for at least 400ms
|
||||||
then:
|
then:
|
||||||
- select.set:
|
- select.set:
|
||||||
id: gate_state
|
id: gate_state
|
||||||
option: Opening
|
option: Opening
|
||||||
- logger.log: "OGI SLOW BLINK => GATE OPENING"
|
- logger.log: "OGI SLOW BLINK => GATE OPENING"
|
||||||
invalid_cooldown: 100ms
|
invalid_cooldown: 100ms
|
||||||
- timing:
|
- timing:
|
||||||
- ON for at most 300ms
|
- ON for at most 300ms
|
||||||
- OFF for at most 300ms
|
- OFF for at most 300ms
|
||||||
- ON for at most 300ms
|
- ON for at most 300ms
|
||||||
- OFF for at most 300ms
|
- OFF for at most 300ms
|
||||||
then:
|
then:
|
||||||
- select.set:
|
- select.set:
|
||||||
id: gate_state
|
id: gate_state
|
||||||
option: Closing
|
option: Closing
|
||||||
- logger.log: "OGI FAST BLINK => GATE CLOSING"
|
- logger.log: "OGI FAST BLINK => GATE CLOSING"
|
||||||
invalid_cooldown: 100ms
|
invalid_cooldown: 100ms
|
||||||
- timing:
|
- timing:
|
||||||
- ON for at least 1500ms
|
- ON for at least 1500ms
|
||||||
then:
|
then:
|
||||||
- select.set:
|
- select.set:
|
||||||
id: gate_state
|
id: gate_state
|
||||||
option: Open
|
option: Open
|
||||||
- logger.log: "OGI ON => GATE OPEN"
|
- logger.log: "OGI ON => GATE OPEN"
|
||||||
invalid_cooldown: 100ms
|
invalid_cooldown: 100ms
|
||||||
|
|
||||||
select:
|
select:
|
||||||
- platform: template
|
- platform: template
|
||||||
name: State
|
name: State
|
||||||
id: gate_state
|
id: gate_state
|
||||||
options:
|
options:
|
||||||
- Open
|
- Open
|
||||||
- Closed
|
- Closed
|
||||||
- Opening
|
- Opening
|
||||||
- Closing
|
- Closing
|
||||||
initial_option: Closed
|
initial_option: Closed
|
||||||
optimistic: true
|
optimistic: true
|
||||||
|
|||||||
@@ -241,7 +241,7 @@ switch:
|
|||||||
number: 5
|
number: 5
|
||||||
# - platform: uart
|
# - platform: uart
|
||||||
# name: Total Heater Power Reset
|
# name: Total Heater Power Reset
|
||||||
# uart_id:
|
# uart_id:
|
||||||
# id: reset_total_heater_power
|
# id: reset_total_heater_power
|
||||||
# data: [0x01, 0x42, 0x80, 0x11]
|
# data: [0x01, 0x42, 0x80, 0x11]
|
||||||
|
|
||||||
@@ -256,7 +256,7 @@ sensor:
|
|||||||
# [22:06:25][D][dallas.sensor:082]: 0xB2041750CF1AFF28 Heating Water (OUT from Heater, TO System)
|
# [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]: 0x960417517301FF28 Hot Water Tank - TOP (Heater)
|
||||||
# address: 0x320417500A93FF28 # 1. broken
|
# address: 0x320417500A93FF28 # 1. broken
|
||||||
# address: 0x67041750F44CFF28 # 2. broken
|
# address: 0x67041750F44CFF28 # 2. broken
|
||||||
address: 0x960417517301FF28 # Hot Water Tank - TOP (Heater)
|
address: 0x960417517301FF28 # Hot Water Tank - TOP (Heater)
|
||||||
name: Heater
|
name: Heater
|
||||||
id: hot_water_heater
|
id: hot_water_heater
|
||||||
@@ -297,7 +297,7 @@ sensor:
|
|||||||
lambda: |-
|
lambda: |-
|
||||||
//# platba za odberne miesto 0,75 1,1
|
//# platba za odberne miesto 0,75 1,1
|
||||||
//# pevna mesacna zlozka tarify 0,15080000 0,1508 * 75 A
|
//# pevna mesacna zlozka tarify 0,15080000 0,1508 * 75 A
|
||||||
|
|
||||||
//## platba za systemove sluzby 0,00629760
|
//## platba za systemove sluzby 0,00629760
|
||||||
//# platba za prevadzku systemu 0,01590000
|
//# platba za prevadzku systemu 0,01590000
|
||||||
//# variabilna zlozka tarify za distribuciu 0,00398400
|
//# variabilna zlozka tarify za distribuciu 0,00398400
|
||||||
@@ -346,7 +346,7 @@ sensor:
|
|||||||
- lambda: return x * (0.001) + 2282;
|
- lambda: return x * (0.001) + 2282;
|
||||||
unit_of_measurement: kWh
|
unit_of_measurement: kWh
|
||||||
icon: mdi:counter
|
icon: mdi:counter
|
||||||
# L2
|
# L2
|
||||||
- platform: pzemac
|
- platform: pzemac
|
||||||
address: 162
|
address: 162
|
||||||
current:
|
current:
|
||||||
@@ -507,4 +507,4 @@ binary_sensor:
|
|||||||
- switch.turn_on: heating_demand
|
- switch.turn_on: heating_demand
|
||||||
on_release:
|
on_release:
|
||||||
then:
|
then:
|
||||||
- switch.turn_off: heating_demand
|
- switch.turn_off: heating_demand
|
||||||
|
|||||||
@@ -10,7 +10,7 @@ esphome:
|
|||||||
friendly_name: ${name}
|
friendly_name: ${name}
|
||||||
area: ${area}
|
area: ${area}
|
||||||
comment: ${comment}
|
comment: ${comment}
|
||||||
|
|
||||||
esp32:
|
esp32:
|
||||||
variant: esp32
|
variant: esp32
|
||||||
framework:
|
framework:
|
||||||
|
|||||||
@@ -29,13 +29,13 @@ i2c:
|
|||||||
psram:
|
psram:
|
||||||
mode: octal
|
mode: octal
|
||||||
speed: 40MHz
|
speed: 40MHz
|
||||||
|
|
||||||
spi:
|
spi:
|
||||||
id: display_qspi
|
id: display_qspi
|
||||||
type: quad
|
type: quad
|
||||||
clk_pin: 47
|
clk_pin: 47
|
||||||
data_pins: [21, 48, 40, 39]
|
data_pins: [21, 48, 40, 39]
|
||||||
|
|
||||||
color:
|
color:
|
||||||
- id: my_red
|
- id: my_red
|
||||||
red: 100%
|
red: 100%
|
||||||
|
|||||||
@@ -28,13 +28,13 @@ i2c:
|
|||||||
psram:
|
psram:
|
||||||
mode: octal
|
mode: octal
|
||||||
speed: 80MHz
|
speed: 80MHz
|
||||||
|
|
||||||
spi:
|
spi:
|
||||||
id: display_qspi
|
id: display_qspi
|
||||||
type: quad
|
type: quad
|
||||||
clk_pin: 47
|
clk_pin: 47
|
||||||
data_pins: [21, 48, 40, 39]
|
data_pins: [21, 48, 40, 39]
|
||||||
|
|
||||||
color:
|
color:
|
||||||
- id: my_red
|
- id: my_red
|
||||||
red: 100%
|
red: 100%
|
||||||
@@ -140,7 +140,7 @@ touchscreen:
|
|||||||
display: main_display
|
display: main_display
|
||||||
i2c_id: touchscreen_bus
|
i2c_id: touchscreen_bus
|
||||||
update_interval: 100ms
|
update_interval: 100ms
|
||||||
# interrupt_pin:
|
# interrupt_pin:
|
||||||
# number: 3
|
# number: 3
|
||||||
# ignore_strapping_warning: true
|
# ignore_strapping_warning: true
|
||||||
calibration:
|
calibration:
|
||||||
@@ -286,4 +286,4 @@ lvgl:
|
|||||||
- homeassistant.action:
|
- homeassistant.action:
|
||||||
action: light.toggle
|
action: light.toggle
|
||||||
data:
|
data:
|
||||||
entity_id: light.mcu_dimmer_exercise_room_fan
|
entity_id: light.mcu_dimmer_exercise_room_fan
|
||||||
|
|||||||
@@ -11,7 +11,6 @@ esphome:
|
|||||||
comment: ${comment}
|
comment: ${comment}
|
||||||
platformio_options:
|
platformio_options:
|
||||||
board_build.flash_mode: dio
|
board_build.flash_mode: dio
|
||||||
includes: ota.h
|
|
||||||
|
|
||||||
esp32:
|
esp32:
|
||||||
variant: esp32s3
|
variant: esp32s3
|
||||||
@@ -27,12 +26,12 @@ esp32:
|
|||||||
|
|
||||||
psram:
|
psram:
|
||||||
mode: octal
|
mode: octal
|
||||||
speed: 80MHz
|
speed: 80MHz
|
||||||
|
|
||||||
packages:
|
packages:
|
||||||
common: !include common/common.yaml
|
common: !include common/common.yaml
|
||||||
|
|
||||||
# PINOUTS: ESP32 Cheap Yellow Display, 4.3", IPS, Capacitive
|
# PINOUTS: ESP32 Cheap Yellow Display, 4.3", IPS, Capacitive
|
||||||
## Display
|
## Display
|
||||||
# R0 GND
|
# R0 GND
|
||||||
# R1 GND
|
# R1 GND
|
||||||
@@ -256,7 +255,7 @@ script:
|
|||||||
# src: solar_power_icon
|
# src: solar_power_icon
|
||||||
# img_recolor: 0xFFF000 #mixes this color with the base image
|
# img_recolor: 0xFFF000 #mixes this color with the base image
|
||||||
# #img_recolor_opa: 100% #opacity defaults to 0% = must set this for recolor to take effect
|
# #img_recolor_opa: 100% #opacity defaults to 0% = must set this for recolor to take effect
|
||||||
# #bg_color: 0xFFFFFF
|
# #bg_color: 0xFFFFFF
|
||||||
# # - lvgl.indicator.line.update:
|
# # - lvgl.indicator.line.update:
|
||||||
# # id: power_meter_input2
|
# # id: power_meter_input2
|
||||||
# # value: !lambda return id(counting_number).state;
|
# # value: !lambda return id(counting_number).state;
|
||||||
@@ -288,7 +287,7 @@ script:
|
|||||||
# src: solar_power_icon
|
# src: solar_power_icon
|
||||||
# img_recolor: 0xFFF000 #mixes this color with the base image
|
# img_recolor: 0xFFF000 #mixes this color with the base image
|
||||||
# #img_recolor_opa: 100% #opacity defaults to 0% = must set this for recolor to take effect
|
# #img_recolor_opa: 100% #opacity defaults to 0% = must set this for recolor to take effect
|
||||||
# #bg_color: 0xFFFFFF
|
# #bg_color: 0xFFFFFF
|
||||||
|
|
||||||
image:
|
image:
|
||||||
- file: mdi:sun-wireless-outline
|
- file: mdi:sun-wireless-outline
|
||||||
@@ -329,7 +328,7 @@ lvgl:
|
|||||||
bg_opa: TRANSP
|
bg_opa: TRANSP
|
||||||
bg_color: 0
|
bg_color: 0
|
||||||
radius: 4
|
radius: 4
|
||||||
pad_all: 2
|
pad_all: 2
|
||||||
- id: details_style
|
- id: details_style
|
||||||
text_font: MONTSERRAT_18
|
text_font: MONTSERRAT_18
|
||||||
align: center
|
align: center
|
||||||
@@ -338,7 +337,7 @@ lvgl:
|
|||||||
bg_opa: TRANSP
|
bg_opa: TRANSP
|
||||||
bg_color: 0
|
bg_color: 0
|
||||||
radius: 4
|
radius: 4
|
||||||
pad_all: 2
|
pad_all: 2
|
||||||
widgets:
|
widgets:
|
||||||
- obj: # Meter
|
- obj: # Meter
|
||||||
height: 240
|
height: 240
|
||||||
@@ -663,4 +662,4 @@ lvgl:
|
|||||||
image_recolor_opa: 100% #opacity defaults to 0% = must set this for recolor to take effect
|
image_recolor_opa: 100% #opacity defaults to 0% = must set this for recolor to take effect
|
||||||
#bg_color: 0xFFFFFF
|
#bg_color: 0xFFFFFF
|
||||||
y: 50
|
y: 50
|
||||||
#x: -60
|
#x: -60
|
||||||
|
|||||||
@@ -27,7 +27,7 @@ time:
|
|||||||
- platform: homeassistant
|
- platform: homeassistant
|
||||||
id: ha_time
|
id: ha_time
|
||||||
timezone: Europe/Bratislava
|
timezone: Europe/Bratislava
|
||||||
on_time_sync:
|
on_time_sync:
|
||||||
- bm8563.write_time
|
- bm8563.write_time
|
||||||
- platform: bm8563
|
- platform: bm8563
|
||||||
id: rtc_time
|
id: rtc_time
|
||||||
@@ -75,9 +75,9 @@ binary_sensor:
|
|||||||
pin:
|
pin:
|
||||||
number: 37
|
number: 37
|
||||||
inverted: true
|
inverted: true
|
||||||
on_press:
|
on_press:
|
||||||
- component.update: m5paper_display
|
- component.update: m5paper_display
|
||||||
on_release:
|
on_release:
|
||||||
- component.update: m5paper_display
|
- component.update: m5paper_display
|
||||||
- platform: gpio
|
- platform: gpio
|
||||||
name: ${name} Button Press
|
name: ${name} Button Press
|
||||||
@@ -100,7 +100,7 @@ binary_sensor:
|
|||||||
x_max: 100
|
x_max: 100
|
||||||
y_min: 0
|
y_min: 0
|
||||||
y_max: 100
|
y_max: 100
|
||||||
on_press:
|
on_press:
|
||||||
# Example of applying the sleep duration and shutting down to the lowest power mode
|
# Example of applying the sleep duration and shutting down to the lowest power mode
|
||||||
- bm8563.apply_sleep_duration
|
- bm8563.apply_sleep_duration
|
||||||
- delay: 1s
|
- delay: 1s
|
||||||
|
|||||||
@@ -21,7 +21,7 @@ esp32:
|
|||||||
variant: esp32
|
variant: esp32
|
||||||
framework:
|
framework:
|
||||||
type: esp-idf
|
type: esp-idf
|
||||||
|
|
||||||
packages:
|
packages:
|
||||||
common: !include common/common.yaml
|
common: !include common/common.yaml
|
||||||
|
|
||||||
@@ -99,7 +99,7 @@ sensor:
|
|||||||
# - lambda: return x * (0.001) + 2282;
|
# - lambda: return x * (0.001) + 2282;
|
||||||
# unit_of_measurement: kWh
|
# unit_of_measurement: kWh
|
||||||
# icon: mdi:counter
|
# icon: mdi:counter
|
||||||
# L2
|
# L2
|
||||||
- platform: pzemac
|
- platform: pzemac
|
||||||
address: 11
|
address: 11
|
||||||
id: pzemac_l2
|
id: pzemac_l2
|
||||||
@@ -224,7 +224,7 @@ button:
|
|||||||
- pzemac.reset_energy: pzemac_l1
|
- pzemac.reset_energy: pzemac_l1
|
||||||
- pzemac.reset_energy: pzemac_l2
|
- pzemac.reset_energy: pzemac_l2
|
||||||
- pzemac.reset_energy: pzemac_l3
|
- pzemac.reset_energy: pzemac_l3
|
||||||
|
|
||||||
time:
|
time:
|
||||||
- platform: homeassistant
|
- platform: homeassistant
|
||||||
id: ha_time
|
id: ha_time
|
||||||
@@ -234,4 +234,4 @@ time:
|
|||||||
then:
|
then:
|
||||||
- pzemac.reset_energy: pzemac_l1
|
- pzemac.reset_energy: pzemac_l1
|
||||||
- pzemac.reset_energy: pzemac_l2
|
- pzemac.reset_energy: pzemac_l2
|
||||||
- pzemac.reset_energy: pzemac_l3
|
- pzemac.reset_energy: pzemac_l3
|
||||||
|
|||||||
10
mcu-nrf-dk.yaml
Normal file
10
mcu-nrf-dk.yaml
Normal file
@@ -0,0 +1,10 @@
|
|||||||
|
esphome:
|
||||||
|
name: mcu-nrf-dk
|
||||||
|
friendly_name: mcu-nrf-dk
|
||||||
|
|
||||||
|
nrf52:
|
||||||
|
board: nrf52840_dk
|
||||||
|
bootloader: adafruit_nrf52_sd140_v7
|
||||||
|
|
||||||
|
# Enable logging
|
||||||
|
logger:
|
||||||
@@ -33,7 +33,7 @@ external_components:
|
|||||||
url: https://github.com/sairon/esphome-nspanel-lovelace-ui
|
url: https://github.com/sairon/esphome-nspanel-lovelace-ui
|
||||||
ref: dev
|
ref: dev
|
||||||
components: [nspanel_lovelace]
|
components: [nspanel_lovelace]
|
||||||
|
|
||||||
packages:
|
packages:
|
||||||
common: !include common/common.yaml
|
common: !include common/common.yaml
|
||||||
|
|
||||||
@@ -63,7 +63,7 @@ api:
|
|||||||
then:
|
then:
|
||||||
- lambda: |-
|
- lambda: |-
|
||||||
id(nspanel_id).upload_tft("${tft_url}");
|
id(nspanel_id).upload_tft("${tft_url}");
|
||||||
|
|
||||||
- service: upload_tft
|
- service: upload_tft
|
||||||
variables:
|
variables:
|
||||||
url: string
|
url: string
|
||||||
@@ -267,7 +267,7 @@ sensor:
|
|||||||
reference_temperature: 25°C
|
reference_temperature: 25°C
|
||||||
reference_resistance: 10kOhm
|
reference_resistance: 10kOhm
|
||||||
name: Temperature
|
name: Temperature
|
||||||
|
|
||||||
- platform: template
|
- platform: template
|
||||||
id: room_temperature_id
|
id: room_temperature_id
|
||||||
|
|
||||||
|
|||||||
@@ -51,7 +51,7 @@ external_components:
|
|||||||
refresh: 0s
|
refresh: 0s
|
||||||
components: [nspanel_lovelace]
|
components: [nspanel_lovelace]
|
||||||
# - source: components
|
# - source: components
|
||||||
|
|
||||||
packages:
|
packages:
|
||||||
common: !include common/common.yaml
|
common: !include common/common.yaml
|
||||||
# common: !include common/common_dev.yaml
|
# common: !include common/common_dev.yaml
|
||||||
@@ -90,7 +90,7 @@ api:
|
|||||||
# then:
|
# then:
|
||||||
# - lambda: |-
|
# - lambda: |-
|
||||||
# id(nspanel_id).upload_tft("${tft_url}");
|
# id(nspanel_id).upload_tft("${tft_url}");
|
||||||
|
|
||||||
# - service: upload_tft
|
# - service: upload_tft
|
||||||
# variables:
|
# variables:
|
||||||
# url: string
|
# url: string
|
||||||
@@ -517,7 +517,7 @@ sensor:
|
|||||||
reference_temperature: 25°C
|
reference_temperature: 25°C
|
||||||
reference_resistance: 10kOhm
|
reference_resistance: 10kOhm
|
||||||
name: Living Room Temperature Entry
|
name: Living Room Temperature Entry
|
||||||
|
|
||||||
- platform: template
|
- platform: template
|
||||||
id: room_temperature_id
|
id: room_temperature_id
|
||||||
|
|
||||||
|
|||||||
@@ -31,7 +31,7 @@ external_components:
|
|||||||
url: https://github.com/sairon/esphome-nspanel-lovelace-ui
|
url: https://github.com/sairon/esphome-nspanel-lovelace-ui
|
||||||
ref: dev
|
ref: dev
|
||||||
components: [nspanel_lovelace]
|
components: [nspanel_lovelace]
|
||||||
|
|
||||||
packages:
|
packages:
|
||||||
common: !include common/common.yaml
|
common: !include common/common.yaml
|
||||||
|
|
||||||
@@ -61,7 +61,7 @@ api:
|
|||||||
then:
|
then:
|
||||||
- lambda: |-
|
- lambda: |-
|
||||||
id(nspanel_id).upload_tft("${tft_url}");
|
id(nspanel_id).upload_tft("${tft_url}");
|
||||||
|
|
||||||
- service: upload_tft
|
- service: upload_tft
|
||||||
variables:
|
variables:
|
||||||
url: string
|
url: string
|
||||||
@@ -294,6 +294,6 @@ sensor:
|
|||||||
reference_temperature: 25°C
|
reference_temperature: 25°C
|
||||||
reference_resistance: 10kOhm
|
reference_resistance: 10kOhm
|
||||||
name: "Living Room Temperature"
|
name: "Living Room Temperature"
|
||||||
|
|
||||||
- platform: template
|
- platform: template
|
||||||
id: room_temperature_id
|
id: room_temperature_id
|
||||||
|
|||||||
@@ -32,13 +32,13 @@ external_components:
|
|||||||
url: https://github.com/sairon/esphome-nspanel-lovelace-ui
|
url: https://github.com/sairon/esphome-nspanel-lovelace-ui
|
||||||
ref: dev
|
ref: dev
|
||||||
components: [nspanel_lovelace]
|
components: [nspanel_lovelace]
|
||||||
|
|
||||||
packages:
|
packages:
|
||||||
common: !include common/common.yaml
|
common: !include common/common.yaml
|
||||||
|
|
||||||
api:
|
api:
|
||||||
# https://github.com/granadaxronos/120-SONG_NOKIA_RTTTL_RINGTONE_PLAYER_FOR_ARDUINO_UNO/blob/master/RTTTL_PLAYER/songs.h
|
# https://github.com/granadaxronos/120-SONG_NOKIA_RTTTL_RINGTONE_PLAYER_FOR_ARDUINO_UNO/blob/master/RTTTL_PLAYER/songs.h
|
||||||
#
|
#
|
||||||
# stupnovane:d=4,o=6,b=180:c,e,g
|
# stupnovane:d=4,o=6,b=180:c,e,g
|
||||||
# help:d=4,o=6,b=100:f,8p,f,8p,f,8p,f,8p,f,8p,f,8p,f,8p,f,8p,f,8p,f
|
# help:d=4,o=6,b=100:f,8p,f,8p,f,8p,f,8p,f,8p,f,8p,f,8p,f,8p,f,8p,f
|
||||||
# gate_opening:d=16,o=5,b=160:a, 8p, a
|
# gate_opening:d=16,o=5,b=160:a, 8p, a
|
||||||
@@ -67,7 +67,7 @@ api:
|
|||||||
then:
|
then:
|
||||||
- lambda: |-
|
- lambda: |-
|
||||||
id(nspanel_id).upload_tft("${tft_url}");
|
id(nspanel_id).upload_tft("${tft_url}");
|
||||||
|
|
||||||
- service: upload_tft
|
- service: upload_tft
|
||||||
variables:
|
variables:
|
||||||
url: string
|
url: string
|
||||||
@@ -299,7 +299,7 @@ sensor:
|
|||||||
# text_sensor:
|
# text_sensor:
|
||||||
# - platform: ble_scanner
|
# - platform: ble_scanner
|
||||||
# name: BLE Scanner
|
# name: BLE Scanner
|
||||||
|
|
||||||
# esp32_ble_beacon:
|
# esp32_ble_beacon:
|
||||||
# type: iBeacon
|
# type: iBeacon
|
||||||
# uuid: '6d68252f-2e6f-b5b9-965f-43c0a3713880'
|
# uuid: '6d68252f-2e6f-b5b9-965f-43c0a3713880'
|
||||||
|
|||||||
@@ -33,7 +33,7 @@ external_components:
|
|||||||
url: https://github.com/sairon/esphome-nspanel-lovelace-ui
|
url: https://github.com/sairon/esphome-nspanel-lovelace-ui
|
||||||
ref: dev
|
ref: dev
|
||||||
components: [nspanel_lovelace]
|
components: [nspanel_lovelace]
|
||||||
|
|
||||||
packages:
|
packages:
|
||||||
common: !include common/common.yaml
|
common: !include common/common.yaml
|
||||||
|
|
||||||
@@ -56,7 +56,7 @@ script:
|
|||||||
|
|
||||||
api:
|
api:
|
||||||
# https://github.com/granadaxronos/120-SONG_NOKIA_RTTTL_RINGTONE_PLAYER_FOR_ARDUINO_UNO/blob/master/RTTTL_PLAYER/songs.h
|
# https://github.com/granadaxronos/120-SONG_NOKIA_RTTTL_RINGTONE_PLAYER_FOR_ARDUINO_UNO/blob/master/RTTTL_PLAYER/songs.h
|
||||||
#
|
#
|
||||||
# stupnovane:d=4,o=6,b=180:c,e,g
|
# stupnovane:d=4,o=6,b=180:c,e,g
|
||||||
# help:d=4,o=6,b=100:f,8p,f,8p,f,8p,f,8p,f,8p,f,8p,f,8p,f,8p,f,8p,f
|
# help:d=4,o=6,b=100:f,8p,f,8p,f,8p,f,8p,f,8p,f,8p,f,8p,f,8p,f,8p,f
|
||||||
# gate_opening:d=16,o=5,b=160:a, 8p, a
|
# gate_opening:d=16,o=5,b=160:a, 8p, a
|
||||||
@@ -86,7 +86,7 @@ api:
|
|||||||
- logger.log: "tft updating from: ${tft_url}"
|
- logger.log: "tft updating from: ${tft_url}"
|
||||||
- lambda: |-
|
- lambda: |-
|
||||||
id(nspanel_id).upload_tft("${tft_url}");
|
id(nspanel_id).upload_tft("${tft_url}");
|
||||||
|
|
||||||
- service: upload_tft
|
- service: upload_tft
|
||||||
variables:
|
variables:
|
||||||
url: string
|
url: string
|
||||||
@@ -356,7 +356,7 @@ sensor:
|
|||||||
# text_sensor:
|
# text_sensor:
|
||||||
# - platform: ble_scanner
|
# - platform: ble_scanner
|
||||||
# name: BLE Scanner
|
# name: BLE Scanner
|
||||||
|
|
||||||
# esp32_ble_beacon:
|
# esp32_ble_beacon:
|
||||||
# type: iBeacon
|
# type: iBeacon
|
||||||
# uuid: '6d68252f-2e6f-b5b9-965f-43c0a3713880'
|
# uuid: '6d68252f-2e6f-b5b9-965f-43c0a3713880'
|
||||||
|
|||||||
@@ -32,7 +32,7 @@ external_components:
|
|||||||
ref: dev
|
ref: dev
|
||||||
components: [nspanel_lovelace]
|
components: [nspanel_lovelace]
|
||||||
- source: components
|
- source: components
|
||||||
|
|
||||||
packages:
|
packages:
|
||||||
common: !include common/common.yaml
|
common: !include common/common.yaml
|
||||||
|
|
||||||
@@ -62,7 +62,7 @@ api:
|
|||||||
then:
|
then:
|
||||||
- lambda: |-
|
- lambda: |-
|
||||||
id(nspanel_id).upload_tft("${tft_url}");
|
id(nspanel_id).upload_tft("${tft_url}");
|
||||||
|
|
||||||
- service: upload_tft
|
- service: upload_tft
|
||||||
variables:
|
variables:
|
||||||
url: string
|
url: string
|
||||||
@@ -235,7 +235,7 @@ switch:
|
|||||||
entity_category: config
|
entity_category: config
|
||||||
pin:
|
pin:
|
||||||
number: 19
|
number: 19
|
||||||
|
|
||||||
- platform: gpio
|
- platform: gpio
|
||||||
name: Screen Power
|
name: Screen Power
|
||||||
id: screen_power
|
id: screen_power
|
||||||
@@ -270,6 +270,6 @@ sensor:
|
|||||||
reference_temperature: 25°C
|
reference_temperature: 25°C
|
||||||
reference_resistance: 10kOhm
|
reference_resistance: 10kOhm
|
||||||
name: Living Room Temperature
|
name: Living Room Temperature
|
||||||
|
|
||||||
- platform: template
|
- platform: template
|
||||||
id: room_temperature_id
|
id: room_temperature_id
|
||||||
|
|||||||
@@ -3,7 +3,7 @@ substitutions:
|
|||||||
name: Office R
|
name: Office R
|
||||||
area: Office R
|
area: Office R
|
||||||
comment: "${area} | MS Teams presence"
|
comment: "${area} | MS Teams presence"
|
||||||
|
|
||||||
esphome:
|
esphome:
|
||||||
name: mcu-${device}
|
name: mcu-${device}
|
||||||
friendly_name: ${name}
|
friendly_name: ${name}
|
||||||
@@ -54,4 +54,4 @@ output:
|
|||||||
pin: 5
|
pin: 5
|
||||||
- platform: ledc
|
- platform: ledc
|
||||||
id: led_blue
|
id: led_blue
|
||||||
pin: 6
|
pin: 6
|
||||||
|
|||||||
@@ -3,7 +3,7 @@ substitutions:
|
|||||||
name: Patio
|
name: Patio
|
||||||
area: Outside
|
area: Outside
|
||||||
comment: "${area}, Patio | On the back yard"
|
comment: "${area}, Patio | On the back yard"
|
||||||
|
|
||||||
esphome:
|
esphome:
|
||||||
name: mcu-${device}
|
name: mcu-${device}
|
||||||
friendly_name: ${name}
|
friendly_name: ${name}
|
||||||
|
|||||||
@@ -16,24 +16,14 @@ esp32:
|
|||||||
advanced:
|
advanced:
|
||||||
minimum_chip_revision: "3.1"
|
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:
|
packages:
|
||||||
common: !include common/common.yaml
|
common: !include common/common.yaml
|
||||||
|
|
||||||
uart:
|
uart:
|
||||||
rx_pin: 16
|
- id: cse7766_uart
|
||||||
baud_rate: 4800
|
rx_pin: 16
|
||||||
parity: EVEN
|
baud_rate: 4800
|
||||||
|
parity: EVEN
|
||||||
|
|
||||||
binary_sensor:
|
binary_sensor:
|
||||||
- platform: gpio
|
- platform: gpio
|
||||||
@@ -92,7 +82,7 @@ display:
|
|||||||
it.display_kwh(false);
|
it.display_kwh(false);
|
||||||
it.printf(0, "%.1f", id(v_sensor).state);
|
it.printf(0, "%.1f", id(v_sensor).state);
|
||||||
it.printf(1, "%.1f", id(a_sensor).state);
|
it.printf(1, "%.1f", id(a_sensor).state);
|
||||||
} else {
|
} else {
|
||||||
it.display_voltage(false);
|
it.display_voltage(false);
|
||||||
it.display_kwh(true);
|
it.display_kwh(true);
|
||||||
it.printf(0, "%.1f", id(wh_sensor).state);
|
it.printf(0, "%.1f", id(wh_sensor).state);
|
||||||
@@ -120,6 +110,7 @@ output:
|
|||||||
|
|
||||||
sensor:
|
sensor:
|
||||||
- platform: cse7766
|
- platform: cse7766
|
||||||
|
uart_id: cse7766_uart
|
||||||
current:
|
current:
|
||||||
name: Current
|
name: Current
|
||||||
id: a_sensor
|
id: a_sensor
|
||||||
@@ -143,10 +134,15 @@ sensor:
|
|||||||
then:
|
then:
|
||||||
- light.turn_off: switch_led
|
- light.turn_off: switch_led
|
||||||
energy:
|
energy:
|
||||||
name: Energy"
|
name: Energy
|
||||||
id: wh_sensor
|
id: wh_sensor
|
||||||
filters:
|
filters:
|
||||||
- throttle_average: ${update_interval}
|
- throttle_average: ${update_interval}
|
||||||
|
power_factor:
|
||||||
|
name: Power Factor
|
||||||
|
id: power_factor
|
||||||
|
filters:
|
||||||
|
- throttle_average: ${update_interval}
|
||||||
|
|
||||||
- platform: total_daily_energy
|
- platform: total_daily_energy
|
||||||
name: Total Daily Energy
|
name: Total Daily Energy
|
||||||
@@ -155,12 +151,6 @@ sensor:
|
|||||||
- multiply: 0.001
|
- multiply: 0.001
|
||||||
unit_of_measurement: kWh
|
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:
|
switch:
|
||||||
- platform: template
|
- platform: template
|
||||||
name: Relay
|
name: Relay
|
||||||
@@ -180,7 +170,6 @@ switch:
|
|||||||
on_turn_on:
|
on_turn_on:
|
||||||
- delay: 500ms
|
- delay: 500ms
|
||||||
- switch.turn_off: relay_on # bi-stable relay so no need to keep on
|
- switch.turn_off: relay_on # bi-stable relay so no need to keep on
|
||||||
- light.turn_on: switch_led
|
|
||||||
interlock: [relay_off]
|
interlock: [relay_off]
|
||||||
|
|
||||||
- platform: gpio
|
- platform: gpio
|
||||||
@@ -191,8 +180,7 @@ switch:
|
|||||||
on_turn_on:
|
on_turn_on:
|
||||||
- delay: 500ms
|
- delay: 500ms
|
||||||
- switch.turn_off: relay_off # bi-stable relay so no need to keep on
|
- switch.turn_off: relay_off # bi-stable relay so no need to keep on
|
||||||
- light.turn_off: switch_led
|
|
||||||
interlock: [relay_on]
|
interlock: [relay_on]
|
||||||
|
|
||||||
time:
|
time:
|
||||||
- !include common/time/homeassistant.yaml
|
- !include common/time/homeassistant.yaml
|
||||||
|
|||||||
@@ -16,24 +16,14 @@ esp32:
|
|||||||
advanced:
|
advanced:
|
||||||
minimum_chip_revision: "3.1"
|
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:
|
packages:
|
||||||
common: !include common/common.yaml
|
common: !include common/common.yaml
|
||||||
|
|
||||||
uart:
|
uart:
|
||||||
rx_pin: 16
|
- id: cse7766_uart
|
||||||
baud_rate: 4800
|
rx_pin: 16
|
||||||
parity: EVEN
|
baud_rate: 4800
|
||||||
|
parity: EVEN
|
||||||
|
|
||||||
binary_sensor:
|
binary_sensor:
|
||||||
- platform: gpio
|
- platform: gpio
|
||||||
@@ -92,7 +82,7 @@ display:
|
|||||||
it.display_kwh(false);
|
it.display_kwh(false);
|
||||||
it.printf(0, "%.1f", id(v_sensor).state);
|
it.printf(0, "%.1f", id(v_sensor).state);
|
||||||
it.printf(1, "%.1f", id(a_sensor).state);
|
it.printf(1, "%.1f", id(a_sensor).state);
|
||||||
} else {
|
} else {
|
||||||
it.display_voltage(false);
|
it.display_voltage(false);
|
||||||
it.display_kwh(true);
|
it.display_kwh(true);
|
||||||
it.printf(0, "%.1f", id(wh_sensor).state);
|
it.printf(0, "%.1f", id(wh_sensor).state);
|
||||||
@@ -120,6 +110,7 @@ output:
|
|||||||
|
|
||||||
sensor:
|
sensor:
|
||||||
- platform: cse7766
|
- platform: cse7766
|
||||||
|
uart_id: cse7766_uart
|
||||||
current:
|
current:
|
||||||
name: Current
|
name: Current
|
||||||
id: a_sensor
|
id: a_sensor
|
||||||
@@ -147,6 +138,11 @@ sensor:
|
|||||||
id: wh_sensor
|
id: wh_sensor
|
||||||
filters:
|
filters:
|
||||||
- throttle_average: ${update_interval}
|
- throttle_average: ${update_interval}
|
||||||
|
power_factor:
|
||||||
|
name: Power Factor
|
||||||
|
id: power_factor
|
||||||
|
filters:
|
||||||
|
- throttle_average: ${update_interval}
|
||||||
|
|
||||||
- platform: total_daily_energy
|
- platform: total_daily_energy
|
||||||
name: Total Daily Energy
|
name: Total Daily Energy
|
||||||
@@ -155,12 +151,6 @@ sensor:
|
|||||||
- multiply: 0.001
|
- multiply: 0.001
|
||||||
unit_of_measurement: kWh
|
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:
|
switch:
|
||||||
- platform: template
|
- platform: template
|
||||||
name: Relay
|
name: Relay
|
||||||
@@ -180,7 +170,6 @@ switch:
|
|||||||
on_turn_on:
|
on_turn_on:
|
||||||
- delay: 500ms
|
- delay: 500ms
|
||||||
- switch.turn_off: relay_on # bi-stable relay so no need to keep on
|
- switch.turn_off: relay_on # bi-stable relay so no need to keep on
|
||||||
- light.turn_on: switch_led
|
|
||||||
interlock: [relay_off]
|
interlock: [relay_off]
|
||||||
|
|
||||||
- platform: gpio
|
- platform: gpio
|
||||||
@@ -191,8 +180,7 @@ switch:
|
|||||||
on_turn_on:
|
on_turn_on:
|
||||||
- delay: 500ms
|
- delay: 500ms
|
||||||
- switch.turn_off: relay_off # bi-stable relay so no need to keep on
|
- switch.turn_off: relay_off # bi-stable relay so no need to keep on
|
||||||
- light.turn_off: switch_led
|
|
||||||
interlock: [relay_on]
|
interlock: [relay_on]
|
||||||
|
|
||||||
time:
|
time:
|
||||||
- !include common/time/homeassistant.yaml
|
- !include common/time/homeassistant.yaml
|
||||||
|
|||||||
@@ -73,4 +73,4 @@ status_led:
|
|||||||
# rc_switch_raw:
|
# rc_switch_raw:
|
||||||
# code: '100000000001010000000010'
|
# code: '100000000001010000000010'
|
||||||
# protocol: 1
|
# protocol: 1
|
||||||
# repeat: 3
|
# repeat: 3
|
||||||
|
|||||||
@@ -108,4 +108,4 @@ switch:
|
|||||||
mode: OUTPUT
|
mode: OUTPUT
|
||||||
|
|
||||||
time:
|
time:
|
||||||
- !include common/time/homeassistant.yaml
|
- !include common/time/homeassistant.yaml
|
||||||
|
|||||||
@@ -72,7 +72,7 @@ light:
|
|||||||
name: Blue LED
|
name: Blue LED
|
||||||
id: light_blue
|
id: light_blue
|
||||||
output: led_blue
|
output: led_blue
|
||||||
|
|
||||||
sensor:
|
sensor:
|
||||||
- platform: hlw8012
|
- platform: hlw8012
|
||||||
sel_pin:
|
sel_pin:
|
||||||
|
|||||||
@@ -74,7 +74,7 @@ output:
|
|||||||
pin: GPIO02
|
pin: GPIO02
|
||||||
id: led_blue
|
id: led_blue
|
||||||
inverted: True
|
inverted: True
|
||||||
|
|
||||||
sensor:
|
sensor:
|
||||||
- platform: hlw8012
|
- platform: hlw8012
|
||||||
sel_pin:
|
sel_pin:
|
||||||
|
|||||||
@@ -59,7 +59,7 @@ binary_sensor:
|
|||||||
- delay: 10s
|
- delay: 10s
|
||||||
- switch.turn_off: relay
|
- switch.turn_off: relay
|
||||||
- light.turn_off: light_blue
|
- light.turn_off: light_blue
|
||||||
|
|
||||||
output:
|
output:
|
||||||
- platform: gpio
|
- platform: gpio
|
||||||
pin: GPIO00
|
pin: GPIO00
|
||||||
@@ -79,7 +79,7 @@ light:
|
|||||||
name: Blue LED
|
name: Blue LED
|
||||||
id: light_blue
|
id: light_blue
|
||||||
output: led_blue
|
output: led_blue
|
||||||
|
|
||||||
sensor:
|
sensor:
|
||||||
- platform: hlw8012
|
- platform: hlw8012
|
||||||
sel_pin:
|
sel_pin:
|
||||||
|
|||||||
@@ -32,7 +32,7 @@ packages:
|
|||||||
|
|
||||||
logger:
|
logger:
|
||||||
logs:
|
logs:
|
||||||
component: ERROR
|
component: ERROR
|
||||||
|
|
||||||
# GPIO1 UART TX
|
# GPIO1 UART TX
|
||||||
# GPIO3 UART RX
|
# GPIO3 UART RX
|
||||||
|
|||||||
@@ -9,7 +9,7 @@ esphome:
|
|||||||
comment: ${comment}
|
comment: ${comment}
|
||||||
on_boot:
|
on_boot:
|
||||||
# priority: -10
|
# priority: -10
|
||||||
priority: 600
|
priority: 600
|
||||||
then:
|
then:
|
||||||
- logger.log: turning modem off
|
- logger.log: turning modem off
|
||||||
- binary_sensor.template.publish:
|
- binary_sensor.template.publish:
|
||||||
@@ -33,7 +33,7 @@ esphome:
|
|||||||
state: ON
|
state: ON
|
||||||
# - switch.turn_on: cmd_gnss_enable
|
# - switch.turn_on: cmd_gnss_enable
|
||||||
# on_boot:
|
# on_boot:
|
||||||
# priority: 600
|
# priority: 600
|
||||||
# then:
|
# then:
|
||||||
# # https://www.manualslib.com/manual/1498555/Simcom-Sim7000g.html?page=25#manual
|
# # https://www.manualslib.com/manual/1498555/Simcom-Sim7000g.html?page=25#manual
|
||||||
# - logger.log: turning modem off
|
# - logger.log: turning modem off
|
||||||
@@ -42,7 +42,7 @@ esphome:
|
|||||||
# state: OFF
|
# state: OFF
|
||||||
# # The doc says that pulling 'modem_power' to ground works,
|
# # The doc says that pulling 'modem_power' to ground works,
|
||||||
# # But I had to put if off for 2.6s, then on ?
|
# # But I had to put if off for 2.6s, then on ?
|
||||||
# - switch.turn_off: modem_powerkey
|
# - switch.turn_off: modem_powerkey
|
||||||
# - delay: 2.6s
|
# - delay: 2.6s
|
||||||
# - switch.turn_on: modem_powerkey
|
# - switch.turn_on: modem_powerkey
|
||||||
# - logger.log: waiting off status
|
# - logger.log: waiting off status
|
||||||
@@ -99,8 +99,7 @@ external_components:
|
|||||||
components: [ network, modem ]
|
components: [ network, modem ]
|
||||||
- source: github://pr#9802
|
- source: github://pr#9802
|
||||||
components: [ modem ]
|
components: [ modem ]
|
||||||
- source: components
|
|
||||||
|
|
||||||
# packages:
|
# packages:
|
||||||
# common: !include common/common.yaml
|
# common: !include common/common.yaml
|
||||||
|
|
||||||
@@ -168,7 +167,7 @@ sensor:
|
|||||||
name: Longitude
|
name: Longitude
|
||||||
altitude:
|
altitude:
|
||||||
name: Altitude
|
name: Altitude
|
||||||
|
|
||||||
switch:
|
switch:
|
||||||
- platform: gpio
|
- platform: gpio
|
||||||
id: modem_powerkey
|
id: modem_powerkey
|
||||||
@@ -273,31 +272,31 @@ text_sensor:
|
|||||||
# parts.push_back(data.substr(0, pos));
|
# parts.push_back(data.substr(0, pos));
|
||||||
# data.erase(0, pos + delimiter.length());
|
# data.erase(0, pos + delimiter.length());
|
||||||
# }
|
# }
|
||||||
# parts.push_back(data);
|
# parts.push_back(data);
|
||||||
|
|
||||||
# if (parts.size() < 14) {
|
# if (parts.size() < 14) {
|
||||||
# return { "Invalid GNSS data: " + gnss_info };
|
# return { "Invalid GNSS data: " + gnss_info };
|
||||||
# }
|
# }
|
||||||
|
|
||||||
# std::string latitude = parts[4];
|
# std::string latitude = parts[4];
|
||||||
# std::string lat_direction = parts[5];
|
# std::string lat_direction = parts[5];
|
||||||
# std::string longitude = parts[6];
|
# std::string longitude = parts[6];
|
||||||
# std::string lon_direction = parts[7];
|
# std::string lon_direction = parts[7];
|
||||||
|
|
||||||
# if (latitude.empty() || lat_direction.empty() || longitude.empty() || lon_direction.empty()) {
|
# if (latitude.empty() || lat_direction.empty() || longitude.empty() || lon_direction.empty()) {
|
||||||
# return { "Invalid GNSS data: " + gnss_info };
|
# return { "Invalid GNSS data: " + gnss_info };
|
||||||
# }
|
# }
|
||||||
|
|
||||||
# double lat_deg = std::stod(latitude.substr(0, 2));
|
# double lat_deg = std::stod(latitude.substr(0, 2));
|
||||||
# double lat_min = std::stod(latitude.substr(2));
|
# double lat_min = std::stod(latitude.substr(2));
|
||||||
# double lat = lat_deg + (lat_min / 60.0);
|
# double lat = lat_deg + (lat_min / 60.0);
|
||||||
# if (lat_direction == "S") lat = -lat;
|
# if (lat_direction == "S") lat = -lat;
|
||||||
|
|
||||||
# double lon_deg = std::stod(longitude.substr(0, 3));
|
# double lon_deg = std::stod(longitude.substr(0, 3));
|
||||||
# double lon_min = std::stod(longitude.substr(3));
|
# double lon_min = std::stod(longitude.substr(3));
|
||||||
# double lon = lon_deg + (lon_min / 60.0);
|
# double lon = lon_deg + (lon_min / 60.0);
|
||||||
# if (lon_direction == "W") lon = -lon;
|
# if (lon_direction == "W") lon = -lon;
|
||||||
|
|
||||||
# std::string google_maps_link = "https://www.google.com/maps/search/?api=1&query=" + std::to_string(lat) + "," + std::to_string(lon);
|
# std::string google_maps_link = "https://www.google.com/maps/search/?api=1&query=" + std::to_string(lat) + "," + std::to_string(lon);
|
||||||
# return { google_maps_link };
|
# return { google_maps_link };
|
||||||
|
|
||||||
@@ -317,7 +316,7 @@ text_sensor:
|
|||||||
# url: https://github.com/ssieb/custom_components
|
# url: https://github.com/ssieb/custom_components
|
||||||
# components: [ serial ]
|
# components: [ serial ]
|
||||||
# - source: components
|
# - source: components
|
||||||
|
|
||||||
# packages:
|
# packages:
|
||||||
# common: !include common/common.yaml
|
# common: !include common/common.yaml
|
||||||
|
|
||||||
@@ -475,4 +474,4 @@ text_sensor:
|
|||||||
# name: USSD Code
|
# name: USSD Code
|
||||||
# - platform: serial
|
# - platform: serial
|
||||||
# uart_id: modem_uart
|
# uart_id: modem_uart
|
||||||
# id: modem_read
|
# id: modem_read
|
||||||
|
|||||||
@@ -23,7 +23,7 @@ packages:
|
|||||||
# B GPIO12 PWM3
|
# B GPIO12 PWM3
|
||||||
# W1 GPIO14 PWM4
|
# W1 GPIO14 PWM4
|
||||||
# W2 GPIO04 PWM5
|
# W2 GPIO04 PWM5
|
||||||
# LED D1 R GPIO05
|
# LED D1 R GPIO05
|
||||||
# LED D2 G GPIO01
|
# LED D2 G GPIO01
|
||||||
|
|
||||||
light:
|
light:
|
||||||
@@ -42,7 +42,7 @@ light:
|
|||||||
name: Slow Strobe
|
name: Slow Strobe
|
||||||
- strobe:
|
- strobe:
|
||||||
name: Fast Strobe
|
name: Fast Strobe
|
||||||
colors:
|
colors:
|
||||||
- state: true
|
- state: true
|
||||||
duration: 100ms
|
duration: 100ms
|
||||||
- state: false
|
- state: false
|
||||||
@@ -63,4 +63,4 @@ output:
|
|||||||
pin: GPIO14
|
pin: GPIO14
|
||||||
- platform: esp8266_pwm
|
- platform: esp8266_pwm
|
||||||
id: pwm_warm_white
|
id: pwm_warm_white
|
||||||
pin: GPIO04
|
pin: GPIO04
|
||||||
|
|||||||
@@ -9,127 +9,13 @@ esphome:
|
|||||||
friendly_name: ${name}
|
friendly_name: ${name}
|
||||||
area: ${area}
|
area: ${area}
|
||||||
comment: ${comment}
|
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:
|
packages:
|
||||||
common: !include common/logger.yaml
|
base: !include common/vehicle_base.yaml
|
||||||
# common: !include common/common.yaml
|
logger: !include common/logger.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
|
|
||||||
|
|
||||||
esp32_ble_beacon:
|
esp32_ble_beacon:
|
||||||
type: iBeacon
|
type: iBeacon
|
||||||
uuid: !secret ble_beacon_honda_uuid
|
uuid: !secret ble_beacon_honda_uuid
|
||||||
major: !secret ble_beacon_honda_major
|
major: !secret ble_beacon_honda_major
|
||||||
minor: !secret ble_beacon_honda_minor
|
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;
|
|
||||||
@@ -9,127 +9,13 @@ esphome:
|
|||||||
friendly_name: ${name}
|
friendly_name: ${name}
|
||||||
area: ${area}
|
area: ${area}
|
||||||
comment: ${comment}
|
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:
|
packages:
|
||||||
common: !include common/logger.yaml
|
base: !include common/vehicle_base.yaml
|
||||||
# common: !include common/common.yaml
|
logger: !include common/logger.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
|
|
||||||
|
|
||||||
esp32_ble_beacon:
|
esp32_ble_beacon:
|
||||||
type: iBeacon
|
type: iBeacon
|
||||||
uuid: !secret ble_beacon_suzuki_uuid
|
uuid: !secret ble_beacon_suzuki_uuid
|
||||||
major: !secret ble_beacon_suzuki_major
|
major: !secret ble_beacon_suzuki_major
|
||||||
minor: !secret ble_beacon_suzuki_minor
|
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;
|
|
||||||
@@ -16,69 +16,12 @@ esphome:
|
|||||||
- binary_sensor.is_off: button
|
- binary_sensor.is_off: button
|
||||||
then:
|
then:
|
||||||
- wifi.disable:
|
- 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:
|
packages:
|
||||||
|
base: !include common/vehicle_base.yaml
|
||||||
wifi: !include common/wifi.yaml
|
wifi: !include common/wifi.yaml
|
||||||
logger: !include common/logger.yaml
|
logger: !include common/logger.yaml
|
||||||
# api: !include common/api.yaml
|
|
||||||
ota: !include common/ota.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:
|
binary_sensor:
|
||||||
- platform: gpio
|
- platform: gpio
|
||||||
@@ -92,63 +35,3 @@ esp32_ble_beacon:
|
|||||||
uuid: !secret ble_beacon_toyota_auris_uuid
|
uuid: !secret ble_beacon_toyota_auris_uuid
|
||||||
major: !secret ble_beacon_toyota_auris_major
|
major: !secret ble_beacon_toyota_auris_major
|
||||||
minor: !secret ble_beacon_toyota_auris_minor
|
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;
|
|
||||||
@@ -9,128 +9,13 @@ esphome:
|
|||||||
friendly_name: ${name}
|
friendly_name: ${name}
|
||||||
area: ${area}
|
area: ${area}
|
||||||
comment: ${comment}
|
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:
|
packages:
|
||||||
common: !include common/logger.yaml
|
base: !include common/vehicle_base.yaml
|
||||||
# wifi: !include common/wifi.yaml
|
logger: !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
|
|
||||||
|
|
||||||
esp32_ble_beacon:
|
esp32_ble_beacon:
|
||||||
type: iBeacon
|
type: iBeacon
|
||||||
uuid: !secret ble_beacon_toyota_yaris_uuid
|
uuid: !secret ble_beacon_toyota_yaris_uuid
|
||||||
major: !secret ble_beacon_toyota_yaris_major
|
major: !secret ble_beacon_toyota_yaris_major
|
||||||
minor: !secret ble_beacon_toyota_yaris_minor
|
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;
|
|
||||||
|
|||||||
@@ -289,4 +289,4 @@ valve:
|
|||||||
- switch.turn_off: irrigation_relay_8
|
- switch.turn_off: irrigation_relay_8
|
||||||
|
|
||||||
time:
|
time:
|
||||||
- !include common/time/homeassistant.yaml
|
- !include common/time/homeassistant.yaml
|
||||||
|
|||||||
@@ -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);
|
|
||||||
|
|
||||||
}
|
|
||||||
};
|
|
||||||
Reference in New Issue
Block a user