human
Solve the following python programming problem given the following code:
@asyncio.coroutine
def async_trigger(hass, config, action):
assistant
#Here is the Python code you requested.

    """Listen for state changes based on configuration.
    """
    value_template = config.get(CONF_VALUE_TEMPLATE)
    value_template.hass = hass
    @callback
    def template_listener(entity_id, from_s, to_s):
        'Listen    for    state    changes    and    calls    action.'
        hass.async_run_job(action, {'trigger': {'platform': 'template', 'entity_id': entity_id, 'from_state': from_s, 'to_state': to_s}})
    return async_track_template(hass, value_template, template_listener)