config files on 28-11-2023 12:46:43

This commit is contained in:
2023-11-28 12:46:43 +01:00
parent 9cc6076da0
commit 423d32fada
101 changed files with 167879 additions and 3008 deletions

View File

@@ -15,8 +15,8 @@ substitutions:
pin_scl: GPIO22
pin_pm_rx: GPIO18
pin_pm_tx: GPIO19
pin_ld_tx: GPIO17
pin_ld_rx: GPIO16
pin_ld_tx: GPIO16
pin_ld_rx: GPIO17
pin_leds: GPIO23
packages:
@@ -26,9 +26,9 @@ packages:
connection: !include common/wifi.yaml
status: !include templates/status.yaml
logger: !include templates/nologger.yaml
bt_proxy: !include templates/ble_proxy.yaml
#bt_proxy: !include common/bluetooth.yaml
#sensors
# mmwave: !include sensors/ld2420.yaml
#mmwave: !include sensors/ld2420.yaml
pmsc: !include sensors/pmsx0003.yaml
co2: !include sensors/scd30.yaml
tvoc: !include sensors/sgp30.yaml

View File

@@ -25,12 +25,11 @@ packages:
connection: !include common/wifi.yaml
status: !include templates/status.yaml
logger: !include templates/nologger.yaml
bt_proxy: !include templates/ble_proxy.yaml
bt_proxy: !include common/bluetooth.yaml
#sensors
mmwave: !include sensors/ld2410.yaml
#mmwave: !include sensors/ld2410.yaml
pms: !include sensors/pm1006.yaml
co2: !include sensors/scd30.yaml
tvoc: !include sensors/sgp30.yaml
pir: !include sensors/pir_raw.yaml
sensor_wifi: !include sensors/wifi.yaml
#pir: !include sensors/pir_raw.yaml

5
esphome/boards/esp32-C3.yaml Executable file
View File

@@ -0,0 +1,5 @@
---
esp32:
board: esp32-c3-devkitm-1
framework:
type: arduino

View File

@@ -0,0 +1,4 @@
esp32:
board: m5stack-core-esp32
framework:
type: arduino

View File

@@ -0,0 +1,5 @@
---
esp32:
board: lolin_d32
framework:
type: arduino

View File

@@ -1,9 +1,23 @@
---
esp32_ble_tracker:
scan_parameters:
interval: 1100ms # default 320ms
window: 1100ms # default 30ms
active: true
# esp32_ble_tracker:
# scan_parameters:
# interval: 1100ms # default 320ms
# window: 1100ms # default 30ms
# active: true
bluetooth_proxy:
active: true
# binary_sensor:
# - platform: ble_presence
# mac_address: C8:B8:49:1F:07:7C
# name: "BLE tracker 1"
# sensor:
# - platform: ble_rssi
# mac_address: C8:B8:49:1F:07:7C
# name: "BLE tracker 1"
# text_sensor:
# - platform: ble_scanner
# name: "BLE Devices Scanner"

View File

@@ -1,4 +1,9 @@
---
esphome:
name: ${device_name}
comment: ${comment}
friendly_name: ${friendly_name}
button:
- platform: restart
name: 'Restart'

View File

@@ -3,17 +3,26 @@ deep_sleep:
id: deep_sleep_control
run_duration: ${run_duration}
sleep_duration: ${sleep_duration}
wakeup_pin:
number: ${pin_wake}
inverted: true
mode:
input: true
# pullup: true
# Wake Button
binary_sensor:
- platform: gpio
name: '${device_name} Wake Button'
pin: ${pin_wake}
internal: true
setup_priority: 1000
- platform: homeassistant
entity_id: input_boolean.esphome_global_prevent_deepsleep
id: prevent_deep_sleep
mqtt:
broker: ${mqtt_broker_ip}
username: ${mqtt_broker_user}
password: ${mqtt_broker_pass}
discovery: true
discovery_retain: true
birth_message:
will_message:
on_message:
- topic: ${mqtt_ota_topic}
payload: 'ON'
then:
- logger.log: 'OTA Mode ON - Deep sleep DISABLED'
- deep_sleep.prevent: deep_sleep_control

View File

@@ -0,0 +1,31 @@
---
deep_sleep:
id: deep_sleep_control
run_duration: ${run_duration}
sleep_duration: ${sleep_duration}
wakeup_pin:
number: ${pin_wake}
inverted: true
wakeup_pin_mode: KEEP_AWAKE
binary_sensor:
- platform: homeassistant
entity_id: input_boolean.esphome_global_prevent_deepsleep
id: prevent_deep_sleep
mqtt:
broker: ${mqtt_broker_ip}
username: ${mqtt_broker_user}
password: ${mqtt_broker_pass}
discovery: true
discovery_retain: true
birth_message:
will_message:
on_message:
- topic: ${mqtt_ota_topic}
payload: 'ON'
then:
- logger.log: 'OTA Mode ON - Deep sleep DISABLED'
- deep_sleep.prevent: deep_sleep_control

View File

@@ -10,7 +10,7 @@ ota:
wifi:
ssid: ${wifi_ssid}
password: ${wifi_password}
fast_connect: True
manual_ip:
static_ip: ${ip}
gateway: ${gateway}
@@ -27,25 +27,25 @@ captive_portal:
sensor:
- platform: wifi_signal
name: "${device_name} WiFi Signal "
name: "WiFi Signal "
update_interval: 10s
text_sensor:
- platform: wifi_info
ssid:
name: "${device_name} Connected SSID"
name: "Connected SSID"
id: ssid
icon: mdi:wifi-strength-2
entity_category: diagnostic
bssid:
name: "${device_name} Connected BSSID"
name: "Connected BSSID"
id: bssid
icon: mdi:wifi-strength-2
entity_category: diagnostic
mac_address:
name: "${device_name} WiFi Mac Address"
name: "WiFi Mac Address"
id: macaddress
icon: mdi:wifi-strength-2
entity_category: diagnostic

View File

@@ -0,0 +1,156 @@
import esphome.codegen as cg
import esphome.config_validation as cv
from esphome import core, pins
from esphome.components import display, spi
from esphome.const import (
CONF_BUSY_PIN,
CONF_DC_PIN,
CONF_FULL_UPDATE_EVERY,
CONF_ID,
CONF_LAMBDA,
CONF_MODEL,
CONF_PAGES,
CONF_RESET_DURATION,
CONF_RESET_PIN,
)
DEPENDENCIES = ["spi"]
waveshare_epaper_ns = cg.esphome_ns.namespace("waveshare_epaper")
WaveshareEPaper = waveshare_epaper_ns.class_(
"WaveshareEPaper", cg.PollingComponent, spi.SPIDevice, display.DisplayBuffer
)
WaveshareEPaperTypeA = waveshare_epaper_ns.class_(
"WaveshareEPaperTypeA", WaveshareEPaper
)
WaveshareEPaper2P7In = waveshare_epaper_ns.class_(
"WaveshareEPaper2P7In", WaveshareEPaper
)
WaveshareEPaper2P9InB = waveshare_epaper_ns.class_(
"WaveshareEPaper2P9InB", WaveshareEPaper
)
WaveshareEPaper4P2In = waveshare_epaper_ns.class_(
"WaveshareEPaper4P2In", WaveshareEPaper
)
WaveshareEPaper4P2InBV2 = waveshare_epaper_ns.class_(
"WaveshareEPaper4P2InBV2", WaveshareEPaper
)
WaveshareEPaper5P8In = waveshare_epaper_ns.class_(
"WaveshareEPaper5P8In", WaveshareEPaper
)
WaveshareEPaper7P5In = waveshare_epaper_ns.class_(
"WaveshareEPaper7P5In", WaveshareEPaper
)
WaveshareEPaper7P5InBC = waveshare_epaper_ns.class_(
"WaveshareEPaper7P5InBC", WaveshareEPaper
)
WaveshareEPaper7P5InBV2 = waveshare_epaper_ns.class_(
"WaveshareEPaper7P5InBV2", WaveshareEPaper
)
WaveshareEPaper7P5InV2 = waveshare_epaper_ns.class_(
"WaveshareEPaper7P5InV2", WaveshareEPaper
)
WaveshareEPaper7P5InV2alt = waveshare_epaper_ns.class_(
"WaveshareEPaper7P5InV2alt", WaveshareEPaper
)
WaveshareEPaper7P5InHDB = waveshare_epaper_ns.class_(
"WaveshareEPaper7P5InHDB", WaveshareEPaper
)
WaveshareEPaper2P13InDKE = waveshare_epaper_ns.class_(
"WaveshareEPaper2P13InDKE", WaveshareEPaper
)
WaveshareEPaperTypeAModel = waveshare_epaper_ns.enum("WaveshareEPaperTypeAModel")
WaveshareEPaperTypeBModel = waveshare_epaper_ns.enum("WaveshareEPaperTypeBModel")
MODELS = {
"1.54in": ("a", WaveshareEPaperTypeAModel.WAVESHARE_EPAPER_1_54_IN),
"1.54inv2": ("a", WaveshareEPaperTypeAModel.WAVESHARE_EPAPER_1_54_IN_V2),
"2.13in": ("a", WaveshareEPaperTypeAModel.WAVESHARE_EPAPER_2_13_IN),
"2.13in-ttgo": ("a", WaveshareEPaperTypeAModel.TTGO_EPAPER_2_13_IN),
"2.13in-ttgo-b1": ("a", WaveshareEPaperTypeAModel.TTGO_EPAPER_2_13_IN_B1),
"2.13in-ttgo-b73": ("a", WaveshareEPaperTypeAModel.TTGO_EPAPER_2_13_IN_B73),
"2.13in-ttgo-b74": ("a", WaveshareEPaperTypeAModel.TTGO_EPAPER_2_13_IN_B74),
"2.90in": ("a", WaveshareEPaperTypeAModel.WAVESHARE_EPAPER_2_9_IN),
"2.90inv2": ("a", WaveshareEPaperTypeAModel.WAVESHARE_EPAPER_2_9_IN_V2),
"2.70in": ("b", WaveshareEPaper2P7In),
"2.90in-b": ("b", WaveshareEPaper2P9InB),
"4.20in": ("b", WaveshareEPaper4P2In),
"4.20in-bv2": ("b", WaveshareEPaper4P2InBV2),
"5.83in": ("b", WaveshareEPaper5P8In),
"7.50in": ("b", WaveshareEPaper7P5In),
"7.50in-bv2": ("b", WaveshareEPaper7P5InBV2),
"7.50in-bc": ("b", WaveshareEPaper7P5InBC),
"7.50inv2": ("b", WaveshareEPaper7P5InV2),
"7.50inv2alt": ("b", WaveshareEPaper7P5InV2alt),
"7.50in-hd-b": ("b", WaveshareEPaper7P5InHDB),
"2.13in-ttgo-dke": ("c", WaveshareEPaper2P13InDKE),
}
def validate_full_update_every_only_type_a(value):
if CONF_FULL_UPDATE_EVERY not in value:
return value
if MODELS[value[CONF_MODEL]][0] == "b":
raise cv.Invalid(
"The 'full_update_every' option is only available for models "
"'1.54in', '1.54inV2', '2.13in', '2.90in', and '2.90inV2'."
)
return value
CONFIG_SCHEMA = cv.All(
display.FULL_DISPLAY_SCHEMA.extend(
{
cv.GenerateID(): cv.declare_id(WaveshareEPaper),
cv.Required(CONF_DC_PIN): pins.gpio_output_pin_schema,
cv.Required(CONF_MODEL): cv.one_of(*MODELS, lower=True),
cv.Optional(CONF_RESET_PIN): pins.gpio_output_pin_schema,
cv.Optional(CONF_BUSY_PIN): pins.gpio_input_pin_schema,
cv.Optional(CONF_FULL_UPDATE_EVERY): cv.uint32_t,
cv.Optional(CONF_RESET_DURATION): cv.All(
cv.positive_time_period_milliseconds,
cv.Range(max=core.TimePeriod(milliseconds=500)),
),
}
)
.extend(cv.polling_component_schema("1s"))
.extend(spi.spi_device_schema()),
validate_full_update_every_only_type_a,
cv.has_at_most_one_key(CONF_PAGES, CONF_LAMBDA),
)
async def to_code(config):
model_type, model = MODELS[config[CONF_MODEL]]
if model_type == "a":
rhs = WaveshareEPaperTypeA.new(model)
var = cg.Pvariable(config[CONF_ID], rhs, WaveshareEPaperTypeA)
elif model_type in ("b", "c"):
rhs = model.new()
var = cg.Pvariable(config[CONF_ID], rhs, model)
else:
raise NotImplementedError()
await cg.register_component(var, config)
await display.register_display(var, config)
await spi.register_spi_device(var, config)
dc = await cg.gpio_pin_expression(config[CONF_DC_PIN])
cg.add(var.set_dc_pin(dc))
if CONF_LAMBDA in config:
lambda_ = await cg.process_lambda(
config[CONF_LAMBDA], [(display.DisplayRef, "it")], return_type=cg.void
)
cg.add(var.set_writer(lambda_))
if CONF_RESET_PIN in config:
reset = await cg.gpio_pin_expression(config[CONF_RESET_PIN])
cg.add(var.set_reset_pin(reset))
if CONF_BUSY_PIN in config:
reset = await cg.gpio_pin_expression(config[CONF_BUSY_PIN])
cg.add(var.set_busy_pin(reset))
if CONF_FULL_UPDATE_EVERY in config:
cg.add(var.set_full_update_every(config[CONF_FULL_UPDATE_EVERY]))
if CONF_RESET_DURATION in config:
cg.add(var.set_reset_duration(config[CONF_RESET_DURATION]))

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,468 @@
#pragma once
#include "esphome/core/component.h"
#include "esphome/components/spi/spi.h"
#include "esphome/components/display/display_buffer.h"
namespace esphome {
namespace waveshare_epaper {
class WaveshareEPaper : public PollingComponent,
public display::DisplayBuffer,
public spi::SPIDevice<spi::BIT_ORDER_MSB_FIRST, spi::CLOCK_POLARITY_LOW,
spi::CLOCK_PHASE_LEADING, spi::DATA_RATE_2MHZ> {
public:
void set_dc_pin(GPIOPin *dc_pin) { dc_pin_ = dc_pin; }
float get_setup_priority() const override;
void set_reset_pin(GPIOPin *reset) { this->reset_pin_ = reset; }
void set_busy_pin(GPIOPin *busy) { this->busy_pin_ = busy; }
void set_reset_duration(uint32_t reset_duration) { this->reset_duration_ = reset_duration; }
void command(uint8_t value);
void data(uint8_t value);
virtual void display() = 0;
virtual void initialize() = 0;
virtual void deep_sleep() = 0;
virtual int get_color_internal() { return 1; }
virtual uint8_t get_color_list_internal(uint8_t indexColor) {
return display::ColorUtil::color_to_332(display::COLOR_ON);
}
void update() override;
void fill(Color color) override;
void setup() override {
this->setup_pins_();
this->initialize();
}
void on_safe_shutdown() override;
display::DisplayType get_display_type() override { return display::DisplayType::DISPLAY_TYPE_BINARY; }
protected:
void draw_absolute_pixel_internal(int x, int y, Color color) override;
bool wait_until_idle_();
void setup_pins_();
void reset_() {
if (this->reset_pin_ != nullptr) {
this->reset_pin_->digital_write(false);
delay(reset_duration_); // NOLINT
this->reset_pin_->digital_write(true);
delay(200); // NOLINT
}
}
uint32_t get_buffer_length_();
uint32_t reset_duration_{200};
void start_command_();
void end_command_();
void start_data_();
void end_data_();
GPIOPin *reset_pin_{nullptr};
GPIOPin *dc_pin_;
GPIOPin *busy_pin_{nullptr};
virtual uint32_t idle_timeout_() { return 1000u; } // NOLINT(readability-identifier-naming)
};
enum WaveshareEPaperTypeAModel {
WAVESHARE_EPAPER_1_54_IN = 0,
WAVESHARE_EPAPER_1_54_IN_V2,
WAVESHARE_EPAPER_2_13_IN,
WAVESHARE_EPAPER_2_9_IN,
WAVESHARE_EPAPER_2_9_IN_V2,
TTGO_EPAPER_2_13_IN,
TTGO_EPAPER_2_13_IN_B73,
TTGO_EPAPER_2_13_IN_B1,
TTGO_EPAPER_2_13_IN_B74,
};
class WaveshareEPaperTypeA : public WaveshareEPaper {
public:
WaveshareEPaperTypeA(WaveshareEPaperTypeAModel model);
void initialize() override;
void dump_config() override;
void display() override;
void deep_sleep() override {
if (this->model_ == WAVESHARE_EPAPER_2_9_IN_V2 || this->model_ == WAVESHARE_EPAPER_1_54_IN_V2) {
// COMMAND DEEP SLEEP MODE
this->command(0x10);
this->data(0x01);
} else {
// COMMAND DEEP SLEEP MODE
this->command(0x10);
}
this->wait_until_idle_();
}
void set_full_update_every(uint32_t full_update_every);
protected:
void write_lut_(const uint8_t *lut, uint8_t size);
int get_width_internal() override;
int get_height_internal() override;
uint32_t full_update_every_{30};
uint32_t at_update_{0};
WaveshareEPaperTypeAModel model_;
uint32_t idle_timeout_() override;
};
enum WaveshareEPaperTypeBModel {
WAVESHARE_EPAPER_2_7_IN = 0,
WAVESHARE_EPAPER_4_2_IN,
WAVESHARE_EPAPER_4_2_IN_B_V2,
WAVESHARE_EPAPER_7_5_IN,
WAVESHARE_EPAPER_7_5_INV2,
WAVESHARE_EPAPER_7_5_IN_B_V2,
};
class WaveshareEPaper2P7In : public WaveshareEPaper {
public:
void initialize() override;
void display() override;
void dump_config() override;
void deep_sleep() override {
// COMMAND DEEP SLEEP
this->command(0x07);
this->data(0xA5); // check byte
}
protected:
int get_width_internal() override;
int get_height_internal() override;
};
class WaveshareEPaper2P9InB : public WaveshareEPaper {
public:
void initialize() override;
void display() override;
void dump_config() override;
void deep_sleep() override {
// COMMAND DEEP SLEEP
this->command(0x07);
this->data(0xA5); // check byte
}
protected:
int get_width_internal() override;
int get_height_internal() override;
};
class WaveshareEPaper4P2In : public WaveshareEPaper {
public:
void initialize() override;
void display() override;
void dump_config() override;
void deep_sleep() override {
// COMMAND VCOM AND DATA INTERVAL SETTING
this->command(0x50);
this->data(0x17); // border floating
// COMMAND VCM DC SETTING
this->command(0x82);
// COMMAND PANEL SETTING
this->command(0x00);
delay(100); // NOLINT
// COMMAND POWER SETTING
this->command(0x01);
this->data(0x00);
this->data(0x00);
this->data(0x00);
this->data(0x00);
this->data(0x00);
delay(100); // NOLINT
// COMMAND POWER OFF
this->command(0x02);
this->wait_until_idle_();
// COMMAND DEEP SLEEP
this->command(0x07);
this->data(0xA5); // check byte
}
protected:
int get_width_internal() override;
int get_height_internal() override;
};
class WaveshareEPaper4P2InBV2 : public WaveshareEPaper {
public:
void initialize() override;
void display() override;
void dump_config() override;
void deep_sleep() override {
// COMMAND VCOM AND DATA INTERVAL SETTING
this->command(0x50);
this->data(0xF7); // border floating
// COMMAND POWER OFF
this->command(0x02);
this->wait_until_idle_();
// COMMAND DEEP SLEEP
this->command(0x07);
this->data(0xA5); // check code
}
int get_color_internal() override { return 2; }
uint8_t get_color_list_internal(uint8_t indexColor) override {
if(indexColor == 1) return display::ColorUtil::color_to_332(Color(255, 0, 0, 0));
return display::ColorUtil::color_to_332(display::COLOR_ON);
}
display::DisplayType get_display_type() override { return display::DisplayType::DISPLAY_TYPE_COLOR; }
protected:
int get_width_internal() override;
int get_height_internal() override;
};
class WaveshareEPaper5P8In : public WaveshareEPaper {
public:
void initialize() override;
void display() override;
void dump_config() override;
void deep_sleep() override {
// COMMAND POWER OFF
this->command(0x02);
this->wait_until_idle_();
// COMMAND DEEP SLEEP
this->command(0x07);
this->data(0xA5); // check byte
}
protected:
int get_width_internal() override;
int get_height_internal() override;
};
class WaveshareEPaper7P5In : public WaveshareEPaper {
public:
void initialize() override;
void display() override;
void dump_config() override;
void deep_sleep() override {
// COMMAND POWER OFF
this->command(0x02);
this->wait_until_idle_();
// COMMAND DEEP SLEEP
this->command(0x07);
this->data(0xA5); // check byte
}
int get_color_internal() override { return 2; }
uint8_t get_color_list_internal(uint8_t indexColor) override {
if(indexColor == 1) return display::ColorUtil::color_to_332(Color(255, 0, 0, 0));
return display::ColorUtil::color_to_332(display::COLOR_ON);
}
display::DisplayType get_display_type() override { return display::DisplayType::DISPLAY_TYPE_COLOR; }
protected:
int get_width_internal() override;
int get_height_internal() override;
};
class WaveshareEPaper7P5InBV2 : public WaveshareEPaper {
public:
void initialize() override;
void display() override;
void dump_config() override;
void deep_sleep() override {
// COMMAND POWER OFF
this->command(0x02);
this->wait_until_idle_();
// COMMAND DEEP SLEEP
this->command(0x07); // deep sleep
this->data(0xA5); // check byte
}
bool wait_until_idle_();
int get_color_internal() override { return 2; }
uint8_t get_color_list_internal(uint8_t indexColor) override {
if(indexColor == 1) return display::ColorUtil::color_to_332(Color(255, 0, 0, 0));
return display::ColorUtil::color_to_332(display::COLOR_ON);
}
display::DisplayType get_display_type() override { return display::DisplayType::DISPLAY_TYPE_COLOR; }
protected:
int get_width_internal() override;
int get_height_internal() override;
void reset_() {
if (this->reset_pin_ != nullptr) {
this->reset_pin_->digital_write(true);
delay(200); // NOLINT
this->reset_pin_->digital_write(false);
delay(2);
this->reset_pin_->digital_write(true);
delay(200);
}
};
};
class WaveshareEPaper7P5InBC : public WaveshareEPaper {
public:
void initialize() override;
void display() override;
void dump_config() override;
void deep_sleep() override {
// COMMAND POWER OFF
this->command(0x02);
this->wait_until_idle_();
// COMMAND DEEP SLEEP
this->command(0x07);
this->data(0xA5); // check byte
}
protected:
int get_width_internal() override;
int get_height_internal() override;
};
class WaveshareEPaper7P5InV2 : public WaveshareEPaper {
public:
void initialize() override;
void display() override;
void dump_config() override;
void deep_sleep() override {
// COMMAND POWER OFF
this->command(0x02);
this->wait_until_idle_();
// COMMAND DEEP SLEEP
this->command(0x07);
this->data(0xA5); // check byte
}
protected:
int get_width_internal() override;
int get_height_internal() override;
};
class WaveshareEPaper7P5InV2alt : public WaveshareEPaper7P5InV2 {
public:
bool wait_until_idle_();
void initialize() override;
void dump_config() override;
protected:
void reset_() {
if (this->reset_pin_ != nullptr) {
this->reset_pin_->digital_write(true);
delay(200); // NOLINT
this->reset_pin_->digital_write(false);
delay(2);
this->reset_pin_->digital_write(true);
delay(20);
}
};
};
class WaveshareEPaper7P5InHDB : public WaveshareEPaper {
public:
void initialize() override;
void display() override;
void dump_config() override;
void deep_sleep() override {
// deep sleep
this->command(0x10);
this->data(0x01);
}
protected:
int get_width_internal() override;
int get_height_internal() override;
};
class WaveshareEPaper2P13InDKE : public WaveshareEPaper {
public:
void initialize() override;
void display() override;
void dump_config() override;
void deep_sleep() override {
// COMMAND POWER DOWN
this->command(0x10);
this->data(0x01);
// cannot wait until idle here, the device no longer responds
}
void set_full_update_every(uint32_t full_update_every);
protected:
int get_width_internal() override;
int get_height_internal() override;
uint32_t idle_timeout_() override;
uint32_t full_update_every_{30};
uint32_t at_update_{0};
};
} // namespace waveshare_epaper
} // namespace esphome

113
esphome/dsmr-meter.yaml Normal file
View File

@@ -0,0 +1,113 @@
substitutions:
device_name: "dsmr"
friendly_name: "dsmr"
comment: "esp8266"
location: "zolder"
api_password: !secret esp_P1_api
ota_password: !secret ota_password
wifi_ssid: !secret wifi_ssid
wifi_password: !secret wifi_password
gateway: !secret ip_gateway
subnet: !secret ip_subnet
ip: !secret esp_P1_ip
pin_data: GPIO12
pin_status: GPIO2
packages:
board: !include boards/esp12f.yaml
device_base: !include common/common.yaml
connection: !include common/wifi.yaml
#status: !include templates/status.yaml
logger: !include templates/logger.yaml
#uart config for DSMR v2 (9600-7N1)
uart:
rx_pin: ${pin_data}
baud_rate: 9600
data_bits: 7
parity: NONE
stop_bits: 1
id: dmsr_uart
#uart config for dsmr (115200-8N1)
# uart:
# rx_pin: ${pin_data}
# baud_rate: 115200
# data_bits: 8
# parity: NONE
# stop_bits: 1
# id: dmsr_uart
dsmr:
crc_check: false
uart_id: dmsr_uart
#https://www.esphome.io/components/sensor/dsmr.html?highlight=dsmr#component-hub
sensor:
- platform: dsmr
energy_delivered_tariff1:
name: energy_delivered_tariff1
energy_delivered_tariff2:
name: energy_delivered_tariff2
energy_returned_tariff1:
name: energy_returned_tariff1
energy_returned_tariff2:
name: energy_returned_tariff2
power_delivered:
name: power_delivered
power_returned:
name: power_returned
electricity_failures:
name: electricity_failures
electricity_long_failures:
name: Long Electricity Failures.
electricity_sags_l1:
name: Number of voltage sags in phase L1.
electricity_sags_l2:
name: Number of voltage sags in phase L2.
electricity_sags_l3:
name: Number of voltage sags in phase L3.
electricity_swells_l1:
name: Number of voltage swells in phase L1.
electricity_swells_l2:
name: Number of voltage swells in phase L2.
electricity_swells_l3:
name: Number of voltage swells in phase L3.
voltage_l1:
name: Voltage Phase 1.
voltage_l2:
name: Voltage Phase 2.
voltage_l3:
name: Voltage Phase 3.
current_l1:
name: Current Phase 1.
current_l2:
name: Current Phase 2.
current_l3:
name: Current Phase 3.
power_delivered_l1:
name: Power Consumed Phase 1.
power_delivered_l2:
name: Power Consumed Phase 2.
power_delivered_l3:
name: Power Consumed Phase 3.
power_returned_l1:
name: Power Produced Phase 1.
power_returned_l2:
name: Power Produced Phase 2.
power_returned_l3:
name: Power Produced Phase 3.
gas_delivered:
name: Gas Consumed.
text_sensor:
- platform: dsmr
identification:
name: "dsmr_identification"
p1_version:
name: "dsmr_p1_version"
electricity_tariff:
name: "electricity_tariff"

592
esphome/ep1-woonkamer.yaml Executable file
View File

@@ -0,0 +1,592 @@
substitutions:
name: ${device_name}
device_name: "ep1_woonkamer"
location: "woonkamer"
comment: "esp32, mmwave, pir"
friendly_name: "ep1_woonkamer"
project_name: "Everything Smart Technology.Everything Presence One"
project_version: "1.1.3"
temperature_offset: "-3"
humidity_offset: "5"
temperature_update_interval: "60s"
illuminance_update_interval: "30s"
pir_delay_off: "10s"
occupancy_delay_off: "15s"
hidden_ssid: "false"
factory_reset_disabled: "true"
uart_target_output_disabled: "true"
uart_presence_output_disabled: "true"
api_password: !secret ep1_woonkamer_api
ota_password: !secret ota_password
wifi_ssid: !secret wifi_ssid
wifi_password: !secret wifi_password
gateway: !secret ip_gateway
subnet: !secret ip_subnet
ip: !secret ep1_woonkamer_ip
pin_sda: GPIO26
pin_scl: GPIO25
pin_status: GPIO32
packages:
board: !include boards/esp32_wroom_arduino.yaml
device_base: !include common/common.yaml
connection: !include common/wifi.yaml
logger: !include templates/logger.yaml
i2c: !include interfaces/i2c_a.yaml
bluetooth: !include common/bluetooth.yaml
improv_serial:
esp32_improv:
authorizer: none
dashboard_import:
package_import_url: github://everythingsmarthome/presence-one/everything-presence-one.yaml@main
import_full_config: false
esphome:
project:
name: "${project_name}"
version: "${project_version}"
includes:
- include/SEN0395_distance.h
light:
- platform: status_led
name: ESP32 status LED
pin: ${pin_status}
entity_category: config
disabled_by_default: True
- platform: binary
name: mmWave LED
restore_mode: RESTORE_DEFAULT_OFF
output: mmwave_led_output
entity_category: config
disabled_by_default: True
output:
- platform: template
id: mmwave_led_output
type: binary
write_action:
- switch.turn_off: mmwave_sensor
- delay: 1s
- if:
condition:
lambda: !lambda return state;
then:
- uart.write: "setLedMode 1 0"
else:
- uart.write: "setLedMode 1 1"
- delay: 1s
- uart.write: "saveConfig"
- delay: 3s
- switch.turn_on: mmwave_sensor
i2c:
sda: 26
scl: 25
scan: true
sensor:
- platform: shtcx
id: "shtc3_sensor"
temperature:
name: Temperature
id: temperature_sensor
filters:
- offset: ${temperature_offset}
- lambda: "return x + id(temperature_offset_ui).state;"
humidity:
name: Humidity
id: humidity_sensor
filters:
- offset: ${humidity_offset}
- lambda: "return x + id(humidity_offset_ui).state;"
address: 0x70
update_interval: ${temperature_update_interval}
- platform: bh1750
name: Illuminance
id: illuminance_sensor
address: 0x23
update_interval: ${illuminance_update_interval}
filters:
- lambda: "return x + id(illuminance_offset_ui).state;"
- platform: template
name: Target 1 Distance # Don't change
id: target_distance_1_m
accuracy_decimals: 2
disabled_by_default: false
- platform: template
name: Target 2 Distance # Don't change
id: target_distance_2_m
accuracy_decimals: 2
disabled_by_default: True
- platform: template
name: Target 3 Distance # Don't change
id: target_distance_3_m
accuracy_decimals: 2
disabled_by_default: True
- platform: template
name: Target 4 Distance # Don't change
id: target_distance_4_m
accuracy_decimals: 2
disabled_by_default: True
- platform: template
name: "Target 1 SNR" # Don't change
disabled_by_default: True
- platform: template
name: "Target 2 SNR" # Don't change
disabled_by_default: True
- platform: template
name: "Target 3 SNR" # Don't change
disabled_by_default: True
- platform: template
name: "Target 4 SNR" # Don't change
disabled_by_default: True
binary_sensor:
- platform: gpio
name: mmWave
id: mmwave
device_class: occupancy
pin:
number: GPIO15
mode: INPUT_PULLDOWN
- platform: gpio
pin:
number: 33
mode: INPUT_PULLDOWN
name: PIR
id: pir_motion_sensor
device_class: motion
filters:
- delayed_off: ${pir_delay_off}
- platform: template
name: Occupancy
id: occupancy
device_class: occupancy
filters:
- delayed_off: ${occupancy_delay_off}
lambda: |-
if ( id(mmwave).state or id(pir_motion_sensor).state) {
return true;
}
else if (id(mmwave).state == 0 and id(pir_motion_sensor).state == 0) {
return false;
}
else {
return id(occupancy).state;
}
- platform: template
name: "Target 1 Active" # Don't change
disabled_by_default: False
- platform: template
name: "Target 2 Active" # Don't change
disabled_by_default: True
- platform: template
name: "Target 3 Active" # Don't change
disabled_by_default: True
- platform: template
name: "Target 4 Active" # Don't change
disabled_by_default: True
uart:
id: uart_bus
tx_pin: GPIO13
rx_pin: GPIO14
baud_rate: 115200
switch:
- platform: template
name: mmWave sensor
id: mmwave_sensor
disabled_by_default: True
entity_category: config
optimistic: true
restore_mode: RESTORE_DEFAULT_ON
turn_on_action:
- uart.write: "sensorStart"
- delay: 1s
turn_off_action:
- uart.write: "sensorStop"
- delay: 1s
- platform: template
name: UART presence output
id: uart_presence_output
entity_category: config
internal: ${uart_presence_output_disabled}
optimistic: true
turn_on_action:
- switch.turn_off: mmwave_sensor
- delay: 1s
- uart.write: "setUartOutput 1 1"
- delay: 1s
- uart.write: "saveConfig"
- delay: 3s
- switch.turn_on: mmwave_sensor
turn_off_action:
- switch.turn_off: mmwave_sensor
- delay: 1s
- uart.write: "setUartOutput 1 0"
- delay: 1s
- uart.write: "saveConfig"
- delay: 3s
- switch.turn_on: mmwave_sensor
- platform: template
name: UART target output
id: uart_target_output
entity_category: config
internal: ${uart_target_output_disabled}
optimistic: true
assumed_state: false
restore_mode: ALWAYS_ON
turn_on_action:
- switch.turn_off: mmwave_sensor
- delay: 1s
- uart.write: "setUartOutput 2 1 1 1"
- delay: 1s
- uart.write: "saveConfig"
- delay: 3s
- switch.turn_on: mmwave_sensor
turn_off_action:
- switch.turn_off: mmwave_sensor
- delay: 1s
- uart.write: "setUartOutput 2 0"
- delay: 1s
- uart.write: "saveConfig"
- delay: 3s
- switch.turn_on: mmwave_sensor
number:
- platform: template
id: mmwave_zone_1_start
name: mmWave Zone 1 Start
min_value: 0
max_value: 800
step: 15
initial_value: 0
mode: slider
unit_of_measurement: cm
optimistic: true
entity_category: config
disabled_by_default: False
icon: "mdi:arrow-left-right"
- platform: template
id: mmwave_zone_1_end
name: mmWave Zone 1 End
min_value: 0
max_value: 800
step: 15
initial_value: 315
mode: slider
unit_of_measurement: cm
optimistic: true
entity_category: config
disabled_by_default: False
icon: "mdi:arrow-left-right"
- platform: template
id: mmwave_zone_2_start
name: mmWave Zone 2 Start
min_value: 0
max_value: 800
step: 15
initial_value: 0
mode: slider
unit_of_measurement: cm
optimistic: true
entity_category: config
disabled_by_default: True
icon: "mdi:arrow-left-right"
- platform: template
id: mmwave_zone_2_end
name: mmWave Zone 2 End
min_value: 0
max_value: 800
step: 15
initial_value: 0
mode: slider
unit_of_measurement: cm
optimistic: true
entity_category: config
disabled_by_default: True
icon: "mdi:arrow-left-right"
- platform: template
id: mmwave_zone_3_start
name: mmWave Zone 3 Start
min_value: 0
max_value: 800
step: 15
initial_value: 0
mode: slider
unit_of_measurement: cm
optimistic: true
entity_category: config
disabled_by_default: True
icon: "mdi:arrow-left-right"
- platform: template
id: mmwave_zone_3_end
name: mmWave Zone 3 End
min_value: 0
max_value: 800
step: 15
initial_value: 0
mode: slider
unit_of_measurement: cm
optimistic: true
entity_category: config
disabled_by_default: True
icon: "mdi:arrow-left-right"
- platform: template
id: mmwave_zone_4_start
name: mmWave Zone 4 Start
min_value: 0
max_value: 800
step: 15
initial_value: 0
mode: slider
unit_of_measurement: cm
optimistic: true
entity_category: config
disabled_by_default: True
icon: "mdi:arrow-left-right"
- platform: template
id: mmwave_zone_4_end
name: mmWave Zone 4 End
min_value: 0
max_value: 800
step: 15
initial_value: 0
mode: slider
unit_of_measurement: cm
optimistic: true
entity_category: config
disabled_by_default: True
icon: "mdi:arrow-left-right"
- platform: template
name: mmWave off latency
icon: mdi:clock-end
entity_category: config
id: mmwave_off_latency
min_value: 1
max_value: 60
initial_value: 15
optimistic: true
step: 1
restore_value: true
unit_of_measurement: seconds
mode: slider
set_action:
- switch.turn_off: mmwave_sensor
- delay: 1s
- uart.write: !lambda |-
std::string mss = "setLatency " + to_string(id(mmwave_on_latency).state) + " " + to_string(id(mmwave_off_latency).state);
return std::vector<unsigned char>(mss.begin(), mss.end());
- delay: 1s
- uart.write: "saveCfg 0x45670123 0xCDEF89AB 0x956128C6 0xDF54AC89"
- delay: 1s
- switch.turn_on: mmwave_sensor
- platform: template
name: mmWave on latency
icon: mdi:clock-start
id: mmwave_on_latency
entity_category: config
min_value: 0
max_value: 60
initial_value: 0
optimistic: true
step: 0.5
restore_value: true
unit_of_measurement: seconds
mode: slider
set_action:
- switch.turn_off: mmwave_sensor
- delay: 1s
- uart.write: !lambda |-
std::string mss = "setLatency " + to_string(id(mmwave_on_latency).state) + " " + to_string(id(mmwave_off_latency).state);
return std::vector<unsigned char>(mss.begin(), mss.end());
- delay: 1s
- uart.write: "saveCfg 0x45670123 0xCDEF89AB 0x956128C6 0xDF54AC89"
- delay: 1s
- switch.turn_on: mmwave_sensor
- platform: template
name: mmWave sensitivity
icon: mdi:target-variant
id: mmwave_sensitivity
entity_category: config
min_value: 0
max_value: 9
initial_value: 7
optimistic: true
step: 1
restore_value: true
set_action:
- switch.turn_off: mmwave_sensor
- delay: 1s
- uart.write:
!lambda std::string mss = "setSensitivity " + to_string((int)x);
return std::vector<unsigned char>(mss.begin(), mss.end());
- delay: 1s
- uart.write: "saveConfig"
- delay: 1s
- switch.turn_on: mmwave_sensor
- platform: template
name: "Temperature Offset"
id: temperature_offset_ui
unit_of_measurement: "°C"
min_value: -20
max_value: 20
step: 0.1
mode: box
update_interval: never
optimistic: true
restore_value: true
initial_value: 0
icon: "mdi:thermometer"
entity_category: config
on_value:
- lambda: 'id(shtc3_sensor).update();'
- platform: template
name: "Humidity Offset"
id: humidity_offset_ui
unit_of_measurement: "%"
min_value: -50
max_value: 50
step: 0.1
mode: box
update_interval: never
optimistic: true
restore_value: true
initial_value: 0
icon: "mdi:water-percent"
entity_category: config
on_value:
- lambda: 'id(shtc3_sensor).update();'
- platform: template
name: "Illuminance Offset"
id: illuminance_offset_ui
unit_of_measurement: "lx"
min_value: -50
max_value: 50
step: 1
mode: box
update_interval: never
optimistic: true
restore_value: true
initial_value: 0
icon: "mdi:brightness-5"
entity_category: config
on_value:
- lambda: 'id(illuminance_sensor).update();'
button:
- platform: restart
id: restart_internal
entity_category: config
internal: true
- platform: template
name: Restart mmWave sensor
id: restart_mmwave
entity_category: config
internal: true
on_press:
- uart.write: "resetSystem"
- platform: template
name: Restart
icon: mdi:restart
entity_category: config
disabled_by_default: True
on_press:
- button.press: restart_mmwave
- button.press: restart_internal
- platform: safe_mode
internal: false
name: Safe mode
entity_category: config
disabled_by_default: True
- platform: template
name: Factory reset mmWave
icon: mdi:cog-counterclockwise
id: factory_reset_mmwave
internal: ${factory_reset_disabled}
entity_category: config
on_press:
- switch.turn_off: mmwave_sensor
- delay: 1s
- uart.write: "resetCfg"
- delay: 3s
- switch.turn_on: mmwave_sensor
- platform: template
name: mmWave Set Distance
id: mmwave_set_distance
icon: "mdi:arrow-left-right"
entity_category: config
on_press:
- switch.turn_off: mmwave_sensor
- delay: 1s
- uart.write: !lambda
int s1 = (int)ceil(id(mmwave_zone_1_start).state / 15.0);
int e1 = (int)ceil(id(mmwave_zone_1_end).state / 15.0);
int s2 = (int)ceil(id(mmwave_zone_2_start).state / 15.0);
int e2 = (int)ceil(id(mmwave_zone_2_end).state / 15.0);
int s3 = (int)ceil(id(mmwave_zone_3_start).state / 15.0);
int e3 = (int)ceil(id(mmwave_zone_3_end).state / 15.0);
int s4 = (int)ceil(id(mmwave_zone_4_start).state / 15.0);
int e4 = (int)ceil(id(mmwave_zone_4_end).state / 15.0);
std::string cmd = "detRangeCfg -1";
if(s1 < e1) {
cmd += " " + to_string(s1) + " " + to_string(e1);
}
if(s2 > e1 && s2 < e2) {
cmd += " " + to_string(s2) + " " + to_string(e2);
}
if(s3 > e2 && s3 < e3) {
cmd += " " + to_string(s3) + " " + to_string(e3);
}
if(s4 > e3 && s4 < e4) {
cmd += " " + to_string(s4) + " " + to_string(e4);
}
if(cmd != "detRangeCfg -1") {
std::vector<unsigned char> cmd_vec(cmd.begin(), cmd.end());
ESP_LOGI("set_mmwave_distance", "Sending command to sensor %s", cmd.c_str());
id(distance_zone_status).publish_state("Successfully sent to sensor! " + cmd.substr(14));
return cmd_vec;
} else {
ESP_LOGE("set_mmwave_distance", "No valid segments configured. Please adjust the sliders.");
id(distance_zone_status).publish_state("No valid segments configured. Please adjust the sliders.");
return std::vector<unsigned char>();
}
- delay: 1s
- uart.write: "saveCfg 0x45670123 0xCDEF89AB 0x956128C6 0xDF54AC89"
- delay: 1s
- switch.turn_on: mmwave_sensor
text_sensor:
- platform: template
name: "Distance Zones Status"
id: "distance_zone_status"
custom_component:
- lambda: |-
auto my_custom = new Sen0395Distance(id(uart_bus));
return {my_custom};

591
esphome/ep1-zolder.yaml Normal file
View File

@@ -0,0 +1,591 @@
substitutions:
name: ${device_name}
device_name: "ep1-zolder"
location: "Zolder"
comment: "esp32, mmwave, pir"
friendly_name: "ep1-zolder"
project_name: "Everything Smart Technology.Everything Presence One"
project_version: "1.1.3"
temperature_offset: "-3"
humidity_offset: "5"
temperature_update_interval: "60s"
illuminance_update_interval: "30s"
pir_delay_off: "10s"
occupancy_delay_off: "15s"
hidden_ssid: "false"
factory_reset_disabled: "true"
uart_target_output_disabled: "true"
uart_presence_output_disabled: "true"
api_password: !secret ep1_zolder_api
ota_password: !secret ota_password
wifi_ssid: !secret wifi_ssid
wifi_password: !secret wifi_password
gateway: !secret ip_gateway
subnet: !secret ip_subnet
ip: !secret ep1_zolder_ip
pin_sda: GPIO26
pin_scl: GPIO25
pin_status: GPIO32
packages:
board: !include boards/esp32_wroom_arduino.yaml
device_base: !include common/common.yaml
connection: !include common/wifi.yaml
logger: !include templates/logger.yaml
i2c: !include interfaces/i2c_a.yaml
bluetooth: !include common/bluetooth.yaml
improv_serial:
esp32_improv:
authorizer: none
dashboard_import:
package_import_url: github://everythingsmarthome/presence-one/everything-presence-one.yaml@main
import_full_config: false
esphome:
project:
name: "${project_name}"
version: "${project_version}"
includes:
- include/SEN0395_distance.h
light:
- platform: status_led
name: ESP32 status LED
pin: ${pin_status}
entity_category: config
disabled_by_default: True
- platform: binary
name: mmWave LED
restore_mode: RESTORE_DEFAULT_OFF
output: mmwave_led_output
entity_category: config
disabled_by_default: True
output:
- platform: template
id: mmwave_led_output
type: binary
write_action:
- switch.turn_off: mmwave_sensor
- delay: 1s
- if:
condition:
lambda: !lambda return state;
then:
- uart.write: "setLedMode 1 0"
else:
- uart.write: "setLedMode 1 1"
- delay: 1s
- uart.write: "saveConfig"
- delay: 3s
- switch.turn_on: mmwave_sensor
i2c:
sda: 26
scl: 25
scan: true
sensor:
- platform: shtcx
id: "shtc3_sensor"
temperature:
name: Temperature
id: temperature_sensor
filters:
- offset: ${temperature_offset}
- lambda: "return x + id(temperature_offset_ui).state;"
humidity:
name: Humidity
id: humidity_sensor
filters:
- offset: ${humidity_offset}
- lambda: "return x + id(humidity_offset_ui).state;"
address: 0x70
update_interval: ${temperature_update_interval}
- platform: bh1750
name: Illuminance
id: illuminance_sensor
address: 0x23
update_interval: ${illuminance_update_interval}
filters:
- lambda: "return x + id(illuminance_offset_ui).state;"
- platform: template
name: Target 1 Distance # Don't change
id: target_distance_1_m
accuracy_decimals: 2
disabled_by_default: false
- platform: template
name: Target 2 Distance # Don't change
id: target_distance_2_m
accuracy_decimals: 2
disabled_by_default: True
- platform: template
name: Target 3 Distance # Don't change
id: target_distance_3_m
accuracy_decimals: 2
disabled_by_default: True
- platform: template
name: Target 4 Distance # Don't change
id: target_distance_4_m
accuracy_decimals: 2
disabled_by_default: True
- platform: template
name: "Target 1 SNR" # Don't change
disabled_by_default: True
- platform: template
name: "Target 2 SNR" # Don't change
disabled_by_default: True
- platform: template
name: "Target 3 SNR" # Don't change
disabled_by_default: True
- platform: template
name: "Target 4 SNR" # Don't change
disabled_by_default: True
binary_sensor:
- platform: gpio
name: mmWave
id: mmwave
device_class: occupancy
pin:
number: GPIO15
mode: INPUT_PULLDOWN
- platform: gpio
pin:
number: 33
mode: INPUT_PULLDOWN
name: PIR
id: pir_motion_sensor
device_class: motion
filters:
- delayed_off: ${pir_delay_off}
- platform: template
name: Occupancy
id: occupancy
device_class: occupancy
filters:
- delayed_off: ${occupancy_delay_off}
lambda: |-
if ( id(mmwave).state or id(pir_motion_sensor).state) {
return true;
}
else if (id(mmwave).state == 0 and id(pir_motion_sensor).state == 0) {
return false;
}
else {
return id(occupancy).state;
}
- platform: template
name: "Target 1 Active" # Don't change
disabled_by_default: False
- platform: template
name: "Target 2 Active" # Don't change
disabled_by_default: True
- platform: template
name: "Target 3 Active" # Don't change
disabled_by_default: True
- platform: template
name: "Target 4 Active" # Don't change
disabled_by_default: True
uart:
id: uart_bus
tx_pin: GPIO13
rx_pin: GPIO14
baud_rate: 115200
switch:
- platform: template
name: mmWave sensor
id: mmwave_sensor
disabled_by_default: True
entity_category: config
optimistic: true
restore_mode: RESTORE_DEFAULT_ON
turn_on_action:
- uart.write: "sensorStart"
- delay: 1s
turn_off_action:
- uart.write: "sensorStop"
- delay: 1s
- platform: template
name: UART presence output
id: uart_presence_output
entity_category: config
internal: ${uart_presence_output_disabled}
optimistic: true
turn_on_action:
- switch.turn_off: mmwave_sensor
- delay: 1s
- uart.write: "setUartOutput 1 1"
- delay: 1s
- uart.write: "saveConfig"
- delay: 3s
- switch.turn_on: mmwave_sensor
turn_off_action:
- switch.turn_off: mmwave_sensor
- delay: 1s
- uart.write: "setUartOutput 1 0"
- delay: 1s
- uart.write: "saveConfig"
- delay: 3s
- switch.turn_on: mmwave_sensor
- platform: template
name: UART target output
id: uart_target_output
entity_category: config
internal: ${uart_target_output_disabled}
optimistic: true
assumed_state: false
restore_mode: ALWAYS_ON
turn_on_action:
- switch.turn_off: mmwave_sensor
- delay: 1s
- uart.write: "setUartOutput 2 1 1 1"
- delay: 1s
- uart.write: "saveConfig"
- delay: 3s
- switch.turn_on: mmwave_sensor
turn_off_action:
- switch.turn_off: mmwave_sensor
- delay: 1s
- uart.write: "setUartOutput 2 0"
- delay: 1s
- uart.write: "saveConfig"
- delay: 3s
- switch.turn_on: mmwave_sensor
number:
- platform: template
id: mmwave_zone_1_start
name: mmWave Zone 1 Start
min_value: 0
max_value: 800
step: 15
initial_value: 0
mode: slider
unit_of_measurement: cm
optimistic: true
entity_category: config
disabled_by_default: False
icon: "mdi:arrow-left-right"
- platform: template
id: mmwave_zone_1_end
name: mmWave Zone 1 End
min_value: 0
max_value: 800
step: 15
initial_value: 315
mode: slider
unit_of_measurement: cm
optimistic: true
entity_category: config
disabled_by_default: False
icon: "mdi:arrow-left-right"
- platform: template
id: mmwave_zone_2_start
name: mmWave Zone 2 Start
min_value: 0
max_value: 800
step: 15
initial_value: 0
mode: slider
unit_of_measurement: cm
optimistic: true
entity_category: config
disabled_by_default: True
icon: "mdi:arrow-left-right"
- platform: template
id: mmwave_zone_2_end
name: mmWave Zone 2 End
min_value: 0
max_value: 800
step: 15
initial_value: 0
mode: slider
unit_of_measurement: cm
optimistic: true
entity_category: config
disabled_by_default: True
icon: "mdi:arrow-left-right"
- platform: template
id: mmwave_zone_3_start
name: mmWave Zone 3 Start
min_value: 0
max_value: 800
step: 15
initial_value: 0
mode: slider
unit_of_measurement: cm
optimistic: true
entity_category: config
disabled_by_default: True
icon: "mdi:arrow-left-right"
- platform: template
id: mmwave_zone_3_end
name: mmWave Zone 3 End
min_value: 0
max_value: 800
step: 15
initial_value: 0
mode: slider
unit_of_measurement: cm
optimistic: true
entity_category: config
disabled_by_default: True
icon: "mdi:arrow-left-right"
- platform: template
id: mmwave_zone_4_start
name: mmWave Zone 4 Start
min_value: 0
max_value: 800
step: 15
initial_value: 0
mode: slider
unit_of_measurement: cm
optimistic: true
entity_category: config
disabled_by_default: True
icon: "mdi:arrow-left-right"
- platform: template
id: mmwave_zone_4_end
name: mmWave Zone 4 End
min_value: 0
max_value: 800
step: 15
initial_value: 0
mode: slider
unit_of_measurement: cm
optimistic: true
entity_category: config
disabled_by_default: True
icon: "mdi:arrow-left-right"
- platform: template
name: mmWave off latency
icon: mdi:clock-end
entity_category: config
id: mmwave_off_latency
min_value: 1
max_value: 60
initial_value: 15
optimistic: true
step: 1
restore_value: true
unit_of_measurement: seconds
mode: slider
set_action:
- switch.turn_off: mmwave_sensor
- delay: 1s
- uart.write: !lambda |-
std::string mss = "setLatency " + to_string(id(mmwave_on_latency).state) + " " + to_string(id(mmwave_off_latency).state);
return std::vector<unsigned char>(mss.begin(), mss.end());
- delay: 1s
- uart.write: "saveCfg 0x45670123 0xCDEF89AB 0x956128C6 0xDF54AC89"
- delay: 1s
- switch.turn_on: mmwave_sensor
- platform: template
name: mmWave on latency
icon: mdi:clock-start
id: mmwave_on_latency
entity_category: config
min_value: 0
max_value: 60
initial_value: 0
optimistic: true
step: 0.5
restore_value: true
unit_of_measurement: seconds
mode: slider
set_action:
- switch.turn_off: mmwave_sensor
- delay: 1s
- uart.write: !lambda |-
std::string mss = "setLatency " + to_string(id(mmwave_on_latency).state) + " " + to_string(id(mmwave_off_latency).state);
return std::vector<unsigned char>(mss.begin(), mss.end());
- delay: 1s
- uart.write: "saveCfg 0x45670123 0xCDEF89AB 0x956128C6 0xDF54AC89"
- delay: 1s
- switch.turn_on: mmwave_sensor
- platform: template
name: mmWave sensitivity
icon: mdi:target-variant
id: mmwave_sensitivity
entity_category: config
min_value: 0
max_value: 9
initial_value: 7
optimistic: true
step: 1
restore_value: true
set_action:
- switch.turn_off: mmwave_sensor
- delay: 1s
- uart.write:
!lambda std::string mss = "setSensitivity " + to_string((int)x);
return std::vector<unsigned char>(mss.begin(), mss.end());
- delay: 1s
- uart.write: "saveConfig"
- delay: 1s
- switch.turn_on: mmwave_sensor
- platform: template
name: "Temperature Offset"
id: temperature_offset_ui
unit_of_measurement: "°C"
min_value: -20
max_value: 20
step: 0.1
mode: box
update_interval: never
optimistic: true
restore_value: true
initial_value: 0
icon: "mdi:thermometer"
entity_category: config
on_value:
- lambda: 'id(shtc3_sensor).update();'
- platform: template
name: "Humidity Offset"
id: humidity_offset_ui
unit_of_measurement: "%"
min_value: -50
max_value: 50
step: 0.1
mode: box
update_interval: never
optimistic: true
restore_value: true
initial_value: 0
icon: "mdi:water-percent"
entity_category: config
on_value:
- lambda: 'id(shtc3_sensor).update();'
- platform: template
name: "Illuminance Offset"
id: illuminance_offset_ui
unit_of_measurement: "lx"
min_value: -50
max_value: 50
step: 1
mode: box
update_interval: never
optimistic: true
restore_value: true
initial_value: 0
icon: "mdi:brightness-5"
entity_category: config
on_value:
- lambda: 'id(illuminance_sensor).update();'
button:
- platform: restart
id: restart_internal
entity_category: config
internal: true
- platform: template
name: Restart mmWave sensor
id: restart_mmwave
entity_category: config
internal: true
on_press:
- uart.write: "resetSystem"
- platform: template
name: Restart
icon: mdi:restart
entity_category: config
disabled_by_default: True
on_press:
- button.press: restart_mmwave
- button.press: restart_internal
- platform: safe_mode
internal: false
name: Safe mode
entity_category: config
disabled_by_default: True
- platform: template
name: Factory reset mmWave
icon: mdi:cog-counterclockwise
id: factory_reset_mmwave
internal: ${factory_reset_disabled}
entity_category: config
on_press:
- switch.turn_off: mmwave_sensor
- delay: 1s
- uart.write: "resetCfg"
- delay: 3s
- switch.turn_on: mmwave_sensor
- platform: template
name: mmWave Set Distance
id: mmwave_set_distance
icon: "mdi:arrow-left-right"
entity_category: config
on_press:
- switch.turn_off: mmwave_sensor
- delay: 1s
- uart.write: !lambda
int s1 = (int)ceil(id(mmwave_zone_1_start).state / 15.0);
int e1 = (int)ceil(id(mmwave_zone_1_end).state / 15.0);
int s2 = (int)ceil(id(mmwave_zone_2_start).state / 15.0);
int e2 = (int)ceil(id(mmwave_zone_2_end).state / 15.0);
int s3 = (int)ceil(id(mmwave_zone_3_start).state / 15.0);
int e3 = (int)ceil(id(mmwave_zone_3_end).state / 15.0);
int s4 = (int)ceil(id(mmwave_zone_4_start).state / 15.0);
int e4 = (int)ceil(id(mmwave_zone_4_end).state / 15.0);
std::string cmd = "detRangeCfg -1";
if(s1 < e1) {
cmd += " " + to_string(s1) + " " + to_string(e1);
}
if(s2 > e1 && s2 < e2) {
cmd += " " + to_string(s2) + " " + to_string(e2);
}
if(s3 > e2 && s3 < e3) {
cmd += " " + to_string(s3) + " " + to_string(e3);
}
if(s4 > e3 && s4 < e4) {
cmd += " " + to_string(s4) + " " + to_string(e4);
}
if(cmd != "detRangeCfg -1") {
std::vector<unsigned char> cmd_vec(cmd.begin(), cmd.end());
ESP_LOGI("set_mmwave_distance", "Sending command to sensor %s", cmd.c_str());
id(distance_zone_status).publish_state("Successfully sent to sensor! " + cmd.substr(14));
return cmd_vec;
} else {
ESP_LOGE("set_mmwave_distance", "No valid segments configured. Please adjust the sliders.");
id(distance_zone_status).publish_state("No valid segments configured. Please adjust the sliders.");
return std::vector<unsigned char>();
}
- delay: 1s
- uart.write: "saveCfg 0x45670123 0xCDEF89AB 0x956128C6 0xDF54AC89"
- delay: 1s
- switch.turn_on: mmwave_sensor
text_sensor:
- platform: template
name: "Distance Zones Status"
id: "distance_zone_status"
custom_component:
- lambda: |-
auto my_custom = new Sen0395Distance(id(uart_bus));
return {my_custom};

View File

@@ -15,6 +15,7 @@ packages:
board: !include boards/esp32_wroom_arduino.yaml
connection: !include common/wifi_nosens.yaml
logger: !include templates/logger.yaml
#bt_proxy: !include common/bluetooth.yaml #no space
esphome:
name: ${device_name}
@@ -24,11 +25,12 @@ esphome:
- include/epaper75.h
external_components:
- source:
type: git
url: https://github.com/atomicmike/esphome.git
ref: waveshare-color-2022.6
components: [waveshare_epaper]
# - source:
# type: git
# url: https://github.com/atomicmike/esphome.git
# ref: waveshare-color-2022.6
# components: [waveshare_epaper]
- source: components/waveshare-epaper-c
sun:
latitude: !secret home_latitude
@@ -87,29 +89,30 @@ button:
# Include custom fonts
font:
- file: 'fonts/GothamRnd-Book.ttf'
id: font_small_book
size: 18
# - file: 'fonts/GothamRnd-Book.ttf'
# id: font_small_book
# size: 18
- file: 'fonts/GothamRnd-Bold.ttf'
id: font_large_bold
size: 108
glyphs: ['-',' ', '°', '0', '1', '2', '3', '4', '5', '6', '7', '8', '9', 'C', 'a', 'n']
- file: 'fonts/GothamRnd-Bold.ttf'
id: font_medium_bold
size: 30
# - file: 'fonts/GothamRnd-Bold.ttf'
# id: font_medium_bold
# size: 30
# glyphs: [' ', '0', '1', '2', '3', '4', '5', '6', '7', '8', '9', 'M', 'I', 'N']
- file: 'fonts/GothamRnd-Bold.ttf'
id: font_small_bold
size: 18
# glyphs: ['°', '0', '1', '2', '3', '4', '5', '6', '7', '8', '9', 'C', 'M', 'I', 'N']
- file: 'fonts/GothamRnd-Bold.ttf'
id: font_time
size: 90
glyphs: [' ', '0', '1', '2', '3', '4', '5', '6', '7', '8', '9', ':']
# - file: 'fonts/GothamRnd-Bold.ttf'
# id: font_time
# size: 90
# glyphs: [' ', '0', '1', '2', '3', '4', '5', '6', '7', '8', '9', ':']
- file: 'fonts/GothamRnd-Book.ttf'
id: font_weekday
size: 30
glyphs: ['a', 'd', 'e','F', 'h', 'i','M', 'n', 'o', 'r', 's','S', 't','T', 'u', 'W', 'y']
- file: 'fonts/GothamRnd-Book.ttf'
id: font_day
size: 65
@@ -118,15 +121,15 @@ font:
id: font_month
size: 40
- file: fonts/materialdesignicons-webfont.ttf
id: font_wifi
size: 20
glyphs:
- "\U000F091F"
- "\U000F0922"
- "\U000F0925"
- "\U000F0928"
- "\U000F092B"
# - file: fonts/materialdesignicons-webfont.ttf
# id: font_wifi
# size: 20
# glyphs:
# - "\U000F091F"
# - "\U000F0922"
# - "\U000F0925"
# - "\U000F0928"
# - "\U000F092B"
# Include Material Design Icons font
# Thanks to https://community.home-assistant.io/t/display-materialdesign-icons-on-esphome-attached-to-screen/199790/16
@@ -147,13 +150,13 @@ font:
- "\U000F0F31" # mdi-weather-night-partly-cloudy
- "\U000F0595" # mdi-weather-partly-cloudy
- "\U000F0F32" # mdi-weather-partly-lightning
- "\U000F0F33" # mdi-weather-partly-rainy
- "\U000F0F34" # mdi-weather-partly-snowy
#- "\U000F0F33" # mdi-weather-partly-rainy
#- "\U000F0F34" # mdi-weather-partly-snowy
- "\U000F0F35" # mdi-weather-partly-snowy-rainy
- "\U000F0596" # mdi-weather-pouring
- "\U000F0597" # mdi-weather-rainy
- "\U000F0598" # mdi-weather-snowy
- "\U000F0F36" # mdi-weather-snowy-heavy
#- "\U000F0F36" # mdi-weather-snowy-heavy
- "\U000F067F" # mdi-weather-snowy-rainy
- "\U000F0599" # mdi-weather-sunny
- "\U000F0F37" # mdi-weather-sunny-alert
@@ -161,24 +164,24 @@ font:
- "\U000F059A" # mdi-weather-sunset
- "\U000F059B" # mdi-weather-sunset-down
- "\U000F059C" # mdi-weather-sunset-up
- "\U000F0F38" # mdi-weather-tornado
#- "\U000F0F38" # mdi-weather-tornado
- "\U000F059D" # mdi-weather-windy
- "\U000F059E" # mdi-weather-windy-variant
#- "\U000F059E" # mdi-weather-windy-variant
- "\U000f010b" # mdi-car
- "\U000f0819" # trash
- file: 'fonts/materialdesignicons-webfont.ttf'
id: font_mdi_medlarge
size: 60
glyphs:
- "\U000f0f64" # new moon
- "\U000f0f67" # mdi-moon-waxing-crescent
- "\U000F0F61" # mdi-moon-first-quarter
- "\U000F0F68" # mdi-moon-waxing-gibbous
- "\U000F0F62" # mdi-moon-full
- "\U000F0F66" # mdi-moon-waning-gibbous
- "\U000F0F63" # mdi-moon-last-quarter
- "\U000F0F65" # mdi-moon-waning-crescent
# - file: 'fonts/materialdesignicons-webfont.ttf'
# id: font_mdi_medlarge
# size: 60
# glyphs:
# - "\U000f0f64" # new moon
# - "\U000f0f67" # mdi-moon-waxing-crescent
# - "\U000F0F61" # mdi-moon-first-quarter
# - "\U000F0F68" # mdi-moon-waxing-gibbous
# - "\U000F0F62" # mdi-moon-full
# - "\U000F0F66" # mdi-moon-waning-gibbous
# - "\U000F0F63" # mdi-moon-last-quarter
# - "\U000F0F65" # mdi-moon-waning-crescent
- file: 'fonts/materialdesignicons-webfont.ttf'
id: font_mdi_medium
size: 36
@@ -357,8 +360,8 @@ display:
dc_pin: GPIO16
busy_pin: GPIO25
reset_pin: GPIO26
#model: 7.50in-bV2
model: 7.50inv2b
model: 7.50in-bV2
#model: 7.50inv2b
#model: 7.50inv2
#model: 7.50inV2alt
update_interval: 30min
@@ -382,27 +385,27 @@ display:
// wifi strength
// if (id(sensor_wifi_signal).has_state())
// {
if (id(sensor_wifi_signal).state >= -50) {
//Excellent
it.print(wifi_x_a, wifi_y_a, id(font_wifi), TextAlign::BASELINE_RIGHT, "󰤨");
ESP_LOGI("WiFi", "Excellent");
} else if (id(sensor_wifi_signal).state >= -60) {
//Good
it.print(wifi_x_a, wifi_y_a, id(font_wifi), TextAlign::BASELINE_RIGHT, "󰤥");
ESP_LOGI("WiFi", "Good");
} else if (id(sensor_wifi_signal).state >= -67) {
//Fair
it.print(wifi_x_a, wifi_y_a, id(font_wifi), TextAlign::BASELINE_RIGHT, "󰤢");
ESP_LOGI("WiFi", "Fair");
} else if (id(sensor_wifi_signal).state >= -70) {
//Weak
it.print(wifi_x_a, wifi_y_a, id(font_wifi), TextAlign::BASELINE_RIGHT, "󰤟");
ESP_LOGI("WiFi", "Weak");
} else {
//Unlikely working signal
it.print(wifi_x_a, wifi_y_a, id(font_wifi), TextAlign::BASELINE_RIGHT, "󰤫");
ESP_LOGI("WiFi", "Unlikely");
}
// if (id(sensor_wifi_signal).state >= -50) {
// //Excellent
// it.print(wifi_x_a, wifi_y_a, id(font_wifi), TextAlign::BASELINE_RIGHT, "󰤨");
// ESP_LOGI("WiFi", "Excellent");
// } else if (id(sensor_wifi_signal).state >= -60) {
// //Good
// it.print(wifi_x_a, wifi_y_a, id(font_wifi), TextAlign::BASELINE_RIGHT, "󰤥");
// ESP_LOGI("WiFi", "Good");
// } else if (id(sensor_wifi_signal).state >= -67) {
// //Fair
// it.print(wifi_x_a, wifi_y_a, id(font_wifi), TextAlign::BASELINE_RIGHT, "󰤢");
// ESP_LOGI("WiFi", "Fair");
// } else if (id(sensor_wifi_signal).state >= -70) {
// //Weak
// it.print(wifi_x_a, wifi_y_a, id(font_wifi), TextAlign::BASELINE_RIGHT, "󰤟");
// ESP_LOGI("WiFi", "Weak");
// } else {
// //Unlikely working signal
// it.print(wifi_x_a, wifi_y_a, id(font_wifi), TextAlign::BASELINE_RIGHT, "󰤫");
// ESP_LOGI("WiFi", "Unlikely");
// }
//}

View File

@@ -29,6 +29,5 @@ packages:
button: !include templates/button.yaml
climate: !include templates/climate_sens.yaml
temp: !include sensors/tuya_mcu.yaml
sensor_wifi: !include sensors/wifi.yaml

View File

@@ -29,7 +29,6 @@ packages:
status: !include templates/status.yaml
logger: !include templates/logger.yaml
sht3x: !include sensors/sht3x.yaml
sensor_wifi: !include sensors/wifi.yaml

View File

@@ -0,0 +1,102 @@
#include "esphome.h"
#include <string>
class Sen0395Distance : public Component, public UARTDevice {
public:
Sen0395Distance(UARTComponent *parent) : UARTDevice(parent) {}
float t_snr[10] = {0, 0, 0, 0, 0, 0, 0, 0, 0, 0};
float t_distance[10] = {0, 0, 0, 0, 0, 0, 0, 0, 0, 0};
bool t_active[10] = {false, false, false, false, false, false, false, false, false, false};
void setup() override {
// nothing to do here
}
int readline(int readch, char *buffer, int len) {
static int pos = 0;
int rpos;
if (readch > 0) {
switch (readch) {
case '\n': // Ignore new-lines
break;
case '\r': // Return on CR
rpos = pos;
pos = 0; // Reset position index ready for next time
return rpos;
default:
if (pos < len - 1) {
buffer[pos++] = readch;
buffer[pos] = 0;
}
}
}
// No end of line has been found, so return -1.
return -1;
}
void loop() override {
const int max_line_length = 40;
static char buffer[max_line_length];
while (available()) {
if (readline(read(), buffer, max_line_length) >= 4) {
std::string line = buffer;
if (line.substr(0, 6) == "$JYRPO") {
std::string vline = line.substr(6);
std::vector<std::string> v;
for (int i = 0; i < vline.length(); i++) {
if (vline[i] == ',') {
v.push_back("");
} else {
v.back() += vline[i];
}
}
int target_count = parse_number<int>(v[0]).value();
int target_index = parse_number<int>(v[1]).value();
float target_distance = parse_number<float>(v[2]).value();
float target_snr = parse_number<float>(v[4]).value();
// Update the SNR, distance, and active status for the current target index
t_snr[target_index] = target_snr;
t_distance[target_index] = target_distance;
t_active[target_index] = true;
if (target_count == target_index) {
// Publish the data for each target without sorting
for (int i = 1; i <= target_count; i++) {
auto get_sensors = App.get_sensors();
for (int j = 0; j < get_sensors.size(); j++) {
std::string name = get_sensors[j]->get_name();
if (name == "Target " + std::to_string(i) + " Distance") {
get_sensors[j]->publish_state(t_distance[i]);
} else if (name == "Target " + std::to_string(i) + " SNR") {
get_sensors[j]->publish_state(t_snr[i]);
}
}
}
// Publish the state of the binary sensor for each target
for (int i = 1; i <= 10; i++) {
auto get_binary_sensors = App.get_binary_sensors();
for (int j = 0; j < get_binary_sensors.size(); j++) {
std::string name = get_binary_sensors[j]->get_name();
if (name == "Target " + std::to_string(i) + " Active") {
get_binary_sensors[j]->publish_state(t_active[i]);
}
}
}
for (int i = target_count + 1; i <= 9; i++) {
t_active[i] = false;
}
//ESP_LOGD("custom", "Target %d Distance: %f, SNR: %f", i, t_distance[i], t_snr[i]);
}
}
}
}
}
};

View File

@@ -0,0 +1 @@
#__init__.py

View File

@@ -0,0 +1,102 @@
#include "esphome.h"
#include <string>
class Sen0395Distance : public Component, public UARTDevice {
public:
Sen0395Distance(UARTComponent *parent) : UARTDevice(parent) {}
float t_snr[10] = {0, 0, 0, 0, 0, 0, 0, 0, 0, 0};
float t_distance[10] = {0, 0, 0, 0, 0, 0, 0, 0, 0, 0};
bool t_active[10] = {false, false, false, false, false, false, false, false, false, false};
void setup() override {
// nothing to do here
}
int readline(int readch, char *buffer, int len) {
static int pos = 0;
int rpos;
if (readch > 0) {
switch (readch) {
case '\n': // Ignore new-lines
break;
case '\r': // Return on CR
rpos = pos;
pos = 0; // Reset position index ready for next time
return rpos;
default:
if (pos < len - 1) {
buffer[pos++] = readch;
buffer[pos] = 0;
}
}
}
// No end of line has been found, so return -1.
return -1;
}
void loop() override {
const int max_line_length = 40;
static char buffer[max_line_length];
while (available()) {
if (readline(read(), buffer, max_line_length) >= 4) {
std::string line = buffer;
if (line.substr(0, 6) == "$JYRPO") {
std::string vline = line.substr(6);
std::vector<std::string> v;
for (int i = 0; i < vline.length(); i++) {
if (vline[i] == ',') {
v.push_back("");
} else {
v.back() += vline[i];
}
}
int target_count = parse_number<int>(v[0]).value();
int target_index = parse_number<int>(v[1]).value();
float target_distance = parse_number<float>(v[2]).value();
float target_snr = parse_number<float>(v[4]).value();
// Update the SNR, distance, and active status for the current target index
t_snr[target_index] = target_snr;
t_distance[target_index] = target_distance;
t_active[target_index] = true;
if (target_count == target_index) {
// Publish the data for each target without sorting
for (int i = 1; i <= target_count; i++) {
auto get_sensors = App.get_sensors();
for (int j = 0; j < get_sensors.size(); j++) {
std::string name = get_sensors[j]->get_name();
if (name == "Target " + std::to_string(i) + " Distance") {
get_sensors[j]->publish_state(t_distance[i]);
} else if (name == "Target " + std::to_string(i) + " SNR") {
get_sensors[j]->publish_state(t_snr[i]);
}
}
}
// Publish the state of the binary sensor for each target
for (int i = 1; i <= 10; i++) {
auto get_binary_sensors = App.get_binary_sensors();
for (int j = 0; j < get_binary_sensors.size(); j++) {
std::string name = get_binary_sensors[j]->get_name();
if (name == "Target " + std::to_string(i) + " Active") {
get_binary_sensors[j]->publish_state(t_active[i]);
}
}
}
for (int i = target_count + 1; i <= 9; i++) {
t_active[i] = false;
}
//ESP_LOGD("custom", "Target %d Distance: %f, SNR: %f", i, t_distance[i], t_snr[i]);
}
}
}
}
}
};

View File

@@ -0,0 +1,34 @@
#include "ACS712.h"
class ACS712Sensor : public PollingComponent {
public:
ACS712 *ACS = new ACS712(A0, 5.0, 1023, 100);
Sensor *current_sensor = new Sensor();
Sensor *power_sensor = new Sensor();
ACS712Sensor() : PollingComponent(15000) {}
void setup() override {
ACS->autoMidPoint();
ESP_LOGD("acs712", "MidPoint: %d", ACS->getMidPoint());
ACS->setNoisemV(43);
ESP_LOGD("acs712", "Noise mV: %d", ACS->getNoisemV());
}
void update() override {
float average = 0;
//uint32_t start = millis();
int count = 5;
for (int i = 0; i < count; i++) {
average += ACS->mA_DC();
}
float amps = average / count / 1000.0;
// float mA = ACS.mA_AC(50,10);
//uint32_t duration = millis() - start;
//ESP_LOGD("acs712", "Time: %d A: ", duration, amps);
current_sensor->publish_state(amps);
power_sensor->publish_state(amps * 19);
}
};

View File

@@ -2,37 +2,37 @@
#include <iostream>
#define ICON_stop "\U000F04DB"
#define ICON_play "\U000F040A"
#define ICON_pause "\U000F03E4"
// #define ICON_stop "\U000F04DB"
// #define ICON_play "\U000F040A"
// #define ICON_pause "\U000F03E4"
std::string playbackStatusToIcon(bool playing, bool paused) {
if (playing) return ICON_play;
else if (paused) return ICON_pause;
else return ICON_stop;
}
// std::string playbackStatusToIcon(bool playing, bool paused) {
// if (playing) return ICON_play;
// else if (paused) return ICON_pause;
// else return ICON_stop;
// }
#define ICON_moon_first_quarter "\U000F0F61"
#define ICON_moon_full "\U000F0F62"
#define ICON_moon_last_quarter "\U000F0F63"
#define ICON_moon_new "\U000F0F64"
#define ICON_moon_waning_crescent "\U000F0F65"
#define ICON_moon_waning_gibbous "\U000F0F66"
#define ICON_moon_waxing_crescent "\U000F0F67"
#define ICON_moon_waxing_gibbous "\U000F0F68"
// #define ICON_moon_first_quarter "\U000F0F61"
// #define ICON_moon_full "\U000F0F62"
// #define ICON_moon_last_quarter "\U000F0F63"
// #define ICON_moon_new "\U000F0F64"
// #define ICON_moon_waning_crescent "\U000F0F65"
// #define ICON_moon_waning_gibbous "\U000F0F66"
// #define ICON_moon_waxing_crescent "\U000F0F67"
// #define ICON_moon_waxing_gibbous "\U000F0F68"
std::string moonToIcon(std::string moonPhase)
{
if (moonPhase == "new_moon") return ICON_moon_new;
if (moonPhase == "waxing_crescent") return ICON_moon_waxing_crescent;
if (moonPhase == "first_quarter") return ICON_moon_first_quarter;
if (moonPhase == "waxing_gibbous") return ICON_moon_waxing_gibbous;
if (moonPhase == "full_moon") return ICON_moon_full;
if (moonPhase == "waning_gibbous") return ICON_moon_waning_gibbous;
if (moonPhase == "last_quarter") return ICON_moon_last_quarter;
if (moonPhase == "waning_crescent") return ICON_moon_waning_crescent;
return "";
}
// std::string moonToIcon(std::string moonPhase)
// {
// if (moonPhase == "new_moon") return ICON_moon_new;
// if (moonPhase == "waxing_crescent") return ICON_moon_waxing_crescent;
// if (moonPhase == "first_quarter") return ICON_moon_first_quarter;
// if (moonPhase == "waxing_gibbous") return ICON_moon_waxing_gibbous;
// if (moonPhase == "full_moon") return ICON_moon_full;
// if (moonPhase == "waning_gibbous") return ICON_moon_waning_gibbous;
// if (moonPhase == "last_quarter") return ICON_moon_last_quarter;
// if (moonPhase == "waning_crescent") return ICON_moon_waning_crescent;
// return "";
// }
// Map weather states to MDI characters.
std::map<std::string, std::string> weather_icon_map
@@ -50,13 +50,13 @@ std::map<std::string, std::string> weather_icon_map
{"night-partly-cloudy", "\U000F0F31"},
{"partlycloudy", "\U000F0595"},
{"partly-lightning", "\U000F0F32"},
{"partly-rainy", "\U000F0F33"},
{"partly-snowy", "\U000F0F34"},
{"partly-rainy", "\U000F0597"}, //compacting U000F0F33
{"partly-snowy", "\U000F0598"}, //compacting U000F0F34
{"partly-snowy-rainy", "\U000F0F35"},
{"pouring", "\U000F0596"},
{"rainy", "\U000F0597"},
{"snowy", "\U000F0598"},
{"snowy-heavy", "\U000F0F36"},
{"snowy-heavy", "\U000F0598"}, //compacting U000F0F36
{"snowy-rainy", "\U000F067F"},
{"sunny", "\U000F0599"},
{"sunny-alert", "\U000F0F37"},
@@ -64,22 +64,22 @@ std::map<std::string, std::string> weather_icon_map
{"sunset", "\U000F059A"},
{"sunset-down", "\U000F059B"},
{"sunset-up", "\U000F059C"},
{"tornado", "\U000F0F38"},
{"tornado", "\U000F059D"}, //compacting U000F0F38
{"windy", "\U000F059D"},
{"windy-variant", "\U000F059E"},
{"windy-variant", "\U000F059D"}, //compacting U000F059E
{"car", "\U000f010b"},
{"trash", "\U000F0819"},
};
std::map<std::string, std::string> moon_icon_map
{
{ "mdi:moon-waxing-crescent", "\U000f0f67" },
{ "mdi:moon-first-quarter", "\U000F0F61" },
{ "mdi:moon-waxing-gibbous", "\U000F0F68" },
{ "mdi:moon-full", "\U000F0F62" },
{ "mdi:moon-waning-gibbous", "\U000F0F66" },
{ "mdi:moon-last-quarter", "\U000F0F63" },
{ "mdi:moon-waning-crescent", "\U000F0F65" },
};
// std::map<std::string, std::string> moon_icon_map
// {
// { "mdi:moon-waxing-crescent", "\U000f0f67" },
// { "mdi:moon-first-quarter", "\U000F0F61" },
// { "mdi:moon-waxing-gibbous", "\U000F0F68" },
// { "mdi:moon-full", "\U000F0F62" },
// { "mdi:moon-waning-gibbous", "\U000F0F66" },
// { "mdi:moon-last-quarter", "\U000F0F63" },
// { "mdi:moon-waning-crescent", "\U000F0F65" },
// };
#define ICON_w_clear_night "\U000F0594"

61
esphome/include/us100.h Executable file
View File

@@ -0,0 +1,61 @@
#include "esphome.h"
/* To start measuring the distance, output a 0x55 over the serial port and
* read back the two byte distance in high byte, low byte format. The
* distance returned is measured in millimeters. Use the following formula
* to obtain the distance as millimeters:
*
* Millimeters = FirstByteRead * 256 + SecondByteRead
*
* This module can also output the temperature when using serial output
* mode. To read the temperature, output a 0x50 byte over the serial port
* and read back a single temperature byte. The actual temperature is
* obtained by using the following formula:
*
* Celsius = ByteRead - 45
*/
class US100 : public PollingComponent, public UARTDevice {
public:
US100(UARTComponent *parent) : PollingComponent(10000), UARTDevice(parent) {}
Sensor *tempsensor = new Sensor();
Sensor *distsensor = new Sensor();
void setup() override {
}
void loop() override {
if(bytesexpected==2 && available() >= 2) {
// we're expecting a distance measurement to come in, and there are
// enough bytes for it, process it
unsigned int mm = read() * 256 + read();
if((mm>1) && (mm<10000)) {
//ESP_LOGD("us100","distance is %u",mm);
distsensor->publish_state(mm);
}
// finished with distance measurement, move on to temperature
flush();
write(0x50); // tell the US100 to start a temperature measurement
bytesexpected=1; // we should start looking for a temperature reading
} else if(bytesexpected==1 && available() >= 1) {
// we are looking for a temperature and there are bytes to read
int temp = read();
if((temp>1) && (temp<130)) {
temp -= 45;
//ESP_LOGD("us100","temperature is %d",temp);
tempsensor->publish_state(temp);
}
bytesexpected=0; // stop looking for bytes
}
}
void update() override {
flush();
write(0x55); // tell the US100 to start a distance measurement
bytesexpected=2; // tell loop() that it should start looking for a distance
}
private:
unsigned int bytesexpected=0;
};

1
esphome/include/www.js Executable file

File diff suppressed because one or more lines are too long

View File

@@ -0,0 +1,14 @@
ethernet:
type: LAN8720
mdc_pin: ${pin_mdc}
mdio_pin: ${pin_mdio}
clk_mode: ${pin_clk}
phy_addr: 0
power_pin: ${pin_power}
manual_ip:
static_ip: ${ip}
gateway: ${gateway}
subnet: ${subnet}
dns1: ${dns1}
dns2: ${dns2}

View File

@@ -4,8 +4,8 @@ rx_pin: ${pin_ld_rx}
baud_rate: 256000
parity: NONE
stop_bits: 1
debug:
direction: BOTH
dummy_receiver: false
after:
delimiter: [0xF8,0xF7,0xF6,0xF5]
# debug:
# direction: BOTH
# dummy_receiver: false
# after:
# delimiter: [0xF8,0xF7,0xF6,0xF5]

View File

@@ -4,8 +4,8 @@ rx_pin: ${pin_ld_rx}
baud_rate: 115200
parity: NONE
stop_bits: 1
debug:
direction: BOTH
#debug:
#direction: BOTH
# dummy_receiver: false
# after:
# delimiter: [0xF8,0xF7,0xF6,0xF5]

84
esphome/kerstboom.yaml Normal file
View File

@@ -0,0 +1,84 @@
substitutions:
device_name: "kerstboom"
friendly_name: "kerstboom"
comment: "esp32-c3"
location: "zolder"
api_password: !secret kerstboom_api
ota_password: !secret ota_password
wifi_ssid: !secret wifi_ssid
wifi_password: !secret wifi_password
gateway: !secret ip_gateway
subnet: !secret ip_subnet
ip: !secret kerstboom_ip
pin_led1: GPIO3
pin_led2: GPIO4
pin_led3: GPIO1
packages:
board: !include boards/esp32-C3.yaml
device_base: !include common/common.yaml
connection: !include common/wifi.yaml
# status: !include templates/status.yaml
logger: !include templates/logger.yaml
light:
- platform: monochromatic
id: ledString1
output: led1
name: "led string 1"
- platform: monochromatic
id: ledString2
output: led2
name: "led string 2"
- platform: monochromatic
id: ledString3
output: led3
name: "led string 3"
- platform: partition
id: master
name: "Master"
restore_mode: RESTORE_DEFAULT_OFF
segments:
- single_light_id: ledString1
- single_light_id: ledString2
- single_light_id: ledString3
# Example output entry
output:
- platform: ledc
pin: ${pin_led1}
id: led1
- platform: ledc
pin: ${pin_led2}
id: led2
- platform: ledc
pin: ${pin_led3}
id: led3
esphome:
libraries:
- https://github.com/RobTillaart/ACS712.git
includes:
- include/acs712_component.h
sensor:
- platform: custom
lambda: |-
auto acs712_sensor = new ACS712Sensor();
App.register_component(acs712_sensor);
return {acs712_sensor->current_sensor, acs712_sensor->power_sensor};
sensors:
- name: "Amperes"
unit_of_measurement: A
accuracy_decimals: 2
- name: "Watts"
unit_of_measurement: W
accuracy_decimals: 2

29
esphome/ld2420-test.yaml Normal file
View File

@@ -0,0 +1,29 @@
substitutions:
device_name: "ld2420test"
friendly_name: "ld2420test"
comment: "esp32, occup"
location: "Zolder"
api_password: !secret ld2420_test_api
ota_password: !secret ota_password
wifi_ssid: !secret wifi_ssid
wifi_password: !secret wifi_password
gateway: !secret ip_gateway
subnet: !secret ip_subnet
ip: !secret ld2420_test_ip
pin_ld_tx: GPIO19
pin_ld_rx: GPIO18
packages:
board: !include boards/esp32_wroom_arduino.yaml
# i2c: !include interfaces/i2c_a.yaml
device_base: !include common/common.yaml
connection: !include common/wifi.yaml
# status: !include templates/status.yaml
logger: !include templates/nologger.yaml
#bt_proxy: !include common/bluetooth.yaml
#sensors
mmwave: !include sensors/ld2420.yaml

View File

@@ -17,79 +17,197 @@ substitutions:
pin_LEDS: GPIO27
packages:
board: !include boards/m5atom.yaml
connection: !include common/wifi.yaml
device_base: !include common/common.yaml
logger: !include templates/logger.yaml
esphome:
name: ${device_name}
friendly_name: ${friendly_name}
project:
name: m5stack.atom-echo-voice-assistant
version: "1.0"
min_version: 2023.10.0
on_boot:
- priority: -100
then:
- wait_until: api.connected
- delay: 1s
- if:
condition:
switch.is_on: use_wake_word
then:
- voice_assistant.start_continuous:
esp32:
board: m5stack-atom
framework:
type: esp-idf
improv_serial:
i2s_audio:
i2s_lrclk_pin: ${pin_lrclk}
i2s_bclk_pin: ${pin_bclk}
i2s_lrclk_pin: GPIO33
i2s_bclk_pin: GPIO19
microphone:
- platform: i2s_audio
id: atom_mic
i2s_din_pin: ${pin_i2sdin}
id: echo_microphone
i2s_din_pin: GPIO23
adc_type: external
pdm: true
speaker:
- platform: i2s_audio
id: echo_speaker
i2s_dout_pin: GPIO22
dac_type: external
mode: mono
voice_assistant:
microphone: atom_mic
id: va
microphone: echo_microphone
speaker: echo_speaker
noise_suppression_level: 2
auto_gain: 31dBFS
volume_multiplier: 2.0
vad_threshold: 3
on_listening:
- light.turn_on:
id: led
blue: 100%
red: 0%
green: 0%
brightness: 100%
effect: pulse
on_tts_start:
then:
- light.turn_on:
id: led
brightness: 100%
red: 0
green: 100%
blue: 0
on_tts_end:
then:
- light.turn_off:
id: led
- light.turn_on:
id: led
blue: 0%
red: 0%
green: 100%
brightness: 100%
effect: pulse
on_end:
- delay: 100ms
- wait_until:
not:
speaker.is_playing:
- script.execute: reset_led
on_error:
then:
- light.turn_on:
id: led
brightness: 100%
red: 100%
green: 0%
blue: 0
- delay: 5s
- light.turn_off:
id: led
media_player:
- platform: i2s_audio
id: media_out
name: "mediaplayer"
dac_type: external
i2s_dout_pin: ${pin_i2sdout}
mode: mono
- light.turn_on:
id: led
blue: 0%
red: 100%
green: 0%
brightness: 100%
effect: none
- delay: 1s
- script.execute: reset_led
- script.wait: reset_led
- lambda: |-
if (code == "wake-provider-missing" || code == "wake-engine-missing") {
id(use_wake_word).turn_off();
}
binary_sensor:
- platform: gpio
pin:
number: ${pin_button}
number: GPIO39
inverted: true
name: "button"
on_press:
- voice_assistant.start:
on_release:
- voice_assistant.stop:
name: Button
disabled_by_default: true
entity_category: diagnostic
id: echo_button
on_click:
- if:
condition:
switch.is_off: use_wake_word
then:
- if:
condition: voice_assistant.is_running
then:
- voice_assistant.stop:
- script.execute: reset_led
else:
- voice_assistant.start:
else:
- voice_assistant.stop
- delay: 1s
- script.execute: reset_led
- script.wait: reset_led
- voice_assistant.start_continuous:
light:
- platform: neopixelbus
type: GRB
variant: ws2812X
pin: ${pin_LEDS}
num_leds: 1
name: "RGB_Light"
- platform: esp32_rmt_led_strip
id: led
name: None
disabled_by_default: true
entity_category: config
pin: GPIO27
default_transition_length: 0s
chipset: SK6812
num_leds: 1
rgb_order: grb
rmt_channel: 0
effects:
- random:
name: "Random"
transition_length: 4s
update_interval: 5s
- addressable_rainbow:
name: Rainbow Effect
speed: 10
width: 50
- pulse:
transition_length: 250ms
update_interval: 250ms
script:
- id: reset_led
then:
- if:
condition:
- switch.is_on: use_wake_word
- switch.is_on: use_listen_light
then:
- light.turn_on:
id: led
blue: 100%
red: 100%
green: 0%
brightness: 100%
effect: none
else:
- light.turn_off: led
switch:
- platform: template
name: Use wake word
id: use_wake_word
optimistic: true
restore_mode: RESTORE_DEFAULT_ON
entity_category: config
on_turn_on:
- lambda: id(va).set_use_wake_word(true);
- if:
condition:
not:
- voice_assistant.is_running
then:
- voice_assistant.start_continuous
- script.execute: reset_led
on_turn_off:
- voice_assistant.stop
- lambda: id(va).set_use_wake_word(false);
- script.execute: reset_led
- platform: template
name: Use Listen Light
id: use_listen_light
optimistic: true
restore_mode: RESTORE_DEFAULT_ON
entity_category: config
on_turn_on:
- script.execute: reset_led
on_turn_off:
- script.execute: reset_led
external_components:
- source: github://pr#5230
components:
- esp_adf
refresh: 0s
esp_adf:

535
esphome/m5-modbus.yaml Normal file
View File

@@ -0,0 +1,535 @@
substitutions:
device_name: "modbus"
friendly_name: "modubs warmtepomp"
comment: "m5 core, modbus"
location: "Zolder"
api_password: !secret modbus_api
ota_password: !secret ota_password
wifi_ssid: !secret wifi_ssid
wifi_password: !secret wifi_password
gateway: !secret ip_gateway
subnet: !secret ip_subnet
ip: !secret modbus_ip
pin_modbus_tx: GPIO17
pin_modbus_rx: GPIO16
packages:
board: !include boards/esp32_M5core.yaml
connection: !include common/wifi.yaml
device_base: !include common/common.yaml
logger: !include templates/logger.yaml
#parameter list: https://tools.remeha.nl/wp-content/uploads/sites/3/2020/08/Lijst-van-parameters-voor-GTW08.pdf
#modbus registers
varApFlowmeter: !include
file: templates/modbusSensorRead.yaml
vars:
entityID: varApFlowmeter
name: "Stromingssnelheid"
address: 410
type: U_WORD
class: water
multiply: 0.01
unit: l/min
FlowTemperatureReceived: !include
file: templates/modbusSensorRead.yaml
vars:
entityID: FlowTemperatureReceived
name: "Aanvoer apparaat"
address: 273
type: S_WORD #INTEGER16
class: temperature
multiply: 0.01
unit: °C
# TemperatureSetpoint: !include
# file: templates/modbusSensorRead.yaml
# vars:
# entityID: TemperatureSetpoint
# name: "Temperatuur Setpoint"
# address: 257
# type: S_WORD #INTEGER16
# class: temperature
# multiply: 0.01
# unit: °C
ReturnTemperatureReceived: !include
file: templates/modbusSensorRead.yaml
vars:
entityID: ReturnTemperatureReceived
name: "Retour apparaat"
address: 274
type: S_WORD #INTEGER16 / maar toch unsigned
class: temperature
multiply: 0.01 #was 0.001
unit: °C
varApTOutside: !include
file: templates/modbusSensorRead.yaml
vars:
entityID: varApTOutside
name: "Buitentemperatuur"
address: 384
type: S_WORD #INTEGER16
class: temperature
multiply: 0.01
unit: °C
varHpHeatPumpTF: !include
file: templates/modbusSensorRead.yaml
vars:
entityID: varHpHeatPumpTF
name: "Aanvoer WP"
address: 403
type: S_WORD #INTEGER16
class: temperature
multiply: 0.01
unit: °C
varHpHeatPumpTR: !include
file: templates/modbusSensorRead.yaml
vars:
entityID: varHpHeatPumpTR
name: "Retour WP"
address: 404
type: S_WORD #INTEGER16
class: temperature
multiply: 0.01
unit: °C
varZoneTemperatureSetpoint: !include
file: templates/modbusSensorRead.yaml
vars:
entityID: varZoneTemperatureSetpoint
name: "Aanvoer Setpoint"
address: 1101
type: U_WORD #UNSIGNED16
class: temperature
multiply: 0.01
unit: °C
varZoneTRoomSetpoint: !include
file: templates/modbusSensorRead.yaml
vars:
entityID: varZoneTRoomSetpoint
name: "Ruimte Setpoint"
address: 1102
type: S_WORD #SIGNED16
class: temperature
multiply: 0.1
unit: °C
varZoneTRoom: !include
file: templates/modbusSensorRead.yaml
vars:
entityID: varZoneTRoom
name: "Zone Setpoint"
address: 1104
type: S_WORD #SIGNED16
class: temperature
multiply: 0.1
unit: °C
parApSummerWinter: !include
file: templates/modbusSensorHolding.yaml
vars:
entityID: parApSummerWinter
name: "sumer/winter temp"
address: 386
type: U_WORD #UNSIGNED16
class: temperature
multiply: 0.01
unit: °C
# GPIO pin of the display backlight
output:
- platform: ledc
pin: 32
id: gpio_32_backlight_pwm
light:
- platform: monochromatic
output: gpio_32_backlight_pwm
name: "Display Backlight"
id: back_light
restore_mode: ALWAYS_OFF
uart:
id: mod_bus
tx_pin: ${pin_modbus_tx}
rx_pin: ${pin_modbus_rx}
baud_rate: 9600
stop_bits: 1
modbus:
flow_control_pin: 5
id: modbus1
modbus_controller:
- id: epever
## the Modbus device addr
address: 100
modbus_id: modbus1
setup_priority: -5
update_interval: 2s
sensor:
#ApWaterPressure 409 UNSIGNED8
- name: "Werkelijke waterdruk"
platform: modbus_controller
modbus_controller_id: epever
id: ApWaterPressure
internal: false
register_type: holding
address: 409
response_size: 1
value_type: S_WORD
accuracy_decimals: 1
device_class: pressure
filters:
- multiply: 0.1
unit_of_measurement: bar
#varApChEnergyConsumption
- name: "Energieverbruik totaal"
platform: modbus_controller
modbus_controller_id: epever
id: varApChEnergyConsumption
internal: false
register_type: holding
address: 433
response_size: 2
value_type: U_DWORD
accuracy_decimals: 0
device_class: energy
filters:
- multiply: 1
unit_of_measurement: kWh
#PowerActualReceived
- name: "Geleverd vermogen"
platform: modbus_controller
modbus_controller_id: epever
id: PowerActualReceived
internal: false
register_type: holding
address: 272
response_size: 1
value_type: U_WORD
accuracy_decimals: 2
device_class: power
filters:
- multiply: 0.1
unit_of_measurement: kW
#varChCtrBurnerStarts 288 + 289
- name: "Teller branderstarts"
platform: modbus_controller
modbus_controller_id: epever
id: varChCtrBurnerStarts
internal: false
register_type: holding
address: 288
#response_size: 2
value_type: U_DWORD
#varApCtrServiceBurnerStarts 295 + 296
- name: "Compressor starts"
platform: modbus_controller
modbus_controller_id: epever
id: varApCtrServiceBurnerStarts
internal: false
register_type: read
address: 293
# response_size: 2
value_type: U_DWORD
#varApCtrBackup1Starts 295 + 296
- name: "Teller starts backup1"
platform: modbus_controller
modbus_controller_id: epever
id: varApCtrBackup1Starts
internal: false
register_type: read
address: 295
value_type: U_DWORD
# calculating COP thanks to JBtL @ tweakers.net
# https://gathering.tweakers.net/forum/view_message/77172604
- name: "PM power"
platform: homeassistant
id: pm_warmtepomp_energy_power
entity_id: sensor.warmtepomp_power_2 #id of your powermeter
internal: false
unit_of_measurement: 'W'
device_class: power
accuracy_decimals: 0
filters:
- timeout:
timeout: 2min
value: 0
- sliding_window_moving_average:
window_size: 20
- name: "COP"
platform: template
id: elgaCOP
internal: False
unit_of_measurement: 'W/W'
accuracy_decimals: 1
filters:
- median:
window_size: 7
send_every: 4
send_first_at: 3
lambda: |-
if( id(pm_warmtepomp_energy_power).state >= 60 )
{
float Deltat = id(varHpHeatPumpTF).state - id(varHpHeatPumpTR).state;
float FlowModified = id(varApFlowmeter).state + 1;
float warmte = Deltat * 69.766667 * FlowModified;
ESP_LOGD("lambda", "COP debug = Deltat: %f, FlowModified: %f, warmte: %f", Deltat, FlowModified, warmte);
return warmte / id(pm_warmtepomp_energy_power).state;
}
else
{
ESP_LOGD("lambda", "power lower than 60W, return 0");
return {};
}
return {};
#reading enums: https://github.com/esphome/feature-requests/issues/1663#issuecomment-1061842308
text_sensor:
- platform: modbus_controller
modbus_controller_id: epever
id: varApSeasonMode
register_type: holding
address: 385
response_size: 2
raw_encode: NONE
name: "Seizoensmodus actief"
lambda: |-
//uint8_t value
uint8_t value = data[1]; // or data[1], depending on, if the device use big, or little-endian
switch (value) {
case 0: return std::string("Winter");
case 1: return std::string("Vorst");
case 2: return std::string("ZomerNeutraalBand");
case 3: return std::string("zomer");
default: return std::string("[0]:" + std::to_string(data[0]) + " [1]:" + std::to_string(data[1]));
}
return x;
# - platform: modbus_controller
# modbus_controller_id: epever
# id: txtAlgorithType
# register_type: holding
# address: 258
# raw_encode: NONE
# response_size: 2
# name: "Type regeling"
# lambda: |-
# //uint8_t value
# uint8_t value = data[1]; // or data[1], depending on, if the device use big, or little-endian
# switch (value) {
# case 0: return std::string("Beide");
# case 1: return std::string("Vermogen");
# case 2: return std::string("Temperatuur");
# case 3: return std::string("geen");
# default: return std::string("[0]:" + std::to_string(data[0]) + " [1]:" + std::to_string(data[1]));
# }
# return x;
- platform: modbus_controller
modbus_controller_id: epever
id: HeatingMode
register_type: holding
address: 1109
raw_encode: NONE
name: "Type warmtevraag (Zone)"
lambda: |-
uint8_t value = data[1];
switch (value) {
case 0: return std::string("Geen");
case 1: return std::string("Verwarming");
case 2: return std::string("Koeling");
default: return std::string("[0]:" + std::to_string(data[0]) + " [1]:" + std::to_string(data[1]));
}
return x;
- platform: modbus_controller
modbus_controller_id: epever
id: Zone1Type
register_type: holding
address: 640
raw_encode: NONE
name: "Zone1 type"
lambda: |-
uint8_t value = data[1];
switch (value) {
case 0: return std::string("Niet aanwezig");
case 1: return std::string("Alleen CV");
case 2: return std::string("CV + KOELING");
case 3: return std::string("SWW");
case 4: return std::string("Processwarmte");
case 5: return std::string("Zwembad");
case 254: return std::string("overige");
default: return std::string("[0]:" + std::to_string(data[0]) + " [1]:" + std::to_string(data[1]));
}
return x;
- platform: modbus_controller
modbus_controller_id: epever
id: parZone1Function
register_type: holding
address: 641
raw_encode: NONE
name: "Zone1 Function"
lambda: |-
uint8_t value = data[1];
switch (value) {
case 0: return std::string("Uitgeschakeld");
case 1: return std::string("Direct");
case 2: return std::string("Mengcircuit");
case 3: return std::string("Zwembad");
case 4: return std::string("Hoge temperatuur");
case 5: return std::string("Ventilatorconvector");
case 6: return std::string("SWW-tank");
case 7: return std::string("Elektrische SWWtank");
case 8: return std::string("Tijdprogramma");
case 9: return std::string("Proceswarmte");
case 254: return std::string("overige");
default: return std::string("[0]:" + std::to_string(data[0]) + " [1]:" + std::to_string(data[1]));
}
return x;
binary_sensor:
#appliance status 1: 279
# b1: varWarmtepompAan
# b2: varElektrischeBack-upAan
# b3: varElektrischeBack-up2Aan
# b4: varSwwElektrischeBack-upAan
# b5: varAp.serviceVereist
# b6: varAp.voedingUitgeschakeldResetnodig
# b7: varAp.waterdrukLaag
- platform: modbus_controller
modbus_controller_id: epever
id: varWarmtepompAan
name: "App Staus 1(b1): WarmtePomp"
register_type: holding
address: 279
bitmask: 0x01 #(bit 1)
- platform: modbus_controller
modbus_controller_id: epever
id: varElektrischeBackupAan
name: "App Staus 1(b2): backup1"
register_type: holding
address: 279
bitmask: 0x02 #(bit 2)
- platform: modbus_controller
modbus_controller_id: epever
id: varElektrischeBackup2Aan
name: "App Staus 1(b3): backup2"
register_type: holding
address: 279
bitmask: 0x04 #(bit 3)
- platform: modbus_controller
modbus_controller_id: epever
id: varSwwElektrischeBack
name: "App Staus 1(b4): SwwElektrischeBackup"
register_type: holding
address: 279
bitmask: 0x08 #(bit 4)
- platform: modbus_controller
modbus_controller_id: epever
id: serviceVereist
name: "App Staus 1(b5): Service vereist"
register_type: holding
address: 279
bitmask: 0x10 #(bit 5)
- platform: modbus_controller
modbus_controller_id: epever
id: voedingUitgeschakeldResetnodig
name: "App Staus 1(b6): voedingUitgeschakeldResetnodig"
register_type: holding
address: 279
bitmask: 0x20 #(bit 6)
- platform: modbus_controller
modbus_controller_id: epever
id: waterdrukLaag
name: "App Staus 1(b7): waterdrukLaag"
register_type: holding
address: 279
bitmask: 0x40 #(bit 7)
#280 - Appliance status 2
# b0: varAp.pomp
# b1: var3-wegklepOpen
# b2: var3-wegklep
# b3: var3-wegklepGesloten
# b4: VarAp.SwwActief
# b5: VarAp.CvActief
# b6: varAp.koelingActief
- platform: modbus_controller
modbus_controller_id: epever
id: varAppomp
name: "App Staus 2(b1): AP pomp"
register_type: holding
address: 280
bitmask: 0x01 #(bit 1)
- platform: modbus_controller
modbus_controller_id: epever
id: var3wegklepOpen
name: "App Staus 2(b2): 3-weg klep open"
register_type: holding
address: 280
bitmask: 0x02 #(bit 2)
- platform: modbus_controller
modbus_controller_id: epever
id: var3wegklep
name: "App Staus 2(b3): 3-weg klep"
register_type: holding
address: 280
bitmask: 0x04 #(bit 3)
- platform: modbus_controller
modbus_controller_id: epever
id: var3wegklepgesloten
name: "App Staus 2(b4): 3-weg klep gesloten"
register_type: holding
address: 280
bitmask: 0x08 #(bit 4)
- platform: modbus_controller
modbus_controller_id: epever
id: varSwwActief
name: "App Staus 2(b5): Sww Actief"
register_type: holding
address: 280
bitmask: 0x10 #(bit 5)
- platform: modbus_controller
modbus_controller_id: epever
id: CvActief
name: "App Staus 2(b6): Cv Actief"
register_type: holding
address: 280
bitmask: 0x20 #(bit 6)
- platform: modbus_controller
modbus_controller_id: epever
id: koelingActief
name: "App Staus 2(b7): koeling Actief"
register_type: holding
address: 280
bitmask: 0x40 #(bit 7)
- name: "CH enabled"
platform: modbus_controller
modbus_controller_id: epever
id: parApChEnabled
internal: false
register_type: holding
address: 500
response_size: 1
# #modbus write registers
# number:
# - platform: modbus_controller
# modbus_controller_id: epever
# id: Num_TemperatureSetpoint
# name: "Temperatuur setpoint"
# address: 257
# value_type: S_WORD
# multiply: 100

38
esphome/mailboxsensor.yaml Executable file
View File

@@ -0,0 +1,38 @@
substitutions:
device_name: "mailboxsensor"
friendly_name: "mailbox sensor"
comment: "esp32, distance"
api_password: !secret mailboxsensor_api
ota_password: !secret ota_password
wifi_ssid: !secret wifi_ssid
wifi_password: !secret wifi_password
gateway: !secret ip_gateway
subnet: !secret ip_subnet
ip: !secret mailboxsensor_ip
pin_echo: GPIO25
pin_trig: GPIO26
pin_vbatt: GPIO35
update_interval: 60s
run_duration: 20s
sleep_duration: 1800s
pin_wake: GPIO14
pin_status: GPIO5
mqtt_broker_ip: !secret mqtt_broker_ip
mqtt_broker_user: !secret mqtt_broker_user
mqtt_broke_pass: !secret mqtt_broker_pass
mqtt_ota_topic: "esphomeOTA/mailbox"
packages:
board: !include boards/esp32_wroom_arduino.yaml
connection: !include common/wifi.yaml
device_base: !include common/common.yaml
logger: !include templates/logger.yaml
#bt_proxy: !include common/bluetooth.yaml
distance: !include sensors/distance_hc-004.yaml
battery: !include sensors/battery.yaml
deepsleep: !include common/deepsleep.yaml
status: !include templates/status.yaml

View File

@@ -12,7 +12,6 @@ substitutions:
ip: !secret plant_sensor1
#project specific params
project_version: '1.0'
update_interval: 30min
loglevel: DEBUG
moisture_min: '2.82'
moisture_max: '1.39'
@@ -20,11 +19,15 @@ substitutions:
conductivity_max: '0.25'
# Uncomment run_duration and sleep_duration if you want to use deepsleep
# set how long to stay awake - NOT less then 10sec
run_duration: 11s
run_duration: 15s
update_interval: 5s
# set how long to sleep in minutes
sleep_duration: 10min
sleep_duration: 60min
mqtt_broker_ip: !secret mqtt_broker_ip
mqtt_broker_user: !secret mqtt_broker_user
mqtt_broke_pass: !secret mqtt_broker_pass
mqtt_ota_topic: "esphomeOTA/plant"
pin_power: GPIO4
pin_sda: GPIO25
pin_scl: GPIO26
pin_wake: GPIO35
@@ -32,64 +35,18 @@ substitutions:
pin_fertilizer: GPIO34
pin_soil: GPIO32
esphome:
name: '${device_name}'
comment: '${comment}'
on_boot:
priority: 240
then:
- wait_until:
condition:
wifi.connected:
timeout: 10s
on_shutdown:
then:
- switch.turn_off: spower
esp32:
board: lolin_d32
packages:
board: !include boards/esp32_lolin32.yaml
device_base: !include common/common.yaml
connection: !include common/wifi.yaml
i2c: !include interfaces/i2c_a.yaml
logger: !include templates/nologger.yaml
bluetooth: !include common/bluetooth.yaml
deepsleep: !include common/deepsleep.yaml
deepsleep: !include common/deepsleep_wakepin.yaml
time: !include templates/time.yaml
#sensors
plantsensors: !include sensors/plantsensors.yaml
light: !include sensors/light_bh1750.yaml
bme280: !include sensors/bme280.yaml
battery: !include sensors/battery.yaml
time:
- platform: homeassistant
button:
- platform: restart
name: 'Restart - ${device_name}'
switch:
# Power Switch
- platform: gpio
name: '${device_name} Sensor Power switch'
pin:
number: 4
mode: INPUT_PULLUP
id: spower
restore_mode: ALWAYS_ON
internal: true
setup_priority: 1000
# packages:
# text_sensors: !include common/text_sensors.yaml
# dht: !include common/dht.yaml
# plantsensors: !include common/plantsensors.yaml
# waterpump: !include common/waterpump.yaml
# bluetooth: !include common/bluetooth.yaml
# Battery only works for 12 hours with deepsleep!
# bme280: !include common/bme280.yaml
# deepsleep: !include common/deepsleep.yaml
# battery: !include common/battery.yaml

53
esphome/plant-sensor-2.yaml Executable file
View File

@@ -0,0 +1,53 @@
substitutions:
device_name: "plant_sensor2"
friendly_name: "plant sensor 2"
comment: "esp32, plant"
location: "zolder"
api_password: !secret plant_sensor1_api
ota_password: !secret ota_password
wifi_ssid: !secret wifi_ssid
wifi_password: !secret wifi_password
gateway: !secret ip_gateway
subnet: !secret ip_subnet
ip: !secret plant_sensor2
#project specific params
project_version: '1.0'
update_interval: 30min
loglevel: DEBUG
moisture_min: '2.82'
moisture_max: '1.39'
conductivity_min: '0.075'
conductivity_max: '0.25'
# Uncomment run_duration and sleep_duration if you want to use deepsleep
# set how long to stay awake - NOT less then 10sec
run_duration: 11s
# set how long to sleep in minutes
sleep_duration: 60min
mqtt_broker_ip: !secret mqtt_broker_ip
mqtt_broker_user: !secret mqtt_broker_user
mqtt_broke_pass: !secret mqtt_broker_pass
mqtt_ota_topic: "esphomeOTA/mailbox"
pin_power: GPIO4
pin_sda: GPIO25
pin_scl: GPIO26
pin_wake: GPIO35
pin_vbatt: GPIO33
pin_fertilizer: GPIO34
pin_soil: GPIO32
packages:
board: !include boards/esp32_lolin32.yaml
device_base: !include common/common.yaml
connection: !include common/wifi.yaml
i2c: !include interfaces/i2c_a.yaml
logger: !include templates/nologger.yaml
deepsleep: !include common/deepsleep_wakepin.yaml
time: !include templates/time.yaml
#sensors
plantsensors: !include sensors/plantsensors.yaml
light: !include sensors/light_bh1750.yaml
bme280: !include sensors/bme280.yaml
battery: !include sensors/battery.yaml

View File

@@ -17,16 +17,22 @@ packages:
board: !include boards/esp32_m5atom.yaml
connection: !include common/wifi.yaml
device_base: !include common/common.yaml
bt_proxy: !include templates/ble_proxy.yaml
bt_proxy: !include common/bluetooth.yaml
logger: !include templates/nologger.yaml
web_server:
port: 80
local: true
js_include: "include/www.js"
js_url: ""
binary_sensor:
- platform: gpio
pin:
number: ${pin_button}
inverted: true
name: ${device_name}_Button
id: button
id: rgb_button
on_click:
then:
- if:
@@ -36,6 +42,17 @@ binary_sensor:
- light.turn_off: RGB_Light
else:
- light.turn_on: RGB_Light
on_double_click:
then:
- if:
condition:
- light.is_on: RGB_Light
then:
- light.dim_relative:
id: RGB_Light
relative_brightness: 10%
else:
- light.turn_on: RGB_Light
light:
- platform: neopixelbus
@@ -53,4 +70,5 @@ light:
- addressable_rainbow:
name: Rainbow Effect
speed: 100
width: 50
width: 50

Submodule esphome/sensors/.esphome/external_components/1e6970f9 added at e995883d66

Submodule esphome/sensors/.esphome/external_components/9cb05fac added at 94b3200604

View File

@@ -3,8 +3,8 @@ sensor:
# Batterie volt
- platform: adc
pin: ${pin_vbatt}
name: '${device_name} Battery Voltage'
id: '${device_name}_voltage'
name: 'Battery Voltage'
id: 'Battery_voltage'
attenuation: 11db
unit_of_measurement: 'V'
icon: 'mdi:battery-high'
@@ -22,8 +22,8 @@ sensor:
# Battery %
- platform: adc
pin: ${pin_vbatt}
name: '${device_name} Battery'
id: '${device_name}_percent'
name: 'Battery level'
id: 'Battery_level'
attenuation: 11db
accuracy_decimals: 2
unit_of_measurement: '%'

View File

@@ -0,0 +1,36 @@
---
sensor:
# Batterie volt
- platform: adc
pin: ${pin_vbatt}
name: 'Battery Voltage'
id: 'Battery_voltage'
attenuation: 11db
unit_of_measurement: 'V'
icon: 'mdi:battery-high'
device_class: 'voltage'
state_class: 'measurement'
accuracy_decimals: 3
filters:
- multiply: 2
- calibrate_linear:
# Map 0.0 (from sensor) to 0.0 (true value)
- 0.0 -> 0.0
- 4.0 -> 4.0
update_interval: ${update_interval}
# Battery %
- platform: adc
pin: ${pin_vbatt}
name: 'Battery level'
id: 'Battery_level'
attenuation: 11db
accuracy_decimals: 3
unit_of_measurement: '%'
filters:
- multiply: 2
- calibrate_linear:
# Map 0.0 (from sensor) to 0.0 (true value)
- 3.18 -> 0.0
- 4.20 -> 100.0
update_interval: ${update_interval}

View File

@@ -3,16 +3,16 @@ sensor:
- platform: bme280
i2c_id: bus_a
temperature:
name: '${device_name} BME280 Temperature'
name: 'Temperature (BME280)'
oversampling: 1x
# filters: # uncomment after calibration
# - offset: -2.3 # offset in °C for the measured temperature
pressure:
name: '${device_name} BME280 Pressure'
name: 'Pressure (BME280)'
# filters: # uncomment after calibration
# - offset: -2.3 # offset in °C for the measured temperature
humidity:
name: '${device_name} BME280 Humidity'
name: 'Humidity (BME280)'
# filters: # uncomment after calibration
# - offset: -2.3 # offset in °C for the measured temperature
address: 0x77

View File

@@ -0,0 +1,8 @@
---
sensor:
- platform: ultrasonic
trigger_pin: ${pin_trig}
echo_pin: ${pin_echo}
name: "Ultrasonic Sensor"
update_interval: 10s
pulse_time: 20us

View File

@@ -5,46 +5,166 @@ uart:
# Example configuration entry
ld2410:
uart_id: uart_ld
timeout: 1s
max_move_distance : 6m
max_still_distance: 3m
# g0_move_threshold: 10
# g0_still_threshold: 20
# g1_move_threshold: 10
# g1_still_threshold: 20
# g2_move_threshold: 20
# g2_still_threshold: 21
# g3_move_threshold: 30
# g3_still_threshold: 31
# g4_move_threshold: 40
# g4_still_threshold: 41
# g5_move_threshold: 50
# g5_still_threshold: 51
# g6_move_threshold: 60
# g6_still_threshold: 61
# g7_move_threshold: 70
# g7_still_threshold: 71
# g8_move_threshold: 80
# g8_still_threshold: 81
button:
- platform: ld2410
factory_reset:
name: "factory reset"
restart:
name: "restart"
query_params:
name: query params
text_sensor:
- platform: ld2410
version:
name: "firmware version"
mac_address:
name: "mac address"
select:
- platform: ld2410
distance_resolution:
name: "distance resolution"
baud_rate:
name: "baud rate"
light_function:
name: light function
out_pin_level:
name: out pin level
number:
- platform: ld2410
timeout:
name: timeout
light_threshold:
name: light threshold
max_move_distance_gate:
name: max move distance gate
max_still_distance_gate:
name: max still distance gate
g0:
move_threshold:
name: g0 move threshold
still_threshold:
name: g0 still threshold
g1:
move_threshold:
name: g1 move threshold
still_threshold:
name: g1 still threshold
g2:
move_threshold:
name: g2 move threshold
still_threshold:
name: g2 still threshold
g3:
move_threshold:
name: g3 move threshold
still_threshold:
name: g3 still threshold
g4:
move_threshold:
name: g4 move threshold
still_threshold:
name: g4 still threshold
g5:
move_threshold:
name: g5 move threshold
still_threshold:
name: g5 still threshold
g6:
move_threshold:
name: g6 move threshold
still_threshold:
name: g6 still threshold
g7:
move_threshold:
name: g7 move threshold
still_threshold:
name: g7 still threshold
g8:
move_threshold:
name: g8 move threshold
still_threshold:
name: g8 still threshold
switch:
- platform: ld2410
engineering_mode:
name: "engineering mode"
bluetooth:
name: "control bluetooth"
sensor:
- platform: ld2410
light:
name: light
moving_distance:
name : ${device_name} Moving Distance
name : Moving Distance
still_distance:
name: ${device_name} Still Distance
name: Still Distance
moving_energy:
name: ${device_name} Move Energy
name: Move Energy
still_energy:
name: ${device_name} Still Energy
name: Still Energy
detection_distance:
name: ${device_name} Detection Distance
name: Detection Distance
g0:
move_energy:
name: g0 move energy
still_energy:
name: g0 still energy
g1:
move_energy:
name: g1 move energy
still_energy:
name: g1 still energy
g2:
move_energy:
name: g2 move energy
still_energy:
name: g2 still energy
g3:
move_energy:
name: g3 move energy
still_energy:
name: g3 still energy
g4:
move_energy:
name: g4 move energy
still_energy:
name: g4 still energy
g5:
move_energy:
name: g5 move energy
still_energy:
name: g5 still energy
g6:
move_energy:
name: g6 move energy
still_energy:
name: g6 still energy
g7:
move_energy:
name: g7 move energy
still_energy:
name: g7 still energy
g8:
move_energy:
name: g8 move energy
still_energy:
name: g8 still energy
binary_sensor:
- platform: ld2410
has_target:
name: ${device_name} Presence
name: Presence
has_moving_target:
name: ${device_name} Moving Target
name: Moving Target
has_still_target:
name: ${device_name} Still Target
name: Still Target
out_pin_presence_status:
name: out pin presence status

View File

@@ -3,9 +3,10 @@ uart:
- !include ../interfaces/uart_ld2420.yaml
external_components:
- source: github://pr#4847
- source: github://descipher/esphome@component.ld2420
#github://pr#4847
components: [ ld2420 ]
refresh: 0s
refresh: 1days
# Example configuration entry
ld2420:
@@ -49,10 +50,10 @@ ld2420:
sensor:
- platform: ld2420
moving_distance:
name : ${device_name} Moving Distance
name : Moving Distance
binary_sensor:
- platform: ld2420
has_target:
name: ${device_name} Presence
name: Presence

View File

@@ -0,0 +1,17 @@
---
sensor:
# Lux sensor
- platform: bh1750
i2c_id: bus_a
name: '${device_name} BH1750 Illuminance'
address: 0x23
unit_of_measurement: 'lx'
icon: 'mdi:white-balance-sunny'
device_class: 'illuminance'
state_class: 'measurement'
setup_priority: -300
update_interval: ${update_interval}
# convert to illuminance
# filters:
# - lambda: |-
# return x * 200.0;

View File

@@ -35,19 +35,4 @@ sensor:
# Map 0.0 (from sensor) to 0.0 (true value)
- ${conductivity_min} -> 0.0 # comment when calibrating
- ${conductivity_max} -> 100.0 # comment when calibrating
# Lux sensor
- platform: bh1750
i2c_id: bus_a
name: '${device_name} BH1750 Illuminance'
address: 0x23
unit_of_measurement: 'lx'
icon: 'mdi:white-balance-sunny'
device_class: 'illuminance'
state_class: 'measurement'
setup_priority: -300
update_interval: ${update_interval}
# convert to illuminance
filters:
- lambda: |-
return x * 200.0;

View File

@@ -4,5 +4,5 @@ uart:
sensor:
- platform: pm1006
pm_2_5:
name: "${location} Particulate Matter 2.5µm Concentration"
name: "Particulate Matter 2.5µm Concentration"
uart_id: uart_pm

View File

@@ -6,9 +6,9 @@ sensor:
uart_id: uart_pm
type: PMSX003
pm_1_0:
name: ${device_name} <1.0µm
name: Particulate Matter 1.0µm Concentration
pm_2_5:
name: ${device_name} <2.5µm
name: Particulate Matter 2.5µm Concentration
pm_10_0:
name: ${device_name} <10.0µm
name: Particulate Matter 10µm Concentration
update_interval: 30000ms

View File

@@ -1,13 +1,13 @@
sensor:
- platform: scd30
co2:
name: "${device_name} CO2"
name: "CO2"
accuracy_decimals: 1
temperature:
name: "${device_name} Temperature"
name: "Temperature"
accuracy_decimals: 2
humidity:
name: "${device_name} Humidity"
name: "Humidity"
accuracy_decimals: 1
temperature_offset: 1.5 °C
address: 0x61

View File

@@ -1,10 +1,10 @@
sensor:
- platform: sgp30
eco2:
name: "${device_name} eCO2"
name: "eCO2"
accuracy_decimals: 1
tvoc:
name: "${device_name} TVOC"
name: "TVOC"
accuracy_decimals: 1
store_baseline: yes
address: 0x58

View File

@@ -1,9 +1,12 @@
sensor:
- platform: sht3xd
temperature:
name: Temperatuur ${device_name}
name: Temperature
id: sht_temp
filters:
- offset: -13.0
humidity:
name: luchtvochtigheid ${device_name}
name: Humidity
address: 0x44
update_interval: 60s
update_interval: 60s

View File

@@ -4,6 +4,7 @@ uart:
time:
- platform: homeassistant
id: homeassistant_time
timezone: CET-1CEST,M3.5.0,M10.5.0/3
tuya:
status_pin: ${pin_tuya_status}
@@ -12,7 +13,7 @@ tuya:
sensor:
- platform: "tuya"
name: "Temperature ${device_name}"
name: "Temperature"
id: tuya_temp
sensor_datapoint: 101
unit_of_measurement: "°C"
@@ -20,10 +21,11 @@ sensor:
state_class: "measurement"
filters:
- multiply: 0.1
- offset: -4.5
accuracy_decimals: 1
- platform: "tuya"
name: "humidity ${device_name}"
name: "humidity"
sensor_datapoint: 102
unit_of_measurement: "%rh"
device_class: "humidity"

30
esphome/sensors/uptime.yaml Executable file
View File

@@ -0,0 +1,30 @@
text_sensor:
- platform: template
name: "Uptime"
lambda: |-
uint32_t dur = id(uptime_s).state;
int dys = 0;
int hrs = 0;
int mnts = 0;
if (dur > 86399) {
dys = trunc(dur / 86400);
dur = dur - (dys * 86400);
}
if (dur > 3599) {
hrs = trunc(dur / 3600);
dur = dur - (hrs * 3600);
}
if (dur > 59) {
mnts = trunc(dur / 60);
dur = dur - (mnts * 60);
}
char buffer[17];
sprintf(buffer, "%ud %02uh %02um %02us", dys, hrs, mnts, dur);
return {buffer};
icon: mdi:clock-start
update_interval: 60s
sensor:
- platform: uptime
id: uptime_s
update_interval: 60s

View File

@@ -1,2 +0,0 @@
bluetooth_proxy:
active: true

View File

@@ -1,7 +1,7 @@
binary_sensor:
- platform: gpio
name: "Button"
id: button
id: gp_button
pin:
number: ${pin_button}
mode: INPUT_PULLUP

View File

@@ -0,0 +1,15 @@
sensor:
- name: ${name}
platform: modbus_controller
modbus_controller_id: epever
id: ${entityID}
internal: false
register_type: holding
address: ${address}
response_size: 1
value_type: ${type}
accuracy_decimals: 1
device_class: ${class}
filters:
- multiply: ${multiply}
unit_of_measurement: ${unit}

View File

@@ -0,0 +1,15 @@
sensor:
- name: ${name}
platform: modbus_controller
modbus_controller_id: epever
id: ${entityID}
internal: false
register_type: read
address: ${address}
#response_size: 1
value_type: ${type}
accuracy_decimals: 1
device_class: ${class}
filters:
- multiply: ${multiply}
unit_of_measurement: ${unit}

View File

@@ -1,2 +1,3 @@
status_led:
pin: ${pin_status}
pin: ${pin_status}
#entity_category: config

3
esphome/templates/time.yaml Executable file
View File

@@ -0,0 +1,3 @@
time:
- platform: homeassistant
id: homeassistant_time

119
esphome/voiceassist.yaml Normal file
View File

@@ -0,0 +1,119 @@
substitutions:
device_name: "voiceassist1"
friendly_name: "ESP32 voice Assist 1"
comment: "esp32, mic, dac, Btn"
api_password: !secret voiceassist1_api
ota_password: !secret ota_password
wifi_ssid: !secret wifi_ssid
wifi_password: !secret wifi_password
gateway: !secret ip_gateway
subnet: !secret ip_subnet
ip: !secret voiceassist1_ip
pin_lrclk: GPIO19
pin_bclk: GPIO18
pin_i2sdin: GPIO23
pin_i2sdout: GPIO5
pin_button: GPIO14
pin_LEDS: GPIO27
packages:
connection: !include common/wifi.yaml
logger: !include templates/logger.yaml
esphome:
name: ${device_name}
friendly_name: ${friendly_name}
project:
name: esp32.voice-assistant
version: "1.0"
min_version: 2023.10.0
on_boot:
- priority: -100
then:
- wait_until: api.connected
- delay: 1s
- if:
condition:
switch.is_on: use_wake_word
then:
- voice_assistant.start_continuous:
esp32:
board: esp32dev
framework:
type: esp-idf
improv_serial:
i2s_audio:
i2s_lrclk_pin: ${pin_lrclk}
i2s_bclk_pin: ${pin_bclk}
microphone:
- platform: i2s_audio
id: mic
i2s_din_pin: ${pin_i2sdin}
adc_type: external
pdm: false
speaker:
- platform: i2s_audio
id: big_speaker
i2s_dout_pin: ${pin_i2sdout}
dac_type: external
mode: mono
voice_assistant:
microphone: mic
use_wake_word: false
noise_suppression_level: 2
auto_gain: 31dBFS
volume_multiplier: 2.0
speaker: big_speaker
id: assist
binary_sensor:
- platform: gpio
pin:
number: ${pin_button}
inverted: true
name: Button
disabled_by_default: true
entity_category: diagnostic
id: echo_button
on_click:
- if:
condition:
switch.is_off: use_wake_word
then:
- if:
condition: voice_assistant.is_running
then:
- voice_assistant.stop:
else:
- voice_assistant.start:
else:
- voice_assistant.stop
- delay: 1s
- voice_assistant.start_continuous:
switch:
- platform: template
name: Use wake word
id: use_wake_word
optimistic: true
restore_mode: RESTORE_DEFAULT_ON
entity_category: config
on_turn_on:
- lambda: id(assist).set_use_wake_word(true);
- if:
condition:
not:
- voice_assistant.is_running
then:
- voice_assistant.start_continuous
on_turn_off:
- voice_assistant.stop
- lambda: id(assist).set_use_wake_word(false);

View File

@@ -27,6 +27,7 @@ switch:
pin: ${pin_motor}
name: "Valve"
icon: mdi:pipe-valve
internal: true
binary_sensor:
- platform: gpio
@@ -36,4 +37,31 @@ binary_sensor:
min_length: 50ms
max_length: 1000ms
then:
- switch.toggle: valveMotor
- sprinkler.start_full_cycle: tuin_sprinkler_ctrlr
on_double_click:
then:
- sprinkler.shutdown: tuin_sprinkler_ctrlr
sprinkler:
- id: tuin_sprinkler_ctrlr
multiplier_number: "Herhaling"
valves:
- valve_switch: "hoofd klep"
run_duration_number: "hoofd klep timer"
valve_switch_id: valveMotor
sensor:
- platform: template
name: "Resterende tijd"
lambda: |-
if (id(tuin_sprinkler_ctrlr).time_remaining_active_valve().has_value()) {
// the controller is running, print the number of seconds remaining
return id(tuin_sprinkler_ctrlr).time_remaining_active_valve().value();
} else {
// the controller is NOT running
return 0;
}
unit_of_measurement: s
accuracy_decimals: 0
device_class: "duration"
update_interval: 1s

105
esphome/zigbee-server.yaml Executable file
View File

@@ -0,0 +1,105 @@
substitutions:
device_name: "zigbee_server"
friendly_name: "Zigbee server"
comment: "esp32, POE eth zigbee"
location: "hass"
api_password: !secret zigbee_server_api
ota_password: !secret ota_password
wifi_ssid: !secret wifi_ssid
wifi_password: !secret wifi_password
gateway: !secret ip_gateway
subnet: !secret ip_subnet
dns1: !secret ip_dns1
dns2: !secret ip_dns2
ip: !secret zigbee_server_ip
pin_button: GPIO39
pin_leds: GPIO25
pin_mdc: GPIO23
pin_mdio: GPIO18
pin_clk: GPIO17_OUT
pin_power: GPIO5
pin_efrReset: GPIO33
pin_efrTX: GPIO12
pin_efrRX: GPIO16
packages:
board: !include boards/esp32_wroom_arduino.yaml
# connection: !include common/wifi.yaml
device_base: !include common/common.yaml
ethernet: !include interfaces/eth_LAN8720A.yaml
# bt_proxy: !include templates/ble_proxy.yaml
logger: !include templates/nologger.yaml
uptimesensor: !include sensors/uptime.yaml
time: !include templates/time.yaml
api:
encryption:
key: ${api_password}
ota:
password: ${ota_password}
external_components:
- source: github://tube0013/esphome-stream-server-v2
- source: github://syssi/esphome-zeroconf@main
web_server:
port: 80
switch:
- platform: gpio
pin: ${pin_efrReset}
id: zRST_gpio
inverted: yes
restore_mode: ALWAYS_OFF
# - platform: gpio
# pin: 32
# name: "Pull Bootloader pin (PA2) to Low"
# id: zBSL
# inverted: yes
# restore_mode: ALWAYS_OFF
# disabled_by_default: true
button:
- platform: restart
name: "Restart the Gateway"
disabled_by_default: true
- platform: template
name: "EFR32 Reset"
id: zRST
disabled_by_default: true
on_press:
- switch.turn_on: zRST_gpio
- delay: 15ms
- switch.turn_off: zRST_gpio
uart:
id: uart_bus
tx_pin: ${pin_efrTX}
rx_pin: ${pin_efrRX}
baud_rate: 115200
stop_bits: 1
stream_server:
uart_id: uart_bus
id: ss
port: 6638 # optional, default is 6638
binary_sensor:
- platform: stream_server
stream_server: ss
name: "TubesZB Serial Connected"
zeroconf:
- service: tubeszb
protocol: tcp
port: 6638
txt:
version: 1.0
name: TubesZB
radio_type: ezsp
baud_rate: 115200
data_flow_control: software