1
0
mirror of https://github.com/esphome/esphome.git synced 2025-09-29 00:22:21 +01:00

Cleanup dashboard JS (#491)

* Cleanup dashboard JS

* Add vscode

* Save start_mark/end_mark

* Updates

* Updates

* Remove need for cv.nameable

It's a bit hacky but removes so much bloat from integrations

* Add enum helper

* Document APIs, and Improvements

* Fixes

* Fixes

* Update PULL_REQUEST_TEMPLATE.md

* Updates

* Updates

* Updates
This commit is contained in:
Otto Winter
2019-04-22 21:56:30 +02:00
committed by GitHub
parent 6682c43dfa
commit 8e75980ebd
359 changed files with 4395 additions and 4223 deletions

View File

@@ -1,20 +1,22 @@
import esphome.codegen as cg
import esphome.config_validation as cv
from esphome.components import sensor
from esphome.const import CONF_ENTITY_ID, CONF_ID, CONF_NAME
from esphome.const import CONF_ENTITY_ID, CONF_ID, ICON_EMPTY, UNIT_EMPTY
from .. import homeassistant_ns
DEPENDENCIES = ['api']
HomeassistantSensor = homeassistant_ns.class_('HomeassistantSensor', sensor.Sensor)
CONFIG_SCHEMA = cv.nameable(sensor.SENSOR_SCHEMA.extend({
cv.GenerateID(): cv.declare_variable_id(HomeassistantSensor),
CONFIG_SCHEMA = sensor.sensor_schema(UNIT_EMPTY, ICON_EMPTY, 1).extend({
cv.GenerateID(): cv.declare_id(HomeassistantSensor),
cv.Required(CONF_ENTITY_ID): cv.entity_id,
}))
})
def to_code(config):
var = cg.new_Pvariable(config[CONF_ID], config[CONF_NAME], config[CONF_ENTITY_ID])
var = cg.new_Pvariable(config[CONF_ID])
yield cg.register_component(var, config)
yield sensor.register_sensor(var, config)
cg.add(var.set_entity_id(config[CONF_ENTITY_ID]))

View File

@@ -7,8 +7,6 @@ namespace homeassistant {
static const char *TAG = "homeassistant.sensor";
HomeassistantSensor::HomeassistantSensor(const std::string &name, const std::string &entity_id)
: Sensor(name), entity_id_(entity_id) {}
void HomeassistantSensor::setup() {
api::global_api_server->subscribe_home_assistant_state(this->entity_id_, [this](std::string state) {
auto val = parse_float(state);

View File

@@ -8,7 +8,7 @@ namespace homeassistant {
class HomeassistantSensor : public sensor::Sensor, public Component {
public:
HomeassistantSensor(const std::string &name, const std::string &entity_id);
void set_entity_id(const std::string &entity_id) { entity_id_ = entity_id; }
void setup() override;
void dump_config() override;
float get_setup_priority() const override;