def trigger(hass, config, action):
    entity_id = config.get(CONF_ENTITY_ID)
    below = config.get(CONF_BELOW)
    above = config.get(CONF_ABOVE)
    value_template = config.get(CONF_VALUE_TEMPLATE)

    # pylint: disable=unused-argument
    def state_automation_listener(entity, from_s, to_s):
        """Listen for state changes and calls action."""
        if to_s is None:
            return

        variables = {
            'trigger': {
                'platform': 'numeric_state',
                'entity_id': entity_id,
                'below': below,
                'above': above,
            }
        }

        # If new one doesn't match, nothing to do
        if not condition.numeric_state(
                hass, to_s, below, above, value_template, variables):
            return

        # Only match if old didn't exist or existed but didn't match
        # Written as: skip if old one did exist and matched
        if from_s is not None and condition.numeric_state(
                hass, from_s, below, above, value_template, variables):
            return

        variables['trigger']['from_state'] = from_s
        variables['trigger']['to_state'] = to_s

        action(variables)

    track_state_change(
        hass, entity_id, state_automation_listener)

    return True
If no lookup table is provided to the constructor, then use the TFT one.
dataset/ETHPy150Open home-assistant/home-assistant/homeassistant/components/automation/numeric_state.py/trigger--crossover with--dataset/ETHPy150Open Axelrod-Python/Axelrod/axelrod/strategies/gambler.py/Gambler.__init__