mirror of
https://github.com/esphome/esphome.git
synced 2024-11-25 08:28:12 +01:00
Improve wrong pin error message
This commit is contained in:
parent
8a509c6551
commit
0c77228421
15 changed files with 47 additions and 32 deletions
|
@ -10,7 +10,7 @@ MakeGPIOBinarySensor = Application.MakeGPIOBinarySensor
|
||||||
|
|
||||||
PLATFORM_SCHEMA = binary_sensor.PLATFORM_SCHEMA.extend({
|
PLATFORM_SCHEMA = binary_sensor.PLATFORM_SCHEMA.extend({
|
||||||
cv.GenerateID(CONF_MAKE_ID): cv.declare_variable_id(MakeGPIOBinarySensor),
|
cv.GenerateID(CONF_MAKE_ID): cv.declare_variable_id(MakeGPIOBinarySensor),
|
||||||
vol.Required(CONF_PIN): pins.GPIO_INPUT_PIN_SCHEMA
|
vol.Required(CONF_PIN): pins.gpio_input_pin_schema
|
||||||
}).extend(binary_sensor.BINARY_SENSOR_SCHEMA.schema)
|
}).extend(binary_sensor.BINARY_SENSOR_SCHEMA.schema)
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -27,7 +27,7 @@ CONF_WAKEUP_PIN_MODE = 'wakeup_pin_mode'
|
||||||
CONFIG_SCHEMA = vol.Schema({
|
CONFIG_SCHEMA = vol.Schema({
|
||||||
cv.GenerateID(): cv.declare_variable_id(DeepSleepComponent),
|
cv.GenerateID(): cv.declare_variable_id(DeepSleepComponent),
|
||||||
vol.Optional(CONF_SLEEP_DURATION): cv.positive_time_period_milliseconds,
|
vol.Optional(CONF_SLEEP_DURATION): cv.positive_time_period_milliseconds,
|
||||||
vol.Optional(CONF_WAKEUP_PIN): vol.All(cv.only_on_esp32, pins.GPIO_INTERNAL_INPUT_PIN_SCHEMA,
|
vol.Optional(CONF_WAKEUP_PIN): vol.All(cv.only_on_esp32, pins.internal_gpio_input_pin_schema,
|
||||||
validate_pin_number),
|
validate_pin_number),
|
||||||
vol.Optional(CONF_WAKEUP_PIN_MODE): vol.All(cv.only_on_esp32, vol.Upper,
|
vol.Optional(CONF_WAKEUP_PIN_MODE): vol.All(cv.only_on_esp32, vol.Upper,
|
||||||
cv.one_of(*WAKEUP_PIN_MODES)),
|
cv.one_of(*WAKEUP_PIN_MODES)),
|
||||||
|
|
|
@ -10,7 +10,7 @@ IRTransmitterComponent = switch.switch_ns.namespace('IRTransmitterComponent')
|
||||||
|
|
||||||
CONFIG_SCHEMA = vol.All(cv.ensure_list, [vol.Schema({
|
CONFIG_SCHEMA = vol.All(cv.ensure_list, [vol.Schema({
|
||||||
cv.GenerateID(): cv.declare_variable_id(IRTransmitterComponent),
|
cv.GenerateID(): cv.declare_variable_id(IRTransmitterComponent),
|
||||||
vol.Required(CONF_PIN): pins.GPIO_OUTPUT_PIN_SCHEMA,
|
vol.Required(CONF_PIN): pins.gpio_output_pin_schema,
|
||||||
vol.Optional(CONF_CARRIER_DUTY_PERCENT): vol.All(vol.Coerce(int),
|
vol.Optional(CONF_CARRIER_DUTY_PERCENT): vol.All(vol.Coerce(int),
|
||||||
vol.Range(min=1, max=100)),
|
vol.Range(min=1, max=100)),
|
||||||
})])
|
})])
|
||||||
|
|
|
@ -20,7 +20,7 @@ ESP8266PWMOutput = output.output_ns.ESP8266PWMOutput
|
||||||
|
|
||||||
PLATFORM_SCHEMA = output.PLATFORM_SCHEMA.extend({
|
PLATFORM_SCHEMA = output.PLATFORM_SCHEMA.extend({
|
||||||
vol.Required(CONF_ID): cv.declare_variable_id(ESP8266PWMOutput),
|
vol.Required(CONF_ID): cv.declare_variable_id(ESP8266PWMOutput),
|
||||||
vol.Required(CONF_PIN): vol.All(pins.GPIO_INTERNAL_OUTPUT_PIN_SCHEMA, valid_pwm_pin),
|
vol.Required(CONF_PIN): vol.All(pins.internal_gpio_output_pin_schema, valid_pwm_pin),
|
||||||
}).extend(output.FLOAT_OUTPUT_SCHEMA.schema)
|
}).extend(output.FLOAT_OUTPUT_SCHEMA.schema)
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -10,7 +10,7 @@ GPIOBinaryOutputComponent = output.output_ns.GPIOBinaryOutputComponent
|
||||||
|
|
||||||
PLATFORM_SCHEMA = output.PLATFORM_SCHEMA.extend({
|
PLATFORM_SCHEMA = output.PLATFORM_SCHEMA.extend({
|
||||||
vol.Required(CONF_ID): cv.declare_variable_id(GPIOBinaryOutputComponent),
|
vol.Required(CONF_ID): cv.declare_variable_id(GPIOBinaryOutputComponent),
|
||||||
vol.Required(CONF_PIN): pins.GPIO_OUTPUT_PIN_SCHEMA,
|
vol.Required(CONF_PIN): pins.gpio_output_pin_schema,
|
||||||
}).extend(output.BINARY_OUTPUT_SCHEMA.schema)
|
}).extend(output.BINARY_OUTPUT_SCHEMA.schema)
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -9,7 +9,7 @@ PowerSupplyComponent = esphomelib_ns.PowerSupplyComponent
|
||||||
|
|
||||||
POWER_SUPPLY_SCHEMA = vol.Schema({
|
POWER_SUPPLY_SCHEMA = vol.Schema({
|
||||||
vol.Required(CONF_ID): cv.declare_variable_id(PowerSupplyComponent),
|
vol.Required(CONF_ID): cv.declare_variable_id(PowerSupplyComponent),
|
||||||
vol.Required(CONF_PIN): pins.GPIO_OUTPUT_PIN_SCHEMA,
|
vol.Required(CONF_PIN): pins.gpio_output_pin_schema,
|
||||||
vol.Optional(CONF_ENABLE_TIME): cv.positive_time_period_milliseconds,
|
vol.Optional(CONF_ENABLE_TIME): cv.positive_time_period_milliseconds,
|
||||||
vol.Optional(CONF_KEEP_ON_TIME): cv.positive_time_period_milliseconds,
|
vol.Optional(CONF_KEEP_ON_TIME): cv.positive_time_period_milliseconds,
|
||||||
})
|
})
|
||||||
|
|
|
@ -4,7 +4,7 @@ import esphomeyaml.config_validation as cv
|
||||||
from esphomeyaml.components import sensor
|
from esphomeyaml.components import sensor
|
||||||
from esphomeyaml.components.dallas import DallasComponent
|
from esphomeyaml.components.dallas import DallasComponent
|
||||||
from esphomeyaml.const import CONF_ADDRESS, CONF_DALLAS_ID, CONF_INDEX, CONF_NAME, \
|
from esphomeyaml.const import CONF_ADDRESS, CONF_DALLAS_ID, CONF_INDEX, CONF_NAME, \
|
||||||
CONF_RESOLUTION, CONF_UPDATE_INTERVAL
|
CONF_RESOLUTION
|
||||||
from esphomeyaml.helpers import HexIntLiteral, get_variable
|
from esphomeyaml.helpers import HexIntLiteral, get_variable
|
||||||
|
|
||||||
PLATFORM_SCHEMA = vol.All(sensor.PLATFORM_SCHEMA.extend({
|
PLATFORM_SCHEMA = vol.All(sensor.PLATFORM_SCHEMA.extend({
|
||||||
|
@ -19,17 +19,12 @@ def to_code(config):
|
||||||
hub = None
|
hub = None
|
||||||
for hub in get_variable(config[CONF_DALLAS_ID]):
|
for hub in get_variable(config[CONF_DALLAS_ID]):
|
||||||
yield
|
yield
|
||||||
update_interval = config.get(CONF_UPDATE_INTERVAL)
|
|
||||||
if CONF_RESOLUTION in config and update_interval is None:
|
|
||||||
update_interval = 10000
|
|
||||||
|
|
||||||
if CONF_ADDRESS in config:
|
if CONF_ADDRESS in config:
|
||||||
address = HexIntLiteral(config[CONF_ADDRESS])
|
address = HexIntLiteral(config[CONF_ADDRESS])
|
||||||
rhs = hub.Pget_sensor_by_address(config[CONF_NAME], address, update_interval,
|
rhs = hub.Pget_sensor_by_address(config[CONF_NAME], address, config.get(CONF_RESOLUTION))
|
||||||
config.get(CONF_RESOLUTION))
|
|
||||||
else:
|
else:
|
||||||
rhs = hub.Pget_sensor_by_index(config[CONF_NAME], config[CONF_INDEX],
|
rhs = hub.Pget_sensor_by_index(config[CONF_NAME], config[CONF_INDEX],
|
||||||
update_interval, config.get(CONF_RESOLUTION))
|
config.get(CONF_RESOLUTION))
|
||||||
sensor.register_sensor(rhs, config)
|
sensor.register_sensor(rhs, config)
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -5,7 +5,7 @@ from esphomeyaml.components import sensor
|
||||||
from esphomeyaml.const import CONF_HUMIDITY, CONF_MAKE_ID, CONF_MODEL, CONF_NAME, CONF_PIN, \
|
from esphomeyaml.const import CONF_HUMIDITY, CONF_MAKE_ID, CONF_MODEL, CONF_NAME, CONF_PIN, \
|
||||||
CONF_TEMPERATURE, CONF_UPDATE_INTERVAL
|
CONF_TEMPERATURE, CONF_UPDATE_INTERVAL
|
||||||
from esphomeyaml.helpers import App, Application, add, gpio_output_pin_expression, variable
|
from esphomeyaml.helpers import App, Application, add, gpio_output_pin_expression, variable
|
||||||
from esphomeyaml.pins import GPIO_OUTPUT_PIN_SCHEMA
|
from esphomeyaml.pins import gpio_output_pin_schema
|
||||||
|
|
||||||
DHT_MODELS = {
|
DHT_MODELS = {
|
||||||
'AUTO_DETECT': sensor.sensor_ns.DHT_MODEL_AUTO_DETECT,
|
'AUTO_DETECT': sensor.sensor_ns.DHT_MODEL_AUTO_DETECT,
|
||||||
|
@ -19,7 +19,7 @@ MakeDHTSensor = Application.MakeDHTSensor
|
||||||
|
|
||||||
PLATFORM_SCHEMA = sensor.PLATFORM_SCHEMA.extend({
|
PLATFORM_SCHEMA = sensor.PLATFORM_SCHEMA.extend({
|
||||||
cv.GenerateID(CONF_MAKE_ID): cv.declare_variable_id(MakeDHTSensor),
|
cv.GenerateID(CONF_MAKE_ID): cv.declare_variable_id(MakeDHTSensor),
|
||||||
vol.Required(CONF_PIN): GPIO_OUTPUT_PIN_SCHEMA,
|
vol.Required(CONF_PIN): gpio_output_pin_schema,
|
||||||
vol.Required(CONF_TEMPERATURE): sensor.SENSOR_SCHEMA,
|
vol.Required(CONF_TEMPERATURE): sensor.SENSOR_SCHEMA,
|
||||||
vol.Required(CONF_HUMIDITY): sensor.SENSOR_SCHEMA,
|
vol.Required(CONF_HUMIDITY): sensor.SENSOR_SCHEMA,
|
||||||
vol.Optional(CONF_MODEL): vol.All(vol.Upper, cv.one_of(*DHT_MODELS)),
|
vol.Optional(CONF_MODEL): vol.All(vol.Upper, cv.one_of(*DHT_MODELS)),
|
||||||
|
|
|
@ -24,9 +24,9 @@ def to_code(config):
|
||||||
config.get(CONF_UPDATE_INTERVAL))
|
config.get(CONF_UPDATE_INTERVAL))
|
||||||
dht = variable(config[CONF_MAKE_ID], rhs)
|
dht = variable(config[CONF_MAKE_ID], rhs)
|
||||||
|
|
||||||
sensor.setup_sensor(dht.Pdht.Pget_temperature_sensor(), dht.Pmqtt_temperature,
|
sensor.setup_sensor(dht.Pdht12.Pget_temperature_sensor(), dht.Pmqtt_temperature,
|
||||||
config[CONF_TEMPERATURE])
|
config[CONF_TEMPERATURE])
|
||||||
sensor.setup_sensor(dht.Pdht.Pget_humidity_sensor(), dht.Pmqtt_humidity,
|
sensor.setup_sensor(dht.Pdht12.Pget_humidity_sensor(), dht.Pmqtt_humidity,
|
||||||
config[CONF_HUMIDITY])
|
config[CONF_HUMIDITY])
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -12,9 +12,9 @@ MakeMAX6675Sensor = Application.MakeMAX6675Sensor
|
||||||
|
|
||||||
PLATFORM_SCHEMA = sensor.PLATFORM_SCHEMA.extend({
|
PLATFORM_SCHEMA = sensor.PLATFORM_SCHEMA.extend({
|
||||||
cv.GenerateID(CONF_MAKE_ID): cv.declare_variable_id(MakeMAX6675Sensor),
|
cv.GenerateID(CONF_MAKE_ID): cv.declare_variable_id(MakeMAX6675Sensor),
|
||||||
vol.Required(CONF_PIN_CS): pins.GPIO_OUTPUT_PIN_SCHEMA,
|
vol.Required(CONF_PIN_CS): pins.gpio_output_pin_schema,
|
||||||
vol.Required(CONF_PIN_CLOCK): pins.GPIO_OUTPUT_PIN_SCHEMA,
|
vol.Required(CONF_PIN_CLOCK): pins.gpio_output_pin_schema,
|
||||||
vol.Optional(CONF_PIN_MISO): pins.GPIO_INPUT_PIN_SCHEMA,
|
vol.Required(CONF_PIN_MISO): pins.gpio_input_pin_schema,
|
||||||
vol.Optional(CONF_UPDATE_INTERVAL): cv.positive_time_period_milliseconds,
|
vol.Optional(CONF_UPDATE_INTERVAL): cv.positive_time_period_milliseconds,
|
||||||
}).extend(sensor.SENSOR_SCHEMA.schema)
|
}).extend(sensor.SENSOR_SCHEMA.schema)
|
||||||
|
|
||||||
|
|
|
@ -20,9 +20,9 @@ MakeRotaryEncoderSensor = Application.MakeRotaryEncoderSensor
|
||||||
|
|
||||||
PLATFORM_SCHEMA = sensor.PLATFORM_SCHEMA.extend({
|
PLATFORM_SCHEMA = sensor.PLATFORM_SCHEMA.extend({
|
||||||
cv.GenerateID(CONF_MAKE_ID): cv.declare_variable_id(MakeRotaryEncoderSensor),
|
cv.GenerateID(CONF_MAKE_ID): cv.declare_variable_id(MakeRotaryEncoderSensor),
|
||||||
vol.Required(CONF_PIN_A): pins.GPIO_INTERNAL_INPUT_PIN_SCHEMA,
|
vol.Required(CONF_PIN_A): pins.internal_gpio_input_pin_schema,
|
||||||
vol.Required(CONF_PIN_B): pins.GPIO_INTERNAL_INPUT_PIN_SCHEMA,
|
vol.Required(CONF_PIN_B): pins.internal_gpio_input_pin_schema,
|
||||||
vol.Optional(CONF_PIN_RESET): pins.GPIO_INTERNAL_INPUT_PIN_SCHEMA,
|
vol.Optional(CONF_PIN_RESET): pins.internal_gpio_input_pin_schema,
|
||||||
vol.Optional(CONF_RESOLUTION): vol.All(cv.string, cv.one_of(*RESOLUTIONS)),
|
vol.Optional(CONF_RESOLUTION): vol.All(cv.string, cv.one_of(*RESOLUTIONS)),
|
||||||
}).extend(sensor.SENSOR_SCHEMA.schema)
|
}).extend(sensor.SENSOR_SCHEMA.schema)
|
||||||
|
|
||||||
|
|
|
@ -12,8 +12,8 @@ MakeUltrasonicSensor = Application.MakeUltrasonicSensor
|
||||||
|
|
||||||
PLATFORM_SCHEMA = sensor.PLATFORM_SCHEMA.extend({
|
PLATFORM_SCHEMA = sensor.PLATFORM_SCHEMA.extend({
|
||||||
cv.GenerateID(CONF_MAKE_ID): cv.declare_variable_id(MakeUltrasonicSensor),
|
cv.GenerateID(CONF_MAKE_ID): cv.declare_variable_id(MakeUltrasonicSensor),
|
||||||
vol.Required(CONF_TRIGGER_PIN): pins.GPIO_OUTPUT_PIN_SCHEMA,
|
vol.Required(CONF_TRIGGER_PIN): pins.gpio_output_pin_schema,
|
||||||
vol.Required(CONF_ECHO_PIN): pins.GPIO_INTERNAL_INPUT_PIN_SCHEMA,
|
vol.Required(CONF_ECHO_PIN): pins.internal_gpio_input_pin_schema,
|
||||||
vol.Exclusive(CONF_TIMEOUT_METER, 'timeout'): cv.positive_float,
|
vol.Exclusive(CONF_TIMEOUT_METER, 'timeout'): cv.positive_float,
|
||||||
vol.Exclusive(CONF_TIMEOUT_TIME, 'timeout'): cv.positive_time_period_microseconds,
|
vol.Exclusive(CONF_TIMEOUT_TIME, 'timeout'): cv.positive_time_period_microseconds,
|
||||||
vol.Optional(CONF_UPDATE_INTERVAL): cv.positive_time_period_milliseconds,
|
vol.Optional(CONF_UPDATE_INTERVAL): cv.positive_time_period_milliseconds,
|
||||||
|
|
|
@ -10,7 +10,7 @@ MakeGPIOSwitch = Application.MakeGPIOSwitch
|
||||||
|
|
||||||
PLATFORM_SCHEMA = switch.PLATFORM_SCHEMA.extend({
|
PLATFORM_SCHEMA = switch.PLATFORM_SCHEMA.extend({
|
||||||
cv.GenerateID(CONF_MAKE_ID): cv.declare_variable_id(MakeGPIOSwitch),
|
cv.GenerateID(CONF_MAKE_ID): cv.declare_variable_id(MakeGPIOSwitch),
|
||||||
vol.Required(CONF_PIN): pins.GPIO_OUTPUT_PIN_SCHEMA,
|
vol.Required(CONF_PIN): pins.gpio_output_pin_schema,
|
||||||
}).extend(switch.SWITCH_SCHEMA.schema)
|
}).extend(switch.SWITCH_SCHEMA.schema)
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -483,7 +483,7 @@ class MockObj(Expression):
|
||||||
obj.requires.append(self)
|
obj.requires.append(self)
|
||||||
return obj
|
return obj
|
||||||
next_op = u'.'
|
next_op = u'.'
|
||||||
if attr.startswith(u'P') and self.op != '::':
|
if attr.startswith(u'P') and self.op not in ['::', '']:
|
||||||
attr = attr[1:]
|
attr = attr[1:]
|
||||||
next_op = u'->'
|
next_op = u'->'
|
||||||
if attr.startswith(u'_'):
|
if attr.startswith(u'_'):
|
||||||
|
|
|
@ -213,10 +213,30 @@ PCF8574_INPUT_PIN_SCHEMA = PCF8574_OUTPUT_PIN_SCHEMA.extend({
|
||||||
vol.Optional(CONF_MODE): vol.All(vol.Upper, vol.Any("INPUT", "INPUT_PULLUP")),
|
vol.Optional(CONF_MODE): vol.All(vol.Upper, vol.Any("INPUT", "INPUT_PULLUP")),
|
||||||
})
|
})
|
||||||
|
|
||||||
GPIO_INTERNAL_OUTPUT_PIN_SCHEMA = vol.Any(shorthand_output_pin, GPIO_FULL_OUTPUT_PIN_SCHEMA)
|
|
||||||
|
|
||||||
GPIO_OUTPUT_PIN_SCHEMA = vol.Any(PCF8574_OUTPUT_PIN_SCHEMA, GPIO_INTERNAL_OUTPUT_PIN_SCHEMA)
|
def internal_gpio_output_pin_schema(value):
|
||||||
|
if isinstance(value, dict):
|
||||||
|
return GPIO_FULL_OUTPUT_PIN_SCHEMA(value)
|
||||||
|
return shorthand_output_pin(value)
|
||||||
|
|
||||||
GPIO_INTERNAL_INPUT_PIN_SCHEMA = vol.Any(shorthand_input_pin, GPIO_FULL_INPUT_PIN_SCHEMA)
|
|
||||||
|
|
||||||
GPIO_INPUT_PIN_SCHEMA = vol.Any(PCF8574_INPUT_PIN_SCHEMA, GPIO_INTERNAL_INPUT_PIN_SCHEMA)
|
def gpio_output_pin_schema(value):
|
||||||
|
if isinstance(value, dict):
|
||||||
|
if CONF_PCF8574 in value:
|
||||||
|
return PCF8574_OUTPUT_PIN_SCHEMA(value)
|
||||||
|
return GPIO_FULL_OUTPUT_PIN_SCHEMA(value)
|
||||||
|
return shorthand_output_pin(value)
|
||||||
|
|
||||||
|
|
||||||
|
def internal_gpio_input_pin_schema(value):
|
||||||
|
if isinstance(value, dict):
|
||||||
|
return GPIO_FULL_INPUT_PIN_SCHEMA(value)
|
||||||
|
return shorthand_input_pin(value)
|
||||||
|
|
||||||
|
|
||||||
|
def gpio_input_pin_schema(value):
|
||||||
|
if isinstance(value, dict):
|
||||||
|
if CONF_PCF8574 in value:
|
||||||
|
return PCF8574_INPUT_PIN_SCHEMA(value)
|
||||||
|
return GPIO_FULL_INPUT_PIN_SCHEMA(value)
|
||||||
|
return shorthand_input_pin(value)
|
||||||
|
|
Loading…
Reference in a new issue