Compare commits

...

8 Commits

Author SHA1 Message Date
Otto Winter
359f54d3c1 Bump version to v1.13.0b3 2019-05-28 16:35:55 +02:00
Otto Winter
68ce1b18c4 Add NTC and resistance sensor (#560)
* Add NTC and resistance sensor

Fixes https://github.com/esphome/feature-requests/issues/248

* Fix

* Fix platformio4 moved get_project_dir
2019-05-28 16:35:50 +02:00
Otto Winter
76d7802650 Do not recompile on version change 2019-05-28 12:11:46 +02:00
Otto Winter
9be16916b7 Fix gitlab 2019-05-28 12:01:32 +02:00
Otto Winter
0ced5509fc Bump version to v1.13.0b2 2019-05-28 10:48:48 +02:00
gitolicious
bd6b9ff1da added link from dashboard to web server, if configured (#556)
* added link from dashboard to web server, if configured

* linter fixes

* simplified integration lookup

* included loaded_integration in storage json

* included loaded_integration in storage json

* fixed loaded_integrations

plus linter changes

* fixed comment: List

Co-Authored-By: Otto Winter <otto@otto-winter.com>

* return empty list

Co-Authored-By: Otto Winter <otto@otto-winter.com>

* convert to list

Co-Authored-By: Otto Winter <otto@otto-winter.com>

* default to empty list on missing loaded_integrations

Co-Authored-By: Otto Winter <otto@otto-winter.com>

* None check no longer needed

Co-Authored-By: Otto Winter <otto@otto-winter.com>

* None check no longer needed

Co-Authored-By: Otto Winter <otto@otto-winter.com>

* removed newline
2019-05-28 10:48:45 +02:00
Otto Winter
edee28acf0 Use lint image for tests 2019-05-28 10:41:19 +02:00
Otto Winter
53e8b3ed3e Update gitlab CI script, add cpp lint 2019-05-28 10:24:13 +02:00
19 changed files with 467 additions and 108 deletions

View File

@@ -3,6 +3,8 @@
variables:
DOCKER_DRIVER: overlay2
DOCKER_HOST: tcp://docker:2375/
BASE_VERSION: '1.5.1'
TZ: UTC
stages:
- lint
@@ -10,7 +12,7 @@ stages:
- deploy
.lint: &lint
image: esphome/esphome-base-amd64
image: esphome/esphome-lint:latest
stage: lint
before_script:
- script/setup
@@ -18,14 +20,12 @@ stages:
- docker
.test: &test
image: esphome/esphome-base-amd64
image: esphome/esphome-lint:latest
stage: test
before_script:
- script/setup
tags:
- docker
variables:
TZ: UTC
.docker-base: &docker-base
image: esphome/esphome-base-builder
@@ -40,11 +40,11 @@ stages:
- |
if [[ "${IS_HASSIO}" == "YES" ]]; then
BUILD_FROM=esphome/esphome-hassio-base-${BUILD_ARCH}:1.5.1
BUILD_FROM=esphome/esphome-hassio-base-${BUILD_ARCH}:${BASE_VERSION}
BUILD_TO=esphome/esphome-hassio-${BUILD_ARCH}
DOCKERFILE=docker/Dockerfile.hassio
else
BUILD_FROM=esphome/esphome-base-${BUILD_ARCH}:1.5.1
BUILD_FROM=esphome/esphome-base-${BUILD_ARCH}:${BASE_VERSION}
if [[ "${BUILD_ARCH}" == "amd64" ]]; then
BUILD_TO=esphome/esphome
else
@@ -93,12 +93,33 @@ stages:
- docker
stage: deploy
lint-python:
lint-custom:
<<: *lint
script:
- script/ci-custom.py
lint-python:
<<: *lint
script:
- script/lint-python
lint-tidy:
<<: *lint
script:
- pio init --ide atom
- |
if ! patch -R -p0 -s -f --dry-run <script/.neopixelbus.patch; then
patch -p0 < script/.neopixelbus.patch
fi
- script/clang-tidy --all-headers --fix
- script/ci-suggest-changes
lint-format:
<<: *lint
script:
- script/clang-format -i
- script/ci-suggest-changes
test1:
<<: *test
script:
@@ -115,16 +136,12 @@ test3:
- esphome tests/test3.yaml compile
.deploy-pypi: &deploy-pypi
<<: *lint
stage: deploy
image: python:2.7
before_script:
- pip install -e .
- pip install twine
script:
- python setup.py sdist bdist_wheel
- twine upload dist/*
tags:
- docker
- pip install twine wheel
- python setup.py sdist bdist_wheel
- twine upload dist/*
deploy-release:pypi:
<<: *deploy-pypi
@@ -143,77 +160,64 @@ deploy-beta:pypi:
.latest: &latest
<<: *docker-base
only:
- /^v([0-9\.]+)$/
- /^v([0-9\.]+)$/
except:
- branches
.latest-vars: &latest-vars
RELEASE: YES
LATEST: YES
# Also push to beta tag
BETA: YES
- branches
.beta: &beta
<<: *docker-base
only:
- /^v([0-9\.]+b\d+)$/
- /^v([0-9\.]+b\d+)$/
except:
- branches
.beta-vars: &beta-vars
RELEASE: YES
BETA: YES
- branches
.dev: &dev
<<: *docker-base
only:
- dev
- dev
.dev-vars: &dev-vars
DEV: YES
#aarch64-beta-docker:
# <<: *beta
# variables:
# BETA: "YES"
# BUILD_ARCH: aarch64
# IS_HASSIO: "NO"
# RELEASE: "YES"
#aarch64-beta-hassio:
# <<: *beta
# variables:
# BETA: "YES"
# BUILD_ARCH: aarch64
# IS_HASSIO: "YES"
# RELEASE: "YES"
#aarch64-dev-docker:
# <<: *dev
# variables:
# BUILD_ARCH: aarch64
# DEV: "YES"
# IS_HASSIO: "NO"
#aarch64-dev-hassio:
# <<: *dev
# variables:
# BUILD_ARCH: aarch64
# DEV: "YES"
# IS_HASSIO: "YES"
#aarch64-latest-docker:
# <<: *latest
# variables:
# BETA: "YES"
# BUILD_ARCH: aarch64
# IS_HASSIO: "NO"
# LATEST: "YES"
# RELEASE: "YES"
#aarch64-latest-hassio:
# <<: *latest
# variables:
# BETA: "YES"
# BUILD_ARCH: aarch64
# IS_HASSIO: "YES"
# LATEST: "YES"
# RELEASE: "YES"
aarch64-beta-docker:
<<: *beta
variables:
BETA: "YES"
BUILD_ARCH: aarch64
IS_HASSIO: "NO"
RELEASE: "YES"
aarch64-beta-hassio:
<<: *beta
variables:
BETA: "YES"
BUILD_ARCH: aarch64
IS_HASSIO: "YES"
RELEASE: "YES"
aarch64-dev-docker:
<<: *dev
variables:
BUILD_ARCH: aarch64
DEV: "YES"
IS_HASSIO: "NO"
aarch64-dev-hassio:
<<: *dev
variables:
BUILD_ARCH: aarch64
DEV: "YES"
IS_HASSIO: "YES"
aarch64-latest-docker:
<<: *latest
variables:
BETA: "YES"
BUILD_ARCH: aarch64
IS_HASSIO: "NO"
LATEST: "YES"
RELEASE: "YES"
aarch64-latest-hassio:
<<: *latest
variables:
BETA: "YES"
BUILD_ARCH: aarch64
IS_HASSIO: "YES"
LATEST: "YES"
RELEASE: "YES"
amd64-beta-docker:
<<: *beta
variables:
@@ -256,45 +260,45 @@ amd64-latest-hassio:
IS_HASSIO: "YES"
LATEST: "YES"
RELEASE: "YES"
armhf-beta-docker:
armv7-beta-docker:
<<: *beta
variables:
BETA: "YES"
BUILD_ARCH: armhf
BUILD_ARCH: armv7
IS_HASSIO: "NO"
RELEASE: "YES"
armhf-beta-hassio:
armv7-beta-hassio:
<<: *beta
variables:
BETA: "YES"
BUILD_ARCH: armhf
BUILD_ARCH: armv7
IS_HASSIO: "YES"
RELEASE: "YES"
armhf-dev-docker:
armv7-dev-docker:
<<: *dev
variables:
BUILD_ARCH: armhf
BUILD_ARCH: armv7
DEV: "YES"
IS_HASSIO: "NO"
armhf-dev-hassio:
armv7-dev-hassio:
<<: *dev
variables:
BUILD_ARCH: armhf
BUILD_ARCH: armv7
DEV: "YES"
IS_HASSIO: "YES"
armhf-latest-docker:
armv7-latest-docker:
<<: *latest
variables:
BETA: "YES"
BUILD_ARCH: armhf
BUILD_ARCH: armv7
IS_HASSIO: "NO"
LATEST: "YES"
RELEASE: "YES"
armhf-latest-hassio:
armv7-latest-hassio:
<<: *latest
variables:
BETA: "YES"
BUILD_ARCH: armhf
BUILD_ARCH: armv7
IS_HASSIO: "YES"
LATEST: "YES"
RELEASE: "YES"

View File

@@ -1,6 +1,18 @@
FROM python:2.7
FROM esphome/esphome-base-amd64:1.5.1
COPY requirements.txt /requirements.txt
RUN \
apt-get update \
&& apt-get install -y --no-install-recommends \
clang-format-7 \
clang-tidy-7 \
patch \
&& rm -rf \
/tmp/* \
/var/{cache,log}/* \
/var/lib/apt/lists/*
RUN pip install -r /requirements.txt && \
pip install flake8==3.6.0 pylint==1.9.4 pillow
COPY requirements_test.txt /requirements_test.txt
RUN pip2 install -r /requirements_test.txt
VOLUME ["/esphome"]
WORKDIR /esphome

View File

@@ -127,7 +127,10 @@ def wrap_to_code(name, comp):
def wrapped(conf):
cg.add(cg.LineComment(u"{}:".format(name)))
if comp.config_schema is not None:
cg.add(cg.LineComment(indent(yaml_util.dump(conf).decode('utf-8'))))
conf_str = yaml_util.dump(conf)
if IS_PY2:
conf_str = conf_str.decode('utf-8')
cg.add(cg.LineComment(indent(conf_str)))
yield coro(conf)
return wrapped

View File

View File

@@ -0,0 +1,31 @@
#include "ntc.h"
#include "esphome/core/log.h"
namespace esphome {
namespace ntc {
static const char *TAG = "ntc";
void NTC::setup() {
this->sensor_->add_on_state_callback([this](float value) { this->process_(value); });
if (this->sensor_->has_state())
this->process_(this->sensor_->state);
}
void NTC::dump_config() { LOG_SENSOR("", "NTC Sensor", this) }
float NTC::get_setup_priority() const { return setup_priority::DATA; }
void NTC::process_(float value) {
if (isnan(value)) {
this->publish_state(NAN);
return;
}
float lr = logf(value);
float v = this->a_ + this->b_ * lr + this->c_ * lr * lr * lr;
float temp = 1 / v - 273.15f;
ESP_LOGD(TAG, "'%s' - Temperature: %.1f°C", this->name_.c_str(), temp);
this->publish_state(temp);
}
} // namespace ntc
} // namespace esphome

View File

@@ -0,0 +1,29 @@
#pragma once
#include "esphome/core/component.h"
#include "esphome/components/sensor/sensor.h"
namespace esphome {
namespace ntc {
class NTC : public Component, public sensor::Sensor {
public:
void set_sensor(Sensor *sensor) { sensor_ = sensor; }
void set_a(float a) { a_ = a; }
void set_b(float b) { b_ = b; }
void set_c(float c) { c_ = c; }
void setup() override;
void dump_config() override;
float get_setup_priority() const override;
protected:
void process_(float value);
sensor::Sensor *sensor_;
float a_;
float b_;
float c_;
};
} // namespace ntc
} // namespace esphome

View File

@@ -0,0 +1,120 @@
# coding=utf-8
from math import log
import esphome.config_validation as cv
import esphome.codegen as cg
from esphome.components import sensor
from esphome.const import UNIT_CELSIUS, ICON_THERMOMETER, CONF_SENSOR, CONF_TEMPERATURE, \
CONF_VALUE, CONF_CALIBRATION, CONF_ID
ntc_ns = cg.esphome_ns.namespace('ntc')
NTC = ntc_ns.class_('NTC', cg.Component, sensor.Sensor)
CONF_B_CONSTANT = 'b_constant'
CONF_REFERENCE_TEMPERATURE = 'reference_temperature'
CONF_REFERENCE_RESISTANCE = 'reference_resistance'
CONF_A = 'a'
CONF_B = 'b'
CONF_C = 'c'
ZERO_POINT = 273.15
def validate_calibration_parameter(value):
if isinstance(value, dict):
return cv.Schema({
cv.Required(CONF_TEMPERATURE): cv.float_,
cv.Required(CONF_VALUE): cv.float_,
})
value = cv.string(value)
parts = value.split('->')
if len(parts) != 2:
raise cv.Invalid(u"Calibration parameter must be of form 3000 -> 23°C")
voltage = cv.resistance(parts[0].strip())
temperature = cv.temperature(parts[1].strip())
return validate_calibration_parameter({
CONF_TEMPERATURE: temperature,
CONF_VALUE: voltage,
})
def calc_steinhart_hart(value):
r1 = value[0][CONF_VALUE]
r2 = value[1][CONF_VALUE]
r3 = value[2][CONF_VALUE]
t1 = value[0][CONF_TEMPERATURE] + ZERO_POINT
t2 = value[1][CONF_TEMPERATURE] + ZERO_POINT
t3 = value[2][CONF_TEMPERATURE] + ZERO_POINT
l1 = log(r1)
l2 = log(r2)
l3 = log(r3)
y1 = 1/t1
y2 = 1/t2
y3 = 1/t3
g2 = (y2-y1)/(l2-l1)
g3 = (y3-y1)/(l3-l1)
c = (g3-g2)/(l3-l2) * 1/(l1+l2+l3)
b = g2 - c*(l1*l1 + l1*l2 + l2*l2)
a = y1 - (b + l1*l1*c) * l1
return a, b, c
def calc_b(value):
beta = value[CONF_B_CONSTANT]
t0 = value[CONF_REFERENCE_TEMPERATURE] + ZERO_POINT
r0 = value[CONF_REFERENCE_RESISTANCE]
a = (1/t0) - (1/beta) * log(r0)
b = 1/beta
c = 0
return a, b, c
def process_calibration(value):
if isinstance(value, dict):
value = cv.Schema({
cv.Required(CONF_B_CONSTANT): cv.float_,
cv.Required(CONF_REFERENCE_TEMPERATURE): cv.temperature,
cv.Required(CONF_REFERENCE_RESISTANCE): cv.resistance,
})(value)
a, b, c = calc_b(value)
elif isinstance(value, list):
if len(value) != 3:
raise cv.Invalid("SteinhartHart Calibration must consist of exactly three values")
value = cv.Schema([validate_calibration_parameter])(value)
a, b, c = calc_steinhart_hart(value)
else:
raise cv.Invalid("Calibration parameter accepts either a list for steinhart-hart "
"calibration, or mapping for b-constant calibration, "
"not {}".format(type(value)))
return {
CONF_A: a,
CONF_B: b,
CONF_C: c,
}
CONFIG_SCHEMA = sensor.sensor_schema(UNIT_CELSIUS, ICON_THERMOMETER, 1).extend({
cv.GenerateID(): cv.declare_id(NTC),
cv.Required(CONF_SENSOR): cv.use_id(sensor.Sensor),
cv.Required(CONF_CALIBRATION): process_calibration,
}).extend(cv.COMPONENT_SCHEMA)
def to_code(config):
var = cg.new_Pvariable(config[CONF_ID])
yield cg.register_component(var, config)
yield sensor.register_sensor(var, config)
sens = yield cg.get_variable(config[CONF_SENSOR])
cg.add(var.set_sensor(sens))
calib = config[CONF_CALIBRATION]
cg.add(var.set_a(calib[CONF_A]))
cg.add(var.set_b(calib[CONF_B]))
cg.add(var.set_c(calib[CONF_C]))

View File

@@ -0,0 +1,42 @@
#include "resistance_sensor.h"
#include "esphome/core/log.h"
namespace esphome {
namespace resistance {
static const char *TAG = "resistance";
void ResistanceSensor::dump_config() {
LOG_SENSOR("", "Resistance Sensor", this);
ESP_LOGCONFIG(TAG, " Configuration: %s", this->configuration_ == UPSTREAM ? "UPSTREAM" : "DOWNSTREAM");
ESP_LOGCONFIG(TAG, " Resistor: %.2fΩ", this->resistor_);
ESP_LOGCONFIG(TAG, " Reference Voltage: %.1fV", this->reference_voltage_);
}
void ResistanceSensor::process_(float value) {
if (isnan(value)) {
this->publish_state(NAN);
return;
}
float res = 0;
switch (this->configuration_) {
case UPSTREAM:
if (value == 0.0f)
res = NAN;
else
res = (this->reference_voltage_ - value) / value;
break;
case DOWNSTREAM:
if (value == this->reference_voltage_)
res = NAN;
else
res = value / (this->reference_voltage_ - value);
break;
}
res *= this->resistor_;
ESP_LOGD(TAG, "'%s' - Resistance %.1fΩ", this->name_.c_str(), res);
this->publish_state(res);
}
} // namespace resistance
} // namespace esphome

View File

@@ -0,0 +1,38 @@
#pragma once
#include "esphome/core/component.h"
#include "esphome/components/sensor/sensor.h"
namespace esphome {
namespace resistance {
enum ResistanceConfiguration {
UPSTREAM,
DOWNSTREAM,
};
class ResistanceSensor : public Component, public sensor::Sensor {
public:
void set_sensor(Sensor *sensor) { sensor_ = sensor; }
void set_configuration(ResistanceConfiguration configuration) { configuration_ = configuration; }
void set_resistor(float resistor) { resistor_ = resistor; }
void set_reference_voltage(float reference_voltage) { reference_voltage_ = reference_voltage; }
void setup() override {
this->sensor_->add_on_state_callback([this](float value) { this->process_(value); });
if (this->sensor_->has_state())
this->process_(this->sensor_->state);
}
void dump_config() override;
float get_setup_priority() const override { return setup_priority::DATA; }
protected:
void process_(float value);
sensor::Sensor *sensor_;
ResistanceConfiguration configuration_;
float resistor_;
float reference_voltage_;
};
} // namespace resistance
} // namespace esphome

View File

@@ -0,0 +1,37 @@
import esphome.codegen as cg
import esphome.config_validation as cv
from esphome.components import sensor
from esphome.const import CONF_SENSOR, UNIT_OHM, ICON_FLASH, CONF_ID
resistance_ns = cg.esphome_ns.namespace('resistance')
ResistanceSensor = resistance_ns.class_('ResistanceSensor', cg.Component, sensor.Sensor)
CONF_REFERENCE_VOLTAGE = 'reference_voltage'
CONF_CONFIGURATION = 'configuration'
CONF_RESISTOR = 'resistor'
ResistanceConfiguration = resistance_ns.enum('ResistanceConfiguration')
CONFIGURATIONS = {
'DOWNSTREAM': ResistanceConfiguration.DOWNSTREAM,
'UPSTREAM': ResistanceConfiguration.UPSTREAM,
}
CONFIG_SCHEMA = sensor.sensor_schema(UNIT_OHM, ICON_FLASH, 1).extend({
cv.GenerateID(): cv.declare_id(ResistanceSensor),
cv.Required(CONF_SENSOR): cv.use_id(sensor.Sensor),
cv.Required(CONF_CONFIGURATION): cv.enum(CONFIGURATIONS, upper=True),
cv.Required(CONF_RESISTOR): cv.resistance,
cv.Optional(CONF_REFERENCE_VOLTAGE, default='3.3V'): cv.voltage,
}).extend(cv.COMPONENT_SCHEMA)
def to_code(config):
var = cg.new_Pvariable(config[CONF_ID])
yield cg.register_component(var, config)
yield sensor.register_sensor(var, config)
sens = yield cg.get_variable(config[CONF_SENSOR])
cg.add(var.set_sensor(sens))
cg.add(var.set_configuration(config[CONF_CONFIGURATION]))
cg.add(var.set_resistor(config[CONF_RESISTOR]))
cg.add(var.set_reference_voltage(config[CONF_REFERENCE_VOLTAGE]))

View File

@@ -3,7 +3,7 @@
MAJOR_VERSION = 1
MINOR_VERSION = 13
PATCH_VERSION = '0b1'
PATCH_VERSION = '0b3'
__short_version__ = '{}.{}'.format(MAJOR_VERSION, MINOR_VERSION)
__version__ = '{}.{}'.format(__short_version__, PATCH_VERSION)
@@ -62,6 +62,7 @@ CONF_BUILD_PATH = 'build_path'
CONF_BUSY_PIN = 'busy_pin'
CONF_BUS_VOLTAGE = 'bus_voltage'
CONF_CALIBRATE_LINEAR = 'calibrate_linear'
CONF_CALIBRATION = 'calibration'
CONF_CARRIER_DUTY_PERCENT = 'carrier_duty_percent'
CONF_CARRIER_FREQUENCY = 'carrier_frequency'
CONF_CHANGE_MODE_EVERY = 'change_mode_every'
@@ -201,6 +202,7 @@ CONF_LEVEL = 'level'
CONF_LG = 'lg'
CONF_LIBRARIES = 'libraries'
CONF_LIGHT = 'light'
CONF_LOADED_INTEGRATIONS = 'loaded_integrations'
CONF_LOCAL = 'local'
CONF_LOGGER = 'logger'
CONF_LOGS = 'logs'

View File

@@ -430,6 +430,12 @@ class DashboardEntry(object):
def update_new(self):
return const.__version__
@property
def loaded_integrations(self):
if self.storage is None:
return []
return self.storage.loaded_integrations
class MainRequestHandler(BaseHandler):
@authenticated

View File

@@ -67,6 +67,9 @@
<div class="card-content">
<span class="card-title">
{{ escape(entry.name) }}
{% if 'web_server' in entry.loaded_integrations %}
<a href="http://{{ escape(entry.address) }}" target="_blank"><i class="material-icons icon-grey">launch</i></a>
{% end %}
<i class="material-icons right dropdown-trigger" data-target="dropdown-{{ i }}">more_vert</i>
</span>
<p>

View File

@@ -19,12 +19,16 @@ def patch_structhash():
# all issues
from platformio.commands import run
from platformio import util
try:
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 import makedirs
def patched_clean_build_dir(build_dir):
structhash_file = join(build_dir, "structure.hash")
platformio_ini = join(util.get_project_dir(), "platformio.ini")
platformio_ini = join(get_project_dir(), "platformio.ini")
# if project's config is modified
if isdir(build_dir) and getmtime(platformio_ini) > getmtime(build_dir):

View File

@@ -37,7 +37,7 @@ def trash_storage_path(base_path): # type: (str) -> str
class StorageJSON(object):
def __init__(self, storage_version, name, esphome_version,
src_version, arduino_version, address, esp_platform, board, build_path,
firmware_bin_path):
firmware_bin_path, loaded_integrations):
# Version of the storage JSON schema
assert storage_version is None or isinstance(storage_version, int)
self.storage_version = storage_version # type: int
@@ -61,6 +61,9 @@ class StorageJSON(object):
self.build_path = build_path # type: str
# The absolute path to the firmware binary
self.firmware_bin_path = firmware_bin_path # type: str
# A list of strings of names of loaded integrations
self.loaded_integrations = loaded_integrations # type: List[str]
self.loaded_integrations.sort()
def as_dict(self):
return {
@@ -74,6 +77,7 @@ class StorageJSON(object):
'board': self.board,
'build_path': self.build_path,
'firmware_bin_path': self.firmware_bin_path,
'loaded_integrations': self.loaded_integrations,
}
def to_json(self):
@@ -97,6 +101,7 @@ class StorageJSON(object):
board=esph.board,
build_path=esph.build_path,
firmware_bin_path=esph.firmware_bin,
loaded_integrations=list(esph.loaded_integrations),
)
@staticmethod
@@ -113,6 +118,7 @@ class StorageJSON(object):
board=board,
build_path=None,
firmware_bin_path=None,
loaded_integrations=[],
)
@staticmethod
@@ -130,9 +136,10 @@ class StorageJSON(object):
board = storage.get('board')
build_path = storage.get('build_path')
firmware_bin_path = storage.get('firmware_bin_path')
loaded_integrations = storage.get('loaded_integrations', [])
return StorageJSON(storage_version, name, esphome_version,
src_version, arduino_version, address, esp_platform, board, build_path,
firmware_bin_path)
firmware_bin_path, loaded_integrations)
@staticmethod
def load(path): # type: (str) -> Optional[StorageJSON]

View File

@@ -130,8 +130,6 @@ def storage_should_clean(old, new): # type: (StorageJSON, StorageJSON) -> bool
if old is None:
return True
if old.esphome_version != new.esphome_version:
return True
if old.src_version != new.src_version:
return True
if old.arduino_version != new.arduino_version:

View File

@@ -11,6 +11,19 @@ import sys
sys.path.append(os.path.dirname(__file__))
from helpers import get_output, git_ls_files, filter_changed
curfile = None
def print_error(file, lineno, msg):
global curfile
if curfile != file:
print()
print("\033[0;32m************* File \033[1;32m{}\033[0m".format(file))
curfile = file
print(u'{}:{} - {}'.format(file, lineno, msg))
def main():
parser = argparse.ArgumentParser()
@@ -38,7 +51,7 @@ def main():
if not files:
sys.exit(0)
errors = collections.defaultdict(list)
errors = 0
cmd = ['flake8'] + files
print("Running flake8...")
log = get_output(*cmd)
@@ -49,7 +62,8 @@ def main():
file_ = line[0]
linno = line[1]
msg = (u':'.join(line[3:])).strip()
errors[file_].append(u'{}:{} - {}'.format(file_, linno, msg))
print_error(file_, linno, msg)
errors += 1
cmd = ['pylint', '-f', 'parseable', '--persistent=n'] + files
print("Running pylint...")
@@ -61,15 +75,10 @@ def main():
file_ = line[0]
linno = line[1]
msg = (u':'.join(line[3:])).strip()
errors[file_].append(u'{}:{} - {}'.format(file_, linno, msg))
print_error(file_, linno, msg)
errors += 1
for f, errs in sorted(errors.items()):
print("\033[0;32m************* File \033[1;32m{}\033[0m".format(f))
for err in errs:
print(err)
print()
sys.exit(len(errors))
sys.exit(errors)
if __name__ == '__main__':

View File

@@ -115,6 +115,20 @@ sensor:
- calibrate_linear:
- 0 -> 0
- 100 -> 100
- platform: resistance
sensor: my_sensor
configuration: DOWNSTREAM
resistor: 10kΩ
reference_voltage: 3.3V
name: Resistance
id: resist
- platform: ntc
sensor: resist
name: NTC Sensor
calibration:
b_constant: 3950
reference_resistance: 10k
reference_temperature: 25°C
- platform: tcs34725
red_channel:
name: Red Channel