1
0
mirror of https://github.com/esphome/esphome.git synced 2025-11-04 00:51:49 +00:00

Compare commits

...

16 Commits

Author SHA1 Message Date
Otto Winter
642bc91a76 Update esp32_ble_tracker.cpp 2019-06-08 17:06:29 +02:00
Otto Winter
d69926ee56 Bump version to v1.13.5 2019-06-08 16:49:04 +02:00
Otto Winter
4758403d44 Work around ESP32 core WiFi Bug (#627)
* Work around ESP32 WiFi Bug

* Lint
2019-06-08 16:49:00 +02:00
Otto Winter
4b0ec5c28a Work around ESP32 BLE issue (#626) 2019-06-08 16:49:00 +02:00
Otto Winter
4b2a9e5e49 Fix status binary sensor for MQTT (#628)
Fixes https://github.com/esphome/issues/issues/417
2019-06-08 16:48:59 +02:00
Otto Winter
1449c51d49 Update base image to 1.8.3 (#625) 2019-06-08 16:48:59 +02:00
Otto Winter
a451705e0b Fix sun default elevation (#620) 2019-06-08 16:48:58 +02:00
Otto Winter
2e6db39173 Fix integration sensor, add test (#619)
* Fix integration sensor, add test

* Fix

* Fix
2019-06-08 16:48:58 +02:00
Otto Winter
373f75253c Update docker base image to 1.8.0 (#618) 2019-06-08 16:48:58 +02:00
Otto Winter
724842084e Make ForCondition a component (#616)
Fixes https://github.com/esphome/issues/issues/396
2019-06-08 16:48:57 +02:00
Otto Winter
8f3635b167 Fix remote_receiver always shows sony (#617)
Fixes https://github.com/esphome/issues/issues/383#issuecomment-498370572
2019-06-08 16:48:57 +02:00
Otto Winter
11605a36f7 Fix Hass.io addon SSL (#613)
Fixes https://github.com/esphome/issues/issues/404
2019-06-08 16:48:56 +02:00
Otto Winter
533f81d625 Template Cover don't auto-set current_operation (#612)
Fixes https://github.com/esphome/issues/issues/408
2019-06-08 16:48:56 +02:00
Otto Winter
aacb9e44e8 DHT22 ignore invalid values (#614)
Fixes https://github.com/esphome/issues/issues/397
2019-06-08 16:48:55 +02:00
Peter Tatrai
c6e3f1bca6 Fix ForCondition time duration check (#610)
According documentation ForCondition should evaluate to true if a nested condition is true for at least the specified time duration and not the less.
2019-06-08 16:48:55 +02:00
Otto Winter
a933d4aeb6 Move ESPHome version define (#607)
* Move ESPHome version define

* Lint
2019-06-08 16:48:55 +02:00
30 changed files with 75 additions and 71 deletions

View File

@@ -3,7 +3,7 @@
variables:
DOCKER_DRIVER: overlay2
DOCKER_HOST: tcp://docker:2375/
BASE_VERSION: '1.7.0'
BASE_VERSION: '1.8.3'
TZ: UTC
stages:

View File

@@ -1,4 +1,4 @@
ARG BUILD_FROM=esphome/esphome-base-amd64:1.7.0
ARG BUILD_FROM=esphome/esphome-base-amd64:1.8.3
FROM ${BUILD_FROM}
COPY . .

View File

@@ -1,4 +1,4 @@
FROM esphome/esphome-base-amd64:1.7.0
FROM esphome/esphome-base-amd64:1.8.3
RUN \
apt-get update \

View File

@@ -1,21 +0,0 @@
FROM ubuntu:bionic
RUN apt-get update && apt-get install -y --no-install-recommends \
python \
python-pip \
python-setuptools \
python-pil \
git \
&& apt-get clean && rm -rf /var/lib/apt/lists/* /tmp/*rm -rf /var/lib/apt/lists/* /tmp/* && \
pip install --no-cache-dir platformio && \
platformio settings set enable_telemetry No && \
platformio settings set check_libraries_interval 1000000 && \
platformio settings set check_platformio_interval 1000000 && \
platformio settings set check_platforms_interval 1000000
COPY docker/platformio.ini /pio/platformio.ini
RUN platformio run -d /pio; rm -rf /pio
COPY requirements.txt /requirements.txt
RUN pip install --no-cache-dir -r /requirements.txt

View File

@@ -1,12 +0,0 @@
; This file allows the docker build file to install the required platformio
; platforms
[env:espressif8266]
platform = espressif8266@1.8.0
board = nodemcuv2
framework = arduino
[env:espressif32]
platform = espressif32@1.5.0
board = nodemcu-32s
framework = arduino

View File

@@ -4,6 +4,11 @@ server {
include /etc/nginx/includes/server_params.conf;
include /etc/nginx/includes/proxy_params.conf;
include /etc/nginx/includes/ssl_params.conf;
ssl on;
ssl_certificate /ssl/%%certfile%%;
ssl_certificate_key /ssl/%%keyfile%%;
# Clear Hass.io Ingress header
proxy_set_header X-Hassio-Ingress "";

View File

@@ -55,7 +55,7 @@ UpdateComponentAction = cg.esphome_ns.class_('UpdateComponentAction', Action)
Automation = cg.esphome_ns.class_('Automation')
LambdaCondition = cg.esphome_ns.class_('LambdaCondition', Condition)
ForCondition = cg.esphome_ns.class_('ForCondition', Condition)
ForCondition = cg.esphome_ns.class_('ForCondition', Condition, cg.Component)
def validate_automation(extra_schema=None, extra_validators=None, single=False):

View File

@@ -6,6 +6,7 @@
#include "esphome/core/application.h"
#include "esphome/core/util.h"
#include "esphome/core/defines.h"
#include "esphome/core/version.h"
#ifdef USE_DEEP_SLEEP
#include "esphome/components/deep_sleep/deep_sleep_component.h"

View File

@@ -2,6 +2,7 @@
#include "esphome/core/log.h"
#include "esphome/core/helpers.h"
#include "esphome/core/defines.h"
#include "esphome/core/version.h"
#ifdef ARDUINO_ARCH_ESP32
#include <rom/rtc.h>
@@ -19,7 +20,7 @@ void DebugComponent::dump_config() {
return;
#endif
ESP_LOGD(TAG, "ESPHome Core version %s", ESPHOME_VERSION);
ESP_LOGD(TAG, "ESPHome version %s", ESPHOME_VERSION);
this->free_heap_ = ESP.getFreeHeap();
ESP_LOGD(TAG, "Free Heap Size: %u bytes", this->free_heap_);

View File

@@ -164,11 +164,18 @@ bool HOT DHT::read_sensor_(float *temperature, float *humidity, bool report_erro
} else {
uint16_t raw_humidity = (uint16_t(data[0] & 0xFF) << 8) | (data[1] & 0xFF);
uint16_t raw_temperature = (uint16_t(data[2] & 0xFF) << 8) | (data[3] & 0xFF);
*humidity = raw_humidity * 0.1f;
if ((raw_temperature & 0x8000) != 0)
raw_temperature = ~(raw_temperature & 0x7FFF);
if (raw_temperature == 1 && raw_humidity == 10) {
if (report_errors) {
ESP_LOGE(TAG, "Invalid temperature+humidity! Sensor reported 1°C and 1%% Hum");
}
return false;
}
*humidity = raw_humidity * 0.1f;
*temperature = int16_t(raw_temperature) * 0.1f;
}

View File

@@ -1,5 +1,6 @@
#include "esp32_ble_tracker.h"
#include "esphome/core/log.h"
#include "esphome/core/application.h"
#ifdef ARDUINO_ARCH_ESP32
@@ -162,6 +163,11 @@ void ESP32BLETracker::start_scan(bool first) {
esp_ble_gap_set_scan_params(&this->scan_params_);
esp_ble_gap_start_scanning(this->scan_interval_);
this->set_timeout("scan", this->scan_interval_ * 2000, []() {
ESP_LOGW(TAG, "ESP-IDF BLE scan never terminated, rebooting to restore BLE stack...");
App.reboot();
});
}
void ESP32BLETracker::gap_event_handler(esp_gap_ble_cb_event_t event, esp_ble_gap_cb_param_t *param) {

View File

@@ -2,7 +2,7 @@ import esphome.codegen as cg
import esphome.config_validation as cv
from esphome import automation
from esphome.components import sensor
from esphome.const import CONF_ID, CONF_TIME_ID, CONF_SENSOR, CONF_RESTORE
from esphome.const import CONF_ID, CONF_SENSOR, CONF_RESTORE
integration_ns = cg.esphome_ns.namespace('integration')
IntegrationSensor = integration_ns.class_('IntegrationSensor', sensor.Sensor, cg.Component)
@@ -26,7 +26,6 @@ INTEGRATION_METHODS = {
CONF_TIME_UNIT = 'time_unit'
CONF_INTEGRATION_METHOD = 'integration_method'
CONFIG_SCHEMA = sensor.SENSOR_SCHEMA.extend({
cv.GenerateID(): cv.declare_id(IntegrationSensor),
cv.Required(CONF_SENSOR): cv.use_id(sensor.Sensor),
@@ -45,7 +44,7 @@ def to_code(config):
sens = yield cg.get_variable(config[CONF_SENSOR])
cg.add(var.set_sensor(sens))
cg.add(var.set_time(config[CONF_TIME_ID]))
cg.add(var.set_time(config[CONF_TIME_UNIT]))
cg.add(var.set_method(config[CONF_INTEGRATION_METHOD]))
cg.add(var.set_restore(config[CONF_RESTORE]))

View File

@@ -19,15 +19,19 @@ void MQTTBinarySensorComponent::dump_config() {
LOG_MQTT_COMPONENT(true, false)
}
MQTTBinarySensorComponent::MQTTBinarySensorComponent(binary_sensor::BinarySensor *binary_sensor)
: MQTTComponent(), binary_sensor_(binary_sensor) {}
: MQTTComponent(), binary_sensor_(binary_sensor) {
if (this->binary_sensor_->is_status_binary_sensor()) {
this->set_custom_state_topic(mqtt::global_mqtt_client->get_availability().topic);
}
}
std::string MQTTBinarySensorComponent::friendly_name() const { return this->binary_sensor_->get_name(); }
void MQTTBinarySensorComponent::send_discovery(JsonObject &root, mqtt::SendDiscoveryConfig &config) {
if (!this->binary_sensor_->get_device_class().empty())
root["device_class"] = this->binary_sensor_->get_device_class();
if (this->is_status_)
if (this->binary_sensor_->is_status_binary_sensor())
root["payload_on"] = mqtt::global_mqtt_client->get_availability().payload_available;
if (this->is_status_)
if (this->binary_sensor_->is_status_binary_sensor())
root["payload_off"] = mqtt::global_mqtt_client->get_availability().payload_not_available;
config.command_topic = false;
}
@@ -40,13 +44,12 @@ bool MQTTBinarySensorComponent::send_initial_state() {
}
bool MQTTBinarySensorComponent::is_internal() { return this->binary_sensor_->is_internal(); }
bool MQTTBinarySensorComponent::publish_state(bool state) {
if (this->is_status_)
if (this->binary_sensor_->is_status_binary_sensor())
return true;
const char *state_s = state ? "ON" : "OFF";
return this->publish(this->get_state_topic_(), state_s);
}
void MQTTBinarySensorComponent::set_is_status(bool status) { this->is_status_ = status; }
} // namespace mqtt
} // namespace esphome

View File

@@ -35,7 +35,6 @@ class MQTTBinarySensorComponent : public mqtt::MQTTComponent {
std::string component_type() const override;
binary_sensor::BinarySensor *binary_sensor_;
bool is_status_{false};
};
} // namespace mqtt

View File

@@ -2,6 +2,7 @@
#include "esphome/core/log.h"
#include "esphome/core/application.h"
#include "esphome/core/helpers.h"
#include "esphome/core/version.h"
namespace esphome {
namespace mqtt {

View File

@@ -31,7 +31,7 @@ optional<SonyData> SonyProtocol::decode(RemoteReceiveData src) {
.nbits = 0,
};
if (!src.expect_item(HEADER_HIGH_US, HEADER_LOW_US))
return out;
return {};
for (; out.nbits < 20; out.nbits++) {
uint32_t bit;

View File

@@ -17,6 +17,10 @@ CONF_ELEVATION = 'elevation'
CONF_ON_SUNRISE = 'on_sunrise'
CONF_ON_SUNSET = 'on_sunset'
# Default sun elevation is a bit below horizon because sunset
# means time when the entire sun disk is below the horizon
DEFAULT_ELEVATION = -0.883
ELEVATION_MAP = {
'sunrise': 0.0,
'sunset': 0.0,
@@ -44,11 +48,11 @@ CONFIG_SCHEMA = cv.Schema({
cv.Optional(CONF_ON_SUNRISE): automation.validate_automation({
cv.GenerateID(CONF_TRIGGER_ID): cv.declare_id(SunTrigger),
cv.Optional(CONF_ELEVATION, default=0.0): elevation,
cv.Optional(CONF_ELEVATION, default=DEFAULT_ELEVATION): elevation,
}),
cv.Optional(CONF_ON_SUNSET): automation.validate_automation({
cv.GenerateID(CONF_TRIGGER_ID): cv.declare_id(SunTrigger),
cv.Optional(CONF_ELEVATION, default=0.0): elevation,
cv.Optional(CONF_ELEVATION, default=DEFAULT_ELEVATION): elevation,
}),
})
@@ -79,7 +83,7 @@ def to_code(config):
@automation.register_condition('sun.is_above_horizon', SunCondition, cv.Schema({
cv.GenerateID(): cv.use_id(Sun),
cv.Optional(CONF_ELEVATION, default=0): cv.templatable(elevation),
cv.Optional(CONF_ELEVATION, default=DEFAULT_ELEVATION): cv.templatable(elevation),
}))
def sun_above_horizon_to_code(config, condition_id, template_arg, args):
var = cg.new_Pvariable(condition_id, template_arg)
@@ -92,7 +96,7 @@ def sun_above_horizon_to_code(config, condition_id, template_arg, args):
@automation.register_condition('sun.is_below_horizon', SunCondition, cv.Schema({
cv.GenerateID(): cv.use_id(Sun),
cv.Optional(CONF_ELEVATION, default=0): cv.templatable(elevation),
cv.Optional(CONF_ELEVATION, default=DEFAULT_ELEVATION): cv.templatable(elevation),
}))
def sun_below_horizon_to_code(config, condition_id, template_arg, args):
var = cg.new_Pvariable(condition_id, template_arg)

View File

@@ -3,7 +3,7 @@ import esphome.config_validation as cv
import esphome.codegen as cg
from esphome.const import CONF_ICON, ICON_WEATHER_SUNSET_DOWN, ICON_WEATHER_SUNSET_UP, CONF_TYPE, \
CONF_ID, CONF_FORMAT
from .. import sun_ns, CONF_SUN_ID, Sun, CONF_ELEVATION, elevation
from .. import sun_ns, CONF_SUN_ID, Sun, CONF_ELEVATION, elevation, DEFAULT_ELEVATION
DEPENDENCIES = ['sun']
@@ -28,7 +28,7 @@ CONFIG_SCHEMA = cv.All(text_sensor.TEXT_SENSOR_SCHEMA.extend({
cv.GenerateID(): cv.declare_id(SunTextSensor),
cv.GenerateID(CONF_SUN_ID): cv.use_id(Sun),
cv.Required(CONF_TYPE): cv.one_of(*SUN_TYPES, lower=True),
cv.Optional(CONF_ELEVATION, default=0): elevation,
cv.Optional(CONF_ELEVATION, default=DEFAULT_ELEVATION): elevation,
cv.Optional(CONF_FORMAT, default='%X'): cv.string_strict,
}).extend(cv.polling_component_schema('60s')), validate_optional_icon)

View File

@@ -74,19 +74,12 @@ void TemplateCover::control(const CoverCall &call) {
this->stop_prev_trigger_();
this->stop_trigger_->trigger();
this->prev_command_trigger_ = this->stop_trigger_;
this->current_operation = COVER_OPERATION_IDLE;
this->publish_state();
}
if (call.get_position().has_value()) {
auto pos = *call.get_position();
this->stop_prev_trigger_();
if (pos < this->position) {
this->current_operation = COVER_OPERATION_CLOSING;
} else if (pos > this->position) {
this->current_operation = COVER_OPERATION_OPENING;
}
if (pos == COVER_OPEN) {
this->open_trigger_->trigger();
this->prev_command_trigger_ = this->open_trigger_;

View File

@@ -1,6 +1,7 @@
#include "version_text_sensor.h"
#include "esphome/core/log.h"
#include "esphome/core/application.h"
#include "esphome/core/version.h"
namespace esphome {
namespace version {

View File

@@ -246,7 +246,11 @@ void print_signal_bars(int8_t rssi, char *buf) {
}
void WiFiComponent::print_connect_params_() {
uint8_t *bssid = WiFi.BSSID();
uint8_t bssid[6] = {};
uint8_t *raw_bssid = WiFi.BSSID();
if (raw_bssid != nullptr)
memcpy(bssid, raw_bssid, sizeof(bssid));
ESP_LOGCONFIG(TAG, " SSID: " LOG_SECRET("'%s'"), WiFi.SSID().c_str());
ESP_LOGCONFIG(TAG, " IP Address: %s", WiFi.localIP().toString().c_str());
ESP_LOGCONFIG(TAG, " BSSID: " LOG_SECRET("%02X:%02X:%02X:%02X:%02X:%02X"), bssid[0], bssid[1], bssid[2], bssid[3],

View File

@@ -3,7 +3,7 @@
MAJOR_VERSION = 1
MINOR_VERSION = 13
PATCH_VERSION = '4'
PATCH_VERSION = '5'
__short_version__ = '{}.{}'.format(MAJOR_VERSION, MINOR_VERSION)
__version__ = '{}.{}'.format(__short_version__, PATCH_VERSION)

View File

@@ -1,5 +1,6 @@
#include "esphome/core/application.h"
#include "esphome/core/log.h"
#include "esphome/core/version.h"
#ifdef USE_STATUS_LED
#include "esphome/components/status_led/status_led.h"

View File

@@ -73,7 +73,7 @@ template<typename... Ts> class ForCondition : public Condition<Ts...>, public Co
bool check(Ts... x) override {
if (!this->check_internal())
return false;
return millis() - this->last_inactive_ < this->time_.value(x...);
return millis() - this->last_inactive_ >= this->time_.value(x...);
}
protected:

View File

@@ -1,8 +1,6 @@
#pragma once
// This file is auto-generated! Do not edit!
#define ESPHOME_VERSION "dev"
#define USE_API
#define USE_LOGGER
#define USE_BINARY_SENSOR

View File

@@ -1,6 +1,7 @@
#include "esphome/core/util.h"
#include "esphome/core/defines.h"
#include "esphome/core/application.h"
#include "esphome/core/version.h"
#ifdef USE_WIFI
#include "esphome/components/wifi/wifi_component.h"

3
esphome/core/version.h Normal file
View File

@@ -0,0 +1,3 @@
#pragma once
// This file is auto-generated! Do not edit!
#define ESPHOME_VERSION "dev"

View File

@@ -10,7 +10,7 @@ from esphome.const import ARDUINO_VERSION_ESP32_DEV, ARDUINO_VERSION_ESP8266_DEV
CONF_ESPHOME, CONF_INCLUDES, CONF_LIBRARIES, \
CONF_NAME, CONF_ON_BOOT, CONF_ON_LOOP, CONF_ON_SHUTDOWN, CONF_PLATFORM, \
CONF_PLATFORMIO_OPTIONS, CONF_PRIORITY, CONF_TRIGGER_ID, \
CONF_ESP8266_RESTORE_FROM_FLASH, __version__, ARDUINO_VERSION_ESP8266_2_3_0, \
CONF_ESP8266_RESTORE_FROM_FLASH, ARDUINO_VERSION_ESP8266_2_3_0, \
ARDUINO_VERSION_ESP8266_2_5_0, ARDUINO_VERSION_ESP8266_2_5_1, ARDUINO_VERSION_ESP8266_2_5_2
from esphome.core import CORE, coroutine_with_priority
from esphome.helpers import copy_file_if_changed, walk_files
@@ -61,7 +61,7 @@ PLATFORMIO_ESP32_LUT = {
'1.0.0': 'espressif32@1.4.0',
'1.0.1': 'espressif32@1.6.0',
'1.0.2': 'espressif32@1.8.0',
'RECOMMENDED': 'espressif32@1.8.0',
'RECOMMENDED': 'espressif32@1.6.0',
'LATEST': 'espressif32',
'DEV': ARDUINO_VERSION_ESP32_DEV,
}
@@ -201,7 +201,6 @@ def add_includes(includes):
@coroutine_with_priority(100.0)
def to_code(config):
cg.add_global(cg.global_ns.namespace('esphome').using)
cg.add_define('ESPHOME_VERSION', __version__)
cg.add(cg.App.pre_setup(config[CONF_NAME], cg.RawExpression('__DATE__ ", " __TIME__')))
for conf in config.get(CONF_ON_BOOT, []):

View File

@@ -6,7 +6,7 @@ import re
from esphome.config import iter_components
from esphome.const import CONF_BOARD_FLASH_MODE, CONF_ESPHOME, CONF_PLATFORMIO_OPTIONS, \
HEADER_FILE_EXTENSIONS, SOURCE_FILE_EXTENSIONS
HEADER_FILE_EXTENSIONS, SOURCE_FILE_EXTENSIONS, __version__
from esphome.core import CORE, EsphomeError
from esphome.helpers import mkdir_p, read_file, write_file_if_changed, walk_files
from esphome.storage_json import StorageJSON, storage_path
@@ -268,7 +268,12 @@ DEFINES_H_FORMAT = ESPHOME_H_FORMAT = u"""\
#pragma once
{}
"""
VERSION_H_FORMAT = u"""\
#pragma once
#define ESPHOME_VERSION "{}"
"""
DEFINES_H_TARGET = 'esphome/core/defines.h'
VERSION_H_TARGET = 'esphome/core/version.h'
ESPHOME_README_TXT = u"""
THIS DIRECTORY IS AUTO-GENERATED, DO NOT MODIFY
@@ -335,6 +340,8 @@ def copy_src_tree():
CORE.relative_src_path('esphome', 'README.txt'))
write_file_if_changed(ESPHOME_H_FORMAT.format(include_s),
CORE.relative_src_path('esphome.h'))
write_file_if_changed(VERSION_H_FORMAT.format(__version__),
CORE.relative_src_path('esphome' 'core', 'version.h'))
def generate_defines_h():

View File

@@ -350,6 +350,10 @@ sensor:
- platform: total_daily_energy
power_id: hlw8012_power
name: "HLW8012 Total Daily Energy"
- platform: integration
sensor: hlw8012_power
name: "Integration Sensor"
time_unit: s
- platform: hmc5883l
address: 0x68
field_strength_x: