         }
       GenServer.cast(self(), :continue) # yields execution of actions.
 
-      #Logger.info("Trigger! #{inspect params} #{inspect state}")
+      # Logger.info("Trigger! #{inspect params} #{inspect state}")
       #{:ok, rule_final_state} = execute_actions(uuid, state.rule.rule["actions"], trigger_state)
       #Logger.info("Final state: #{inspect rule_final_state}")
 

  end

  def handle_cast(:continue, %{ running: [] } = state) do
    # Logger.debug("Action chain finished. Final state is #{inspect state.state, pretty: true}")

    # Store the state in the DB
    set_state(state.uuid, state.state)

  end
  def handle_call({:trigger, params}, from, state) do
    if state.signal_end_of_trigger do
      # queue
      # {:reply, {:error, :already_running}, state}

      {:noreply, %{
        state |
        trigger_queue: state.trigger_queue ++ [{from, params}]
      }}
    else
      GenServer.cast(self(), {:trigger, params})
      {:noreply, %{ state | signal_end_of_trigger: from }}
