Can dicts be used in scripts? The following:
state = hass.states.get('sensor.next_waterloo_train_status')
train_status = state.state
mappings = {
'ON TIME':'green',
'LATE':'orange',
'CANCELLED':'red',
}
hass.services.call('light', 'turn_on', { "entity_id" : 'light.lamp',
'color_name': mappings[train_status]
})
Gives error:
Traceback (most recent call last):
File "/usr/src/app/homeassistant/components/python_script.py", line 107, in execute
exec(compiled.code, restricted_globals, local)
File "hello_world.py", line 17, in <module>
NameError: name '_getitem_' is not defined