mirror of
https://github.com/esphome/esphome.git
synced 2025-11-06 01:51:49 +00:00
Compare commits
23 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
72f656ffef | ||
|
|
b60239d5e5 | ||
|
|
d02e280c3c | ||
|
|
6535b0966e | ||
|
|
82dbacbee5 | ||
|
|
2432901974 | ||
|
|
ebb5d58c14 | ||
|
|
605e365405 | ||
|
|
5ab995d8ca | ||
|
|
4248741b11 | ||
|
|
4b8ecc7634 | ||
|
|
25d04c759c | ||
|
|
b4ec84030e | ||
|
|
29e8761373 | ||
|
|
a04299c59e | ||
|
|
d7bf3c51d9 | ||
|
|
ac0b095941 | ||
|
|
cda9bad233 | ||
|
|
41db8a1264 | ||
|
|
e7e785fd60 | ||
|
|
300d3a1f46 | ||
|
|
356554c08d | ||
|
|
ced28ad006 |
@@ -1,5 +1,6 @@
|
|||||||
sudo: false
|
sudo: false
|
||||||
language: python
|
language: python
|
||||||
|
python: '2.7'
|
||||||
install: script/setup
|
install: script/setup
|
||||||
cache:
|
cache:
|
||||||
directories:
|
directories:
|
||||||
|
|||||||
@@ -25,4 +25,4 @@ def to_code(config):
|
|||||||
|
|
||||||
wwhite = yield cg.get_variable(config[CONF_WARM_WHITE])
|
wwhite = yield cg.get_variable(config[CONF_WARM_WHITE])
|
||||||
cg.add(var.set_warm_white(wwhite))
|
cg.add(var.set_warm_white(wwhite))
|
||||||
cg.add(var.set_warm_white_temperature(config[CONF_COLD_WHITE_COLOR_TEMPERATURE]))
|
cg.add(var.set_warm_white_temperature(config[CONF_WARM_WHITE_COLOR_TEMPERATURE]))
|
||||||
|
|||||||
@@ -87,7 +87,7 @@ void DeepSleepComponent::begin_sleep(bool manual) {
|
|||||||
ESP.deepSleep(*this->sleep_duration_);
|
ESP.deepSleep(*this->sleep_duration_);
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
float DeepSleepComponent::get_setup_priority() const { return -100.0f; }
|
float DeepSleepComponent::get_setup_priority() const { return setup_priority::LATE; }
|
||||||
void DeepSleepComponent::prevent_deep_sleep() { this->prevent_ = true; }
|
void DeepSleepComponent::prevent_deep_sleep() { this->prevent_ = true; }
|
||||||
|
|
||||||
} // namespace deep_sleep
|
} // namespace deep_sleep
|
||||||
|
|||||||
@@ -5,8 +5,7 @@ from esphome.const import CONF_OUTPUT_ID, CONF_NUM_LEDS, CONF_RGB_ORDER, CONF_MA
|
|||||||
from esphome.core import coroutine
|
from esphome.core import coroutine
|
||||||
|
|
||||||
fastled_base_ns = cg.esphome_ns.namespace('fastled_base')
|
fastled_base_ns = cg.esphome_ns.namespace('fastled_base')
|
||||||
FastLEDLightOutput = fastled_base_ns.class_('FastLEDLightOutput', cg.Component,
|
FastLEDLightOutput = fastled_base_ns.class_('FastLEDLightOutput', light.AddressableLight)
|
||||||
light.AddressableLight)
|
|
||||||
|
|
||||||
RGB_ORDERS = [
|
RGB_ORDERS = [
|
||||||
'RGB',
|
'RGB',
|
||||||
|
|||||||
@@ -16,7 +16,7 @@
|
|||||||
namespace esphome {
|
namespace esphome {
|
||||||
namespace fastled_base {
|
namespace fastled_base {
|
||||||
|
|
||||||
class FastLEDLightOutput : public Component, public light::AddressableLight {
|
class FastLEDLightOutput : public light::AddressableLight {
|
||||||
public:
|
public:
|
||||||
/// Only for custom effects: Get the internal controller.
|
/// Only for custom effects: Get the internal controller.
|
||||||
CLEDController *get_controller() const { return this->controller_; }
|
CLEDController *get_controller() const { return this->controller_; }
|
||||||
|
|||||||
@@ -50,7 +50,7 @@ void I2CComponent::dump_config() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
float I2CComponent::get_setup_priority() const { return setup_priority::HARDWARE; }
|
float I2CComponent::get_setup_priority() const { return setup_priority::BUS; }
|
||||||
|
|
||||||
void I2CComponent::raw_begin_transmission(uint8_t address) {
|
void I2CComponent::raw_begin_transmission(uint8_t address) {
|
||||||
ESP_LOGVV(TAG, "Beginning Transmission to 0x%02X:", address);
|
ESP_LOGVV(TAG, "Beginning Transmission to 0x%02X:", address);
|
||||||
|
|||||||
@@ -4,6 +4,8 @@
|
|||||||
namespace esphome {
|
namespace esphome {
|
||||||
namespace light {
|
namespace light {
|
||||||
|
|
||||||
|
static const char *TAG = "light.addressable";
|
||||||
|
|
||||||
const ESPColor ESPColor::BLACK = ESPColor(0, 0, 0, 0);
|
const ESPColor ESPColor::BLACK = ESPColor(0, 0, 0, 0);
|
||||||
const ESPColor ESPColor::WHITE = ESPColor(255, 255, 255, 255);
|
const ESPColor ESPColor::WHITE = ESPColor(255, 255, 255, 255);
|
||||||
|
|
||||||
@@ -92,5 +94,24 @@ int32_t HOT interpret_index(int32_t index, int32_t size) {
|
|||||||
return index;
|
return index;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void AddressableLight::call_setup() {
|
||||||
|
this->setup_internal_();
|
||||||
|
this->setup();
|
||||||
|
|
||||||
|
#ifdef ESPHOME_LOG_HAS_VERY_VERBOSE
|
||||||
|
this->set_interval(5000, [this]() {
|
||||||
|
const char *name = this->state_parent_ == nullptr ? "" : this->state_parent_->get_name().c_str();
|
||||||
|
ESP_LOGVV(TAG, "Addressable Light '%s' (effect_active=%s next_show=%s)", name, YESNO(this->effect_active_),
|
||||||
|
YESNO(this->next_show_));
|
||||||
|
for (int i = 0; i < this->size(); i++) {
|
||||||
|
auto color = this->get(i);
|
||||||
|
ESP_LOGVV(TAG, " [%2d] Color: R=%3u G=%3u B=%3u W=%3u", i, color.get_red_raw(), color.get_green_raw(),
|
||||||
|
color.get_blue_raw(), color.get_white_raw());
|
||||||
|
}
|
||||||
|
ESP_LOGVV(TAG, "");
|
||||||
|
});
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
|
||||||
} // namespace light
|
} // namespace light
|
||||||
} // namespace esphome
|
} // namespace esphome
|
||||||
|
|||||||
@@ -335,13 +335,21 @@ class ESPColorView : public ESPColorSettable {
|
|||||||
void darken(uint8_t delta) override { this->set(this->get().darken(delta)); }
|
void darken(uint8_t delta) override { this->set(this->get().darken(delta)); }
|
||||||
ESPColor get() const { return ESPColor(this->get_red(), this->get_green(), this->get_blue(), this->get_white()); }
|
ESPColor get() const { return ESPColor(this->get_red(), this->get_green(), this->get_blue(), this->get_white()); }
|
||||||
uint8_t get_red() const { return this->color_correction_->color_uncorrect_red(*this->red_); }
|
uint8_t get_red() const { return this->color_correction_->color_uncorrect_red(*this->red_); }
|
||||||
|
uint8_t get_red_raw() const { return *this->red_; }
|
||||||
uint8_t get_green() const { return this->color_correction_->color_uncorrect_green(*this->green_); }
|
uint8_t get_green() const { return this->color_correction_->color_uncorrect_green(*this->green_); }
|
||||||
|
uint8_t get_green_raw() const { return *this->green_; }
|
||||||
uint8_t get_blue() const { return this->color_correction_->color_uncorrect_blue(*this->blue_); }
|
uint8_t get_blue() const { return this->color_correction_->color_uncorrect_blue(*this->blue_); }
|
||||||
|
uint8_t get_blue_raw() const { return *this->blue_; }
|
||||||
uint8_t get_white() const {
|
uint8_t get_white() const {
|
||||||
if (this->white_ == nullptr)
|
if (this->white_ == nullptr)
|
||||||
return 0;
|
return 0;
|
||||||
return this->color_correction_->color_uncorrect_white(*this->white_);
|
return this->color_correction_->color_uncorrect_white(*this->white_);
|
||||||
}
|
}
|
||||||
|
uint8_t get_white_raw() const {
|
||||||
|
if (this->white_ == nullptr)
|
||||||
|
return 0;
|
||||||
|
return *this->white_;
|
||||||
|
}
|
||||||
uint8_t get_effect_data() const {
|
uint8_t get_effect_data() const {
|
||||||
if (this->effect_data_ == nullptr)
|
if (this->effect_data_ == nullptr)
|
||||||
return 0;
|
return 0;
|
||||||
@@ -475,7 +483,7 @@ class ESPRangeView : public ESPColorSettable {
|
|||||||
int32_t end_;
|
int32_t end_;
|
||||||
};
|
};
|
||||||
|
|
||||||
class AddressableLight : public LightOutput {
|
class AddressableLight : public LightOutput, public Component {
|
||||||
public:
|
public:
|
||||||
virtual int32_t size() const = 0;
|
virtual int32_t size() const = 0;
|
||||||
ESPColorView operator[](int32_t index) const { return this->get_view_internal(interpret_index(index, this->size())); }
|
ESPColorView operator[](int32_t index) const { return this->get_view_internal(interpret_index(index, this->size())); }
|
||||||
@@ -530,13 +538,18 @@ class AddressableLight : public LightOutput {
|
|||||||
this->correction_.set_max_brightness(ESPColor(uint8_t(roundf(red * 255.0f)), uint8_t(roundf(green * 255.0f)),
|
this->correction_.set_max_brightness(ESPColor(uint8_t(roundf(red * 255.0f)), uint8_t(roundf(green * 255.0f)),
|
||||||
uint8_t(roundf(blue * 255.0f)), uint8_t(roundf(white * 255.0f))));
|
uint8_t(roundf(blue * 255.0f)), uint8_t(roundf(white * 255.0f))));
|
||||||
}
|
}
|
||||||
void setup_state(LightState *state) override { this->correction_.calculate_gamma_table(state->get_gamma_correct()); }
|
void setup_state(LightState *state) override {
|
||||||
|
this->correction_.calculate_gamma_table(state->get_gamma_correct());
|
||||||
|
this->state_parent_ = state;
|
||||||
|
}
|
||||||
void schedule_show() { this->next_show_ = true; }
|
void schedule_show() { this->next_show_ = true; }
|
||||||
|
|
||||||
#ifdef USE_POWER_SUPPLY
|
#ifdef USE_POWER_SUPPLY
|
||||||
void set_power_supply(power_supply::PowerSupply *power_supply) { this->power_.set_parent(power_supply); }
|
void set_power_supply(power_supply::PowerSupply *power_supply) { this->power_.set_parent(power_supply); }
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
void call_setup() override;
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
bool should_show_() const { return this->effect_active_ || this->next_show_; }
|
bool should_show_() const { return this->effect_active_ || this->next_show_; }
|
||||||
void mark_shown_() {
|
void mark_shown_() {
|
||||||
@@ -559,6 +572,7 @@ class AddressableLight : public LightOutput {
|
|||||||
#ifdef USE_POWER_SUPPLY
|
#ifdef USE_POWER_SUPPLY
|
||||||
power_supply::PowerSupplyRequester power_;
|
power_supply::PowerSupplyRequester power_;
|
||||||
#endif
|
#endif
|
||||||
|
LightState *state_parent_{nullptr};
|
||||||
};
|
};
|
||||||
|
|
||||||
} // namespace light
|
} // namespace light
|
||||||
|
|||||||
@@ -155,6 +155,6 @@ def light_addressable_set_to_code(config, action_id, template_arg, args):
|
|||||||
automation.maybe_simple_id({
|
automation.maybe_simple_id({
|
||||||
cv.Required(CONF_ID): cv.use_id(LightState),
|
cv.Required(CONF_ID): cv.use_id(LightState),
|
||||||
}))
|
}))
|
||||||
def binary_sensor_is_on_to_code(config, condition_id, template_arg, args):
|
def light_is_on_off_to_code(config, condition_id, template_arg, args):
|
||||||
paren = yield cg.get_variable(config[CONF_ID])
|
paren = yield cg.get_variable(config[CONF_ID])
|
||||||
yield cg.new_Pvariable(condition_id, template_arg, paren)
|
yield cg.new_Pvariable(condition_id, template_arg, paren)
|
||||||
|
|||||||
@@ -7,7 +7,7 @@ LightState = light_ns.class_('LightState', cg.Nameable, cg.Component)
|
|||||||
# Fake class for addressable lights
|
# Fake class for addressable lights
|
||||||
AddressableLightState = light_ns.class_('LightState', LightState)
|
AddressableLightState = light_ns.class_('LightState', LightState)
|
||||||
LightOutput = light_ns.class_('LightOutput')
|
LightOutput = light_ns.class_('LightOutput')
|
||||||
AddressableLight = light_ns.class_('AddressableLight')
|
AddressableLight = light_ns.class_('AddressableLight', cg.Component)
|
||||||
AddressableLightRef = AddressableLight.operator('ref')
|
AddressableLightRef = AddressableLight.operator('ref')
|
||||||
LightColorValues = light_ns.class_('LightColorValues')
|
LightColorValues = light_ns.class_('LightColorValues')
|
||||||
|
|
||||||
|
|||||||
@@ -41,7 +41,8 @@ MQTTClientComponent = mqtt_ns.class_('MQTTClientComponent', cg.Component)
|
|||||||
MQTTPublishAction = mqtt_ns.class_('MQTTPublishAction', automation.Action)
|
MQTTPublishAction = mqtt_ns.class_('MQTTPublishAction', automation.Action)
|
||||||
MQTTPublishJsonAction = mqtt_ns.class_('MQTTPublishJsonAction', automation.Action)
|
MQTTPublishJsonAction = mqtt_ns.class_('MQTTPublishJsonAction', automation.Action)
|
||||||
MQTTMessageTrigger = mqtt_ns.class_('MQTTMessageTrigger',
|
MQTTMessageTrigger = mqtt_ns.class_('MQTTMessageTrigger',
|
||||||
automation.Trigger.template(cg.std_string))
|
automation.Trigger.template(cg.std_string),
|
||||||
|
cg.Component)
|
||||||
MQTTJsonMessageTrigger = mqtt_ns.class_('MQTTJsonMessageTrigger',
|
MQTTJsonMessageTrigger = mqtt_ns.class_('MQTTJsonMessageTrigger',
|
||||||
automation.Trigger.template(cg.JsonObjectConstRef))
|
automation.Trigger.template(cg.JsonObjectConstRef))
|
||||||
MQTTComponent = mqtt_ns.class_('MQTTComponent', cg.Component)
|
MQTTComponent = mqtt_ns.class_('MQTTComponent', cg.Component)
|
||||||
@@ -104,7 +105,7 @@ CONFIG_SCHEMA = cv.All(cv.Schema({
|
|||||||
cv.Optional(CONF_PORT, default=1883): cv.port,
|
cv.Optional(CONF_PORT, default=1883): cv.port,
|
||||||
cv.Optional(CONF_USERNAME, default=''): cv.string,
|
cv.Optional(CONF_USERNAME, default=''): cv.string,
|
||||||
cv.Optional(CONF_PASSWORD, default=''): cv.string,
|
cv.Optional(CONF_PASSWORD, default=''): cv.string,
|
||||||
cv.Optional(CONF_CLIENT_ID, default=lambda: CORE.name): cv.string,
|
cv.Optional(CONF_CLIENT_ID): cv.string,
|
||||||
cv.Optional(CONF_DISCOVERY, default=True): cv.Any(cv.boolean, cv.one_of("CLEAN", upper=True)),
|
cv.Optional(CONF_DISCOVERY, default=True): cv.Any(cv.boolean, cv.one_of("CLEAN", upper=True)),
|
||||||
cv.Optional(CONF_DISCOVERY_RETAIN, default=True): cv.boolean,
|
cv.Optional(CONF_DISCOVERY_RETAIN, default=True): cv.boolean,
|
||||||
cv.Optional(CONF_DISCOVERY_PREFIX, default="homeassistant"): cv.publish_topic,
|
cv.Optional(CONF_DISCOVERY_PREFIX, default="homeassistant"): cv.publish_topic,
|
||||||
@@ -161,7 +162,8 @@ def to_code(config):
|
|||||||
cg.add(var.set_broker_port(config[CONF_PORT]))
|
cg.add(var.set_broker_port(config[CONF_PORT]))
|
||||||
cg.add(var.set_username(config[CONF_USERNAME]))
|
cg.add(var.set_username(config[CONF_USERNAME]))
|
||||||
cg.add(var.set_password(config[CONF_PASSWORD]))
|
cg.add(var.set_password(config[CONF_PASSWORD]))
|
||||||
cg.add(var.set_client_id(config[CONF_CLIENT_ID]))
|
if CONF_CLIENT_ID in config:
|
||||||
|
cg.add(var.set_client_id(config[CONF_CLIENT_ID]))
|
||||||
|
|
||||||
discovery = config[CONF_DISCOVERY]
|
discovery = config[CONF_DISCOVERY]
|
||||||
discovery_retain = config[CONF_DISCOVERY_RETAIN]
|
discovery_retain = config[CONF_DISCOVERY_RETAIN]
|
||||||
@@ -216,6 +218,7 @@ def to_code(config):
|
|||||||
cg.add(trig.set_qos(conf[CONF_QOS]))
|
cg.add(trig.set_qos(conf[CONF_QOS]))
|
||||||
if CONF_PAYLOAD in conf:
|
if CONF_PAYLOAD in conf:
|
||||||
cg.add(trig.set_payload(conf[CONF_PAYLOAD]))
|
cg.add(trig.set_payload(conf[CONF_PAYLOAD]))
|
||||||
|
yield cg.register_component(trig, conf)
|
||||||
yield automation.build_automation(trig, [(cg.std_string, 'x')], conf)
|
yield automation.build_automation(trig, [(cg.std_string, 'x')], conf)
|
||||||
|
|
||||||
for conf in config.get(CONF_ON_JSON_MESSAGE, []):
|
for conf in config.get(CONF_ON_JSON_MESSAGE, []):
|
||||||
|
|||||||
@@ -15,7 +15,10 @@ namespace mqtt {
|
|||||||
|
|
||||||
static const char *TAG = "mqtt";
|
static const char *TAG = "mqtt";
|
||||||
|
|
||||||
MQTTClientComponent::MQTTClientComponent() { global_mqtt_client = this; }
|
MQTTClientComponent::MQTTClientComponent() {
|
||||||
|
global_mqtt_client = this;
|
||||||
|
this->credentials_.client_id = App.get_name() + "-" + get_mac_address();
|
||||||
|
}
|
||||||
|
|
||||||
// Connection
|
// Connection
|
||||||
void MQTTClientComponent::setup() {
|
void MQTTClientComponent::setup() {
|
||||||
|
|||||||
@@ -7,7 +7,7 @@ from esphome.const import CONF_CLOCK_PIN, CONF_DATA_PIN, CONF_METHOD, CONF_NUM_L
|
|||||||
from esphome.core import CORE
|
from esphome.core import CORE
|
||||||
|
|
||||||
neopixelbus_ns = cg.esphome_ns.namespace('neopixelbus')
|
neopixelbus_ns = cg.esphome_ns.namespace('neopixelbus')
|
||||||
NeoPixelBusLightOutputBase = neopixelbus_ns.class_('NeoPixelBusLightOutputBase', cg.Component,
|
NeoPixelBusLightOutputBase = neopixelbus_ns.class_('NeoPixelBusLightOutputBase',
|
||||||
light.AddressableLight)
|
light.AddressableLight)
|
||||||
NeoPixelRGBLightOutput = neopixelbus_ns.class_('NeoPixelRGBLightOutput', NeoPixelBusLightOutputBase)
|
NeoPixelRGBLightOutput = neopixelbus_ns.class_('NeoPixelRGBLightOutput', NeoPixelBusLightOutputBase)
|
||||||
NeoPixelRGBWLightOutput = neopixelbus_ns.class_('NeoPixelRGBWLightOutput',
|
NeoPixelRGBWLightOutput = neopixelbus_ns.class_('NeoPixelRGBWLightOutput',
|
||||||
|
|||||||
@@ -48,7 +48,7 @@ enum class ESPNeoPixelOrder {
|
|||||||
};
|
};
|
||||||
|
|
||||||
template<typename T_METHOD, typename T_COLOR_FEATURE>
|
template<typename T_METHOD, typename T_COLOR_FEATURE>
|
||||||
class NeoPixelBusLightOutputBase : public Component, public light::AddressableLight {
|
class NeoPixelBusLightOutputBase : public light::AddressableLight {
|
||||||
public:
|
public:
|
||||||
NeoPixelBus<T_COLOR_FEATURE, T_METHOD> *get_controller() const { return this->controller_; }
|
NeoPixelBus<T_COLOR_FEATURE, T_METHOD> *get_controller() const { return this->controller_; }
|
||||||
|
|
||||||
|
|||||||
@@ -33,4 +33,5 @@ def to_code(config):
|
|||||||
conf[CONF_TO] - conf[CONF_FROM] + 1))
|
conf[CONF_TO] - conf[CONF_FROM] + 1))
|
||||||
|
|
||||||
var = cg.new_Pvariable(config[CONF_OUTPUT_ID], segments)
|
var = cg.new_Pvariable(config[CONF_OUTPUT_ID], segments)
|
||||||
|
yield cg.register_component(var, config)
|
||||||
yield light.register_light(var, config)
|
yield light.register_light(var, config)
|
||||||
|
|||||||
@@ -24,7 +24,7 @@ class AddressableSegment {
|
|||||||
int32_t dst_offset_;
|
int32_t dst_offset_;
|
||||||
};
|
};
|
||||||
|
|
||||||
class PartitionLightOutput : public light::AddressableLight, public Component {
|
class PartitionLightOutput : public light::AddressableLight {
|
||||||
public:
|
public:
|
||||||
explicit PartitionLightOutput(std::vector<AddressableSegment> segments) : segments_(segments) {
|
explicit PartitionLightOutput(std::vector<AddressableSegment> segments) : segments_(segments) {
|
||||||
int32_t off = 0;
|
int32_t off = 0;
|
||||||
|
|||||||
@@ -101,15 +101,15 @@ void RotaryEncoderSensor::setup() {
|
|||||||
ESP_LOGCONFIG(TAG, "Setting up Rotary Encoder '%s'...", this->name_.c_str());
|
ESP_LOGCONFIG(TAG, "Setting up Rotary Encoder '%s'...", this->name_.c_str());
|
||||||
this->pin_a_->setup();
|
this->pin_a_->setup();
|
||||||
this->store_.pin_a = this->pin_a_->to_isr();
|
this->store_.pin_a = this->pin_a_->to_isr();
|
||||||
this->pin_a_->attach_interrupt(RotaryEncoderSensorStore::gpio_intr, &this->store_, CHANGE);
|
|
||||||
|
|
||||||
this->pin_b_->setup();
|
this->pin_b_->setup();
|
||||||
this->store_.pin_b = this->pin_b_->to_isr();
|
this->store_.pin_b = this->pin_b_->to_isr();
|
||||||
this->pin_b_->attach_interrupt(RotaryEncoderSensorStore::gpio_intr, &this->store_, CHANGE);
|
|
||||||
|
|
||||||
if (this->pin_i_ != nullptr) {
|
if (this->pin_i_ != nullptr) {
|
||||||
this->pin_i_->setup();
|
this->pin_i_->setup();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
this->pin_a_->attach_interrupt(RotaryEncoderSensorStore::gpio_intr, &this->store_, CHANGE);
|
||||||
|
this->pin_b_->attach_interrupt(RotaryEncoderSensorStore::gpio_intr, &this->store_, CHANGE);
|
||||||
}
|
}
|
||||||
void RotaryEncoderSensor::dump_config() {
|
void RotaryEncoderSensor::dump_config() {
|
||||||
LOG_SENSOR("", "Rotary Encoder", this);
|
LOG_SENSOR("", "Rotary Encoder", this);
|
||||||
|
|||||||
@@ -36,7 +36,7 @@ CONFIG_SCHEMA = cv.All(sensor.sensor_schema(UNIT_STEPS, ICON_ROTATE_RIGHT, 0).ex
|
|||||||
pins.validate_has_interrupt),
|
pins.validate_has_interrupt),
|
||||||
cv.Required(CONF_PIN_B): cv.All(pins.internal_gpio_input_pin_schema,
|
cv.Required(CONF_PIN_B): cv.All(pins.internal_gpio_input_pin_schema,
|
||||||
pins.validate_has_interrupt),
|
pins.validate_has_interrupt),
|
||||||
cv.Optional(CONF_PIN_RESET): pins.internal_gpio_input_pin_schema,
|
cv.Optional(CONF_PIN_RESET): pins.internal_gpio_output_pin_schema,
|
||||||
cv.Optional(CONF_RESOLUTION, default=1): cv.enum(RESOLUTIONS, int=True),
|
cv.Optional(CONF_RESOLUTION, default=1): cv.enum(RESOLUTIONS, int=True),
|
||||||
cv.Optional(CONF_MIN_VALUE): cv.int_,
|
cv.Optional(CONF_MIN_VALUE): cv.int_,
|
||||||
cv.Optional(CONF_MAX_VALUE): cv.int_,
|
cv.Optional(CONF_MAX_VALUE): cv.int_,
|
||||||
@@ -50,7 +50,7 @@ def to_code(config):
|
|||||||
pin_a = yield cg.gpio_pin_expression(config[CONF_PIN_A])
|
pin_a = yield cg.gpio_pin_expression(config[CONF_PIN_A])
|
||||||
cg.add(var.set_pin_a(pin_a))
|
cg.add(var.set_pin_a(pin_a))
|
||||||
pin_b = yield cg.gpio_pin_expression(config[CONF_PIN_B])
|
pin_b = yield cg.gpio_pin_expression(config[CONF_PIN_B])
|
||||||
cg.add(var.set_pin_a(pin_b))
|
cg.add(var.set_pin_b(pin_b))
|
||||||
|
|
||||||
if CONF_PIN_RESET in config:
|
if CONF_PIN_RESET in config:
|
||||||
pin_i = yield cg.gpio_pin_expression(config[CONF_PIN_RESET])
|
pin_i = yield cg.gpio_pin_expression(config[CONF_PIN_RESET])
|
||||||
|
|||||||
@@ -103,7 +103,7 @@ class SunTrigger : public Trigger<>, public PollingComponent, public Parented<Su
|
|||||||
crossed = this->last_elevation_ >= this->elevation_ && this->elevation_ > current;
|
crossed = this->last_elevation_ >= this->elevation_ && this->elevation_ > current;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (crossed) {
|
if (crossed && !isnan(this->last_elevation_)) {
|
||||||
this->trigger();
|
this->trigger();
|
||||||
}
|
}
|
||||||
this->last_elevation_ = current;
|
this->last_elevation_ = current;
|
||||||
@@ -111,7 +111,7 @@ class SunTrigger : public Trigger<>, public PollingComponent, public Parented<Su
|
|||||||
|
|
||||||
protected:
|
protected:
|
||||||
bool sunrise_;
|
bool sunrise_;
|
||||||
double last_elevation_;
|
double last_elevation_{NAN};
|
||||||
double elevation_;
|
double elevation_;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
@@ -24,7 +24,7 @@ MODELS = {
|
|||||||
'2.90in': ('a', WaveshareEPaperTypeAModel.WAVESHARE_EPAPER_2_9_IN),
|
'2.90in': ('a', WaveshareEPaperTypeAModel.WAVESHARE_EPAPER_2_9_IN),
|
||||||
'2.70in': ('b', WaveshareEPaper2P7In),
|
'2.70in': ('b', WaveshareEPaper2P7In),
|
||||||
'4.20in': ('b', WaveshareEPaper4P2In),
|
'4.20in': ('b', WaveshareEPaper4P2In),
|
||||||
'7.50in': ('b', WaveshareEPaperTypeBModel),
|
'7.50in': ('b', WaveshareEPaper7P5In),
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -1175,7 +1175,6 @@ def validate_registry_entry(name, registry):
|
|||||||
if not isinstance(value, dict):
|
if not isinstance(value, dict):
|
||||||
raise Invalid(u"{} must consist of key-value mapping! Got {}"
|
raise Invalid(u"{} must consist of key-value mapping! Got {}"
|
||||||
u"".format(name.title(), value))
|
u"".format(name.title(), value))
|
||||||
value = base_schema(value)
|
|
||||||
key = next((x for x in value if x not in ignore_keys), None)
|
key = next((x for x in value if x not in ignore_keys), None)
|
||||||
if key is None:
|
if key is None:
|
||||||
raise Invalid(u"Key missing from {}! Got {}".format(name, value))
|
raise Invalid(u"Key missing from {}! Got {}".format(name, value))
|
||||||
|
|||||||
@@ -3,7 +3,7 @@
|
|||||||
|
|
||||||
MAJOR_VERSION = 1
|
MAJOR_VERSION = 1
|
||||||
MINOR_VERSION = 13
|
MINOR_VERSION = 13
|
||||||
PATCH_VERSION = '0b7'
|
PATCH_VERSION = '2'
|
||||||
__short_version__ = '{}.{}'.format(MAJOR_VERSION, MINOR_VERSION)
|
__short_version__ = '{}.{}'.format(MAJOR_VERSION, MINOR_VERSION)
|
||||||
__version__ = '{}.{}'.format(__short_version__, PATCH_VERSION)
|
__version__ = '{}.{}'.format(__short_version__, PATCH_VERSION)
|
||||||
|
|
||||||
|
|||||||
@@ -5,12 +5,13 @@
|
|||||||
document.addEventListener('DOMContentLoaded', () => {
|
document.addEventListener('DOMContentLoaded', () => {
|
||||||
M.AutoInit(document.body);
|
M.AutoInit(document.body);
|
||||||
});
|
});
|
||||||
let wsProtocol = "ws:";
|
const loc = window.location;
|
||||||
if (window.location.protocol === "https:") {
|
const wsLoc = new URL("./",`${loc.protocol}//${loc.host}${loc.pathname}`);
|
||||||
wsProtocol = 'wss:';
|
wsLoc.protocol = 'ws:';
|
||||||
|
if (loc.protocol === "https:") {
|
||||||
|
wsLoc.protocol = 'wss:';
|
||||||
}
|
}
|
||||||
const wsUrl = `${wsProtocol}//${window.location.host}${window.location.pathname}`;
|
const wsUrl = wsLoc.href;
|
||||||
|
|
||||||
|
|
||||||
// ============================= Color Log Parsing =============================
|
// ============================= Color Log Parsing =============================
|
||||||
const initializeColorState = () => {
|
const initializeColorState = () => {
|
||||||
|
|||||||
@@ -469,7 +469,7 @@
|
|||||||
</div>
|
</div>
|
||||||
<div class="footer-copyright">
|
<div class="footer-copyright">
|
||||||
<div class="container">
|
<div class="container">
|
||||||
© 2019 Copyright Otto Winter, Made with <a class="grey-text text-lighten-4" href="https://materializecss.com/" target="_blank">Materialize</a>
|
© 2019 Copyright ESPHome, Made with <a class="grey-text text-lighten-4" href="https://materializecss.com/" target="_blank">Materialize</a>
|
||||||
<a class="grey-text text-lighten-4 right" href="{{ docs_link }}" target="_blank" rel="noreferrer">ESPHome {{ version }} Documentation</a>
|
<a class="grey-text text-lighten-4 right" href="{{ docs_link }}" target="_blank" rel="noreferrer">ESPHome {{ version }} Documentation</a>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
@@ -65,7 +65,7 @@
|
|||||||
</div>
|
</div>
|
||||||
<div class="footer-copyright">
|
<div class="footer-copyright">
|
||||||
<div class="container">
|
<div class="container">
|
||||||
© 2019 Copyright Otto Winter, Made with <a class="grey-text text-lighten-4" href="https://materializecss.com/" target="_blank">Materialize</a>
|
© 2019 Copyright ESPHome, Made with <a class="grey-text text-lighten-4" href="https://materializecss.com/" target="_blank">Materialize</a>
|
||||||
<a class="grey-text text-lighten-4 right" href="{{ docs_link }}"
|
<a class="grey-text text-lighten-4 right" href="{{ docs_link }}"
|
||||||
target="_blank">ESPHome {{ version }} Documentation</a>
|
target="_blank">ESPHome {{ version }} Documentation</a>
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
@@ -7,6 +7,7 @@ import re
|
|||||||
import subprocess
|
import subprocess
|
||||||
|
|
||||||
from esphome.core import CORE
|
from esphome.core import CORE
|
||||||
|
from esphome.py_compat import IS_PY2
|
||||||
from esphome.util import run_external_command, run_external_process
|
from esphome.util import run_external_command, run_external_process
|
||||||
|
|
||||||
_LOGGER = logging.getLogger(__name__)
|
_LOGGER = logging.getLogger(__name__)
|
||||||
@@ -17,12 +18,10 @@ def patch_structhash():
|
|||||||
# removed/added. This might have unintended consequences, but this improves compile
|
# removed/added. This might have unintended consequences, but this improves compile
|
||||||
# times greatly when adding/removing components and a simple clean build solves
|
# times greatly when adding/removing components and a simple clean build solves
|
||||||
# all issues
|
# all issues
|
||||||
|
# pylint: disable=no-member,no-name-in-module
|
||||||
from platformio.commands import run
|
from platformio.commands import run
|
||||||
from platformio import util
|
from platformio import util
|
||||||
try:
|
from platformio.util import get_project_dir
|
||||||
from platformio.util import get_project_dir
|
|
||||||
except ImportError:
|
|
||||||
from platformio.project.helpers import get_project_dir
|
|
||||||
from os.path import join, isdir, getmtime, isfile
|
from os.path import join, isdir, getmtime, isfile
|
||||||
from os import makedirs
|
from os import makedirs
|
||||||
|
|
||||||
@@ -69,7 +68,8 @@ def run_platformio_cli(*args, **kwargs):
|
|||||||
if os.environ.get('ESPHOME_USE_SUBPROCESS') is None:
|
if os.environ.get('ESPHOME_USE_SUBPROCESS') is None:
|
||||||
import platformio.__main__
|
import platformio.__main__
|
||||||
try:
|
try:
|
||||||
patch_structhash()
|
if IS_PY2:
|
||||||
|
patch_structhash()
|
||||||
except Exception: # pylint: disable=broad-except
|
except Exception: # pylint: disable=broad-except
|
||||||
# Ignore when patch fails
|
# Ignore when patch fails
|
||||||
pass
|
pass
|
||||||
|
|||||||
@@ -78,8 +78,12 @@ def indexbytes(buf, i):
|
|||||||
if IS_PY2:
|
if IS_PY2:
|
||||||
def decode_text(data, encoding='utf-8', errors='strict'):
|
def decode_text(data, encoding='utf-8', errors='strict'):
|
||||||
# type: (str, str, str) -> unicode
|
# type: (str, str, str) -> unicode
|
||||||
|
if isinstance(data, unicode):
|
||||||
|
return data
|
||||||
return unicode(data, encoding=encoding, errors=errors)
|
return unicode(data, encoding=encoding, errors=errors)
|
||||||
else:
|
else:
|
||||||
def decode_text(data, encoding='utf-8', errors='strict'):
|
def decode_text(data, encoding='utf-8', errors='strict'):
|
||||||
# type: (bytes, str, str) -> str
|
# type: (bytes, str, str) -> str
|
||||||
|
if isinstance(data, str):
|
||||||
|
return data
|
||||||
return data.decode(encoding=encoding, errors=errors)
|
return data.decode(encoding=encoding, errors=errors)
|
||||||
|
|||||||
@@ -105,6 +105,9 @@ mqtt:
|
|||||||
- light.control:
|
- light.control:
|
||||||
id: living_room_lights
|
id: living_room_lights
|
||||||
brightness: !lambda 'return id(living_room_lights).current_values.get_brightness() + 0.5;'
|
brightness: !lambda 'return id(living_room_lights).current_values.get_brightness() + 0.5;'
|
||||||
|
- light.dim_relative:
|
||||||
|
id: living_room_lights
|
||||||
|
relative_brightness: 5%
|
||||||
- uart.write:
|
- uart.write:
|
||||||
id: uart0
|
id: uart0
|
||||||
data: Hello World
|
data: Hello World
|
||||||
|
|||||||
Reference in New Issue
Block a user