Skip to content

Commit

Permalink
Merge branch 'fix/wg/wifi_disconnect' into feature/wireguard_component
Browse files Browse the repository at this point in the history
* restart wireguard link after local network connection loss
* upgrade esp_wireguard to version 0.3.2
   - fix wrong latest handshake retrieval
   - add support for eth interface if wifi not available (thanks to J. Peletier)
  • Loading branch information
droscy committed Jul 2, 2023
2 parents 2b4f2be + c9d255a commit 4a87453
Show file tree
Hide file tree
Showing 20 changed files with 710 additions and 667 deletions.
6 changes: 0 additions & 6 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -241,12 +241,6 @@ jobs:
with:
python-version: ${{ env.DEFAULT_PYTHON }}
cache-key: ${{ needs.common.outputs.cache-key }}
- name: Cache platformio
uses: actions/cache@v3.3.1
with:
path: ~/.platformio
# yamllint disable-line rule:line-length
key: platformio-test${{ matrix.file }}-${{ hashFiles('platformio.ini') }}
- name: Run esphome compile tests/test${{ matrix.file }}.yaml
run: |
. venv/bin/activate
Expand Down
15 changes: 2 additions & 13 deletions .github/workflows/sync-device-classes.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,14 +6,12 @@ on:
schedule:
- cron: '45 6 * * *'

permissions:
contents: write
pull-requests: write

jobs:
sync:
name: Sync Device Classes
runs-on: ubuntu-latest
if: github.repository == 'esphome/esphome'
steps:
- name: Checkout
uses: actions/checkout@v3
Expand All @@ -38,15 +36,6 @@ jobs:
run: |
python ./script/sync-device_class.py
- name: Get PR template
id: pr-template-body
run: |
body=$(cat .github/PULL_REQUEST_TEMPLATE.md)
delimiter="$(openssl rand -hex 8)"
echo "body<<$delimiter" >> $GITHUB_OUTPUT
echo "$body" >> $GITHUB_OUTPUT
echo "$delimiter" >> $GITHUB_OUTPUT
- name: Commit changes
uses: peter-evans/create-pull-request@v5
with:
Expand All @@ -56,5 +45,5 @@ jobs:
branch: sync/device-classes
delete-branch: true
title: "Synchronise Device Classes from Home Assistant"
body: ${{ steps.pr-template-body.outputs.body }}
body-path: .github/PULL_REQUEST_TEMPLATE.md
token: ${{ secrets.DEVICE_CLASS_SYNC_TOKEN }}
2 changes: 1 addition & 1 deletion .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ repos:
- --branch=release
- --branch=beta
- repo: https://github.com/asottile/pyupgrade
rev: v3.4.0
rev: v3.7.0
hooks:
- id: pyupgrade
args: [--py39-plus]
2 changes: 2 additions & 0 deletions esphome/components/button/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
CONF_TRIGGER_ID,
CONF_MQTT_ID,
DEVICE_CLASS_EMPTY,
DEVICE_CLASS_IDENTIFY,
DEVICE_CLASS_RESTART,
DEVICE_CLASS_UPDATE,
)
Expand All @@ -24,6 +25,7 @@

DEVICE_CLASSES = [
DEVICE_CLASS_EMPTY,
DEVICE_CLASS_IDENTIFY,
DEVICE_CLASS_RESTART,
DEVICE_CLASS_UPDATE,
]
Expand Down
5 changes: 4 additions & 1 deletion esphome/components/dsmr/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
CONF_DECRYPTION_KEY = "decryption_key"
CONF_DSMR_ID = "dsmr_id"
CONF_GAS_MBUS_ID = "gas_mbus_id"
CONF_WATER_MBUS_ID = "water_mbus_id"
CONF_MAX_TELEGRAM_LENGTH = "max_telegram_length"
CONF_REQUEST_INTERVAL = "request_interval"
CONF_REQUEST_PIN = "request_pin"
Expand Down Expand Up @@ -53,6 +54,7 @@ def _validate_key(value):
cv.Optional(CONF_DECRYPTION_KEY): _validate_key,
cv.Optional(CONF_CRC_CHECK, default=True): cv.boolean,
cv.Optional(CONF_GAS_MBUS_ID, default=1): cv.int_,
cv.Optional(CONF_WATER_MBUS_ID, default=2): cv.int_,
cv.Optional(CONF_MAX_TELEGRAM_LENGTH, default=1500): cv.int_,
cv.Optional(CONF_REQUEST_PIN): pins.gpio_output_pin_schema,
cv.Optional(
Expand Down Expand Up @@ -82,9 +84,10 @@ async def to_code(config):
cg.add(var.set_receive_timeout(config[CONF_RECEIVE_TIMEOUT].total_milliseconds))

cg.add_build_flag("-DDSMR_GAS_MBUS_ID=" + str(config[CONF_GAS_MBUS_ID]))
cg.add_build_flag("-DDSMR_WATER_MBUS_ID=" + str(config[CONF_WATER_MBUS_ID]))

# DSMR Parser
cg.add_library("glmnet/Dsmr", "0.5")
cg.add_library("glmnet/Dsmr", "0.7")

# Crypto
cg.add_library("rweather/Crypto", "0.4.0")
7 changes: 7 additions & 0 deletions esphome/components/dsmr/sensor.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
DEVICE_CLASS_GAS,
DEVICE_CLASS_POWER,
DEVICE_CLASS_VOLTAGE,
DEVICE_CLASS_WATER,
STATE_CLASS_MEASUREMENT,
STATE_CLASS_TOTAL_INCREASING,
UNIT_AMPERE,
Expand Down Expand Up @@ -236,6 +237,12 @@
device_class=DEVICE_CLASS_GAS,
state_class=STATE_CLASS_TOTAL_INCREASING,
),
cv.Optional("water_delivered"): sensor.sensor_schema(
unit_of_measurement=UNIT_CUBIC_METER,
accuracy_decimals=3,
device_class=DEVICE_CLASS_WATER,
state_class=STATE_CLASS_TOTAL_INCREASING,
),
}
).extend(cv.COMPONENT_SCHEMA)

Expand Down
1 change: 1 addition & 0 deletions esphome/components/esp32_ble/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -55,3 +55,4 @@ async def to_code(config):

if CORE.using_esp_idf:
add_idf_sdkconfig_option("CONFIG_BT_ENABLED", True)
add_idf_sdkconfig_option("CONFIG_BT_BLE_42_FEATURES_SUPPORTED", True)
19 changes: 12 additions & 7 deletions esphome/components/scd30/scd30.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -42,13 +42,18 @@ void SCD30Component::setup() {
ESP_LOGD(TAG, "SCD30 Firmware v%0d.%02d", (uint16_t(raw_firmware_version[0]) >> 8),
uint16_t(raw_firmware_version[0] & 0xFF));

if (this->temperature_offset_ != 0) {
if (!this->write_command(SCD30_CMD_TEMPERATURE_OFFSET, (uint16_t) (temperature_offset_ * 100.0))) {
ESP_LOGE(TAG, "Sensor SCD30 error setting temperature offset.");
this->error_code_ = MEASUREMENT_INIT_FAILED;
this->mark_failed();
return;
}
uint16_t temp_offset;
if (this->temperature_offset_ > 0) {
temp_offset = (this->temperature_offset_ * 100);
} else {
temp_offset = 0;
}

if (!this->write_command(SCD30_CMD_TEMPERATURE_OFFSET, temp_offset)) {
ESP_LOGE(TAG, "Sensor SCD30 error setting temperature offset.");
this->error_code_ = MEASUREMENT_INIT_FAILED;
this->mark_failed();
return;
}
#ifdef USE_ESP32
// According ESP32 clock stretching is typically 30ms and up to 150ms "due to
Expand Down
5 changes: 4 additions & 1 deletion esphome/components/scd30/sensor.py
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,10 @@
cv.int_range(min=0, max=0xFFFF, max_included=False),
),
cv.Optional(CONF_AMBIENT_PRESSURE_COMPENSATION, default=0): cv.pressure,
cv.Optional(CONF_TEMPERATURE_OFFSET): cv.temperature,
cv.Optional(CONF_TEMPERATURE_OFFSET): cv.All(
cv.temperature,
cv.float_range(min=0, max=655.35),
),
cv.Optional(CONF_UPDATE_INTERVAL, default="60s"): cv.All(
cv.positive_time_period_seconds,
cv.Range(
Expand Down
15 changes: 14 additions & 1 deletion esphome/components/script/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@

PARAMETER_TYPE_TRANSLATIONS = {
"string": "std::string",
"boolean": "bool",
}


Expand Down Expand Up @@ -149,6 +150,16 @@ async def to_code(config):
),
)
async def script_execute_action_to_code(config, action_id, template_arg, args):
def convert(type: str):
def converter(value):
if type == "std::string":
return value
if type == "bool":
return cg.RawExpression(str(value).lower())
return cg.RawExpression(str(value))

return converter

async def get_ordered_args(config, script_params):
config_args = config.copy()
config_args.pop(CONF_ID)
Expand All @@ -160,7 +171,9 @@ async def get_ordered_args(config, script_params):
raise EsphomeError(
f"Missing parameter: '{name}' in script.execute {config[CONF_ID]}"
)
arg = await cg.templatable(config_args[name], args, type)
arg = await cg.templatable(
config_args[name], args, type, convert(str(type))
)
script_args.append(arg)
return script_args

Expand Down
Loading

0 comments on commit 4a87453

Please sign in to comment.