Fix globals.set (#635)

* Fix globals.set

* Update __init__.py
This commit is contained in:
Otto Winter 2019-06-14 12:40:14 +02:00 committed by GitHub
parent f4160c363b
commit 97f2becc9e
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 5 additions and 1 deletions

View file

@ -50,6 +50,7 @@ def globals_set_to_code(config, action_id, template_arg, args):
full_id, paren = yield cg.get_variable_with_full_id(config[CONF_ID]) full_id, paren = yield cg.get_variable_with_full_id(config[CONF_ID])
template_arg = cg.TemplateArguments(full_id.type, *template_arg) template_arg = cg.TemplateArguments(full_id.type, *template_arg)
var = cg.new_Pvariable(action_id, template_arg, paren) var = cg.new_Pvariable(action_id, template_arg, paren)
templ = yield cg.templatable(config[CONF_VALUE], args, None) templ = yield cg.templatable(config[CONF_VALUE], args, None,
to_exp=cg.RawExpression)
cg.add(var.set_value(templ)) cg.add(var.set_value(templ))
yield var yield var

View file

@ -1277,6 +1277,9 @@ text_sensor:
id: template_text id: template_text
state: |- state: |-
return "Hello World2"; return "Hello World2";
- globals.set:
id: glob_int
value: '0'
- platform: template - platform: template
name: Template Text Sensor name: Template Text Sensor
id: template_text id: template_text