From 55f3948ad7b429f2b704a6156468ee853ce3603a Mon Sep 17 00:00:00 2001 From: Otto Winter Date: Mon, 12 Nov 2018 22:53:09 +0100 Subject: [PATCH] Tests and better validation --- esphomeyaml/components/globals.py | 4 ++-- tests/test1.yaml | 19 +++++++++++++++++++ 2 files changed, 21 insertions(+), 2 deletions(-) diff --git a/esphomeyaml/components/globals.py b/esphomeyaml/components/globals.py index 757822d749..d9a6cf0978 100644 --- a/esphomeyaml/components/globals.py +++ b/esphomeyaml/components/globals.py @@ -9,8 +9,8 @@ GlobalVariableComponent = esphomelib_ns.class_('GlobalVariableComponent', Compon GLOBAL_VAR_SCHEMA = vol.Schema({ vol.Required(CONF_ID): cv.declare_variable_id(GlobalVariableComponent), - vol.Required(CONF_TYPE): cv.string, - vol.Optional(CONF_INITIAL_VALUE): cv.string, + vol.Required(CONF_TYPE): cv.string_strict, + vol.Optional(CONF_INITIAL_VALUE): cv.string_strict, vol.Optional(CONF_RESTORE_VALUE): cv.boolean, }).extend(cv.COMPONENT_SCHEMA.schema) diff --git a/tests/test1.yaml b/tests/test1.yaml index fadd001008..d3acfa95c3 100644 --- a/tests/test1.yaml +++ b/tests/test1.yaml @@ -1001,3 +1001,22 @@ stepper: max_speed: 250 steps/s acceleration: 100 steps/s^2 deceleration: 200 steps/s^2 + + +globals: +- id: glob_int + type: int + restore_value: yes + initial_value: '0' +- id: glob_float + type: float + restore_value: yes + initial_value: '0.0f' +- id: glob_bool + type: bool + restore_value: no + initial_value: 'true' +- id: glob_string + type: std::string + restore_value: no + # initial_value: ""