mirror of
https://github.com/esphome/esphome.git
synced 2024-11-28 01:34:18 +01:00
Merge branch 'esphome:dev' into dev
This commit is contained in:
commit
b843bfd83c
30 changed files with 147 additions and 92 deletions
8
.github/workflows/release.yml
vendored
8
.github/workflows/release.yml
vendored
|
@ -96,12 +96,12 @@ jobs:
|
||||||
uses: docker/setup-qemu-action@v3.0.0
|
uses: docker/setup-qemu-action@v3.0.0
|
||||||
|
|
||||||
- name: Log in to docker hub
|
- name: Log in to docker hub
|
||||||
uses: docker/login-action@v3.1.0
|
uses: docker/login-action@v3.2.0
|
||||||
with:
|
with:
|
||||||
username: ${{ secrets.DOCKER_USER }}
|
username: ${{ secrets.DOCKER_USER }}
|
||||||
password: ${{ secrets.DOCKER_PASSWORD }}
|
password: ${{ secrets.DOCKER_PASSWORD }}
|
||||||
- name: Log in to the GitHub container registry
|
- name: Log in to the GitHub container registry
|
||||||
uses: docker/login-action@v3.1.0
|
uses: docker/login-action@v3.2.0
|
||||||
with:
|
with:
|
||||||
registry: ghcr.io
|
registry: ghcr.io
|
||||||
username: ${{ github.actor }}
|
username: ${{ github.actor }}
|
||||||
|
@ -188,13 +188,13 @@ jobs:
|
||||||
|
|
||||||
- name: Log in to docker hub
|
- name: Log in to docker hub
|
||||||
if: matrix.registry == 'dockerhub'
|
if: matrix.registry == 'dockerhub'
|
||||||
uses: docker/login-action@v3.1.0
|
uses: docker/login-action@v3.2.0
|
||||||
with:
|
with:
|
||||||
username: ${{ secrets.DOCKER_USER }}
|
username: ${{ secrets.DOCKER_USER }}
|
||||||
password: ${{ secrets.DOCKER_PASSWORD }}
|
password: ${{ secrets.DOCKER_PASSWORD }}
|
||||||
- name: Log in to the GitHub container registry
|
- name: Log in to the GitHub container registry
|
||||||
if: matrix.registry == 'ghcr'
|
if: matrix.registry == 'ghcr'
|
||||||
uses: docker/login-action@v3.1.0
|
uses: docker/login-action@v3.2.0
|
||||||
with:
|
with:
|
||||||
registry: ghcr.io
|
registry: ghcr.io
|
||||||
username: ${{ github.actor }}
|
username: ${{ github.actor }}
|
||||||
|
|
2
.github/workflows/sync-device-classes.yml
vendored
2
.github/workflows/sync-device-classes.yml
vendored
|
@ -36,7 +36,7 @@ jobs:
|
||||||
python ./script/sync-device_class.py
|
python ./script/sync-device_class.py
|
||||||
|
|
||||||
- name: Commit changes
|
- name: Commit changes
|
||||||
uses: peter-evans/create-pull-request@v6.0.4
|
uses: peter-evans/create-pull-request@v6.0.5
|
||||||
with:
|
with:
|
||||||
commit-message: "Synchronise Device Classes from Home Assistant"
|
commit-message: "Synchronise Device Classes from Home Assistant"
|
||||||
committer: esphomebot <esphome@nabucasa.com>
|
committer: esphomebot <esphome@nabucasa.com>
|
||||||
|
|
|
@ -3,7 +3,7 @@
|
||||||
# See https://pre-commit.com/hooks.html for more hooks
|
# See https://pre-commit.com/hooks.html for more hooks
|
||||||
repos:
|
repos:
|
||||||
- repo: https://github.com/psf/black-pre-commit-mirror
|
- repo: https://github.com/psf/black-pre-commit-mirror
|
||||||
rev: 24.2.0
|
rev: 24.4.2
|
||||||
hooks:
|
hooks:
|
||||||
- id: black
|
- id: black
|
||||||
args:
|
args:
|
||||||
|
|
|
@ -414,7 +414,7 @@ esphome/components/veml3235/* @kbx81
|
||||||
esphome/components/veml7700/* @latonita
|
esphome/components/veml7700/* @latonita
|
||||||
esphome/components/version/* @esphome/core
|
esphome/components/version/* @esphome/core
|
||||||
esphome/components/voice_assistant/* @jesserockz
|
esphome/components/voice_assistant/* @jesserockz
|
||||||
esphome/components/wake_on_lan/* @willwill2will54
|
esphome/components/wake_on_lan/* @clydebarrow @willwill2will54
|
||||||
esphome/components/waveshare_epaper/* @clydebarrow
|
esphome/components/waveshare_epaper/* @clydebarrow
|
||||||
esphome/components/web_server_base/* @OttoWinter
|
esphome/components/web_server_base/* @OttoWinter
|
||||||
esphome/components/web_server_idf/* @dentra
|
esphome/components/web_server_idf/* @dentra
|
||||||
|
|
|
@ -10,6 +10,7 @@
|
||||||
#include "ade7880.h"
|
#include "ade7880.h"
|
||||||
#include "ade7880_registers.h"
|
#include "ade7880_registers.h"
|
||||||
#include "esphome/core/log.h"
|
#include "esphome/core/log.h"
|
||||||
|
|
||||||
#include <cinttypes>
|
#include <cinttypes>
|
||||||
|
|
||||||
namespace esphome {
|
namespace esphome {
|
||||||
|
|
|
@ -1,5 +1,6 @@
|
||||||
#include "ade7953_base.h"
|
#include "ade7953_base.h"
|
||||||
#include "esphome/core/log.h"
|
#include "esphome/core/log.h"
|
||||||
|
|
||||||
#include <cinttypes>
|
#include <cinttypes>
|
||||||
|
|
||||||
namespace esphome {
|
namespace esphome {
|
||||||
|
|
|
@ -1,5 +1,7 @@
|
||||||
#include "ags10.h"
|
#include "ags10.h"
|
||||||
|
|
||||||
|
#include <cinttypes>
|
||||||
|
|
||||||
namespace esphome {
|
namespace esphome {
|
||||||
namespace ags10 {
|
namespace ags10 {
|
||||||
static const char *const TAG = "ags10";
|
static const char *const TAG = "ags10";
|
||||||
|
@ -35,7 +37,7 @@ void AGS10Component::setup() {
|
||||||
|
|
||||||
auto resistance = this->read_resistance_();
|
auto resistance = this->read_resistance_();
|
||||||
if (resistance) {
|
if (resistance) {
|
||||||
ESP_LOGD(TAG, "AGS10 Sensor Resistance: 0x%08X", *resistance);
|
ESP_LOGD(TAG, "AGS10 Sensor Resistance: 0x%08" PRIX32, *resistance);
|
||||||
if (this->resistance_ != nullptr) {
|
if (this->resistance_ != nullptr) {
|
||||||
this->resistance_->publish_state(*resistance);
|
this->resistance_->publish_state(*resistance);
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,6 +1,7 @@
|
||||||
#include "ct_clamp_sensor.h"
|
#include "ct_clamp_sensor.h"
|
||||||
|
|
||||||
#include "esphome/core/log.h"
|
#include "esphome/core/log.h"
|
||||||
|
#include <cinttypes>
|
||||||
#include <cmath>
|
#include <cmath>
|
||||||
|
|
||||||
namespace esphome {
|
namespace esphome {
|
||||||
|
@ -37,8 +38,8 @@ void CTClampSensor::update() {
|
||||||
float rms_ac = 0;
|
float rms_ac = 0;
|
||||||
if (rms_ac_squared > 0)
|
if (rms_ac_squared > 0)
|
||||||
rms_ac = std::sqrt(rms_ac_squared);
|
rms_ac = std::sqrt(rms_ac_squared);
|
||||||
ESP_LOGD(TAG, "'%s' - Raw AC Value: %.3fA after %d different samples (%d SPS)", this->name_.c_str(), rms_ac,
|
ESP_LOGD(TAG, "'%s' - Raw AC Value: %.3fA after %" PRIu32 " different samples (%" PRIu32 " SPS)",
|
||||||
this->num_samples_, 1000 * this->num_samples_ / this->sample_duration_);
|
this->name_.c_str(), rms_ac, this->num_samples_, 1000 * this->num_samples_ / this->sample_duration_);
|
||||||
this->publish_state(rms_ac);
|
this->publish_state(rms_ac);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
|
@ -377,7 +377,7 @@ uint8_t FingerprintGrowComponent::transfer_(std::vector<uint8_t> *p_data_buffer)
|
||||||
this->write((uint8_t) (wire_length >> 8));
|
this->write((uint8_t) (wire_length >> 8));
|
||||||
this->write((uint8_t) (wire_length & 0xFF));
|
this->write((uint8_t) (wire_length & 0xFF));
|
||||||
|
|
||||||
uint16_t sum = ((wire_length) >> 8) + ((wire_length) &0xFF) + COMMAND;
|
uint16_t sum = (wire_length >> 8) + (wire_length & 0xFF) + COMMAND;
|
||||||
for (auto data : *p_data_buffer) {
|
for (auto data : *p_data_buffer) {
|
||||||
this->write(data);
|
this->write(data);
|
||||||
sum += data;
|
sum += data;
|
||||||
|
|
|
@ -1,6 +1,7 @@
|
||||||
#include "he60r.h"
|
#include "he60r.h"
|
||||||
#include "esphome/core/hal.h"
|
#include "esphome/core/hal.h"
|
||||||
#include "esphome/core/log.h"
|
#include "esphome/core/log.h"
|
||||||
|
|
||||||
#include <cinttypes>
|
#include <cinttypes>
|
||||||
|
|
||||||
namespace esphome {
|
namespace esphome {
|
||||||
|
@ -125,10 +126,10 @@ void HE60rCover::process_rx_(uint8_t data) {
|
||||||
}
|
}
|
||||||
|
|
||||||
void HE60rCover::update_() {
|
void HE60rCover::update_() {
|
||||||
if (toggles_needed_ != 0) {
|
if (this->toggles_needed_ != 0) {
|
||||||
if ((this->counter_++ & 0x3) == 0) {
|
if ((this->counter_++ & 0x3) == 0) {
|
||||||
toggles_needed_--;
|
this->toggles_needed_--;
|
||||||
ESP_LOGD(TAG, "Writing byte 0x30, still needed=%" PRIu32, toggles_needed_);
|
ESP_LOGD(TAG, "Writing byte 0x30, still needed=%" PRIu32, this->toggles_needed_);
|
||||||
this->write_byte(TOGGLE_BYTE);
|
this->write_byte(TOGGLE_BYTE);
|
||||||
} else {
|
} else {
|
||||||
this->write_byte(QUERY_BYTE);
|
this->write_byte(QUERY_BYTE);
|
||||||
|
|
|
@ -12,6 +12,8 @@
|
||||||
#include "esphome/core/helpers.h"
|
#include "esphome/core/helpers.h"
|
||||||
#include "esphome/core/log.h"
|
#include "esphome/core/log.h"
|
||||||
|
|
||||||
|
#include <cinttypes>
|
||||||
|
|
||||||
namespace esphome {
|
namespace esphome {
|
||||||
namespace htu31d {
|
namespace htu31d {
|
||||||
|
|
||||||
|
@ -204,7 +206,7 @@ uint32_t HTU31DComponent::read_serial_num_() {
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
ESP_LOGD(TAG, "Found serial: 0x%X", serial);
|
ESP_LOGD(TAG, "Found serial: 0x%" PRIX32, serial);
|
||||||
|
|
||||||
return serial;
|
return serial;
|
||||||
}
|
}
|
||||||
|
|
|
@ -483,7 +483,7 @@ bool INA2XX::read_power_w_(float &power_out) {
|
||||||
uint64_t power_reading{0};
|
uint64_t power_reading{0};
|
||||||
auto ret = this->read_unsigned_((uint8_t) RegisterMap::REG_POWER, 3, power_reading);
|
auto ret = this->read_unsigned_((uint8_t) RegisterMap::REG_POWER, 3, power_reading);
|
||||||
|
|
||||||
ESP_LOGV(TAG, "read_power_w_ ret=%s, reading_lsb=%d", OKFAILED(ret), (uint32_t) power_reading);
|
ESP_LOGV(TAG, "read_power_w_ ret=%s, reading_lsb=%" PRIu32, OKFAILED(ret), (uint32_t) power_reading);
|
||||||
if (ret) {
|
if (ret) {
|
||||||
power_out = this->cfg_.power_coeff * this->current_lsb_ * (float) power_reading;
|
power_out = this->cfg_.power_coeff * this->current_lsb_ * (float) power_reading;
|
||||||
}
|
}
|
||||||
|
@ -503,8 +503,8 @@ bool INA2XX::read_energy_(double &joules_out, double &watt_hours_out) {
|
||||||
uint64_t previous_energy = this->energy_overflows_count_ * (((uint64_t) 1) << 40);
|
uint64_t previous_energy = this->energy_overflows_count_ * (((uint64_t) 1) << 40);
|
||||||
auto ret = this->read_unsigned_((uint8_t) RegisterMap::REG_ENERGY, 5, joules_reading);
|
auto ret = this->read_unsigned_((uint8_t) RegisterMap::REG_ENERGY, 5, joules_reading);
|
||||||
|
|
||||||
ESP_LOGV(TAG, "read_energy_j_ ret=%s, reading_lsb=0x%" PRIX64 ", current_lsb=%f, overflow_cnt=%d", OKFAILED(ret),
|
ESP_LOGV(TAG, "read_energy_j_ ret=%s, reading_lsb=0x%" PRIX64 ", current_lsb=%f, overflow_cnt=%" PRIu32,
|
||||||
joules_reading, this->current_lsb_, this->energy_overflows_count_);
|
OKFAILED(ret), joules_reading, this->current_lsb_, this->energy_overflows_count_);
|
||||||
if (ret) {
|
if (ret) {
|
||||||
joules_out = this->cfg_.energy_coeff * this->current_lsb_ * (double) joules_reading + (double) previous_energy;
|
joules_out = this->cfg_.energy_coeff * this->current_lsb_ * (double) joules_reading + (double) previous_energy;
|
||||||
watt_hours_out = joules_out / 3600.0;
|
watt_hours_out = joules_out / 3600.0;
|
||||||
|
@ -528,7 +528,7 @@ bool INA2XX::read_charge_(double &coulombs_out, double &_hours_out) {
|
||||||
auto ret = this->read_unsigned_((uint8_t) RegisterMap::REG_CHARGE, 5, raw);
|
auto ret = this->read_unsigned_((uint8_t) RegisterMap::REG_CHARGE, 5, raw);
|
||||||
coulombs_reading = this->two_complement_(raw, 40);
|
coulombs_reading = this->two_complement_(raw, 40);
|
||||||
|
|
||||||
ESP_LOGV(TAG, "read_charge_c_ ret=%d, curr_charge=%f + 39-bit overflow_cnt=%d", ret, coulombs_reading,
|
ESP_LOGV(TAG, "read_charge_c_ ret=%d, curr_charge=%f + 39-bit overflow_cnt=%" PRIu32, ret, coulombs_reading,
|
||||||
this->charge_overflows_count_);
|
this->charge_overflows_count_);
|
||||||
if (ret) {
|
if (ret) {
|
||||||
coulombs_out = this->current_lsb_ * (double) coulombs_reading + (double) previous_charge;
|
coulombs_out = this->current_lsb_ * (double) coulombs_reading + (double) previous_charge;
|
||||||
|
|
|
@ -2,8 +2,6 @@
|
||||||
#include "esphome/core/helpers.h"
|
#include "esphome/core/helpers.h"
|
||||||
#include "esphome/core/log.h"
|
#include "esphome/core/log.h"
|
||||||
|
|
||||||
#include <cinttypes>
|
|
||||||
|
|
||||||
// Very basic support for JSN_SR04T V3.0 distance sensor in mode 2
|
// Very basic support for JSN_SR04T V3.0 distance sensor in mode 2
|
||||||
|
|
||||||
namespace esphome {
|
namespace esphome {
|
||||||
|
@ -38,7 +36,7 @@ void Jsnsr04tComponent::check_buffer_() {
|
||||||
uint16_t distance = encode_uint16(this->buffer_[1], this->buffer_[2]);
|
uint16_t distance = encode_uint16(this->buffer_[1], this->buffer_[2]);
|
||||||
if (distance > 250) {
|
if (distance > 250) {
|
||||||
float meters = distance / 1000.0f;
|
float meters = distance / 1000.0f;
|
||||||
ESP_LOGV(TAG, "Distance from sensor: %" PRIu32 "mm, %.3fm", distance, meters);
|
ESP_LOGV(TAG, "Distance from sensor: %umm, %.3fm", distance, meters);
|
||||||
this->publish_state(meters);
|
this->publish_state(meters);
|
||||||
} else {
|
} else {
|
||||||
ESP_LOGW(TAG, "Invalid data read from sensor: %s", format_hex_pretty(this->buffer_).c_str());
|
ESP_LOGW(TAG, "Invalid data read from sensor: %s", format_hex_pretty(this->buffer_).c_str());
|
||||||
|
|
|
@ -1,5 +1,6 @@
|
||||||
#include "mhz19.h"
|
#include "mhz19.h"
|
||||||
#include "esphome/core/log.h"
|
#include "esphome/core/log.h"
|
||||||
|
|
||||||
#include <cinttypes>
|
#include <cinttypes>
|
||||||
|
|
||||||
namespace esphome {
|
namespace esphome {
|
||||||
|
|
|
@ -20,6 +20,7 @@
|
||||||
#include <tensorflow/lite/micro/micro_interpreter.h>
|
#include <tensorflow/lite/micro/micro_interpreter.h>
|
||||||
#include <tensorflow/lite/micro/micro_mutable_op_resolver.h>
|
#include <tensorflow/lite/micro/micro_mutable_op_resolver.h>
|
||||||
|
|
||||||
|
#include <cinttypes>
|
||||||
#include <cmath>
|
#include <cmath>
|
||||||
|
|
||||||
namespace esphome {
|
namespace esphome {
|
||||||
|
@ -316,7 +317,7 @@ float MicroWakeWord::perform_streaming_inference_() {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
ESP_LOGV(TAG, "Streaming Inference Latency=%u ms", (millis() - prior_invoke));
|
ESP_LOGV(TAG, "Streaming Inference Latency=%" PRIu32 " ms", (millis() - prior_invoke));
|
||||||
|
|
||||||
TfLiteTensor *output = this->streaming_interpreter_->output(0);
|
TfLiteTensor *output = this->streaming_interpreter_->output(0);
|
||||||
|
|
||||||
|
|
|
@ -1,5 +1,6 @@
|
||||||
#include "byronsx_protocol.h"
|
#include "byronsx_protocol.h"
|
||||||
#include "esphome/core/log.h"
|
#include "esphome/core/log.h"
|
||||||
|
|
||||||
#include <cinttypes>
|
#include <cinttypes>
|
||||||
|
|
||||||
namespace esphome {
|
namespace esphome {
|
||||||
|
|
|
@ -1,6 +1,8 @@
|
||||||
#include "drayton_protocol.h"
|
#include "drayton_protocol.h"
|
||||||
#include "esphome/core/log.h"
|
#include "esphome/core/log.h"
|
||||||
|
|
||||||
|
#include <cinttypes>
|
||||||
|
|
||||||
namespace esphome {
|
namespace esphome {
|
||||||
namespace remote_base {
|
namespace remote_base {
|
||||||
|
|
||||||
|
|
|
@ -469,7 +469,8 @@ class LWIPRawImpl : public Socket {
|
||||||
}
|
}
|
||||||
ssize_t sendto(const void *buf, size_t len, int flags, const struct sockaddr *to, socklen_t tolen) override {
|
ssize_t sendto(const void *buf, size_t len, int flags, const struct sockaddr *to, socklen_t tolen) override {
|
||||||
// return ::sendto(fd_, buf, len, flags, to, tolen);
|
// return ::sendto(fd_, buf, len, flags, to, tolen);
|
||||||
return 0;
|
errno = ENOSYS;
|
||||||
|
return -1;
|
||||||
}
|
}
|
||||||
int setblocking(bool blocking) override {
|
int setblocking(bool blocking) override {
|
||||||
if (pcb_ == nullptr) {
|
if (pcb_ == nullptr) {
|
||||||
|
|
|
@ -128,7 +128,8 @@ bool SonoffD1Output::read_ack_(const uint8_t *cmd, const size_t len) {
|
||||||
// Expected acknowledgement from rf chip
|
// Expected acknowledgement from rf chip
|
||||||
uint8_t ref_buffer[7] = {0xAA, 0x55, cmd[2], cmd[3], 0x00, 0x00, 0x00};
|
uint8_t ref_buffer[7] = {0xAA, 0x55, cmd[2], cmd[3], 0x00, 0x00, 0x00};
|
||||||
uint8_t buffer[sizeof(ref_buffer)] = {0};
|
uint8_t buffer[sizeof(ref_buffer)] = {0};
|
||||||
uint32_t pos = 0, buf_len = sizeof(ref_buffer);
|
uint32_t pos = 0;
|
||||||
|
size_t buf_len = sizeof(ref_buffer);
|
||||||
|
|
||||||
// Update the reference checksum
|
// Update the reference checksum
|
||||||
this->populate_checksum_(ref_buffer, sizeof(ref_buffer));
|
this->populate_checksum_(ref_buffer, sizeof(ref_buffer));
|
||||||
|
|
|
@ -1 +1 @@
|
||||||
CODEOWNERS = ["@willwill2will54"]
|
CODEOWNERS = ["@willwill2will54", "@clydebarrow"]
|
||||||
|
|
|
@ -2,6 +2,16 @@ import esphome.codegen as cg
|
||||||
from esphome.components import button
|
from esphome.components import button
|
||||||
import esphome.config_validation as cv
|
import esphome.config_validation as cv
|
||||||
from esphome.const import CONF_ID
|
from esphome.const import CONF_ID
|
||||||
|
from esphome.core import CORE
|
||||||
|
|
||||||
|
DEPENDENCIES = ["network"]
|
||||||
|
|
||||||
|
|
||||||
|
def AUTO_LOAD():
|
||||||
|
if CORE.is_esp8266 or CORE.is_rp2040:
|
||||||
|
return []
|
||||||
|
return ["socket"]
|
||||||
|
|
||||||
|
|
||||||
CONF_TARGET_MAC_ADDRESS = "target_mac_address"
|
CONF_TARGET_MAC_ADDRESS = "target_mac_address"
|
||||||
|
|
||||||
|
@ -9,25 +19,19 @@ wake_on_lan_ns = cg.esphome_ns.namespace("wake_on_lan")
|
||||||
|
|
||||||
WakeOnLanButton = wake_on_lan_ns.class_("WakeOnLanButton", button.Button, cg.Component)
|
WakeOnLanButton = wake_on_lan_ns.class_("WakeOnLanButton", button.Button, cg.Component)
|
||||||
|
|
||||||
DEPENDENCIES = ["network"]
|
CONFIG_SCHEMA = (
|
||||||
|
|
||||||
CONFIG_SCHEMA = cv.All(
|
|
||||||
button.button_schema(WakeOnLanButton)
|
button.button_schema(WakeOnLanButton)
|
||||||
.extend(cv.COMPONENT_SCHEMA)
|
.extend(cv.COMPONENT_SCHEMA)
|
||||||
.extend(
|
.extend(
|
||||||
cv.Schema(
|
{
|
||||||
{
|
cv.Required(CONF_TARGET_MAC_ADDRESS): cv.mac_address,
|
||||||
cv.Required(CONF_TARGET_MAC_ADDRESS): cv.mac_address,
|
}
|
||||||
}
|
)
|
||||||
),
|
|
||||||
),
|
|
||||||
cv.only_with_arduino,
|
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
def to_code(config):
|
async def to_code(config):
|
||||||
var = cg.new_Pvariable(config[CONF_ID])
|
var = cg.new_Pvariable(config[CONF_ID])
|
||||||
|
cg.add(var.set_macaddr(*config[CONF_TARGET_MAC_ADDRESS].parts))
|
||||||
yield cg.add(var.set_macaddr(*config[CONF_TARGET_MAC_ADDRESS].parts))
|
await cg.register_component(var, config)
|
||||||
yield cg.register_component(var, config)
|
await button.register_button(var, config)
|
||||||
yield button.register_button(var, config)
|
|
||||||
|
|
|
@ -1,5 +1,3 @@
|
||||||
#ifdef USE_ARDUINO
|
|
||||||
|
|
||||||
#include "wake_on_lan.h"
|
#include "wake_on_lan.h"
|
||||||
#include "esphome/core/log.h"
|
#include "esphome/core/log.h"
|
||||||
#include "esphome/components/network/ip_address.h"
|
#include "esphome/components/network/ip_address.h"
|
||||||
|
@ -22,40 +20,68 @@ void WakeOnLanButton::set_macaddr(uint8_t a, uint8_t b, uint8_t c, uint8_t d, ui
|
||||||
|
|
||||||
void WakeOnLanButton::dump_config() {
|
void WakeOnLanButton::dump_config() {
|
||||||
LOG_BUTTON("", "Wake-on-LAN Button", this);
|
LOG_BUTTON("", "Wake-on-LAN Button", this);
|
||||||
ESP_LOGCONFIG(TAG, " Target MAC address: %02X:%02X:%02X:%02X:%02X:%02X", macaddr_[0], macaddr_[1], macaddr_[2],
|
ESP_LOGCONFIG(TAG, " Target MAC address: %02X:%02X:%02X:%02X:%02X:%02X", this->macaddr_[0], this->macaddr_[1],
|
||||||
macaddr_[3], macaddr_[4], macaddr_[5]);
|
this->macaddr_[2], this->macaddr_[3], this->macaddr_[4], this->macaddr_[5]);
|
||||||
}
|
}
|
||||||
|
|
||||||
void WakeOnLanButton::press_action() {
|
void WakeOnLanButton::press_action() {
|
||||||
|
if (!network::is_connected()) {
|
||||||
|
ESP_LOGW(TAG, "Network not connected");
|
||||||
|
return;
|
||||||
|
}
|
||||||
ESP_LOGI(TAG, "Sending Wake-on-LAN Packet...");
|
ESP_LOGI(TAG, "Sending Wake-on-LAN Packet...");
|
||||||
bool begin_status = false;
|
#if defined(USE_SOCKET_IMPL_BSD_SOCKETS) || defined(USE_SOCKET_IMPL_LWIP_SOCKETS)
|
||||||
bool end_status = false;
|
struct sockaddr_storage saddr {};
|
||||||
|
auto addr_len =
|
||||||
|
socket::set_sockaddr(reinterpret_cast<sockaddr *>(&saddr), sizeof(saddr), "255.255.255.255", this->port_);
|
||||||
|
uint8_t buffer[6 + sizeof this->macaddr_ * 16];
|
||||||
|
memcpy(buffer, PREFIX, sizeof(PREFIX));
|
||||||
|
for (size_t i = 0; i != 16; i++) {
|
||||||
|
memcpy(buffer + i * sizeof(this->macaddr_) + sizeof(PREFIX), this->macaddr_, sizeof(this->macaddr_));
|
||||||
|
}
|
||||||
|
if (this->broadcast_socket_->sendto(buffer, sizeof(buffer), 0, reinterpret_cast<const sockaddr *>(&saddr),
|
||||||
|
addr_len) <= 0)
|
||||||
|
ESP_LOGW(TAG, "sendto() error %d", errno);
|
||||||
|
#else
|
||||||
IPAddress broadcast = IPAddress(255, 255, 255, 255);
|
IPAddress broadcast = IPAddress(255, 255, 255, 255);
|
||||||
#ifdef USE_ESP8266
|
|
||||||
for (auto ip : esphome::network::get_ip_addresses()) {
|
for (auto ip : esphome::network::get_ip_addresses()) {
|
||||||
if (ip.is_ip4()) {
|
if (ip.is_ip4()) {
|
||||||
begin_status = this->udp_client_.beginPacketMulticast(broadcast, 9, ip, 128);
|
if (this->udp_client_.beginPacketMulticast(broadcast, 9, ip, 128) != 0) {
|
||||||
break;
|
this->udp_client_.write(PREFIX, 6);
|
||||||
|
for (size_t i = 0; i < 16; i++) {
|
||||||
|
this->udp_client_.write(macaddr_, 6);
|
||||||
|
}
|
||||||
|
if (this->udp_client_.endPacket() != 0)
|
||||||
|
return;
|
||||||
|
ESP_LOGW(TAG, "WOL broadcast failed");
|
||||||
|
return;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
ESP_LOGW(TAG, "No ip4 addresses to broadcast to");
|
||||||
#endif
|
#endif
|
||||||
#ifdef USE_ESP32
|
}
|
||||||
begin_status = this->udp_client_.beginPacket(broadcast, 9);
|
|
||||||
#endif
|
|
||||||
|
|
||||||
if (begin_status) {
|
void WakeOnLanButton::setup() {
|
||||||
this->udp_client_.write(PREFIX, 6);
|
#if defined(USE_SOCKET_IMPL_BSD_SOCKETS) || defined(USE_SOCKET_IMPL_LWIP_SOCKETS)
|
||||||
for (size_t i = 0; i < 16; i++) {
|
this->broadcast_socket_ = socket::socket(AF_INET, SOCK_DGRAM, IPPROTO_IP);
|
||||||
this->udp_client_.write(macaddr_, 6);
|
if (this->broadcast_socket_ == nullptr) {
|
||||||
}
|
this->mark_failed();
|
||||||
end_status = this->udp_client_.endPacket();
|
this->status_set_error("Could not create socket");
|
||||||
|
return;
|
||||||
}
|
}
|
||||||
if (!begin_status || end_status) {
|
int enable = 1;
|
||||||
ESP_LOGE(TAG, "Sending Wake-on-LAN Packet Failed!");
|
auto err = this->broadcast_socket_->setsockopt(SOL_SOCKET, SO_REUSEADDR, &enable, sizeof(int));
|
||||||
|
if (err != 0) {
|
||||||
|
this->status_set_warning("Socket unable to set reuseaddr");
|
||||||
|
// we can still continue
|
||||||
}
|
}
|
||||||
|
err = this->broadcast_socket_->setsockopt(SOL_SOCKET, SO_BROADCAST, &enable, sizeof(int));
|
||||||
|
if (err != 0) {
|
||||||
|
this->status_set_warning("Socket unable to set broadcast");
|
||||||
|
}
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
} // namespace wake_on_lan
|
} // namespace wake_on_lan
|
||||||
} // namespace esphome
|
} // namespace esphome
|
||||||
|
|
||||||
#endif
|
|
||||||
|
|
|
@ -1,10 +1,12 @@
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#ifdef USE_ARDUINO
|
|
||||||
|
|
||||||
#include "esphome/components/button/button.h"
|
#include "esphome/components/button/button.h"
|
||||||
#include "esphome/core/component.h"
|
#include "esphome/core/component.h"
|
||||||
|
#if defined(USE_SOCKET_IMPL_BSD_SOCKETS) || defined(USE_SOCKET_IMPL_LWIP_SOCKETS)
|
||||||
|
#include "esphome/components/socket/socket.h"
|
||||||
|
#else
|
||||||
#include "WiFiUdp.h"
|
#include "WiFiUdp.h"
|
||||||
|
#endif
|
||||||
|
|
||||||
namespace esphome {
|
namespace esphome {
|
||||||
namespace wake_on_lan {
|
namespace wake_on_lan {
|
||||||
|
@ -14,14 +16,19 @@ class WakeOnLanButton : public button::Button, public Component {
|
||||||
void set_macaddr(uint8_t a, uint8_t b, uint8_t c, uint8_t d, uint8_t e, uint8_t f);
|
void set_macaddr(uint8_t a, uint8_t b, uint8_t c, uint8_t d, uint8_t e, uint8_t f);
|
||||||
|
|
||||||
void dump_config() override;
|
void dump_config() override;
|
||||||
|
void setup() override;
|
||||||
|
float get_setup_priority() const override { return setup_priority::AFTER_WIFI; }
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
|
#if defined(USE_SOCKET_IMPL_BSD_SOCKETS) || defined(USE_SOCKET_IMPL_LWIP_SOCKETS)
|
||||||
|
std::unique_ptr<socket::Socket> broadcast_socket_{};
|
||||||
|
#else
|
||||||
WiFiUDP udp_client_{};
|
WiFiUDP udp_client_{};
|
||||||
|
#endif
|
||||||
void press_action() override;
|
void press_action() override;
|
||||||
|
uint16_t port_{9};
|
||||||
uint8_t macaddr_[6];
|
uint8_t macaddr_[6];
|
||||||
};
|
};
|
||||||
|
|
||||||
} // namespace wake_on_lan
|
} // namespace wake_on_lan
|
||||||
} // namespace esphome
|
} // namespace esphome
|
||||||
|
|
||||||
#endif
|
|
||||||
|
|
|
@ -375,8 +375,8 @@ void WeikaiChannel::set_baudrate_() {
|
||||||
this->parent_->page1_ = false; // switch back to page 0
|
this->parent_->page1_ = false; // switch back to page 0
|
||||||
this->reg(WKREG_SPAGE) = 0;
|
this->reg(WKREG_SPAGE) = 0;
|
||||||
|
|
||||||
ESP_LOGV(TAG, " Crystal=%d baudrate=%d => registers [%d %d %d]", this->parent_->crystal_, this->baud_rate_,
|
ESP_LOGV(TAG, " Crystal=%" PRId32 " baudrate=%" PRId32 " => registers [%d %d %d]", this->parent_->crystal_,
|
||||||
baud_high, baud_low, baud_dec);
|
this->baud_rate_, baud_high, baud_low, baud_dec);
|
||||||
}
|
}
|
||||||
|
|
||||||
inline bool WeikaiChannel::tx_fifo_is_not_empty_() { return this->reg(WKREG_FSR) & FSR_TFDAT; }
|
inline bool WeikaiChannel::tx_fifo_is_not_empty_() { return this->reg(WKREG_FSR) & FSR_TFDAT; }
|
||||||
|
|
|
@ -1,6 +1,8 @@
|
||||||
#include "wl_134.h"
|
#include "wl_134.h"
|
||||||
#include "esphome/core/log.h"
|
#include "esphome/core/log.h"
|
||||||
|
|
||||||
|
#include <cinttypes>
|
||||||
|
|
||||||
namespace esphome {
|
namespace esphome {
|
||||||
namespace wl_134 {
|
namespace wl_134 {
|
||||||
|
|
||||||
|
@ -71,7 +73,7 @@ Wl134Component::Rfid134Error Wl134Component::read_packet_() {
|
||||||
ESP_LOGV(TAG, "isData: %s", reading.isData ? "true" : "false");
|
ESP_LOGV(TAG, "isData: %s", reading.isData ? "true" : "false");
|
||||||
ESP_LOGV(TAG, "isAnimal: %s", reading.isAnimal ? "true" : "false");
|
ESP_LOGV(TAG, "isAnimal: %s", reading.isAnimal ? "true" : "false");
|
||||||
ESP_LOGV(TAG, "Reserved0: %d", reading.reserved0);
|
ESP_LOGV(TAG, "Reserved0: %d", reading.reserved0);
|
||||||
ESP_LOGV(TAG, "Reserved1: %d", reading.reserved1);
|
ESP_LOGV(TAG, "Reserved1: %" PRId32, reading.reserved1);
|
||||||
|
|
||||||
char buf[20];
|
char buf[20];
|
||||||
sprintf(buf, "%03d%012lld", reading.country, reading.id);
|
sprintf(buf, "%03d%012lld", reading.country, reading.id);
|
||||||
|
|
|
@ -3,6 +3,7 @@
|
||||||
#include "esphome/core/hal.h"
|
#include "esphome/core/hal.h"
|
||||||
#include "esphome/core/helpers.h"
|
#include "esphome/core/helpers.h"
|
||||||
#include "esphome/components/i2c/i2c.h"
|
#include "esphome/components/i2c/i2c.h"
|
||||||
|
|
||||||
#include <cinttypes>
|
#include <cinttypes>
|
||||||
|
|
||||||
namespace esphome {
|
namespace esphome {
|
||||||
|
|
|
@ -1,12 +1,12 @@
|
||||||
pylint==3.1.0
|
pylint==3.1.0
|
||||||
flake8==7.0.0 # also change in .pre-commit-config.yaml when updating
|
flake8==7.0.0 # also change in .pre-commit-config.yaml when updating
|
||||||
black==24.4.0 # also change in .pre-commit-config.yaml when updating
|
black==24.4.2 # also change in .pre-commit-config.yaml when updating
|
||||||
pyupgrade==3.15.2 # also change in .pre-commit-config.yaml when updating
|
pyupgrade==3.15.2 # also change in .pre-commit-config.yaml when updating
|
||||||
pre-commit
|
pre-commit
|
||||||
|
|
||||||
# Unit tests
|
# Unit tests
|
||||||
pytest==8.2.0
|
pytest==8.2.0
|
||||||
pytest-cov==4.1.0
|
pytest-cov==5.0.0
|
||||||
pytest-mock==3.14.0
|
pytest-mock==3.14.0
|
||||||
pytest-asyncio==0.23.6
|
pytest-asyncio==0.23.6
|
||||||
asyncmock==0.4.2
|
asyncmock==0.4.2
|
||||||
|
|
|
@ -32,8 +32,8 @@ remote_receiver:
|
||||||
on_coolix:
|
on_coolix:
|
||||||
then:
|
then:
|
||||||
- logger.log:
|
- logger.log:
|
||||||
format: "on_coolix: %u %u"
|
format: "on_coolix: %lu %lu"
|
||||||
args: ["x.first", "x.second"]
|
args: ["long(x.first)", "long(x.second)"]
|
||||||
on_dish:
|
on_dish:
|
||||||
then:
|
then:
|
||||||
- logger.log:
|
- logger.log:
|
||||||
|
@ -52,13 +52,13 @@ remote_receiver:
|
||||||
on_jvc:
|
on_jvc:
|
||||||
then:
|
then:
|
||||||
- logger.log:
|
- logger.log:
|
||||||
format: "on_jvc: %u"
|
format: "on_jvc: %lu"
|
||||||
args: ["x.data"]
|
args: ["long(x.data)"]
|
||||||
on_keeloq:
|
on_keeloq:
|
||||||
then:
|
then:
|
||||||
- logger.log:
|
- logger.log:
|
||||||
format: "on_keeloq: %u %u %u"
|
format: "on_keeloq: %lu %lu %u"
|
||||||
args: ["x.encrypted", "x.address", "x.command"]
|
args: ["long(x.encrypted)", "long(x.address)", "x.command"]
|
||||||
on_haier:
|
on_haier:
|
||||||
then:
|
then:
|
||||||
- logger.log:
|
- logger.log:
|
||||||
|
@ -67,13 +67,13 @@ remote_receiver:
|
||||||
on_lg:
|
on_lg:
|
||||||
then:
|
then:
|
||||||
- logger.log:
|
- logger.log:
|
||||||
format: "on_lg: %u %u"
|
format: "on_lg: %lu %u"
|
||||||
args: ["x.data", "x.nbits"]
|
args: ["long(x.data)", "x.nbits"]
|
||||||
on_magiquest:
|
on_magiquest:
|
||||||
then:
|
then:
|
||||||
- logger.log:
|
- logger.log:
|
||||||
format: "on_magiquest: %u %u"
|
format: "on_magiquest: %u %lu"
|
||||||
args: ["x.magnitude", "x.wand_id"]
|
args: ["x.magnitude", "long(x.wand_id)"]
|
||||||
on_midea:
|
on_midea:
|
||||||
then:
|
then:
|
||||||
- logger.log:
|
- logger.log:
|
||||||
|
@ -87,13 +87,13 @@ remote_receiver:
|
||||||
on_nexa:
|
on_nexa:
|
||||||
then:
|
then:
|
||||||
- logger.log:
|
- logger.log:
|
||||||
format: "on_nexa: %u %u %u %u %u"
|
format: "on_nexa: %lu %u %u %u %u"
|
||||||
args: ["x.device", "x.group", "x.state", "x.channel", "x.level"]
|
args: ["long(x.device)", "x.group", "x.state", "x.channel", "x.level"]
|
||||||
on_panasonic:
|
on_panasonic:
|
||||||
then:
|
then:
|
||||||
- logger.log:
|
- logger.log:
|
||||||
format: "on_panasonic: %u %u"
|
format: "on_panasonic: %u %lu"
|
||||||
args: ["x.address", "x.command"]
|
args: ["x.address", "long(x.command)"]
|
||||||
on_pioneer:
|
on_pioneer:
|
||||||
then:
|
then:
|
||||||
- logger.log:
|
- logger.log:
|
||||||
|
@ -107,8 +107,8 @@ remote_receiver:
|
||||||
on_raw:
|
on_raw:
|
||||||
then:
|
then:
|
||||||
- logger.log:
|
- logger.log:
|
||||||
format: "on_raw: %u"
|
format: "on_raw: %lu"
|
||||||
args: ["x.front()"]
|
args: ["long(x.front())"]
|
||||||
on_rc5:
|
on_rc5:
|
||||||
then:
|
then:
|
||||||
- logger.log:
|
- logger.log:
|
||||||
|
@ -132,13 +132,13 @@ remote_receiver:
|
||||||
on_samsung36:
|
on_samsung36:
|
||||||
then:
|
then:
|
||||||
- logger.log:
|
- logger.log:
|
||||||
format: "on_samsung36: %u %u"
|
format: "on_samsung36: %u %lu"
|
||||||
args: ["x.address", "x.command"]
|
args: ["x.address", "long(x.command)"]
|
||||||
on_sony:
|
on_sony:
|
||||||
then:
|
then:
|
||||||
- logger.log:
|
- logger.log:
|
||||||
format: "on_sony: %u %u"
|
format: "on_sony: %lu %u"
|
||||||
args: ["x.data", "x.nbits"]
|
args: ["long(x.data)", "x.nbits"]
|
||||||
on_toshiba_ac:
|
on_toshiba_ac:
|
||||||
then:
|
then:
|
||||||
- logger.log:
|
- logger.log:
|
||||||
|
|
1
tests/components/wake_on_lan/test.esp32-c3-idf.yaml
Normal file
1
tests/components/wake_on_lan/test.esp32-c3-idf.yaml
Normal file
|
@ -0,0 +1 @@
|
||||||
|
<<: !include common.yaml
|
1
tests/components/wake_on_lan/test.esp32-idf.yaml
Normal file
1
tests/components/wake_on_lan/test.esp32-idf.yaml
Normal file
|
@ -0,0 +1 @@
|
||||||
|
<<: !include common.yaml
|
Loading…
Reference in a new issue